/* ============================================================
   Premium Interactive Template — Greetify
   Палитра: тёмный изумруд + золотисто-кремовый акцент
   ============================================================ */

:root {
  --bg:          #0A2A22;
  --bg-soft:     #071F19;
  --surface:     rgba(14, 51, 41, 0.65);
  --surface-brd: rgba(201, 162, 75, 0.28);

  --gold:        #C9A24B;
  --gold-soft:   #E4C77A;
  --cream:       #F5E9D3;

  --text:        #F5E9D3;
  --text-muted:  rgba(245, 233, 211, 0.72);

  --font-head:   'Playfair Display', serif;
  --font-body:   'Montserrat', system-ui, sans-serif;

  --space-1: 8px;  --space-2: 16px;  --space-3: 24px;
  --space-4: 32px; --space-6: 48px;  --space-8: 64px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --z-canvas: 10; --z-float: 20; --z-ui: 40;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }
html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body:not(.story-mode) { height: 100dvh; overflow: hidden; }
body.story-mode { overflow-x: hidden; overflow-y: auto; }

body {
  background: radial-gradient(120% 80% at 50% 15%, #123B30 0%, var(--bg) 55%, var(--bg-soft) 100%);
}

/* ============================================================
   ЭКРАНЫ
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s var(--ease-out), visibility 1s var(--ease-out);
}
.screen.active { opacity: 1; visibility: visible; }

.bokeh {
  position: absolute; inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(201,162,75,.16) 0 6px, transparent 7px),
    radial-gradient(circle at 82% 18%, rgba(245,233,211,.10) 0 8px, transparent 9px),
    radial-gradient(circle at 70% 75%, rgba(201,162,75,.12) 0 5px, transparent 6px),
    radial-gradient(circle at 25% 80%, rgba(245,233,211,.08) 0 10px, transparent 11px);
  filter: blur(1px);
  animation: bokehDrift 14s var(--ease-out) infinite alternate;
}
@keyframes bokehDrift {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-16px) scale(1.04); }
}

#heartField {
  position: absolute; inset: 0;
  z-index: var(--z-canvas);
  display: block;
  width: 100%; height: 100%;
}

.floating-layer { position: absolute; inset: 0; z-index: var(--z-float); pointer-events: none; }
.float-word {
  position: absolute;
  font-family: var(--font-head);
  font-style: italic;
  font-size: clamp(1rem, 3vw, 1.6rem);
  letter-spacing: .06em;
  opacity: .35;
  color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(201,162,75,.4);
  animation: floatA 16s var(--ease-out) infinite;
}
.float-word.w1 { top: 14%; left: 8%; }
.float-word.w2 { top: 30%; right: 10%; animation-delay: 2s; }
.float-word.w3 { bottom: 18%; left: 14%; animation-delay: 4s; }
@keyframes floatA {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-20px); }
}

.welcome-content {
  position: relative;
  z-index: var(--z-ui);
  text-align: center;
  padding: var(--space-3);
  max-width: 640px;
  pointer-events: none;
}
.title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3.6rem);
  line-height: 1.2;
  text-shadow: 0 0 30px rgba(201,162,75,.35);
}
.title .accent { color: var(--gold); }
.subtitle {
  margin-top: var(--space-2);
  font-size: clamp(.95rem, 3vw, 1.15rem);
  color: var(--text-muted);
  max-width: 38ch;
  margin-inline: auto;
}
.hint {
  pointer-events: auto;
  margin-top: var(--space-4);
  min-height: 48px;
  padding: 14px 30px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(.95rem, 3vw, 1.05rem);
  color: var(--bg);
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(201,162,75,.35);
  transition: transform .22s var(--ease-out), box-shadow .22s var(--ease-out);
}
.hint:hover { transform: translateY(-2px); box-shadow: 0 0 32px rgba(201,162,75,.5); }

/* ============================================================
   ПРОГРЕСС-БАР
   ============================================================ */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 100; background: rgba(245,233,211,0.08);
}
.progress span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
  transition: width .1s linear;
}

/* ============================================================
   МУЗЫКАЛЬНАЯ КНОПКА
   ============================================================ */
.music-btn {
  position: fixed; top: 16px; right: 16px; z-index: 90;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--surface-brd);
  border-radius: 50%;
  color: var(--gold-soft);
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.music-btn svg { width: 20px; height: 20px; }
.music-btn .ico-off { display: none; }
.music-btn[aria-pressed="true"] .ico-on { display: none; }
.music-btn[aria-pressed="true"] .ico-off { display: block; }
.music-btn .eq { display: none; }

/* ============================================================
   ИСТОРИЯ
   ============================================================ */
.story {
  position: relative; z-index: 5;
  padding-bottom: 40px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .6s var(--ease-out), visibility .6s var(--ease-out);
}
body.story-mode .story {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.chapter {
  min-height: 90vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-3);
}
.eyebrow {
  font-family: var(--font-body);
  letter-spacing: .3em;
  font-size: .8rem;
  color: var(--gold-soft);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.chapter-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.8rem, 6vw, 3rem);
  line-height: 1.25;
}
.chapter-title .accent { color: var(--gold); }
.chapter-sub {
  margin-top: var(--space-2);
  color: var(--text-muted);
  max-width: 46ch;
}

.wish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  max-width: 900px;
  margin: 0 auto;
}
.wish-card {
  padding: var(--space-4) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--surface-brd);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}
.wish-icon { font-size: 28px; color: var(--gold); margin-bottom: var(--space-2); }
.wish-text { color: var(--text); line-height: 1.6; }

/* ============================================================
   ФИНАЛ
   ============================================================ */
.chapter-final { position: relative; padding-bottom: clamp(80px, 14vh, 160px); }
.final-glow {
  position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(50% 50% at 50% 40%, rgba(201,162,75,.14), transparent 70%);
}
.final-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 3.4rem);
  color: var(--gold);
}
.final-letter {
  position: relative;
  margin: var(--space-4) auto 0;
  max-width: 52ch;
  text-align: left;
  padding: clamp(28px, 5vw, 42px);
  border-radius: 24px;
  background:
    repeating-linear-gradient(0deg, transparent 0 37px, rgba(201,162,75,.05) 37px 38px) padding-box,
    linear-gradient(180deg, rgba(14,51,41,.9), rgba(7,31,25,.94)) padding-box,
    linear-gradient(135deg, var(--gold), var(--gold-soft) 50%, var(--gold)) border-box;
  border: 2px solid transparent;
  box-shadow: 0 0 50px rgba(201,162,75,.15);
}
.final-letter::before {
  content: '✦';
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--bg);
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold));
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(201,162,75,.5);
}
#letterText {
  font-size: clamp(1rem, 3.4vw, 1.1rem);
  line-height: 1.85;
  color: var(--text);
  min-height: 1.85em;
}
.type-caret {
  display: inline-block; width: 2px; height: 1.1em;
  margin-left: 2px; vertical-align: -0.15em;
  background: var(--gold); box-shadow: 0 0 8px var(--gold);
  animation: caretBlink .8s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

.final-sign {
  margin-top: var(--space-4);
  font-family: var(--font-head);
  font-style: italic;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  color: var(--gold);
}
.ghost-btn {
  margin-top: var(--space-4);
  min-height: 48px;
  padding: 12px 24px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--surface-brd);
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s var(--ease-out), border-color .2s var(--ease-out), transform .2s var(--ease-out);
}
.ghost-btn:hover { color: var(--text); border-color: var(--gold); transform: translateY(-2px); }

/* ============================================================
   SCROLL-REVEAL
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
.reveal.in { opacity: 1; transform: none; }

.confetti-canvas {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;
}

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