:root {
  /* pear-olive green palette — Maya's favourite */
  --bg: #14180c;
  --bg-2: #232a14;
  --ink: #f3efd8;
  --accent: #b8c46a;
  --accent-2: #d9dfa3;
  --gold: #e6c878;
  --serif: "Fraunces", Georgia, serif;
  --hand: "Caveat", "Segoe Script", cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--serif);
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2), var(--bg) 70%);
  overflow-x: hidden;
  cursor: pointer;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(2px 2px at 20% 30%, #ffffff22 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 70% 60%, #ffffff1c 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 80%, #ffffff18 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 20%, #ffffff22 50%, transparent 51%);
  pointer-events: none;
  z-index: 0;
}

/* ============ STORY BEATS ============ */
.beat {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
  animation: beat-in 0.9s cubic-bezier(.2,.7,.3,1) both;
}

@keyframes beat-in {
  from { opacity: 0; transform: translateY(24px) scale(0.98); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.kicker {
  font-family: var(--hand);
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  letter-spacing: 0.15em;
  text-transform: lowercase;
  color: var(--accent-2);
  margin: 0 0 1rem;
  opacity: 0.85;
}

.name-big {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(4rem, 14vw, 9rem);
  line-height: 1;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.02em;
}

.hint {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--hand);
  font-size: 1.1rem;
  color: var(--ink);
  opacity: 0;
  margin: 0;
  animation: hint-in 0.8s ease 2.2s forwards, hint-pulse 2.2s ease-in-out 3s infinite;
  pointer-events: none;
}

@keyframes hint-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 0.5; transform: translateX(-50%); }
}
@keyframes hint-pulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.7; }
}

/* staggered fade-in for the cold open */
.fade-1, .fade-2, .fade-3 { opacity: 0; animation: fade-up 0.9s ease forwards; }
.fade-1 { animation-delay: 0.3s; }
.fade-2 { animation-delay: 1.0s; }
.fade-3 { animation-delay: 2.2s; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.fade-3 { animation-name: fade-half; }
@keyframes fade-half {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 0.5; transform: none; }
}

/* polaroid photos */
.polaroid {
  margin: 0 0 2rem;
  padding: 0.8rem 0.8rem 1.6rem;
  background: #f8f4e3;
  box-shadow: 0 25px 50px #00000099, 0 2px 4px #00000055;
  border-radius: 3px;
  animation: drop-in 0.9s cubic-bezier(.2,.8,.2,1) both;
  max-width: min(420px, 80vw);
}

.polaroid img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: cover;
  background: #1a1a1a;
}

.tilt-l { transform: rotate(-4deg); }
.tilt-r { transform: rotate(4deg); }
.tilt-yes { transform: rotate(-2deg); }

@keyframes drop-in {
  from { opacity: 0; transform: translateY(-30px) rotate(0deg) scale(0.9); }
  to   { opacity: 1; }
}
.tilt-l { animation-name: drop-in-l; }
.tilt-r { animation-name: drop-in-r; }
@keyframes drop-in-l {
  from { opacity: 0; transform: translateY(-30px) rotate(2deg) scale(0.9); }
  to   { opacity: 1; transform: rotate(-4deg); }
}
@keyframes drop-in-r {
  from { opacity: 0; transform: translateY(-30px) rotate(-2deg) scale(0.9); }
  to   { opacity: 1; transform: rotate(4deg); }
}

.caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  line-height: 1.3;
  max-width: 22ch;
  margin: 0;
  opacity: 0;
  animation: fade-up 1s ease 0.7s forwards;
}

.subhead {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  color: var(--accent-2);
  margin: 1rem 0 0;
  opacity: 0.9;
}

/* ============ SONNET BEATS ============ */
.beat-sonnet {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.1fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  justify-items: center;
  max-width: 1200px;
  margin: 0 auto;
  text-align: left;
}

.beat-sonnet .polaroid {
  margin: 0;
  max-width: min(360px, 90%);
}

.stanza {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.1rem, 1.9vw, 1.6rem);
  line-height: 1.65;
  max-width: 30ch;
  opacity: 0;
  animation: stanza-in 1.1s ease 0.55s forwards;
}

.stanza p {
  margin: 0 0 0.35rem;
  opacity: 0;
  animation: line-in 0.7s ease forwards;
}
.stanza p:nth-child(1) { animation-delay: 0.7s; }
.stanza p:nth-child(2) { animation-delay: 1.2s; }
.stanza p:nth-child(3) { animation-delay: 1.7s; }
.stanza p:nth-child(4) { animation-delay: 2.2s; }

@keyframes line-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: none; }
}

@keyframes stanza-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ink {
  font-family: var(--hand);
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
  font-size: 1.15em;
  letter-spacing: 0.02em;
}

.couplet .stanza,
.beat-couplet .stanza {
  font-size: clamp(1.3rem, 2.4vw, 2rem);
  max-width: 32ch;
}

.final-line {
  font-family: var(--hand);
  font-style: normal;
  color: var(--accent);
  font-size: 1.4em;
  line-height: 1.3;
  margin-top: 0.8rem !important;
}

@media (max-width: 820px) {
  .beat-sonnet {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1.5rem;
  }
  .beat-sonnet .polaroid { max-width: min(70vw, 320px); }
  .stanza { max-width: 28ch; margin: 0 auto; }
  .stanza p { text-align: center; }
}

/* ============ QUESTION SCREEN ============ */
.headline {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.4rem, 6.5vw, 5rem);
  line-height: 1.05;
  margin: 0 0 2.5rem;
  max-width: 18ch;
}
.headline .name {
  font-family: var(--hand);
  font-weight: 700;
  font-style: normal;
  color: var(--accent);
  font-size: 1.2em;
}
.headline em { color: var(--gold); font-style: italic; }

.buttons {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-top: 1rem;
}

.btn {
  font-family: var(--serif);
  font-style: italic;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 1.3rem 3.2rem;
  font-size: 2rem;
  transition: transform 0.25s ease, top 0.2s ease, left 0.2s ease, box-shadow 0.25s ease, filter 0.25s ease;
  will-change: transform, top, left;
}
.btn.yes {
  background: var(--accent);
  color: #1f2410;
  font-weight: 600;
  box-shadow: 0 8px 24px #b8c46a55, inset 0 -3px 0 #00000022;
}
.btn.yes:hover { filter: brightness(1.07); }
.btn.no {
  background: transparent;
  color: var(--ink);
  border: 2px solid #ffffff66;
  padding: 1.3rem 3.6rem;
}
.btn.no.fleeing { position: fixed; }

.taunt {
  font-family: var(--hand);
  font-size: 1.5rem;
  color: var(--accent-2);
  min-height: 1.6em;
  margin: 2rem 0 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.taunt.show { opacity: 0.95; }

/* ============ YES SCREEN ============ */
.beat-yes {
  background: radial-gradient(120% 80% at 50% 0%, #2f3a18, var(--bg) 70%);
}
.yes-headline {
  font-family: var(--hand);
  font-size: clamp(3rem, 9vw, 6.5rem);
  color: var(--accent);
  margin: 0 0 1rem;
}
.yes-message {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  max-width: 28ch;
  line-height: 1.5;
  margin: 0 0 2rem;
}
.yes-photo { max-height: 55vh; }
.beat-yes .polaroid { max-width: min(640px, 92vw); }
.beat-yes .yes-photo { aspect-ratio: auto; object-fit: cover; }
.yes-footer {
  font-family: var(--hand);
  font-size: 1.7rem;
  color: var(--gold);
  margin-top: 2rem;
}
.yes-ps {
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--accent-2);
  margin-top: 0.5rem;
  opacity: 0.85;
}

/* ============ MUSIC TOGGLE + PROGRESS ============ */
#music-toggle {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 10;
  background: #ffffff14;
  color: var(--ink);
  border: 1px solid #ffffff33;
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-family: var(--hand);
  font-size: 1.1rem;
  cursor: pointer;
}
#music-toggle:hover { background: #ffffff22; }

#progress {
  position: fixed;
  top: 1rem; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 0.4rem;
  z-index: 10;
}
#progress .dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: #ffffff22;
  transition: background 0.3s ease, transform 0.3s ease;
}
#progress .dot.on {
  background: var(--accent);
  transform: scale(1.3);
}
#progress.hide { opacity: 0; pointer-events: none; transition: opacity 0.6s ease; }

/* Keep the YT player onscreen (browsers throttle offscreen iframes) but invisible */
#yt-wrap {
  position: fixed;
  bottom: 0; right: 0;
  width: 1px; height: 1px;
  opacity: 0.01;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}
#yt-wrap iframe { width: 200px; height: 120px; border: 0; }

/* ============ PASSWORD GATE ============ */
#gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2), var(--bg) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: default;
}
#gate.gone {
  animation: gate-out 0.7s ease forwards;
  pointer-events: none;
}
@keyframes gate-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: scale(1.02); }
}
#gate-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.gate-kicker {
  font-family: var(--hand);
  font-size: 1.4rem;
  color: var(--accent-2);
  opacity: 0.85;
  margin: 0;
}
.gate-name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(3.5rem, 10vw, 6rem);
  color: var(--accent);
  margin: 0 0 1.5rem;
  line-height: 1;
}
.gate-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink);
  margin: 0;
  opacity: 0.85;
}
#gate-input {
  font-family: var(--hand);
  font-size: 1.6rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent);
  text-align: center;
  padding: 0.6rem 1rem;
  width: min(280px, 80%);
  outline: none;
  caret-color: var(--accent);
}
#gate-input:focus { border-bottom-color: var(--accent-2); }
.gate-error {
  font-family: var(--hand);
  font-size: 1.1rem;
  color: #ff9b9b;
  margin: 0.3rem 0 0;
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.gate-hint {
  font-family: var(--hand);
  font-size: 1rem;
  color: var(--accent-2);
  margin-top: 1.2rem;
  opacity: 0.6;
}

@media (max-width: 640px) {
  .buttons { gap: 1rem; }
  .btn { padding: 1rem 2rem; font-size: 1.5rem; }
  .btn.no { padding: 1rem 2.4rem; }
  .polaroid { max-width: 90vw; }
}
