:root {
  --no-bg: #ffffff;
  --no-fg: #111111;
  --yes-fg: #ffffff;
  --switch-w: 64px;
  --switch-h: 36px;
  --switch-pad: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: background-color 0.6s ease, color 0.6s ease;
}

/* ---------- NO state ---------- */
body.state-no {
  background: var(--no-bg);
  color: var(--no-fg);
}

/* ---------- YES state ---------- */
body.state-yes {
  color: var(--yes-fg);
  /* Long YES copy may exceed the viewport: scroll, top-aligned. */
  overflow-x: hidden;
  overflow-y: auto;
  align-items: flex-start;
}

/* Animated festive background, fixed to the viewport (not the document),
   so scrolling past one screen height never reveals a seam. */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  background: linear-gradient(
    300deg,
    #ff4e50, #f9d423, #ff6ec4, #7873f5, #43e97b, #38f9d7
  );
  background-size: 400% 400%;
  animation: festive 12s ease infinite;
}

body.state-yes .bg { opacity: 1; }

@keyframes festive {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---------- Giant faint YES watermark ---------- */
.watermark {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  font-weight: 900;
  font-size: 45vw;
  line-height: 1;
  letter-spacing: -0.05em;
  color: rgba(255, 255, 255, 0.18);
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Only visible in YES state and only once toggled on by JS (heading off-screen) */
body.state-yes .watermark.show { opacity: 1; }

/* ---------- Stage / content ---------- */
.stage {
  text-align: center;
  padding: 2rem;
  max-width: 640px;
  margin: 0 auto;
  width: min(90vw, 640px);
  z-index: 2;
  position: relative;
}

.headline {
  font-weight: 700;
  font-size: clamp(3rem, 10vw, 3rem);
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  opacity: 0.7;
  transition: opacity 0.6s ease;
}

body.state-yes .headline { opacity: 0.95; }

.answer {
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  font-size: clamp(6rem, 30vw, 18rem);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.state-yes .answer {
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  transform-origin: center bottom;
  /* Default loop: continuous pulse + playful sway */
  animation: dance 1.4s ease-in-out infinite;
}

/* Entrance pop (transient, applied on toggle) */
body.state-yes .answer.intro {
  animation: pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Extravagant full spin (transient, fired randomly from JS) */
body.state-yes .answer.spin {
  animation: spin 1.3s cubic-bezier(0.45, 0, 0.3, 1);
}

@keyframes pop {
  0%   { transform: scale(0.4) rotate(-8deg); }
  70%  { transform: scale(1.12) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes dance {
  0%   { transform: scale(1)    rotate(-3deg) translateY(0); }
  25%  { transform: scale(1.08) rotate(3deg)  translateY(-6px); }
  50%  { transform: scale(1)    rotate(-3deg) translateY(0); }
  75%  { transform: scale(1.08) rotate(3deg)  translateY(-6px); }
  100% { transform: scale(1)    rotate(-3deg) translateY(0); }
}

@keyframes spin {
  0%   { transform: scale(1)    rotate(0deg); }
  15%  { transform: scale(0.85) rotate(-25deg) translateY(8px); }
  55%  { transform: scale(1.3)  rotate(400deg) translateY(-14px); }
  80%  { transform: scale(1.1)  rotate(700deg) translateY(0); }
  100% { transform: scale(1)    rotate(720deg); }
}

.blurb {
  margin: 1.5rem auto 0;
  font-size: clamp(0.8rem, 2.4vw, 0.95rem);
  line-height: 1.6;
  max-width: 46ch;
  opacity: 0.85;
}

body.state-yes .blurb { opacity: 0.95; }

/* Verse rendering for the long YES monologue */
.blurb.verse {
  white-space: pre-line;
  text-align: left;
  max-width: 60ch;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  line-height: 1.7;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

.blurb.verse em { font-style: italic; }

/* Give the top-aligned YES content room to breathe above and below */
body.state-yes .stage { padding-block: 4.5rem 3rem; }

/* ---------- Action buttons (Preview / Back) ---------- */
.action {
  display: inline-block;
  margin: 2rem auto 0;
  padding: 0.7rem 1.8rem;
  font: inherit;
  font-weight: 700;
  font-size: clamp(0.9rem, 2.4vw, 1.05rem);
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.2s ease, background 0.3s ease,
              color 0.3s ease, opacity 0.3s ease;
}

.action:active { transform: scale(0.96); }

/* Preview: dark pill on the white NO screen */
.preview {
  border: 2px solid var(--no-fg);
  background: var(--no-fg);
  color: #fff;
}

.preview:hover { transform: translateY(-2px); }

.preview:focus-visible {
  outline: 2px solid #7873f5;
  outline-offset: 3px;
}

/* Back: translucent pill on the festive YES screen */
.revert {
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.revert:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.3);
}

.revert:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* State-based visibility: Preview only on NO, Back only on YES */
body.state-yes .preview { display: none; }
body.state-no .revert { display: none; }

/* ---------- Confetti ---------- */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.confetti i {
  position: absolute;
  top: -10vh;
  width: 10px;
  height: 14px;
  opacity: 0.9;
  animation: fall linear infinite;
}

@keyframes fall {
  0%   { transform: translateY(-10vh) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Audio player (dramatic reading) ---------- */
/* Translucent pill, fixed bottom-center, matching the festive YES aesthetic.
   Hidden by default; JS reveals it only once a valid audio file has loaded
   and the page is in the YES state. */
.player {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(1rem);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 1.1rem 0.5rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.player.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.player-toggle {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.player-toggle:hover { background: #fff; transform: scale(1.05); }
.player-toggle:active { transform: scale(0.94); }

.player-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.player-toggle .icon { width: 20px; height: 20px; fill: currentColor; }

/* Icon swap is driven by the .playing class on the player. */
.player .icon-pause { display: none; }
.player.playing .icon-play { display: none; }
.player.playing .icon-pause { display: block; }

/* Slim, elegant seek bar. */
.player-seek {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(120px, 30vw, 220px);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  outline: none;
}

.player-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}

.player-seek::-webkit-slider-thumb:hover { transform: scale(1.2); }

.player-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.player-seek:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.player-time {
  flex: none;
  min-width: 3.2ch;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Leave room so the player never overlaps the trailing verse lines. */
body.state-yes .stage { padding-bottom: 7rem; }

@media (prefers-reduced-motion: reduce) {
  .player { transition: opacity 0.4s ease; transform: translateX(-50%); }
  .player.show { transform: translateX(-50%); }

  .bg { animation: none; }
  .answer,
  body.state-yes .answer,
  body.state-yes .answer.intro,
  body.state-yes .answer.spin { animation: none; transform: none; }
  .confetti i { animation: none; display: none; }
}
