/* Visual style derived from the Stitch export (design/stitch/DESIGN.md): deep charcoal + projector amber,
   Playfair Display for titles and her lines, Plus Jakarta Sans for UI, frosted-glass cards. */
:root {
  --bg: #0d0d11;
  --surface: #13131a;
  --cream: #f5f3ef;
  --stone: #a3a09a;
  --slate: #52515a;
  --amber: #f59e0b;
  --amber-soft: #ffc174;
  --amber-deep: #d97706;
  --glass: rgba(19, 19, 26, 0.5);
  --glass-strong: rgba(19, 19, 26, 0.75);
  --rim: rgba(245, 243, 239, 0.12);
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--sans);
  overflow: hidden;
}

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hidden { display: none !important; }

/* ---------- Start / End screens ---------- */
#start-screen, #end-screen, #bad-ending-screen {
  background: radial-gradient(circle at 50% 30%, #1b1b24 0%, var(--bg) 75%);
  gap: 16px;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
}

#start-screen { overflow: hidden; justify-content: flex-end; padding-bottom: max(36px, env(safe-area-inset-bottom)); }

/* Blurred still of her from the episode's first frame */
#start-bg {
  position: absolute;
  inset: -30px;
  background-size: cover;
  background-position: center;
  filter: blur(9px) saturate(1.1);
  transform: scale(1.08);
  z-index: 0;
}
#start-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(13,13,17,0.35) 0%, rgba(13,13,17,0.55) 45%, rgba(13,13,17,0.94) 100%);
  z-index: 1;
}
#start-screen > *:not(#start-bg) { position: relative; z-index: 2; }

#start-ep {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber-soft);
  margin: 0;
}

#start-screen h1, #end-screen h1, #bad-ending-screen h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(32px, 9vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--cream);
  text-shadow: 0 2px 18px rgba(0,0,0,0.55);
}
#end-screen h1, #bad-ending-screen h1 { letter-spacing: 0.04em; }

.tagline {
  font-family: var(--serif);
  font-style: italic;
  color: var(--amber-soft);
  font-size: 17px;
  margin: 0 0 8px;
}

.big-btn {
  min-height: 56px;
  min-width: 220px;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 16px 40px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(245, 158, 11, 0.28);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.big-btn:hover { background: var(--amber-soft); transform: scale(1.02); }
.big-btn:active { transform: scale(0.97); }

/* Toggles as frosted rows with an amber switch */
#voice-tap-toggle-label, #hands-free-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  min-height: 48px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--cream);
  text-align: left;
  background: var(--glass);
  border: 1px solid var(--rim);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  cursor: pointer;
  user-select: none;
  flex-direction: row-reverse;
}
#voice-tap-toggle, #hands-free-toggle {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: var(--slate);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
#voice-tap-toggle::after, #hands-free-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cream);
  transition: transform 0.2s;
}
#voice-tap-toggle:checked, #hands-free-toggle:checked { background: var(--amber); }
#voice-tap-toggle:checked::after, #hands-free-toggle:checked::after { transform: translateX(20px); background: var(--bg); }

.headphones-note {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--stone);
}
.headphones-note svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- Movie screen ---------- */
#movie-screen {
  background: #000;
}

#video-stage {
  position: absolute;
  inset: 0;
}

.stage-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transform: scale(1);
  transform-origin: center;
  opacity: 0;
  z-index: 1;
  transition-property: opacity;
  transition-duration: 0ms;
  transition-timing-function: linear;
}

/* Photo mode (?mode=photo): the stage "videos" are divs holding 3 stills (see photo-mode.js). */
.photo-player { overflow: hidden; }
.photo-player .ph-wrap { position: absolute; inset: 0; transform-origin: center; will-change: transform; }
.photo-player .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; user-select: none; pointer-events: none; }
.photo-player .ph:first-child { opacity: 1; }

.stage-video.front {
  opacity: 1;
  z-index: 2;
}

/* Slow "still here, waiting" zoom on the frozen last frame while a clip has
   ended but the viewer hasn't answered yet (fallback for scenes with no
   idle_video configured, e.g. scene1). */
.stage-video.idle-zoom {
  animation: idle-zoom 8s ease-in-out infinite alternate;
}

@keyframes idle-zoom {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}

/* Her line: serif with a soft shadow, no box behind it, so her face stays visible. */
#subtitle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30%;
  padding: 10px 28px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(20px, 5.4vw, 28px);
  line-height: 1.35;
  color: var(--cream);
  text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 2px 16px rgba(0,0,0,0.6), 0 0 32px rgba(0,0,0,0.35);
  background: none;
  pointer-events: none;
  z-index: 2;
}

/* ---------- Choice UI ---------- */
#choice-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px max(30px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: transparent;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s ease-out, background 0.2s ease-out;
  pointer-events: none;
}

/* Only a faint vignette (no dark band) and only while the options panel is actually
   visible - it must never appear, even briefly, before the cards themselves do. */
#choice-ui.panel-visible {
  opacity: 1;
  /* Eased multi-stop gradient (transparent -> dark) so there is no visible line; extra top padding
     gives the fade room above the cards. */
  padding-top: 90px;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.03) 12%, rgba(0,0,0,0.10) 25%,
    rgba(0,0,0,0.24) 40%, rgba(0,0,0,0.42) 55%, rgba(0,0,0,0.60) 70%, rgba(0,0,0,0.74) 85%, rgba(0,0,0,0.82) 100%);
  pointer-events: auto;
}

#voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--cream);
  min-height: 20px;
  max-width: 380px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.7);
}
#voice-status:not(:empty)::before {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  background: var(--amber);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-3.08A7 7 0 0 0 19 11z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-3.08A7 7 0 0 0 19 11z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The amber mic button (hold-to-talk) */
#hold-to-talk-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid rgba(245, 158, 11, 0.6);
  background: radial-gradient(circle, rgba(245,158,11,0.32) 0%, rgba(19,19,26,0.7) 72%);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.25);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
#hold-to-talk-btn svg { width: 32px; height: 32px; fill: currentColor; }
#hold-to-talk-btn:active { transform: scale(0.95); }

#hold-to-talk-btn.recording {
  background: var(--amber);
  color: var(--bg);
  border-color: var(--amber-soft);
  animation: hold-to-talk-pulse 1s ease-in-out infinite;
}

@keyframes hold-to-talk-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245,158,11,0.55); }
  100% { box-shadow: 0 0 0 18px rgba(245,158,11,0); }
}

#hold-to-talk-hint {
  font-size: 12px;
  color: var(--stone);
  max-width: 260px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

#options-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

/* Semi-transparent frosted cards: the video shows through. */
.option-card {
  flex: 1 1 100%;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--rim);
  border-radius: 12px;
  padding: 14px 18px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s, opacity 0.2s;
}
.option-card:hover { border-color: rgba(245, 158, 11, 0.45); }
.option-card:active { transform: scale(0.98); border-color: var(--amber); }

/* Chosen (correct) card: amber rim + glow. */
.option-card.correct {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.28);
  color: var(--cream);
}

/* Dimmed via blended color, not the `opacity` property,
   so the hint text nested inside stays fully legible. */
.option-card.wrong {
  background: rgba(147, 0, 10, 0.22);
  border-color: rgba(255, 180, 171, 0.25);
  color: rgba(245, 243, 239, 0.5);
  text-decoration: line-through;
  text-decoration-color: rgba(245, 243, 239, 0.35);
  cursor: not-allowed;
  pointer-events: none;
}

/* "Did you mean...?" suggestion after 2 failed voice attempts - pulses amber while it waits
   for a confirm-or-override tap. */
.option-card.suggested {
  border-color: var(--amber);
  animation: suggested-pulse 1s ease-in-out infinite;
}

@keyframes suggested-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
  100% { box-shadow: 0 0 0 10px rgba(245,158,11,0); }
}

.option-hint {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(245, 243, 239, 0.12);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: #ffdad6;
}

.charm-line {
  color: var(--stone);
  font-size: 15px;
  margin: 0;
}

/* ---------- Coach whisper text ---------- */
#coach-text {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--amber-soft);
  opacity: 0.95;
  min-height: 16px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.7);
}

/* ---------- Waiting nudge: one gentle pulse on the option cards ---------- */
#options-row.nudge-pulse .option-card {
  animation: nudge-pulse 0.7s ease-in-out;
}

@keyframes nudge-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.035); }
  100% { transform: scale(1); }
}

/* ---------- Bad-ending fade-to-black overlay ---------- */
#fade-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
}

/* ---------- Restart button ---------- */
.corner-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 9999;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--cream);
  border: 1px solid var(--rim);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
}
.corner-btn:hover { border-color: rgba(245, 158, 11, 0.5); }

/* ---------- Debug 3-tap zone (invisible, top-left) ---------- */
#debug-tap-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 64px;
  height: 64px;
  z-index: 9998; /* below the debug panel itself, above everything else */
  background: transparent;
}

/* ---------- Debug panel ---------- */
#debug-panel {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 9999;
  background: rgba(0,0,0,0.8);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  max-width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  line-height: 1.6;
  text-align: left;
}

#debug-log {
  margin: 4px 0 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  color: var(--stone);
}

/* ---------- Feedback box (end screens) ---------- */
.feedback-box { margin-top: 12px; text-align: center; font-size: 14px; color: var(--stone); width: 100%; max-width: 340px; }
.feedback-box .fb-q { margin: 0 0 8px; font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--cream); }
.fb-choices { display: flex; gap: 8px; justify-content: center; }
.fb-choice, .fb-send {
  min-height: 44px;
  min-width: 44px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--cream);
  border: 1px solid var(--rim);
  border-radius: 999px;
  padding: 8px 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.fb-choice.picked { background: var(--amber); color: var(--bg); border-color: var(--amber); }
.fb-comment-row { display: flex; gap: 8px; margin-top: 10px; }
.fb-comment-row.hidden { display: none; }
.fb-comment { flex: 1; min-width: 0; min-height: 44px; background: var(--glass); color: var(--cream); border: 1px solid var(--rim); border-radius: 12px; padding: 8px 12px; font-family: var(--sans); font-size: 16px; }
.fb-comment::placeholder { color: var(--stone); }
.fb-thanks { margin: 8px 0 0; min-height: 1em; color: var(--amber-soft); }

/* Wider screens: keep the choice UI a phone-width column under the letterboxed video. */
@media (min-width: 700px) {
  #options-row { max-width: 440px; }
}

/* ---------- Paywall screen (demand test) ---------- */
#paywall-screen {
  background: radial-gradient(circle at 50% 28%, #22202a 0%, var(--bg) 75%);
  gap: 14px;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
}
.pw-kicker { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--amber-soft); }
.pw-title { margin: 0; font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 8vw, 44px); line-height: 1.12; max-width: 14em; }
.pw-sub { margin: 0; max-width: 22em; color: var(--stone); font-size: 16px; line-height: 1.5; }
.pw-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 360px; margin-top: 10px; }
.pw-buy { width: 100%; }
.pw-link { background: none; border: none; color: var(--stone); font-family: var(--sans); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 10px 14px; min-height: 44px; }
.pw-link:hover { color: var(--cream); }
.pw-soon, .pw-thanks { margin: 0; font-family: var(--serif); font-style: italic; font-size: 19px; line-height: 1.4; color: var(--cream); }
.pw-thanks { color: var(--amber-soft); font-size: 22px; }
.pw-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.pw-form input[type=email] { width: 100%; min-height: 50px; background: var(--glass); color: var(--cream); border: 1px solid var(--rim); border-radius: 14px; padding: 10px 14px; font-family: var(--sans); font-size: 16px; }
.pw-form input[type=email]::placeholder { color: var(--stone); }
.pw-form input[type=email]:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.pw-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.pw-notify { width: 100%; }
.pw-notify:disabled { opacity: 0.6; cursor: default; }
.pw-msg { margin: 0; min-height: 1.3em; font-size: 14px; color: var(--amber-soft); }

/* Mic-blocked fallback (itch.io build only): small pill linking to the full version */
#mic-fallback {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  top: max(10px, env(safe-area-inset-top));
  z-index: 60;
  max-width: calc(100% - 132px); /* clear of the restart button */
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(13, 13, 17, 0.78);
  border: 1px solid var(--rim);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  backdrop-filter: blur(6px);
}
#mic-fallback:hover, #mic-fallback:focus-visible { background: rgba(13, 13, 17, 0.95); text-decoration: underline; }
