/* 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); scroll-snap-type: y proximity; }
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; scroll-snap-align: start; }
#theatre .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%;
  -webkit-mask-image: linear-gradient(#000 86%, transparent); mask-image: linear-gradient(#000 86%, transparent); }   /* the stage's satin skirt runs on into the satin below */

.opening { position: absolute; left: 6cqw; right: 6cqw; top: 11.5cqh; height: 52cqh; 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 min(7cqw, 3.3cqh) / 1.4 var(--arabic); color: var(--gold); }
.tr { font: italic 500 min(3.9cqw, 1.85cqh) / 1.3 var(--serif); color: var(--soft); }
.salam { font: 400 min(3.3cqw, 1.55cqh) / 1 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.we { font: 400 min(4.1cqw, 1.95cqh) / 1.3 var(--serif); }
.we b { font-weight: 600; }
.it { font: italic 400 min(3.9cqw, 1.85cqh) / 1.3 var(--serif); color: var(--soft); }
.name { font: 400 min(8.4cqw, 4.2cqh) / 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 min(4.2cqw, 2cqh) / 1 var(--serif); color: var(--soft); }
.rel { font: 400 min(2.9cqw, 1.35cqh) / 1 var(--caps); letter-spacing: .26em; text-transform: uppercase; color: var(--gold); }
.par { font: 500 min(3.8cqw, 1.8cqh) / 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 10px rgba(80,55,25,.25)); will-change: transform; }
.curtain::before { content: ''; position: absolute; inset: 0; background: url(../img/curtain.webp) 0 0 / 100% 100% no-repeat; }
.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(.2); }
.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; }
.open .valance { transform: translateY(-48%); }

.cue { position: absolute; left: 0; right: 0; bottom: max(3.5cqh, 18px); 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); }
.ev.last { height: calc(100svh * 2.6); }
.snap { position: absolute; left: 0; top: calc(100svh * 1.25); height: 1px; scroll-snap-align: start; }
.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 min(2.9cqw, 1.35cqh) / 1 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.title { font: 400 min(11cqw, 5.6cqh) / 1 var(--script); color: var(--gold); white-space: nowrap; margin-top: -.6cqh; }
.lede { font: italic 400 min(4cqw, 1.95cqh) / 1.3 var(--serif); color: var(--soft); max-width: 15em; }
.couple { font: 500 min(5cqw, 2.4cqh) / 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 min(4.6cqw, 2.2cqh) / 1.25 var(--serif); }
.when span { display: block; font: 400 min(2.9cqw, 1.35cqh) / 1.6 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.venue { font: 600 min(4.4cqw, 2.1cqh) / 1.2 var(--serif); }
.addr { font: 400 min(3.6cqw, 1.7cqh) / 1.3 var(--serif); color: var(--soft); margin-top: -1cqh; }
.links { display: flex; gap: 22px; white-space: nowrap; }
.links a { font: 400 11.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); }

/* ---------- 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(9svh, 52px); }
.veil .it { font-size: 18px; color: var(--ink); }
.veil .mono { margin-top: 8px; font: 400 14px var(--caps); letter-spacing: .4em; 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 46px / 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; }
}
