/* ————————————————————————————————————————————
   Letters for Elizabeth
   Soft cream · hydrangea · white hearts · candle-free.
   Motion is transform/opacity only — composited, no flicker.
   ———————————————————————————————————————————— */

:root {
  --cream: #f6eddc;
  --cream-2: #efe2cb;
  --paper: #fffaf1;
  --ink: #4f4339;
  --ink-soft: #7a6c5e;
  --whisper: rgba(79, 67, 57, 0.5);
  --gold: #b9965a;
  --gold-soft: #d8c08f;
  --peri: #aebfe0;
  --lilac: #c9bce0;
  --blush: #e6cdd8;
  --sage: #b6c8a4;
  --shadow: 0 20px 55px rgba(120, 95, 60, 0.16), 0 3px 10px rgba(120, 95, 60, 0.08);
  --serif: "Cormorant Garamond", Georgia, serif;
  --hand: "Caveat", cursive;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* the hidden attribute must win over the display rules below */
[hidden] { display: none !important; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--serif);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ———— Atmosphere ———— */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.bg-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(68% 50% at 50% 44%, rgba(248, 240, 226, 0.62), transparent 72%),
    radial-gradient(120% 80% at 50% -10%, rgba(255, 252, 245, 0.7), transparent 55%),
    radial-gradient(110% 90% at 50% 115%, rgba(214, 224, 206, 0.28), transparent 60%);
}

.bloom {
  position: absolute;
  background: url("hydrangea.svg") center / contain no-repeat;
  transform-origin: 50% 100%; /* pivot from the base, like a stem in the wind */
  will-change: transform;
}
.bloom--1 { top: -6%; left: -10%; width: 50vmax; height: 50vmax; opacity: 0.95;
  filter: blur(1.5px); animation: breeze-a 11s ease-in-out -2s infinite; }
.bloom--2 { bottom: -12%; right: -11%; width: 58vmax; height: 58vmax; opacity: 0.88;
  filter: blur(2px); animation: breeze-b 14s ease-in-out -5s infinite; }
.bloom--3 { top: 20%; right: -16%; width: 40vmax; height: 40vmax; opacity: 0.8;
  filter: blur(3px); animation: breeze-a 9s ease-in-out -1s infinite reverse; }
.bloom--4 { bottom: -7%; left: -8%; width: 35vmax; height: 35vmax; opacity: 0.82;
  filter: blur(2.5px); animation: breeze-b 12.5s ease-in-out -3s infinite reverse; }

/* gentle, gusty sway — pivots from the base + drifts slightly */
@keyframes breeze-a {
  0%   { transform: rotate(0deg) translate3d(0, 0, 0) scale(1); }
  22%  { transform: rotate(2.4deg) translate3d(0.8%, -0.4%, 0) scale(1.012); }
  46%  { transform: rotate(-1.4deg) translate3d(-0.5%, 0.3%, 0) scale(1); }
  70%  { transform: rotate(3deg) translate3d(1.1%, -0.7%, 0) scale(1.02); }
  100% { transform: rotate(0deg) translate3d(0, 0, 0) scale(1); }
}
@keyframes breeze-b {
  0%   { transform: rotate(0deg) translate3d(0, 0, 0) scale(1); }
  25%  { transform: rotate(-2.8deg) translate3d(-1%, 0.4%, 0) scale(1.015); }
  52%  { transform: rotate(1.6deg) translate3d(0.5%, -0.3%, 0) scale(1); }
  78%  { transform: rotate(-2.1deg) translate3d(-0.8%, 0.6%, 0) scale(1.02); }
  100% { transform: rotate(0deg) translate3d(0, 0, 0) scale(1); }
}

/* drifting white hearts (spawned by JS) */
.hearts { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.heart {
  position: absolute;
  bottom: -6vh;
  color: #fff;
  text-shadow: 0 2px 8px rgba(120, 95, 60, 0.18);
  opacity: 0;
  will-change: transform, opacity;
  animation: float-up linear forwards;
}
@keyframes float-up {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  12% { opacity: 0.7; }
  88% { opacity: 0.7; }
  100% { transform: translate3d(var(--sway, 0px), -112vh, 0) rotate(var(--spin, 20deg)); opacity: 0; }
}

/* ———— Screens ———— */
.screen { position: relative; z-index: 3; }
.gate, .finale {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2.4rem 1.4rem;
}

.gate-inner > *, .finale-inner > * {
  opacity: 0;
  animation: rise 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.gate-inner > *:nth-child(1) { animation-delay: 0.25s; }
.gate-inner > *:nth-child(2) { animation-delay: 0.6s; }
.gate-inner > *:nth-child(3) { animation-delay: 1.05s; }
.gate-inner > *:nth-child(4) { animation-delay: 1.6s; }
.finale-inner > *:nth-child(1) { animation-delay: 0.3s; }
.finale-inner > *:nth-child(2) { animation-delay: 0.7s; }
.finale-inner > *:nth-child(3) { animation-delay: 1.3s; }
.finale-inner > *:nth-child(4) { animation-delay: 2.2s; }
.finale-inner > *:nth-child(5) { animation-delay: 2.8s; }
.finale-inner > *:nth-child(6) { animation-delay: 3.4s; }

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 22px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* labels / eyebrows — letter-spaced serif, gold */
.gate-eyebrow, .puzzle-eyebrow, .finale-eyebrow,
.study-progress, .memory-num, .finale-playlist-label {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

.gate-title {
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 500;
  font-style: italic;
  line-height: 1.04;
  margin: 1.3rem 0 1.5rem;
  color: var(--ink);
}
.gate-name {
  color: var(--ink);
}
.gate-sub {
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  line-height: 1.85;
  color: var(--ink-soft);
  font-style: italic;
}

/* ———— Seal button ———— */
.seal-button {
  margin-top: 2.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--paper);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.85rem 1.7rem 0.85rem 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
}
.seal-button:hover { transform: translateY(-2px); border-color: var(--gold); }
.seal-button:active { transform: translateY(0); }
.seal-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--blush) 78%, #d9b9c6);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.7), 0 3px 8px rgba(150, 110, 120, 0.25);
  color: #fff;
  font-size: 1.05rem;
}

/* ———— Study ———— */
.study { max-width: 680px; margin: 0 auto; padding: 4rem 1.4rem 7rem; }
.study-head { text-align: center; margin-bottom: 3.4rem; }
.study-progress { display: block; margin-bottom: 1.1rem; }
.thread { height: 2px; background: rgba(185, 150, 90, 0.2); position: relative; max-width: 300px; margin: 0 auto; border-radius: 2px; }
.thread-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--peri), var(--gold-soft));
  border-radius: 2px;
  transition: width 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* unlocked memories */
.memories { display: flex; flex-direction: column; gap: 2.6rem; margin-bottom: 3.4rem; }
.memory {
  background: var(--paper);
  color: var(--ink);
  padding: 2.1rem 2.2rem 1.9rem;
  position: relative;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, -0.5deg));
  animation: unfold 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.memory:nth-child(even) { --tilt: 0.5deg; }
@keyframes unfold {
  from { opacity: 0; transform: rotate(var(--tilt, -0.5deg)) translate3d(0, 28px, 0) scale(0.97); }
  to { opacity: 1; transform: rotate(var(--tilt, -0.5deg)) translate3d(0, 0, 0) scale(1); }
}
.memory::before {
  content: "♡";
  position: absolute;
  top: -1.05rem; left: 50%;
  transform: translateX(-50%);
  width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--peri) 80%, #97abd6);
  color: #fff; font-size: 0.85rem;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.6), 0 3px 8px rgba(120, 130, 170, 0.3);
}
.memory-num { display: block; }
.memory-title {
  font-style: italic; font-weight: 600;
  font-size: 1.95rem; margin: 0.5rem 0 0.7rem;
  color: var(--ink);
}
.memory-note { font-family: var(--hand); font-size: 1.5rem; line-height: 1.5; color: #5e5044; }
.memory-photo {
  display: block; width: 100%; margin-top: 1.3rem;
  border-radius: 4px;
  border: 7px solid #fff;
  box-shadow: 0 10px 26px rgba(120, 95, 60, 0.18);
  transform: rotate(0.5deg);
}

/* ———— Puzzle card ———— */
.card {
  background: var(--paper);
  border: 1px solid rgba(185, 150, 90, 0.22);
  border-radius: 10px;
  padding: 2.6rem 2.3rem;
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}
.card.shake { animation: shake 0.45s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
.puzzle-eyebrow { display: block; }
.puzzle-question {
  font-style: italic; font-weight: 500;
  font-size: clamp(1.55rem, 4.4vw, 2.2rem);
  line-height: 1.3; margin: 0.9rem 0 1.8rem;
  color: var(--ink);
}

.answer-form { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.answer-input {
  flex: 1; min-width: 220px;
  background: #fdf6ea;
  border: 1px solid rgba(185, 150, 90, 0.25);
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--serif); font-size: 1.15rem;
  padding: 0.85rem 1rem; outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.answer-input::placeholder { color: rgba(122, 108, 94, 0.5); font-style: italic; font-size: 1.05rem; }
.answer-input:focus { border-color: var(--peri); box-shadow: 0 0 0 3px rgba(174, 191, 224, 0.22); }

.answer-go {
  background: linear-gradient(160deg, var(--peri), #9aafd9);
  color: #fff; border: none; border-radius: 8px;
  font-family: var(--serif); font-weight: 600;
  font-size: 0.92rem; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 0.85rem 1.7rem; cursor: pointer;
  box-shadow: 0 8px 20px rgba(150, 165, 205, 0.4);
  transition: transform 0.25s, box-shadow 0.25s, filter 0.25s;
}
.answer-go:hover { transform: translateY(-2px); filter: brightness(1.05); }

.feedback { margin-top: 1.2rem; font-family: var(--hand); font-size: 1.45rem; color: var(--gold); min-height: 1.6rem; }
.hint-btn {
  margin-top: 0.9rem; background: none; border: none; color: var(--ink-soft);
  font-family: var(--serif); font-weight: 600; font-size: 0.8rem;
  letter-spacing: 0.18em; text-transform: uppercase; cursor: pointer;
  border-bottom: 1px dotted rgba(122, 108, 94, 0.5); padding-bottom: 2px;
}
.hint-btn:hover { color: var(--gold); }
.hint { margin-top: 0.9rem; font-style: italic; font-size: 1.2rem; color: var(--peri); animation: rise 0.6s both; }

/* ———— Finale ———— */
.finale-title {
  font-style: italic; font-weight: 500;
  font-size: clamp(2.3rem, 7vw, 4.2rem);
  margin: 1rem 0 2.4rem; color: var(--ink);
}
.finale-letter {
  max-width: 600px; margin: 0 auto;
  background: var(--paper);
  border-radius: 10px;
  color: var(--ink);
  padding: 2.6rem 2.6rem 2.2rem;
  text-align: left;
  transform: rotate(-0.5deg);
  box-shadow: var(--shadow);
}
.finale-letter p:first-child { font-size: 1.28rem; line-height: 1.85; white-space: pre-line; }
.finale-sign { font-family: var(--hand); font-size: 1.8rem; margin-top: 1.6rem; text-align: right; color: var(--peri); }

.finale-video-wrap { margin: 2.4rem auto 0; max-width: 330px; }
.finale-video {
  width: 100%; display: block; border-radius: 4px;
  border: 7px solid #fff; box-shadow: var(--shadow);
  transform: rotate(0.8deg); background: #efe7d8;
}
.finale-closing {
  font-family: var(--hand); font-size: clamp(1.45rem, 4.5vw, 1.95rem);
  color: var(--peri); margin: 2rem auto 0; max-width: 30ch; line-height: 1.45;
}

/* ———— Docked Spotify player ———— */
.player-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  padding: 0.45rem calc(0.5rem + env(safe-area-inset-right))
    calc(0.45rem + env(safe-area-inset-bottom)) calc(0.5rem + env(safe-area-inset-left));
  background: linear-gradient(0deg, rgba(246, 237, 220, 0.98), rgba(246, 237, 220, 0.82));
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(185, 150, 90, 0.2);
  box-shadow: 0 -8px 26px rgba(120, 95, 60, 0.1);
  animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.player-dock iframe { display: block; width: 100%; border: 0; }
body.has-dock .study { padding-bottom: 9rem; }
body.has-dock .finale { padding-bottom: 10rem; }

.finale-playlist-wrap { margin: 2.6rem auto 0; max-width: 420px; }
.finale-playlist-label { display: block; margin-bottom: 0.7rem; }
.finale-playlist-hint { font-family: var(--hand); font-size: 1.3rem; color: var(--whisper); }

/* ———— Music toggle ———— */
.mute {
  position: fixed; top: calc(0.9rem + env(safe-area-inset-top)); right: calc(0.9rem + env(safe-area-inset-right));
  z-index: 40; width: 3rem; height: 3rem; border-radius: 50%;
  border: 1px solid var(--gold-soft); background: rgba(255, 250, 241, 0.85);
  backdrop-filter: blur(6px); color: var(--gold); font-size: 1.05rem;
  cursor: pointer; display: grid; place-items: center;
  transition: transform 0.2s, border-color 0.3s;
}
.mute:active { transform: scale(0.92); }
.mute .mute-off { display: none; }
.mute.muted .mute-on { display: none; }
.mute.muted .mute-off { display: inline; color: var(--whisper); }

/* ———— Celebration burst ———— */
.heart-bit {
  position: fixed; z-index: 50; pointer-events: none; font-size: 1.15rem;
  will-change: transform, opacity;
  animation: heart-pop 1.5s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes heart-pop {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(0.6) rotate(0deg); }
  to { opacity: 0; transform: translate3d(var(--dx), var(--dy), 0) scale(1.35) rotate(var(--rot)); }
}

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

@media (max-width: 540px) {
  .study { padding: 3rem 1.1rem 6rem; }
  .card { padding: 2rem 1.4rem; }
  .memory { padding: 1.8rem 1.4rem 1.6rem; }
  .finale-letter { padding: 2rem 1.5rem 1.8rem; }
  .finale-letter p:first-child { font-size: 1.16rem; }
  .answer-form { flex-direction: column; gap: 0.7rem; }
  .answer-input { width: 100%; min-width: 0; }
  .answer-go { width: 100%; padding: 1rem; }
  .memory-note { font-size: 1.55rem; }
}
