/* Tahia & Hamza: glitter → curtains → an empty stage with the invitation → one lace envelope per celebration.
   Everything lives in one phone-shaped column (the full width on a phone), centred on an ivory page. */
:root {
  --col: min(100vw, 62svh);
  --page: #efe6d8;
  --ink: #4a3520;
  --gold: #7a5826;   /* at least 4.5:1 on the stage haze and the paper, for the small capitals */
  --soft: #6e5634;
  --script: 'Great Vibes', cursive;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --caps: 'Marcellus', 'Cormorant Garamond', serif;
  --arabic: 'Aref Ruqaa', 'Amiri', serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--page); }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--serif); -webkit-font-smoothing: antialiased; font-variant-numeric: lining-nums; overflow-x: hidden; }
body.locked { overflow: hidden; height: 100svh; }
p, h1, h2 { margin: 0; font-weight: inherit; }
main { position: relative; z-index: 1; width: var(--col); margin: 0 auto; }

#satin { position: fixed; top: 0; bottom: 0; left: 50%; width: var(--col); transform: translateX(-50%); z-index: 0;
  background: #efe4d2 url(../img/satin.webp) center / cover no-repeat; }
@media (min-aspect-ratio: 2/3) { #satin, #theatre { box-shadow: 0 0 60px rgba(90,65,30,.14); } }

/* ---------- 1 · the stage ---------- */
#theatre { position: relative; height: 100svh; overflow: hidden; container-type: size; background: #dcd2ca; }   /* the stage picture's top colour */
/* set 7% lower than the screen top, so the platform sits lower and the words have more room above it */
#theatre .bg { position: absolute; left: 0; top: 7cqh; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%;
  -webkit-mask-image: linear-gradient(transparent, #000 4cqh, #000 80%, transparent 93%); mask-image: linear-gradient(transparent, #000 4cqh, #000 80%, transparent 93%); }   /* the stage's satin skirt runs on into the satin below */

.opening { position: absolute; left: 9cqw; right: 9cqw;   /* clear of the gathered curtains */ top: 11.5cqh; height: 54.5cqh; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; text-align: center; }
.opening .ln { opacity: 0; transform: translateY(8px); filter: blur(5px); transition: opacity 1.1s ease, transform 1.3s cubic-bezier(.16,1,.3,1), filter 1.1s ease;
  text-shadow: 0 0 2px #fbf6ec, 0 0 12px rgba(251,246,236,.9); }
.open .opening .ln { opacity: 1; transform: none; filter: none; }
.arabic { font: 400 calc(var(--k, 1) * min(8.40cqw, 3.96cqh)) / 1.4 var(--arabic); color: var(--gold); }
.tr { font: italic 500 calc(var(--k, 1) * min(4.68cqw, 2.22cqh)) / 1.3 var(--serif); color: var(--soft); }
.salam { font: 400 calc(var(--k, 1) * min(4.12cqw, 1.94cqh)) / 1 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.we { font: 400 calc(var(--k, 1) * min(5.40cqw, 2.59cqh)) / 1.3 var(--serif); }
.we b { font-weight: 600; }
.it { font: italic 400 calc(var(--k, 1) * min(4.68cqw, 2.22cqh)) / 1.3 var(--serif); color: var(--soft); }
.name { font: 400 calc(var(--k, 1) * min(9.66cqw, 4.83cqh)) / 1.15 var(--script); color: var(--gold); white-space: nowrap; }
.open .opening .name { clip-path: inset(-20% -5% -20% -5%); }
.opening .name { clip-path: inset(-20% 105% -20% -5%); transition: clip-path 1.6s cubic-bezier(.45,0,.25,1), opacity .4s ease; }   /* "written" left to right */
.with { font: italic 400 calc(var(--k, 1) * min(5.04cqw, 2.40cqh)) / 1 var(--serif); color: var(--soft); }
.rel { font: 400 calc(var(--k, 1) * min(3.77cqw, 1.76cqh)) / 1 var(--caps); letter-spacing: .26em; text-transform: uppercase; color: var(--gold); }
.par { font: 500 calc(var(--k, 1) * min(5.29cqw, 2.53cqh)) / 1.3 var(--serif); }

/* the curtains: one panel, mirrored; opening squeezes each towards its side so the folds bunch up */
.curtain { position: absolute; top: 0; bottom: 0; width: 52%;
  transition: transform 2.8s cubic-bezier(.62,0,.22,1); filter: drop-shadow(0 0 8px rgba(80,55,25,.12)); will-change: transform; }
.curtain::before { content: ''; position: absolute; inset: 0; background: url(../img/curtain.webp) 0 0 / 100% 100% no-repeat;
  filter: saturate(.18) brightness(1.24) contrast(.82); opacity: .8; }   /* sheer white voile: the stage shows through */
.curtain.r::before { transform: scaleX(-1); }   /* the same panel, mirrored, so its gold edge faces the middle */
.curtain.l { left: 0; transform-origin: 0 50%; }
.curtain.r { right: 0; transform-origin: 100% 50%; }
.open .curtain { transform: scaleX(.15); }   /* gathered to 7.8% of the width on each side */
.valance { position: absolute; top: 0; left: 0; width: 100%; height: auto; z-index: 2; transition: transform 2.6s cubic-bezier(.62,0,.22,1) .3s; pointer-events: none;
  filter: saturate(.45) brightness(1.16) contrast(.9); }   /* whitened to match the sheers, the fringe still reads as gold */
.open .valance { transform: translateY(-48%); }

.cue { position: absolute; left: 0; right: 0; bottom: max(9cqh, 64px); z-index: 3; text-align: center; font: 400 11px / 1 var(--caps); letter-spacing: .24em; text-transform: uppercase;
  color: var(--soft); text-shadow: 0 0 6px #fbf6ec, 0 0 14px #fbf6ec; opacity: 0; transition: opacity 1.2s ease; }
.cue i { display: block; width: 9px; height: 9px; margin: 9px auto 0; border: solid var(--soft); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); animation: nudge 1.8s ease-in-out infinite; }
.ready .cue { opacity: 1; }
@keyframes nudge { 50% { transform: translate(0, 5px) rotate(45deg); } }

/* ---------- 2 · the envelopes ---------- */
.ev { position: relative; height: calc(100svh * 3.6); }
.pin { position: sticky; top: 0; height: 100svh; overflow: hidden; container-type: size; }
/* the envelope's size and the letter's travel are set by js/main.js from the screen size */
.env { position: absolute; left: 50%; bottom: 0; width: var(--ew, 94cqw); aspect-ratio: .8154; transform: translateX(-50%); }
.env .back, .env .front { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.env .back { filter: drop-shadow(0 8px 18px rgba(80,55,25,.28)); }
.env .front { z-index: 2; }
/* the letter is clipped at the bottom of the envelope, so it only ever shows above it */
.slot { position: absolute; left: -10%; right: -10%; bottom: 1.2%; height: 400cqh; overflow: hidden; z-index: 1; pointer-events: none; }
.letter { position: absolute; left: 50%; bottom: 0; width: var(--lw, 82cqw); height: var(--lh, 80cqh); margin-left: calc(var(--lw, 82cqw) / -2);
  transform: translateY(var(--ly, 0px)); padding: var(--lp, 6cqh) 7% var(--lb, 20cqh); pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center;
  background: #fbf7ef url(../img/paper.webp) center / cover; border-radius: 3px; box-shadow: 0 2px 6px rgba(80,55,25,.12), 0 14px 30px rgba(80,55,25,.16); }
.letter > * { flex: none; }
.brooch { position: absolute; left: -4%; top: -2.2cqh; width: min(17cqw, 74px); transform: rotate(-12deg); filter: drop-shadow(1px 3px 3px rgba(60,40,15,.35)); }
.kick { font: 400 calc(var(--k, 1) * min(3.77cqw, 1.76cqh)) / 1 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.title { font: 400 calc(var(--k, 1) * min(12.32cqw, 6.27cqh)) / 1 var(--script); color: var(--gold); white-space: nowrap; margin-top: -.6cqh; }
.lede { white-space: nowrap; font: italic 400 calc(var(--k, 1) * min(4.80cqw, 2.34cqh)) / 1.3 var(--serif); color: var(--soft); }
.couple { font: 500 calc(var(--k, 1) * min(5.90cqw, 2.83cqh)) / 1.15 var(--serif); color: var(--ink); white-space: nowrap; }
.couple span { display: block; font: 400 1.15em / 1 var(--script); color: var(--gold); margin: .1em 0 .05em; }
.divider { width: 72%; height: auto; }
.when { font: 500 calc(var(--k, 1) * min(5.29cqw, 2.53cqh)) / 1.25 var(--serif); }
.when span { display: block; font: 400 calc(var(--k, 1) * min(3.77cqw, 1.76cqh)) / 1.6 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.venue { font: 600 calc(var(--k, 1) * min(5.19cqw, 2.48cqh)) / 1.2 var(--serif); }
.addr { font: 400 calc(var(--k, 1) * min(4.39cqw, 2.07cqh)) / 1.3 var(--serif); color: var(--soft); margin-top: -1cqh; }
.attire { font: italic 500 calc(var(--k, 1) * min(4.39cqw, 2.07cqh)) / 1.3 var(--serif); color: var(--soft); margin-top: -.6cqh; }
.attire span { display: block; font: 400 calc(var(--k, 1) * min(3.77cqw, 1.76cqh)) / 1.6 var(--caps); font-style: normal; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.links { display: flex; gap: 22px; white-space: nowrap; }
.links a { font: 400 calc(var(--k, 1) * 12.5px) var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); text-decoration: none; padding: 10px 2px 6px; border-bottom: 1px solid rgba(143,106,51,.5); }

/* every line is laid out by hand (<br>), so none may wrap: js/main.js fits them (see fitText) */
.opening .ln, .letter > p, .letter > h2, #finale .card > p, .veil p, .veil span { white-space: nowrap; }

/* ---------- the countdown ---------- */
#finale { position: relative; height: 100svh; container-type: size; display: flex; align-items: center; justify-content: center; }
#finale .card { position: relative; width: 84cqw; max-height: 92cqh; padding: 5.5cqh 7% 4.5cqh; display: flex; flex-direction: column; align-items: center; gap: 1.9cqh; text-align: center;
  background: #fbf7ef url(../img/paper.webp) center / cover; border-radius: 3px; box-shadow: 0 2px 6px rgba(80,55,25,.12), 0 14px 30px rgba(80,55,25,.16); }
#finale .brooch { top: -2.4cqh; }
.count { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; border-top: 1px solid rgba(122,88,38,.45); border-bottom: 1px solid rgba(122,88,38,.45); }
.count div { padding: 1.3cqh 6px 1cqh; display: grid; } .count div + div { border-left: 1px solid rgba(122,88,38,.3); }
.count b { font: 500 calc(var(--k, 1) * min(9.72cqw, 4.97cqh)) / 1 var(--serif); color: var(--ink); }
.count span { font: 400 calc(var(--k, 1) * 9.5px) var(--caps); letter-spacing: .06em; text-transform: uppercase; color: var(--gold); margin-top: 5px; }
#finale .tr { max-width: 17em; }
#finale .divider { width: 62%; }

/* ---------- the glitter cover ---------- */
#cover { position: fixed; inset: 0; z-index: 20; }
#glitter { position: absolute; top: 0; left: 50%; height: 100%; width: var(--col); transform: translateX(-50%); }
.veil { position: absolute; left: 50%; width: var(--col); transform: translateX(-50%); text-align: center; color: var(--ink); transition: opacity .5s ease;
  text-shadow: 0 0 3px #fbf6ec, 0 0 10px #fbf6ec, 0 0 22px rgba(251,246,236,.95); }
.veil.top { top: max(8svh, 44px); }
.veil::before { content: ''; position: absolute; inset: -40px -10px; z-index: -1; background: radial-gradient(closest-side, rgba(251,246,236,.94), rgba(251,246,236,.75) 55%, rgba(251,246,236,0)); }
.veil .it { font: italic 500 calc(var(--k, 1) * min(8.4vw, 5.2svh, 34px)) / 1.25 var(--serif); color: var(--ink); }
.veil .mono { margin-top: 12px; font: 400 calc(var(--k, 1) * min(6.4vw, 4svh, 26px)) var(--caps); letter-spacing: .3em; color: var(--gold); }
.veil.tap { bottom: max(9svh, 40px); background: none; border: 0; padding: 18px 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.veil.tap .script { font: 400 calc(var(--k, 1) * min(12vw, 7.4svh, 52px)) / 1.1 var(--script); color: var(--gold); }
.veil.tap .it { font-size: 15px; color: var(--soft); }
.blowing .veil { opacity: 0; }
#cover.gone { display: none; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 30; pointer-events: none; }

.music { position: fixed; right: max(14px, env(safe-area-inset-right), calc((100vw - var(--col)) / 2 + 14px)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(143,106,51,.35); background: rgba(251,247,239,.82); display: flex; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.music i { width: 2px; height: 15px; background: var(--gold); animation: bar .9s ease-in-out infinite alternate; transform-origin: bottom; }
.music i:nth-child(2) { animation-delay: .3s; } .music i:nth-child(3) { animation-delay: .6s; }
.music.off i { animation: none; transform: scaleY(.3); }
.music[hidden] { display: none; }
@keyframes bar { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

/* link-preview capture (#og): the open stage, wide, with the short names */
.ogcard { display: none; }
.og { --col: 100vw; }
.og #theatre { height: 100vh; }
.og #theatre .bg { left: 50%; top: -30%; width: auto; height: 190%; transform: translateX(-50%); -webkit-mask-image: none; mask-image: none; }
.og .opening, .og .cue, .og #satin, .og .music { display: none; }
.og .curtain { width: 30%; }
.og.open .curtain { transform: scaleX(.8); }   /* half open, hiding the stage picture's edges */
.og.open .valance { transform: translateY(-64%); }
.og .ogcard { display: flex; position: absolute; left: 0; right: 0; top: 29%; height: 38%; flex-direction: column; align-items: center; justify-content: center; gap: 2.2vh;
  text-shadow: 0 0 3px #fbf6ec, 0 0 16px #fbf6ec, 0 0 30px #fbf6ec; }
.og .ogcard .name { font-size: 15vh; clip-path: none; }
.og .ogcard .salam { font-size: 3.3vh; }

/* test hook: #settle shows everything in place at once */
.settle * { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .curtain, .valance, .opening .ln { transition-duration: .01s !important; transition-delay: 0s !important; }
  .cue i, .music i { animation: none; }
}
