/* ============================================================
   Zaffa — shared viewer styles (all templates)
   ============================================================ */
:root {
  --paper: #efe6d8;
  --paper-2: #e7dbc7;
  --ink: #5a4838;
  --ink-2: #86735f;
  --ink-3: #a99880;
  --gold: #c9ae7c;
  --gold-2: #b3955f;
  --glass: rgba(255, 252, 246, 0.55);
  --glass-border: rgba(201, 174, 124, 0.55);

  --font-latin: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --font-ar-display: 'Aref Ruqaa', 'Amiri', serif;
  --font-ar: 'Amiri', 'Noto Naskh Arabic', serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-door: cubic-bezier(0.33, 1, 0.68, 1);       /* heavy leaf: swings, then settles edge-on */

  /* Timeline (tune freely) */
  --door-dur: 3400ms;        /* door swing */
  --reveal-base: 2400ms;     /* first text appears this long after the click */
  --reveal-step: 500ms;      /* gap between items */
  --reveal-dur: 1200ms;      /* each item's fade */

  --card-max: 560px;
  color-scheme: only light;

  /* Typography slots (the admin can override --names-*, --joiner-*, --body-* per invitation) */
  --names-font-default: var(--font-latin);
  --joiner-font-default: var(--font-latin);
  --body-font-default: var(--font-latin);
  --names-weight-default: 500;
}
html[lang="ar"] {
  --names-font-default: var(--font-ar-display);
  --joiner-font-default: var(--font-ar-display);
  --body-font-default: var(--font-ar);
  --names-weight-default: 400;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--paper);
  height: 100%;
}
html.is-closed { overflow: hidden; }

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  font-family: var(--body-font, var(--body-font-default));
  background: var(--paper-2) url('/templates/lace-doors/paper.webp') center / cover;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button, a, [role="button"] {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
a { color: inherit; text-decoration: none; }
p, h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

/* Arabic script must never get letter-spacing or uppercase */
html[lang="ar"] .caps,
html[lang="ar"] [data-t],
html[lang="ar"] .pill span { letter-spacing: 0 !important; text-transform: none !important; }
[data-t], [data-f] { unicode-bidi: plaintext; }

/* ---------- Reveal choreography ---------- */
[data-reveal] { opacity: 0; }
.is-revealing [data-reveal] {
  animation: reveal var(--reveal-dur) var(--ease-out) both;
  animation-delay: calc(var(--reveal-base) + var(--i, 0) * var(--reveal-step));
}
.is-revealed [data-reveal] { opacity: 1; animation: none; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(14px); filter: blur(7px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}
@media (prefers-reduced-motion: reduce) {
  :root { --reveal-step: 180ms; --reveal-dur: 600ms; --reveal-base: 600ms; --door-dur: 900ms; }
  @keyframes reveal { from { opacity: 0; } to { opacity: 1; } }
}

/* ---------- Glass pill (buttons / links) ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: calc(11px * var(--body-scale, 1)); font-weight: var(--body-weight, 400); letter-spacing: 0.22em; text-transform: uppercase; line-height: 1;
  box-shadow: 0 6px 18px rgba(90, 72, 56, 0.08);
  transition: transform 120ms var(--ease-out), background 160ms ease, border-color 160ms ease;
  min-height: 42px;
}
html[lang="ar"] .pill { font-size: calc(14px * var(--body-scale, 1)); }
.pill:active { transform: scale(0.97); background: rgba(255, 252, 246, 0.8); }
.pill svg { width: 13px; height: 13px; flex: none; }
.pill.primary { background: rgba(201, 174, 124, 0.32); border-color: var(--gold-2); }
.pill:disabled { opacity: 0.6; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .pill:hover { background: rgba(255, 252, 246, 0.85); border-color: var(--gold-2); }
}

/* ---------- Floating controls ---------- */
.ctl {
  position: fixed; z-index: 60;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(201, 174, 124, 0.5);
  background: rgba(255, 252, 246, 0.62);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(90, 72, 56, 0.12);
  transition: transform 120ms var(--ease-out), background 160ms ease, opacity 300ms ease;
  font-size: 12px; letter-spacing: 0.1em;
}
.ctl:active { transform: scale(0.94); }
.ctl svg { width: 18px; height: 18px; }
.ctl-music { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 44px; padding: 0; }
.ctl-lang  { right: 16px; top: calc(12px + env(safe-area-inset-top, 0px)); font-family: var(--font-latin); }
html[lang="en"] .ctl-lang { font-family: var(--font-ar); font-size: 14px; letter-spacing: 0; }
.ctl-lang:not([data-two]) { display: none; }

/* equalizer bars when music plays */
.eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { display: block; width: 2.5px; background: var(--ink); border-radius: 2px; height: 30%; animation: eq 900ms ease-in-out infinite; transform-origin: bottom; }
.eq i:nth-child(2) { animation-delay: 150ms; } .eq i:nth-child(3) { animation-delay: 300ms; } .eq i:nth-child(4) { animation-delay: 450ms; }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
.ctl-music[aria-pressed="true"] .eq { display: inline-flex; }
.ctl-music[aria-pressed="true"] .ico { display: none; }
@media (prefers-reduced-motion: reduce) { .eq i { animation: none; height: 60%; } }

/* ---------- Optional blocks ---------- */
.block { width: 100%; max-width: 340px; margin-inline: auto; }

/* Countdown */
.countdown { text-align: center; }
.countdown .label { font-size: calc(10.5px * var(--body-scale, 1)); letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 12px; }
html[lang="ar"] .countdown .label { font-size: calc(13.5px * var(--body-scale, 1)); }
.cd-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.cd-cell { position: relative; padding: 4px 2px; }
.cd-cell + .cd-cell::before { content: ''; position: absolute; inset-block: 10%; inset-inline-start: 0; width: 1px; background: linear-gradient(to bottom, transparent, var(--gold), transparent); }
.cd-num { display: block; font-family: var(--names-font, var(--names-font-default)); font-size: calc(28px * var(--names-scale, 1)); font-weight: var(--names-weight, var(--names-weight-default)); line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.cd-unit { display: block; margin-top: 6px; font-size: calc(9.5px * var(--body-scale, 1)); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); }
html[lang="ar"] .cd-unit { font-size: calc(12px * var(--body-scale, 1)); }
html[lang="ar"] .cd-num { font-family: var(--names-font, var(--font-ar)); }
.cd-today { font-size: 15px; color: var(--ink-2); font-style: italic; }

/* Calendar */
.calendar { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cal-menu { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cal-menu .pill { padding: 9px 16px; min-height: 36px; font-size: 10px; }
html[lang="ar"] .cal-menu .pill { font-size: 13px; }
.cal-menu[hidden] { display: none; }

/* RSVP */
.rsvp { text-align: center; }
.rsvp .title { font-size: calc(11px * var(--body-scale, 1)); letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 14px; }
html[lang="ar"] .rsvp .title { font-size: calc(14.5px * var(--body-scale, 1)); }
.rsvp-form { display: grid; gap: 10px; }
.field {
  width: 100%; padding: 12px 14px; border-radius: 14px;
  border: 1px solid rgba(179, 149, 95, 0.45); background: rgba(255, 253, 249, 0.72);
  color: var(--ink); font: inherit; font-size: 16px; text-align: center; outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  -webkit-appearance: none; appearance: none;
}
html[lang="ar"] .field { font-size: 16px; }
.field::placeholder { color: var(--ink-3); }
.field:focus-visible { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(201, 174, 124, 0.25); }
textarea.field { min-height: 72px; resize: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 10px; border-radius: 999px;
  border: 1px solid rgba(179, 149, 95, 0.45); background: rgba(255, 253, 249, 0.66); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
html[lang="ar"] .seg span { font-size: 14px; letter-spacing: 0; text-transform: none; }
.seg input:checked + span { background: rgba(201, 174, 124, 0.35); border-color: var(--gold-2); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(201, 174, 124, 0.25); }
.guests { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 12px; letter-spacing: 0.1em; color: var(--ink-2); }
html[lang="ar"] .guests { font-size: 14px; letter-spacing: 0; }
.guests .field { width: 84px; padding-inline: 8px; }
.rsvp-done { font-size: 15px; color: var(--ink-2); font-style: italic; line-height: 1.6; }
html[lang="ar"] .rsvp-done { font-style: normal; }
.rsvp-error { font-size: 12.5px; color: #9a4b3c; }

/* ---------- Draft watermark ---------- */
.wm { position: fixed; inset: -50%; z-index: 55; pointer-events: none; transform: rotate(-28deg); display: flex; flex-wrap: wrap; align-content: space-around; justify-content: space-around; gap: 70px 60px; }
.wm span { font-family: var(--font-latin); font-size: 15px; letter-spacing: 0.35em; text-transform: uppercase; color: rgba(90, 72, 56, 0.16); white-space: nowrap; }

/* ---------- Status screens ---------- */
.status { min-height: 100svh; display: grid; place-items: center; text-align: center; padding: 32px; }
.status .brand { font-style: italic; color: var(--ink-3); font-size: 14px; margin-top: 18px; }
.status h1 { font-weight: 500; font-size: 22px; color: var(--ink-2); }

/* ---------- Loading veil ---------- */
.veil { position: fixed; inset: 0; z-index: 70; background: var(--paper); display: grid; place-items: center; transition: opacity 500ms ease; }
.veil.hide { opacity: 0; pointer-events: none; }
.veil i { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid rgba(179, 149, 95, 0.35); border-top-color: var(--gold-2); animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .veil i { animation-duration: 1.8s; } }
