/* Not My Event: "The Butterfly Announcement" (public/templates/the-butterfly-announcement.html). The owner's own pictures (public/assets/butterfly/, cut by
   scripts/art/make-butterfly.mjs). butterfly.js places every layer for the screen it is on and moves them with transform and opacity only. */
:root {
  --burgundy: #6E1423; --wine: #4A0E1A; --gold: #9C7536; --charcoal: #3B3330; --ivory: #F7EBDD;
  --f-script: 'Pinyon Script', 'Snell Roundhand', cursive;
  --f-serif: 'Cormorant Garamond', 'Cormorant', Garamond, 'Times New Roman', serif;
  --parch: url(/assets/butterfly/ba-parchment.webp);
}
html, body { margin: 0; height: 100%; background: #3A0C17; overflow: hidden; }
body { -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--ivory); color: var(--wine); padding: 8px 12px; }

#stage { position: fixed; inset: 0; overflow: hidden; touch-action: manipulation; }
html.closed #stage { cursor: pointer; user-select: none; -webkit-user-select: none; }
/* the rose wine paper stands still behind everything (butterfly.js picks the one drawn closest to the screen's shape, so all four corner scrolls show) */
.bg { position: absolute; inset: 0; background: #4A1020 center / 100% 100% no-repeat; }

/* every layer sits at the stage's top left; butterfly.js gives it its size and place, and moves it */
.ly { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
img.ly, .ly img { display: block; max-width: none; pointer-events: none; -webkit-user-drag: none; }
/* the envelope and the card, back to front (the flap goes behind the card once it has turned past upright; the card comes in front of all once it is out) */
.e-back { z-index: 1; }
.e-flap { z-index: 6; }
.card-p { z-index: 3; background: #F1E3CC var(--parch) 0 0 / 100% 100% no-repeat; box-shadow: 0 0 calc(var(--k, 1px) * 30) calc(var(--k, 1px) * 3) rgba(26, 2, 10, .45); }
.card-p .psh { display: none; }
.e-pocket { z-index: 4; }
.e-flapsh { z-index: 5; }
.e-flap > * { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.e-flap .fi { opacity: 0; }
/* the flap darkens as it turns edge-on to the light (only its opacity moves) */
.e-flap .fd { background: #12030A; opacity: 0; clip-path: polygon(0 0, 100% 0, 50% 100%); }

/* the announcement, on the parchment under the butterfly */
.ann { position: absolute; left: 0; top: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--charcoal); pointer-events: none; will-change: transform; }
.ann p { margin: 0; opacity: 0; will-change: transform, opacity; }
.ann .caps { font: 600 calc(var(--pw) * .032) / 1.6 var(--f-serif); letter-spacing: .2em; text-transform: uppercase; color: var(--charcoal); }
.ann .t2 { margin-bottom: calc(var(--ph) * .014); }
.ann .nm { font: 400 calc(var(--pw) * .152) / 1.04 var(--f-script); color: var(--burgundy); white-space: nowrap; padding: 0 .12em; }
.ann .amp { font: italic 500 calc(var(--pw) * .085) / 1 var(--f-serif); color: var(--gold); }
.ann .t3 { margin-top: calc(var(--ph) * .016); }
.ann .orn { display: flex; align-items: center; gap: calc(var(--pw) * .02); margin: calc(var(--ph) * .018) 0; opacity: 0; will-change: transform, opacity; }
.ann .orn i { display: block; width: calc(var(--pw) * .13); height: 1px; background: linear-gradient(90deg, rgba(156, 117, 54, 0), var(--gold)); }
.ann .orn i + b + i { background: linear-gradient(90deg, var(--gold), rgba(156, 117, 54, 0)); }
.ann .orn b { display: block; width: calc(var(--pw) * .016); height: calc(var(--pw) * .016); background: var(--gold); transform: rotate(45deg); }
.ann .dt { font: 600 calc(var(--pw) * .043) / 1.5 var(--f-serif); letter-spacing: .14em; text-transform: uppercase; color: var(--burgundy); }
.ann .tm { font: italic 500 calc(var(--pw) * .048) / 1.45 var(--f-serif); color: var(--charcoal); }
.ann .vn { margin-top: calc(var(--ph) * .018); font: 600 calc(var(--pw) * .038) / 1.5 var(--f-serif); letter-spacing: .2em; text-transform: uppercase; color: var(--burgundy); }
.ann .ad { font: italic 500 calc(var(--pw) * .046) / 1.45 var(--f-serif); color: var(--charcoal); }

/* the photo album: everything inside is measured in the open album picture's own pixels (1672 x 941), the closed cover laid over it */
.album { z-index: 9; }
.ab-in { position: absolute; left: 0; top: 0; width: 1800px; height: 960px; transform-origin: 0 0; }
.ab-in .box { position: absolute; top: 0; overflow: hidden; }
.ab-in .pg { position: absolute; left: 0; top: 0; width: 1672px; height: 941px; max-width: none; }
.ab-in .ph { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; background: #EFE3D2; }
.ab-in .ph img { position: relative; display: block; width: 100%; height: 100%; object-fit: cover; }
.ab-in .ph img:not([src]) { visibility: hidden; }
/* a frame with no photo: the couple's initials on ivory */
.ab-in .ph .mono { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--f-script); font-weight: 400; line-height: 1; color: var(--burgundy); background: radial-gradient(ellipse at 50% 45%, #FBF3E7, #EBDCC6); white-space: nowrap; }
.ab-in .half { z-index: 1; }
.ab-in .half.l { opacity: 0; }
.ab-in .rib { z-index: 3; }
.ab-in .cstat { z-index: 4; }
.ab-in .cstat img, .ab-in .cface img { position: absolute; top: 0; height: 944.6px; width: 1417px; max-width: none; }
/* a leaf: the cover as it opens, or a page as it turns; it swings about the spine (x 838) with a face on each side */
.ab-in .lw { position: absolute; left: 0; top: 0; width: 1800px; height: 960px; pointer-events: none; }
.ab-in .lw.covw { z-index: 5; }
.ab-in .lw.pagew { z-index: 2; opacity: 0; }
.ab-in .leaf { position: absolute; top: 0; left: 838px; transform-origin: 0 50%; transform-style: preserve-3d; will-change: transform; }
.ab-in .leaf.cov { width: 956px; height: 950px; }
.ab-in .leaf.page { width: 750px; height: 941px; }
.ab-in .face { position: absolute; left: 0; top: 0; overflow: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.ab-in .face.bk { transform: rotateY(180deg); }
.ab-in .shade { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.ab-in .fr .shade { background: linear-gradient(90deg, rgba(60, 26, 20, .62), rgba(60, 26, 20, .14) 45%, rgba(60, 26, 20, 0)); }
.ab-in .bk .shade { background: linear-gradient(270deg, rgba(60, 26, 20, .62), rgba(60, 26, 20, .14) 45%, rgba(60, 26, 20, 0)); }

/* the registry and the reply: cards of the same blank parchment, the butterfly perched at the top of each */
.pcard { z-index: 10; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--charcoal);
  padding: calc(var(--cw) * .25) calc(var(--cw) * .08) calc(var(--cw) * .06); background: #F1E3CC var(--parch) 0 0 / 100% 100% no-repeat; box-shadow: 0 14px 40px rgba(26, 2, 10, .5); }
.pcard.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pcard .script { margin: 0; font: 400 calc(var(--cw) * .09) / 1 var(--f-script); color: var(--burgundy); }
.pcard h2 { margin: calc(var(--cw) * -.01) 0 0; font: 700 calc(var(--cw) * .06) / 1.2 var(--f-serif); letter-spacing: .3em; text-transform: uppercase; color: var(--burgundy); padding-left: .3em; }
.pcard .lede { margin: calc(var(--cw) * .04) 0 0; font: italic 500 calc(var(--cw) * .047) / 1.45 var(--f-serif); color: var(--charcoal); max-width: 26em; }
.pcard .by { margin: calc(var(--cw) * .012) 0 0; font: italic 500 calc(var(--cw) * .047) / 1.3 var(--f-serif); color: var(--gold); }
.stores { display: grid; gap: calc(var(--cw) * .028); width: 100%; margin-top: calc(var(--cw) * .06); }
.store { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(var(--cw) * .032) calc(var(--cw) * .05); border: 1px solid rgba(156, 117, 54, .55); border-radius: 4px; background: rgba(255, 250, 242, .55); text-decoration: none; color: var(--burgundy); }
.store b { display: block; font: 600 calc(var(--cw) * .05) / 1.2 var(--f-serif); text-align: left; }
.store small { display: block; font: italic 500 calc(var(--cw) * .036) / 1.3 var(--f-serif); color: var(--charcoal); text-align: left; }
.store .ar { font: 400 calc(var(--cw) * .07) / 1 var(--f-serif); color: var(--gold); }
.store:hover { background: rgba(255, 250, 242, .85); }
.store-none { margin: 0; font: italic 500 calc(var(--cw) * .042) / 1.4 var(--f-serif); color: var(--gold); }
/* the host's editor: the film stands still on a step, every line of the announcement written */
html.held .ann p, html.held .ann .orn { opacity: 1; }
/* the reply form */
#rsvp-form, .rdone { width: 100%; margin-top: calc(var(--cw) * .04); text-align: left; }
.ans { display: flex; gap: calc(var(--cw) * .025); margin: 0 0 calc(var(--cw) * .03); padding: 0; border: 0; }
.ans label { flex: 1; position: relative; }
.ans input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ans span { display: block; padding: 12px 6px; border: 1px solid rgba(110, 20, 35, .45); border-radius: 4px; text-align: center; font: 600 calc(var(--cw) * .043) / 1.2 var(--f-serif); color: var(--burgundy); background: rgba(255, 250, 242, .5); }
.ans input:checked + span { background: var(--burgundy); color: #FBF1E4; border-color: var(--burgundy); }
.ans input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.f { display: block; margin: 0 0 calc(var(--cw) * .026); font: 600 calc(var(--cw) * .036) / 1.3 var(--f-serif); letter-spacing: .06em; text-transform: uppercase; color: var(--charcoal); }
.f input, .f textarea { display: block; box-sizing: border-box; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid rgba(59, 51, 48, .35); border-radius: 4px; background: rgba(255, 252, 246, .85); font: 500 16px / 1.3 var(--f-serif); color: var(--charcoal); letter-spacing: 0; text-transform: none; }
.f textarea { resize: none; }
#plus-field { display: flex; align-items: center; justify-content: space-between; }
.step { display: flex; align-items: center; gap: 10px; }
.step button { width: 40px; height: 40px; border: 1px solid rgba(110, 20, 35, .45); border-radius: 50%; background: rgba(255, 250, 242, .6); color: var(--burgundy); font: 600 20px / 1 var(--f-serif); cursor: pointer; }
.step output { min-width: 1.4em; text-align: center; font: 600 18px / 1 var(--f-serif); color: var(--burgundy); }
#err { min-height: 1.2em; margin: 0 0 6px; font: italic 500 15px / 1.3 var(--f-serif); color: #7A1022; }
.btn { display: block; width: 100%; min-height: 48px; border: 0; border-radius: 4px; background: var(--burgundy); color: #FBF1E4; font: 600 calc(var(--cw) * .045) / 1 var(--f-serif); letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }
.btn:disabled { opacity: .6; }
.rdone { text-align: center; }
.rdone .got { margin: calc(var(--cw) * .04) 0 6px; font: 400 calc(var(--cw) * .085) / 1.1 var(--f-script); color: var(--burgundy); }
.rdone p { font: italic 500 calc(var(--cw) * .046) / 1.45 var(--f-serif); }
.linkish { border: 0; background: none; padding: 8px; font: italic 500 16px / 1 var(--f-serif); color: var(--burgundy); text-decoration: underline; cursor: pointer; }
/* (rclosed, not "closed": html.closed is the film's state before the touch, and a style of that name would land on the whole page) */
.rclosed { font: italic 500 16px / 1.4 var(--f-serif); }
.going { margin: calc(var(--cw) * .03) 0 0; text-align: center; font: italic 500 calc(var(--cw) * .042) / 1.3 var(--f-serif); color: var(--gold); }
.going b { font-style: normal; font-weight: 700; color: var(--burgundy); }
html:not(.at-reply) .rsvp form, html:not(.at-reply) .rsvp button, html:not(.at-reg) .reg .store { pointer-events: none; }

/* the butterfly: its body, the wings that hinge where they meet it, the antennae that turn at the head */
.bfly { z-index: 20; }
.bfly > * { position: absolute; left: 0; top: 0; will-change: transform; }
.bfly img { width: 100%; height: 100%; }
.bfly .wing { z-index: 1; } .bfly .ant { z-index: 2; } .bfly .body { z-index: 3; }
.shd { z-index: 19; opacity: 0; }

/* before the guest opens it, and while the album waits: one quiet line at the foot of the screen */
.hint { position: absolute; z-index: 30; left: 0; right: 0; bottom: max(5.5svh, 28px); margin: 0; text-align: center; font: italic 500 clamp(16px, 4.4vw, 22px) / 1.3 var(--f-serif); letter-spacing: .06em; color: rgba(247, 235, 221, .9); opacity: 0; transition: opacity .6s ease; pointer-events: none; }
html.closed .hint.on, html.at-album:not(.lb-on) .hint.on { opacity: 1; }
.open-hit, .go-hit { position: absolute; z-index: 25; border: 0; padding: 0; margin: 0; background: transparent; cursor: pointer; border-radius: 50%; }
.open-hit:focus-visible, .go-hit:focus-visible { outline: 2px solid rgba(247, 235, 221, .8); outline-offset: 4px; }
html:not(.closed) .open-hit, html:not(.at-album) .go-hit, html.lb-on .go-hit { display: none; }

/* a photo from the album, big, on an ivory mount over the darkened scene (butterfly.js sizes it and lifts it out of its frame) */
.lb { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; -webkit-user-select: none; user-select: none; }
.lb[hidden] { display: none; }
.lb-bg { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 42%, rgba(74, 14, 26, .84), rgba(22, 3, 9, .95)); will-change: opacity; }
.lb-fig { position: relative; margin: 0; padding: 10px; background: #FBF6EC; border-radius: 2px; box-shadow: 0 22px 60px rgba(10, 1, 4, .6), 0 4px 12px rgba(10, 1, 4, .35), inset 0 0 0 1px rgba(156, 117, 54, .25); will-change: transform, opacity; }
.lb-fig img { display: block; max-width: none; cursor: pointer; -webkit-user-drag: none; }
.lb-a, .lb-x { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin: 0; padding: 0 0 4px; box-sizing: border-box; border: 1px solid rgba(247, 235, 221, .4); border-radius: 50%; background: rgba(42, 6, 15, .6); color: var(--ivory); font: 400 34px / 1 var(--f-serif); cursor: pointer; }
.lb-a:focus-visible, .lb-x:focus-visible { outline: 2px solid var(--ivory); outline-offset: 2px; }
.lb-prev { left: max(12px, 2vw); top: calc(50% - 24px); }
.lb-next { right: max(12px, 2vw); top: calc(50% - 24px); }
.lb-x { left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); font-size: 30px; }
html.lb-one .lb-a { display: none; }
/* on a phone the arrows sit under the photo, not over its edges */
@media (max-width: 640px) { .lb-prev, .lb-next { top: auto; bottom: max(26px, 5svh); } .lb-prev { left: calc(50% - 64px); } .lb-next { right: calc(50% - 64px); } }

/* no script: the words, the registry and the reply, one under the other on the parchment */
html:not(.ba), html:not(.ba) body { overflow: auto; height: auto; }
html:not(.ba) #stage { position: static; background: #F1E3CC var(--parch) 0 0 / 100% 100%; padding: 24px 0; }
html:not(.ba) .ly:not(.pcard), html:not(.ba) .hint, html:not(.ba) .open-hit, html:not(.ba) .go-hit, html:not(.ba) .bg { display: none; }
html:not(.ba) .ann, html:not(.ba) .pcard { position: relative; width: min(92vw, 560px); margin: 0 auto 24px; --pw: min(92vw, 560px); --ph: 640px; --cw: min(92vw, 560px); transform: none; }
html:not(.ba) .ann p, html:not(.ba) .ann .orn { opacity: 1; }
html:not(.ba) .pcard form, html:not(.ba) .pcard button { pointer-events: auto; }
