/* ============================================================================
   Ellie's birthday site — "Candlelit grimoire" world (impeccable, experience)
   Each screen is a dark aged page read by candlelight: warm near-black ground,
   a central candle-glow, faint parchment grain, aged-bone text, candlelight-gold
   and oxblood accents, hand-inked gold celestial line-work, wax-seal touches.
   ========================================================================== */

:root {
  --ink: #ece2cc;              /* aged bone/parchment — body + display text */
  --ink-soft: #b7a684;         /* dimmer parchment (secondary/hand), warm tint */
  --gold: #c9a24a;             /* candlelight gold */
  --gold-bright: #ecc978;
  --oxblood: #8f2c33;
  --oxblood-deep: #571920;
  --night: #0b080b;            /* deepest ground behind the pages */
  --night-2: #150f16;

  /* dark page grounds — one per screen (all very dark, a whisper of hue) */
  --page-espresso: #1a1310;
  --page-aubergine: #191324;
  --page-oxblood: #1d1215;
  --page-indigo: #111527;
  --page-forest: #101b16;
  --page-plum: #1a1221;

  --sheet: var(--page-espresso);   /* per-screen override sets this */

  --font-display: "Grenze Gotisch", "Trattatello", "Papyrus", fantasy, serif;
  --font-body: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --font-hand: "Caveat", "Segoe Print", cursive;

  /* faint parchment/dust grain, screen-blended to catch candlelight */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='0.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(140% 100% at 50% -10%, var(--night-2) 0%, var(--night) 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;               /* clip tilt/decoration; allow vertical scroll */
  overflow-y: auto;
}

/* ---- the page (each screen) ---------------------------------------------- */
.screen {
  display: none;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(1.5rem, 6vw, 4rem);
  text-align: center;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: clamp(1rem, 3.5vh, 2rem);
  isolation: isolate;          /* tall content grows the page; the body scrolls */
  color: var(--ink);
  background-color: var(--sheet);
  /* a candle glow from upper-centre, then vignette darkening toward the edges */
  background-image:
    radial-gradient(72% 56% at 50% 30%, rgba(201, 162, 74, 0.16), rgba(201, 162, 74, 0.05) 42%, transparent 66%),
    radial-gradient(125% 105% at 50% 46%, transparent 52%, rgba(0, 0, 0, 0.6) 100%);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 74, 0.10), inset 0 0 170px rgba(0, 0, 0, 0.62);
}
/* parchment grain overlay */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--grain);
  background-size: 180px 180px;
  opacity: 0.045;
  mix-blend-mode: screen;
  pointer-events: none;
}
.screen.is-active { display: flex; }

/* per-screen page ground */
.welcome  { --sheet: var(--page-espresso); }
.question { --sheet: var(--page-aubergine); }
.message  { --sheet: var(--page-oxblood); }
.notes    { --sheet: var(--page-indigo); }
.gallery  { --sheet: var(--page-forest); }
.farewell { --sheet: var(--page-plum); }
.gate     { --sheet: #150f13; }

/* the one authored motion: the page kindles up out of the dark */
.screen.is-active {
  animation: kindle 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes kindle {
  0%   { opacity: 0; transform: translateY(16px) scale(0.985); filter: blur(5px) brightness(0.55); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; filter: none; }
}

/* ---- a gold crescent moon + stars, inked into a corner ------------------- */
.welcome::after,
.farewell::after,
.gate::after {
  content: "";
  position: absolute;
  width: clamp(78px, 12vw, 132px);
  aspect-ratio: 6 / 5;
  right: clamp(1rem, 5vw, 3.5rem);
  top: clamp(1rem, 5vh, 3rem);
  opacity: 0.9;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 100'%3E%3Cpath fill='none' stroke='%23c9a24a' stroke-width='2.2' stroke-linejoin='round' d='M86 15 a37 37 0 1 0 18 64 A29 29 0 1 1 86 15 Z'/%3E%3Cpath fill='%23c9a24a' d='M34 25 l3 8 8 3 -8 3 -3 8 -3 -8 -8 -3 8 -3 z'/%3E%3Cpath fill='%23c9a24a' d='M20 58 l2 5.5 5.5 2 -5.5 2 -2 5.5 -2 -5.5 -5.5 -2 5.5 -2 z'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 7px rgba(236, 201, 120, 0.5));
  pointer-events: none;
}
.farewell::after { left: clamp(1rem, 5vw, 3.5rem); right: auto; transform: scaleX(-1); }

/* ---- type ---------------------------------------------------------------- */
.greeting {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.7rem, 9.5vw, 5.8rem);
  line-height: 1.0;
  text-wrap: balance;
  max-width: 15ch;
  text-shadow: 0 0 26px rgba(201, 162, 74, 0.28);
}
.ask {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 6.5vw, 3.9rem);
  line-height: 1.08;
  text-wrap: balance;
  max-width: 18ch;
  text-shadow: 0 0 20px rgba(201, 162, 74, 0.22);
}
.subtitle {
  margin: 0;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: clamp(1.4rem, 4.5vw, 2.1rem);
  color: var(--gold-bright);
  transform: rotate(-1.5deg);
}
.note {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  line-height: 1.75;
  max-width: 40ch;
  color: var(--ink);
  text-wrap: pretty;
}
.note + .note { margin-top: 0.9em; }
.caption {
  margin: 0;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--gold-bright);
  transform: rotate(-1deg);
}
.bye {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-size: clamp(1.45rem, 3.6vw, 2.2rem);
  line-height: 1.32;
  text-wrap: pretty;
  max-width: 26ch;
  text-shadow: 0 0 18px rgba(201, 162, 74, 0.2);
}
.fallback {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  text-align: center;
  margin: 40vh auto 0;
  font-size: clamp(2.2rem, 7.5vw, 3.6rem);
  text-shadow: 0 0 22px rgba(201, 162, 74, 0.28);
}
body:has(.screen.is-active) .fallback { display: none; }

/* ---- the message, an illuminated passage in the book -------------------- */
.card {
  position: relative;
  max-width: min(40rem, 90vw);
  padding: clamp(1.75rem, 5vw, 3rem);
  text-align: left;
  background: linear-gradient(180deg, rgba(32, 22, 28, 0.92), rgba(20, 14, 18, 0.94));
  border: 1px solid rgba(201, 162, 74, 0.35);
  border-radius: 3px;
  box-shadow:
    0 0 0 4px rgba(201, 162, 74, 0.06),
    inset 0 0 70px rgba(0, 0, 0, 0.5),
    0 26px 60px -24px rgba(0, 0, 0, 0.85);
}
/* an illuminated gold drop-cap on the first line */
.card .note:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 3.4em;
  float: left;
  line-height: 0.72;
  padding: 0.06em 0.14em 0 0;
  color: var(--gold-bright);
  text-shadow: 0 0 14px rgba(236, 201, 120, 0.45);
}

/* ---- buttons: aged, gold-edged, candlelit -------------------------------- */
.btn {
  position: relative;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.05rem, 2.3vw, 1.3rem);
  letter-spacing: 0.02em;
  color: var(--gold-bright);
  padding: 0.68em 1.5em;
  border: 1px solid rgba(201, 162, 74, 0.5);
  border-radius: 3px;
  cursor: pointer;
  background: linear-gradient(180deg, #241820, #180f15);
  box-shadow: 0 12px 26px -14px rgba(0, 0, 0, 0.9), inset 0 0 18px rgba(201, 162, 74, 0.06);
  transition: transform 220ms cubic-bezier(0.16,1,0.3,1), box-shadow 220ms ease, border-color 220ms ease;
}
.btn:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 16px 30px -14px rgba(0, 0, 0, 0.9), 0 0 20px rgba(236, 201, 120, 0.35), inset 0 0 22px rgba(201, 162, 74, 0.12);
}
.btn:active { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

.btn.primary {
  color: #f5e8d0;
  background: linear-gradient(180deg, var(--oxblood), var(--oxblood-deep));
  border-color: rgba(201, 162, 74, 0.6);
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.9), 0 0 16px rgba(143, 44, 51, 0.45), inset 0 0 22px rgba(0, 0, 0, 0.35);
}
.btn.primary:hover {
  box-shadow: 0 18px 34px -14px rgba(0, 0, 0, 0.9), 0 0 24px rgba(236, 201, 120, 0.4), inset 0 0 22px rgba(0, 0, 0, 0.3);
}

.btn.ghost {          /* the runaway "No" — a small dark scrap */
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  padding: 0.5em 1.05em;
  color: var(--ink-soft);
  background: linear-gradient(180deg, #1c151a, #150e12);
  transform: rotate(2deg);
}

.choices {
  display: flex;
  gap: clamp(1rem, 4vw, 2.5rem);
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

/* ---- notes: aged slips wax-sealed to the page --------------------------- */
.notes-title,
.gallery-title {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.1;
  text-wrap: balance;
  max-width: 20ch;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(201, 162, 74, 0.22);
}
.notes-wall {
  columns: 250px 3;
  column-gap: clamp(0.8rem, 2vw, 1.3rem);
  width: min(60rem, 92vw);
  text-align: left;
}
.note-card {
  position: relative;
  break-inside: avoid;
  margin: 0 0 clamp(0.8rem, 2vw, 1.3rem);
  padding: 1.6rem 1.25rem 1.15rem;
  color: var(--ink);
  background: linear-gradient(180deg, #221a22, #17111a);
  border: 1px solid rgba(201, 162, 74, 0.22);
  border-radius: 4px;
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.9);
  transform: rotate(var(--tilt, 0deg));
}
.note-card:nth-child(3n+1) { --tilt: -1.5deg; background: linear-gradient(180deg, #201527, #16101c); }
.note-card:nth-child(3n+2) { --tilt:  1.3deg; background: linear-gradient(180deg, #241417, #170e11); }
.note-card:nth-child(3n+3) { --tilt: -0.7deg; background: linear-gradient(180deg, #14172a, #0f1120); }
.note-card:nth-child(5n)   { background: linear-gradient(180deg, #12201a, #0d1712); }
/* a red wax seal pinning each note */
.note-card::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 15px; height: 15px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #bb4650, var(--oxblood) 58%, var(--oxblood-deep));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), inset 0 0 3px rgba(0, 0, 0, 0.55), 0 0 8px rgba(143, 44, 51, 0.35);
}
.note-card-text {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  line-height: 1.6;
  color: var(--ink);
  text-wrap: pretty;
}
.note-card-from {
  margin-top: 0.7rem;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--gold-bright);
  text-align: right;
}

/* ---- memories: portraits framed like tarot cards ------------------------ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: clamp(1rem, 3vw, 1.8rem);
  max-width: min(52rem, 92vw);
  width: 100%;
}
.cell {
  margin: 0;
  padding: 10px;
  background: linear-gradient(180deg, #20161c, #150e13);
  border: 1px solid rgba(201, 162, 74, 0.3);
  border-radius: 3px;
  box-shadow: 0 16px 34px -18px rgba(0, 0, 0, 0.9);
  transform: rotate(var(--tilt, -1.5deg));
  transition: transform 240ms cubic-bezier(0.16,1,0.3,1), box-shadow 240ms ease, border-color 240ms ease;
}
.cell:nth-child(even) { --tilt: 1.8deg; }
.cell:nth-child(3n)   { --tilt: -2.4deg; }
.cell:hover {
  transform: rotate(0deg) translateY(-4px) scale(1.02);
  border-color: var(--gold);
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.9), 0 0 20px rgba(201, 162, 74, 0.28);
}
.thumb {
  display: block;
  width: 100%;
  height: 165px;
  object-fit: cover;
  border-radius: 1px;
  cursor: pointer;
  background: #0f0b0e;
}
.cell figcaption {
  padding: 0.5rem 0.25rem 0.35rem;
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--gold-bright);
}

/* ---- lightbox ----------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5vmin;
  background: rgba(6, 4, 7, 0.9);
  backdrop-filter: blur(8px);
  animation: lb-in 260ms ease both;
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}
.lightbox img, .lightbox video {
  max-width: min(92vw, 1100px);
  max-height: 78vh;
  padding: 12px;
  background: #1a1218;
  border: 1px solid rgba(201, 162, 74, 0.4);
  border-radius: 2px;
  box-shadow: 0 40px 90px -30px #000, 0 0 44px rgba(201, 162, 74, 0.12);
}
.lightbox-caption {
  margin-top: 0.9rem;
  font-family: var(--font-hand);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  color: var(--gold-bright);
  text-align: center;
  max-width: 40ch;
}
.lightbox-close,
.lightbox-nav {
  position: fixed;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  color: var(--gold-bright);
  background: linear-gradient(180deg, #241820, #170f14);
  border: 1px solid rgba(201, 162, 74, 0.5);
  border-radius: 50%;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.8);
  z-index: 51;
}
.lightbox-close {
  top: clamp(0.8rem, 3vw, 1.6rem);
  right: clamp(0.8rem, 3vw, 1.6rem);
  width: 46px; height: 46px;
}
.lightbox-close svg { width: 20px; height: 20px; }
.lightbox-close:hover { transform: rotate(90deg); transition: transform 240ms ease; border-color: var(--gold); }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.lightbox-nav.prev { left: clamp(0.5rem, 3vw, 1.5rem); }
.lightbox-nav.next { right: clamp(0.5rem, 3vw, 1.5rem); }
.lightbox-nav svg { width: 22px; height: 22px; }
.lightbox-nav:hover { border-color: var(--gold); box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.8), 0 0 16px rgba(236, 201, 120, 0.3); }
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }
.lightbox-counter {
  position: fixed;
  bottom: clamp(0.8rem, 3vh, 1.6rem);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--gold-bright);
  opacity: 0.9;
  z-index: 51;
}

/* replay icon inside a button */
.btn .icon { width: 1.05em; height: 1.05em; vertical-align: -0.16em; margin-right: 0.45em; }

/* ---- countdown gate ----------------------------------------------------- */
.gate-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 6.2vw, 3.7rem);
  line-height: 1.06;
  text-wrap: balance;
  max-width: 18ch;
  color: var(--ink);
  text-shadow: 0 0 22px rgba(201, 162, 74, 0.26);
}
.countdown {
  display: flex;
  gap: clamp(0.6rem, 2.4vw, 1.4rem);
  flex-wrap: wrap;
  justify-content: center;
}
.cd-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: clamp(64px, 18vw, 98px);
  padding: clamp(0.7rem, 2.2vw, 1.1rem) clamp(0.5rem, 2vw, 1rem);
  background: linear-gradient(180deg, #221820, #160f14);
  border: 1px solid rgba(201, 162, 74, 0.3);
  border-radius: 6px;
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.85), inset 0 0 22px rgba(201, 162, 74, 0.06);
}
.cd-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 7vw, 3.6rem);
  line-height: 1;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(236, 201, 120, 0.35);
}
.cd-label {
  font-family: var(--font-hand);
  font-weight: 600;
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  color: var(--ink-soft);
}
.btn.ghost.skip {          /* dev-only escape hatch — a plain, quiet tab */
  transform: none;
  margin-top: 0.4rem;
  opacity: 0.8;
}

/* ---- ember confetti ----------------------------------------------------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}
.confetti {
  position: absolute;
  top: -12vh;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;               /* JS sets the ember colour */
  box-shadow: 0 0 8px 2px currentColor;
  animation: fall 2.8s cubic-bezier(0.4, 0, 0.7, 1) forwards;
}
@keyframes fall {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(118vh); opacity: 0; }
}

/* ---- reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .screen.is-active { animation: none; }
  .lightbox { animation: none; }
  .confetti { animation-duration: 0.01s; opacity: 0; }
  .btn, .cell, .lightbox-close, .lightbox-nav { transition: none; }
}
