/* ANAMITRA Diwali — palette tokens (REQUIREMENTS §2.1). Use only these. */
:root {
  --midnight: #1B2B3B;
  --indigo: #2E546E;
  --mist: #91BFE2;
  --sage: #8FA59B;
  --sand: #F2C78D;
  --peach: #F8D3B9;
  --coral: #E67A5E;
  --ivory: #F7F8F1;

  --font-display: "Gloock", "Playfair Display", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-script: "Dancing Script", cursive;

  --ease: cubic-bezier(.37, 0, .63, 1); /* ~sine.inOut */
}

/* Devanagari fallbacks (brand: Jaini Purva / Katha → free Tiro / Mukta) */
:lang(mr), :lang(hi) {
  --font-display: "Tiro Devanagari Marathi", "Tiro Devanagari Hindi", Georgia, serif;
  --font-sans: "Mukta", system-ui, sans-serif;
  --font-script: var(--font-display);
}
:lang(hi) { --font-display: "Tiro Devanagari Hindi", "Tiro Devanagari Marathi", Georgia, serif; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--midnight); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 90% at 50% 0%, var(--indigo) -40%, var(--midnight) 60%);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}
:lang(mr) body, :lang(hi) body { line-height: 1.6; }

/* Faint stars (mist, very subtle) */
.stars {
  position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    radial-gradient(1px 1px at 12% 18%, var(--mist), transparent 60%),
    radial-gradient(1px 1px at 78% 12%, var(--mist), transparent 60%),
    radial-gradient(1.5px 1.5px at 34% 8%, var(--mist), transparent 60%),
    radial-gradient(1px 1px at 90% 34%, var(--mist), transparent 60%),
    radial-gradient(1px 1px at 6% 46%, var(--mist), transparent 60%),
    radial-gradient(1.5px 1.5px at 58% 26%, var(--mist), transparent 60%);
}

.screen {
  position: relative;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; padding: 2rem 1.5rem; text-align: center;
}
.hidden { display: none !important; }

.monogram { width: 56px; height: auto; display: block; }
.mark { display: block; }

h1, .greeting { font-family: var(--font-display); font-weight: 400; line-height: 1.2; margin: 0; }
.greeting { font-size: clamp(2rem, 8vw, 3.25rem); color: var(--ivory); }
.tagline { color: var(--sage); margin: 0; }
.muted { color: var(--sage); margin: 0; font-size: .95rem; }

/* Buttons: ≥44px tap targets, visible focus */
.btn {
  appearance: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; min-width: 48px; padding: .75rem 1.75rem;
  font: inherit; font-size: 1.125rem; color: var(--ivory);
  background: transparent; border: 1.5px solid var(--sand); border-radius: 999px;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}
.btn:hover { background: rgba(242, 199, 141, .14); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--mist); outline-offset: 3px; }
.btn-primary { background: var(--coral); border-color: var(--coral); color: var(--midnight); font-weight: 600; }
.btn-primary:hover { background: var(--peach); border-color: var(--peach); }

.lang-list { display: flex; flex-direction: column; gap: .875rem; width: min(100%, 18rem); }
.lang-list .btn { width: 100%; font-family: var(--font-display); font-size: 1.25rem; }

.icon-btn {
  appearance: none; cursor: pointer; width: 48px; height: 48px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--ivory); border-radius: 50%;
}

/* ---------- Stage (scenes 1–7) ---------- */
.stage { position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; }
.sky-warm {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(90% 55% at 50% 100%, rgba(248, 211, 185, .30), rgba(242, 199, 141, .08) 55%, transparent 80%);
}

.scene-book {
  position: absolute; left: 50%; top: 42%;
  width: min(54vw, 230px); aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
}
.book-wrap { width: 100%; height: 100%; perspective: 900px; }
.book { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform-origin: 50% 60%; }
.book-pages {
  position: absolute; inset: 0; border-radius: 4px 10px 10px 4px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 19px, rgba(143, 165, 155, .28) 19px 20px) 14% 22% / 72% 58% no-repeat,
    var(--ivory);
  box-shadow: inset 6px 0 0 rgba(143, 165, 155, .35);
}
.book-cover {
  position: absolute; inset: 0; background: var(--indigo);
  border-radius: 4px 10px 10px 4px; transform-origin: left center;
  box-shadow: inset 8px 0 0 rgba(27, 43, 59, .35);
}
.book-dot { position: absolute; top: 14%; right: 14%; width: 12%; aspect-ratio: 1; border-radius: 50%; background: var(--coral); }

.diya-first {
  position: absolute; left: 50%; bottom: -4%; width: clamp(54px, 15vw, 76px); z-index: 2;
  transform: translateX(-50%);
}
.diya-row {
  position: absolute; left: 0; right: 0; bottom: calc(5vh + env(safe-area-inset-bottom));
  display: flex; justify-content: center; align-items: flex-end; gap: clamp(4px, 2vw, 14px); padding: 0 1rem;
}
.diya { display: block; width: clamp(36px, 10.5vw, 62px); height: auto; overflow: visible; }
.diya-first .diya { width: 100%; }
.diya .flame, .diya .halo { transform-box: fill-box; transform-origin: 50% 100%; }
.diya .halo { transform-origin: 50% 50%; }

.invite {
  position: absolute; left: 0; right: 0; top: 68%;
  display: flex; flex-direction: column; align-items: center; gap: .75rem; padding: 0 1.5rem; text-align: center;
}
.mute { position: absolute; top: calc(.5rem + env(safe-area-inset-top)); right: calc(.5rem + env(safe-area-inset-right)); z-index: 5; }
.mute .slash { opacity: 0; }
.mute[aria-pressed="true"] .slash { opacity: 1; }
.mute[aria-pressed="true"] .wave { opacity: 0; }

/* Book opening glow */
.book-glow {
  position: absolute; left: 50%; top: 50%; width: 220%; aspect-ratio: 1; opacity: 0;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(247, 248, 241, .55), rgba(242, 199, 141, .22) 45%, transparent 75%);
}
.sparks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

/* 3D mode: WebGL canvas replaces the 2D visuals; DOM keeps text, hints and buttons */
.gl { display: none; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.mode3d .gl { display: block; }
.mode3d .stars, .mode3d #diya-row, .mode3d .diya-first, .mode3d .book-wrap, .mode3d .book-glow,
.mode3d #sky, .mode3d #sparks { display: none !important; }

/* Fireworks sky (behind the wish text) */
.sky { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

/* Guided taps: pulsing ring + label */
.tap-target { position: absolute; inset: 0; z-index: 5; background: transparent; border: 0; padding: 0; cursor: pointer; pointer-events: none; border-radius: 10px; }
.tap-target:not(:disabled) { pointer-events: auto; }
.tap-target:focus-visible, .cracker-btn:focus-visible { outline: 3px solid var(--mist); outline-offset: 4px; }
.hint-ring {
  position: absolute; width: 84px; height: 84px; border: 2px solid var(--sand); border-radius: 50%;
  pointer-events: none; animation: ring 1.9s ease-out infinite; opacity: .8;
}
@keyframes ring { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.3); opacity: 0; } }
.hint-label {
  display: inline-block; padding: .45rem 1rem; text-align: center; font-size: 1rem; line-height: 1.4;
  color: var(--ivory); background: rgba(27, 43, 59, .72); border: 1.5px solid var(--sand); border-radius: 999px;
}
.book-hint { position: absolute; inset: 0; visibility: hidden; pointer-events: none; z-index: 4; }
.book-hint .hint-ring { left: 50%; top: 46%; margin: -42px 0 0 -42px; }
.book-hint .hint-label { position: absolute; left: 50%; top: 100%; margin-top: 2.6rem; transform: translateX(-50%); white-space: nowrap; }

.cracker {
  position: absolute; left: 50%; top: 52%; transform: translateX(-50%); z-index: 5; visibility: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
}
.cracker-btn {
  position: relative; display: block; width: 64px; height: 110px; padding: 0; background: transparent; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cracker-btn:disabled { cursor: default; }
.cracker-btn .hint-ring { left: 50%; top: 50%; margin: -42px 0 0 -42px; }

/* Scene 5: the wish */
.wish {
  position: absolute; left: 0; right: 0; top: 40%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 0 1.75rem; text-align: center; z-index: 4; pointer-events: none;
}
.wish p { margin: 0; max-width: 28rem; }
.line1 { font-family: var(--font-display); font-size: clamp(1.5rem, 6vw, 2.25rem); line-height: 1.3; }
.wish .greeting { font-size: clamp(2.25rem, 10vw, 3.75rem); }
.dayline:empty { display: none; }
.line2 { font-size: clamp(1.0625rem, 4.2vw, 1.375rem); color: var(--peach); }
.signature { font-family: var(--font-script); font-size: 1.75rem; color: var(--sand); margin-top: .5rem !important; opacity: 0; }
.w { display: inline-block; opacity: 0; }

/* Scenes 6–7: logo + CTA */
.final {
  position: absolute; inset: 0; z-index: 4; visibility: hidden; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2rem; padding: 3rem 1.5rem calc(16vh + env(safe-area-inset-bottom)); text-align: center;
}
.lockup { position: relative; width: min(88vw, 420px); }
.lk-mark, .lk-text { position: absolute; display: block; }
.lk-text { height: auto; }
.cta { visibility: hidden; pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }
.motto { margin: 0; color: var(--sage); letter-spacing: .02em; }
.social { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.social a { color: var(--sage); padding: .75rem .9rem; min-height: 44px; text-decoration: underline; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }
.btn-small { min-height: 44px; padding: .5rem 1.25rem; font-size: 1rem; }
.skip { position: absolute; top: calc(.5rem + env(safe-area-inset-top)); left: calc(.75rem + env(safe-area-inset-left)); z-index: 5; border-color: transparent; color: var(--sage); }

/* No-JS fallback: visible by default, hidden once JS adds .js to <html> */
.js #fallback { display: none; }
#app { display: none; }
.js #app { display: block; }

.fallback-text { font-family: var(--font-display); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
