/* Tokens, base, sealed letter + opening, sound + language buttons, petals, notice. */
:root {
  --euc: #5f7a6a;          /* eucalyptus */
  --euc-deep: #46634f;
  --euc-night: #2f4a3c;
  --euc-mist: #b9c9bd;
  --euc-haze: #e2eae3;
  --linen: #f5efe3;
  --card: #fffdf8;
  --backdrop: #d3dbd3;
  --text: #2f3a33;
  --text-soft: #4d5a52;
  --text-mute: #5f6b63;    /* ≥ 4.5:1 on card and linen */
  --brass: #b8945a;        /* rules and ornaments only */
  --brass-soft: #e2cfa5;
  --brass-text: #84652f;   /* brass for text, ≥ 4.5:1 */
  --font-calli: 'Great Vibes', cursive;
  --font-serif: 'Cormorant Garamond', 'Amiri', Georgia, serif;
  --font-ui: 'Jost', 'Readex Pro', system-ui, sans-serif;
  --spacing-caps: .28em;   /* must stay 0 for Arabic, or the letters come apart */
  --bounce: cubic-bezier(.22, 1.18, .36, 1);
  --glide: cubic-bezier(.65, 0, .35, 1);
  --col: 480px;
  --unit: min(1vw, calc(var(--col) / 100)); /* 1% of the page column; works without container queries */
  /* palette pieces that aren't single tokens above */
  --ink: #3c443d;
  --shade: 30, 45, 35;          /* shadows, as r, g, b */
  --accent-rgb: 70, 99, 79;     /* thin borders and glows */
  --ink-rgb: 36, 48, 41;        /* the notice bubble */
  --board-bg: linear-gradient(180deg, #edf1ec 0%, #e5ebe5 42%, #dce5dd 100%);
  --band: linear-gradient(180deg, #5b7a69 0%, #435f50 100%);
  --band-deep: linear-gradient(180deg, #5b7a69 0%, #4b6858 50%, #3d5747 100%);
  --formal-top: #e8eee7;
  --map-bg: #edf1ea;
  --farewell-end: #eaefe8;
  --og-bg: #dfe7df;
  --mic-hi: #7f9c8a;
}
/* Beige, white & caramel (invite.json "palette": "caramel"). The drawings follow in js/art.js. */
html[data-palette="caramel"] {
  --euc: #a8784d;
  --euc-deep: #855a35;
  --euc-night: #5a3c24;
  --euc-mist: #e6d3bb;
  --euc-haze: #f5ebdf;
  --linen: #f8f2ea;
  --card: #fffdfa;
  --backdrop: #ebe1d4;
  --text: #3d3027;
  --text-soft: #5c4a3c;
  --text-mute: #735e4c;
  --brass: #c4a06a;
  --brass-soft: #ecdcbf;
  --brass-text: #86602f;
  --ink: #4a3a2d;
  --shade: 74, 48, 24;
  --accent-rgb: 133, 90, 53;
  --ink-rgb: 58, 40, 26;
  --board-bg: linear-gradient(180deg, #faf5ee 0%, #f4ebdf 45%, #ecdcc9 100%);
  --band: linear-gradient(180deg, #9c6b3f 0%, #8d5f37 100%);
  --band-deep: linear-gradient(180deg, #95663b 0%, #8f6139 50%, #885b34 100%); /* white kicker ≥ 4.5:1 at the top */
  --formal-top: #f3eadf;
  --map-bg: #f6efe6;
  --farewell-end: #f2e8db;
  --og-bg: #f1e7da;
  --mic-hi: #c99a6c;
}
/* Classic printed Arabic for names and titles (invite.json "fontAr": "amiri"): easy to read, a little flourish. */
html[lang="ar"][data-font-ar="amiri"] { --font-calli: 'Amiri', serif; }
html[lang="ar"][data-font-ar="amiri"] .calli { letter-spacing: 0; }
html[lang="ar"] {
  --font-calli: 'Aref Ruqaa', 'Amiri', serif;
  --font-serif: 'Amiri', serif;
  --font-ui: 'Readex Pro', system-ui, sans-serif;
  --spacing-caps: 0;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--backdrop);
  color: var(--text);
  font: 400 17px/1.6 var(--font-serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.is-sealed { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; box-shadow: 0 0 0 5px var(--card); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.page {
  position: relative;
  max-width: var(--col);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  overflow: clip; /* nothing can scroll the page sideways */
  background: var(--card);
  box-shadow: 0 0 60px rgba(var(--shade), .12);
  outline: none;
}
.noscript { max-width: 420px; margin: 40vh auto 0; padding: 0 20px; text-align: center; font-family: system-ui, sans-serif; }

/* ---------- type ---------- */
.calli { font-family: var(--font-calli); font-weight: 400; line-height: 1.15; }
html[lang="ar"] .calli { font-weight: 700; line-height: 1.5; }
.kicker {
  margin: 0;
  font: 500 12px/1.5 var(--font-ui);
  letter-spacing: var(--spacing-caps);
  text-transform: uppercase;
  color: var(--brass-text);
}
html[lang="ar"] .kicker { font-size: 15px; text-transform: none; }
.join { color: var(--brass-text); }

/* ---------- pills & links ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 26px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font: 600 13px/1 var(--font-ui);
  letter-spacing: calc(var(--spacing-caps) * .55);
  text-transform: uppercase;
  text-decoration: none;
  transition: transform .2s, background-color .2s;
}
html[lang="ar"] .pill { font-size: 16px; font-weight: 500; text-transform: none; }
.pill:active { transform: scale(.97); }
.pill--fill { background: var(--euc-deep); color: var(--card); box-shadow: 0 12px 22px -12px rgba(var(--shade), .7); }
.pill--line { background: transparent; border-color: currentColor; }
.pill--wide { width: 100%; }
.pill[disabled] { opacity: .6; cursor: default; }
.icon { width: 20px; height: 20px; flex: none; }
.textlink {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--euc-deep);
  font: 500 15px var(--font-ui);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- sealed letter ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  place-items: safe center;
  overflow-x: hidden;
  overflow-y: auto; /* landscape phones: the hint stays reachable */
  background: radial-gradient(110% 75% at 50% 38%, #fdfaf3 0%, var(--linen) 58%, #e9e2d3 100%);
  transition: opacity .7s ease;
}
.gate.is-leaving { opacity: 0; pointer-events: none; }
.gate__inner { width: 100%; max-width: var(--col); min-width: 0; padding: 20px 22px calc(22px + env(safe-area-inset-bottom)); text-align: center; }
.gate__kicker { color: var(--text-mute); transition: opacity .45s, transform .5s; }
.guest-name { letter-spacing: 0; text-transform: none; }
.gate__names {
  margin: 8px 0 38px;
  white-space: nowrap;
  font-size: clamp(42px, 13vw, 60px);
  color: var(--euc-night);
  transition: opacity .45s, transform .5s;
}
.gate__names.is-stacked { display: flex; flex-direction: column; align-items: center; white-space: normal; line-height: 1.08; font-size: clamp(36px, 11vw, 52px); }
.gate__names .join { margin: 0 .1em; font-size: .62em; }

.letter {
  --lw: min(calc(100vw - 44px), calc(var(--col) - 44px), max(220px, calc((100vh - 250px) * 600 / 420))); /* the letter's width */
  position: relative;
  width: var(--lw);
  margin-inline: auto;
  aspect-ratio: 600 / 420;
  cursor: pointer;
  filter: drop-shadow(0 24px 24px rgba(52, 46, 30, .2));
}
@supports (height: 100svh) {
  .letter { --lw: min(calc(100vw - 44px), calc(var(--col) - 44px), max(220px, calc((100svh - 250px) * 600 / 420))); }
}
.letter__back, .letter__pocket { position: absolute; inset: 0; width: 100%; height: 100%; }
.letter__back { z-index: 1; }
.letter__card {
  position: absolute;
  z-index: 2;
  top: 9%;
  right: 8%;
  left: 8%;
  height: 70%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 6%;
  background: var(--card);
  box-shadow: inset 0 0 0 6px var(--card), inset 0 0 0 7px var(--brass-soft);
  transition: transform .85s var(--bounce);
}
/* With the Quran opening, the Basmala crowns the card as it rises out of the envelope. */
.letter__card--blessed { padding-top: 3.6%; }
.letter__basmala { margin-bottom: calc(var(--lw) * .004); font: 400 calc(var(--lw) * .036)/1.6 'Amiri', serif; letter-spacing: 0; color: var(--brass-text); }
.letter__mono { font-size: calc(var(--lw) * .1); color: var(--euc-night); }
.letter__mono { display: flex; align-items: center; gap: .22em; }
.mono-heart { width: .34em; height: .34em; fill: var(--brass); }
.letter__date { font: 500 calc(var(--lw) * .03) var(--font-ui); letter-spacing: var(--spacing-caps); text-transform: uppercase; color: var(--text-mute); }
html[lang="ar"] .letter__date { font-size: calc(var(--lw) * .038); }
/* Sealed, the card sits inside the envelope (under the flap, the pocket and the seal): its lines come in as the seal
   breaks, so nothing half-hidden shows through the paper or under the wax. */
.letter__card > * { transition: opacity .4s ease .15s; }
.gate:not(.is-breaking) .letter__card > * { visibility: hidden; opacity: 0; }
.letter__pocket { z-index: 3; filter: drop-shadow(0 -2px 3px rgba(40, 35, 25, .08)); }
.letter__flap { position: absolute; inset: 0; z-index: 4; transform-origin: 50% 0; transition: transform .62s var(--glide); }
.flap-face { position: absolute; inset: 0; width: 100%; height: 100%; }
.flap-face--in { opacity: 0; }
.letter__sprig { position: absolute; z-index: 6; pointer-events: none; filter: drop-shadow(0 6px 8px rgba(var(--shade), .2)); }
.letter__sprig img { width: 100%; transform-origin: 50% 92%; animation: sprigSway 5.5s ease-in-out infinite alternate; }
.letter__sprig--a { top: -24%; right: -8%; width: 36%; transform: rotate(200deg); }
.letter__sprig--b { bottom: -20%; left: -9%; width: 32%; transform: rotate(28deg); }

.wax {
  position: absolute;
  z-index: 7;
  top: 60%;
  left: 50%;
  width: 26%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 7px 8px rgba(var(--shade), .35));
  animation: waxPulse 2.8s ease-in-out infinite;
}
.wax::after {
  content: '';
  position: absolute;
  inset: -9%;
  border: 1.5px solid rgba(184, 148, 90, .8);
  border-radius: 50%;
  pointer-events: none;
  animation: halo 2.8s ease-out infinite;
}
.wax__half { position: absolute; inset: 0; }
.wax__half svg { width: 100%; height: 100%; }
.wax__half--a { clip-path: polygon(0 0, 53% 0, 47% 21%, 55% 40%, 46% 60%, 53% 79%, 48% 100%, 0 100%); }
.wax__half--b { clip-path: polygon(53% 0, 100% 0, 100% 100%, 48% 100%, 53% 79%, 46% 60%, 55% 40%, 47% 21%); }
.wax-letter { font-family: var(--font-calli); font-size: 50px; }
html[lang="ar"] .wax-letter { font-size: 44px; font-weight: 700; }
.letter__petals { position: absolute; z-index: 5; top: 30%; left: 50%; width: 0; height: 0; pointer-events: none; }
.letter__petals i { position: absolute; top: 0; left: -8px; width: 16px; height: 16px; opacity: 0; filter: drop-shadow(0 1px 1.5px rgba(var(--shade), .3)); }
.letter__petals svg { width: 100%; height: 100%; }

.gate__hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 36px 0 0;
  font: 500 13px var(--font-ui);
  letter-spacing: calc(var(--spacing-caps) * .9);
  text-transform: uppercase;
  color: var(--text-mute);
  transition: opacity .3s;
}
html[lang="ar"] .gate__hint { font-size: 17px; text-transform: none; }
.gate__hint span { white-space: nowrap; }
.gate__hint::before, .gate__hint::after { content: ''; flex: 0 1 46px; min-width: 14px; height: 1px; background: var(--brass); }

@keyframes waxPulse { 50% { transform: translate(-50%, -50%) scale(1.05); } }
@keyframes halo { from { opacity: .9; transform: scale(.92); } to { opacity: 0; transform: scale(1.3); } }
@keyframes sprigSway { from { transform: rotate(-2deg); } to { transform: rotate(2.5deg); } }

/* opening: seal cracks → flap lifts → card rises (classes added in app.js) */
.is-breaking .wax { animation: none; }
.is-breaking .wax::after { display: none; }
.is-breaking .wax__half--a { animation: crackA .7s var(--glide) forwards; }
.is-breaking .wax__half--b { animation: crackB .7s var(--glide) forwards; }
.is-breaking .gate__kicker, .is-breaking .gate__names { opacity: 0; transform: translateY(-10px); }
.is-breaking .gate__hint { opacity: 0; }
.is-flap .letter__flap { transform: scaleY(-1); }
.is-flap .flap-face--out { animation: faceOff .62s linear forwards; }
.is-flap .flap-face--in { animation: faceOn .62s linear forwards; }
.is-flap-back .letter__flap { z-index: 1; }
.is-card .letter__card { transform: translateY(-44%); }
.is-card .letter__petals i { animation: petalLift 1.5s calc(var(--k) * 60ms) ease-out forwards; }
@keyframes crackA {
  18% { transform: translateX(-4%) rotate(-6deg); }
  100% { transform: translate(-60%, 70%) rotate(-38deg); opacity: 0; }
}
@keyframes crackB {
  18% { transform: translateX(4%) rotate(6deg); }
  100% { transform: translate(60%, 70%) rotate(38deg); opacity: 0; }
}
@keyframes faceOff { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes faceOn { 0%, 49% { opacity: 0; } 50%, 100% { opacity: 1; } }
@keyframes petalLift {
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), -170px) rotate(var(--rot)); }
}

/* ---------- sound button ---------- */
/* Top left in both languages: the board isn't mirrored in English (the date tag stays top left), so the two buttons
   keep the same corners as in Arabic and the language button never lands on the date. */
.sound {
  position: fixed;
  z-index: 40;
  top: calc(12px + env(safe-area-inset-top)); /* a bottom corner would sit on the countdown tiles */
  left: max(12px, calc((100vw - var(--col)) / 2 + 12px));
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 50%;
  background: rgba(255, 253, 248, .93);
  color: var(--euc-night);
  box-shadow: 0 10px 22px -10px rgba(var(--shade), .5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.sound__bars { display: flex; align-items: flex-end; gap: 3px; height: 16px; }
.sound__bars i { width: 3.5px; height: 100%; border-radius: 2px; background: currentColor; transform: scaleY(.3); transform-origin: 50% 100%; }
.sound__bars i:nth-child(2) { transform: scaleY(.6); }
.sound:not(.is-on) .sound__bars { opacity: .55; }
.sound.is-on .sound__bars i { animation: level .85s ease-in-out infinite alternate; }
.sound.is-on .sound__bars i:nth-child(2) { animation-delay: -.28s; }
.sound.is-on .sound__bars i:nth-child(3) { animation-delay: -.56s; }
@keyframes level { from { transform: scaleY(.25); } to { transform: scaleY(1); } }
@media (max-width: 359px) { .sound { width: 44px; height: 44px; } }

/* ---------- language switch (top right in both languages, see the sound button) ---------- */
.lang-switch {
  position: fixed;
  z-index: 65; /* over the cover too */
  top: calc(16px + env(safe-area-inset-top)); /* centred on the 48px sound button */
  right: max(12px, calc((100vw - var(--col)) / 2 + 12px));
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 999px;
  background: rgba(255, 253, 248, .93);
  color: var(--euc-night);
  font: 500 14px/1 'Jost', system-ui, sans-serif;
  letter-spacing: .06em;
  box-shadow: 0 10px 22px -10px rgba(var(--shade), .5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: transform .2s;
}
.lang-switch:lang(ar) { font: 500 15px/1 'Readex Pro', system-ui, sans-serif; letter-spacing: 0; }
.lang-switch:active { transform: scale(.96); }

/* ---------- falling petals ---------- */
.petals {
  position: fixed;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(100%, var(--col));
  overflow: hidden;
  transform: translateX(-50%);
  pointer-events: none;
}
/* small white blossoms drifting down (drawn in Art.petal) */
.petal { position: absolute; top: -24px; left: var(--px); width: var(--ps); height: var(--ps); animation: drift var(--pt) linear forwards; filter: drop-shadow(0 1px 1.5px rgba(var(--shade), .28)); }
.petal svg { width: 100%; height: 100%; animation: flutter 3.2s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(var(--pd), calc(100vh + 40px)) rotate(var(--pr)); } }
@keyframes flutter { from { transform: translateX(-6px) rotate(-28deg) scale(.86); } to { transform: translateX(6px) rotate(28deg) scale(1); } }

/* ---------- "scroll down" hint after the envelope opens ---------- */
.scroll-hint {
  position: fixed;
  z-index: 35;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 18px 6px;
  border: 1px solid rgba(var(--accent-rgb), .22);
  border-radius: 999px;
  background: rgba(255, 253, 248, .9);
  color: var(--euc-night);
  font: 500 12px/1.3 var(--font-ui);
  letter-spacing: calc(var(--spacing-caps) * .6);
  text-transform: uppercase;
  box-shadow: 0 10px 22px -12px rgba(var(--shade), .55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s ease, transform .6s ease;
}
html[lang="ar"] .scroll-hint { font-size: 14px; text-transform: none; }
.scroll-hint--board { position: absolute; z-index: 5; bottom: calc(6 * var(--unit)); }
.scroll-hint.is-on { opacity: 1; pointer-events: auto; }
.scroll-hint.is-off { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
.scroll-hint svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(-2px); opacity: .55; } 50% { transform: translateY(3px); opacity: 1; } }

/* ---------- notice ---------- */
.notice {
  position: fixed;
  z-index: 70;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: min(90vw, 400px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(var(--ink-rgb), .95);
  color: var(--card);
  font: 400 14px/1.5 var(--font-ui);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.notice.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- scroll entrance ---------- */
.rise { opacity: 0; transform: translateY(20px); transition: opacity .8s ease, transform .9s var(--bounce); }
.rise.is-shown { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .rise { opacity: 1; transform: none; transition: none; }
  .wax, .wax::after, .letter__sprig img, .sound.is-on .sound__bars i, .scroll-hint svg { animation: none; }
  .is-breaking .wax__half--a, .is-breaking .wax__half--b { animation: none; opacity: 0; }
  .letter__flap, .letter__card { transition: none; }
}
