/* ============================================================================
 * styles.css — mobile-first, high contrast, outdoor-legible.
 *
 * Design targets:
 *  - readable in bright daylight AND at 1am in a dark ruin bar
 *  - every tap target >= 56px tall
 *  - base body text 18px, puzzle text 19px (bigger than typical web)
 *  - inputs at 17px+ so iOS Safari doesn't zoom the page on focus
 *  - portrait first; landscape just centres a max-width column
 * ========================================================================== */

:root {
  --bg:        #12100e;
  --bg-raised: #1d1a17;
  --bg-input:  #26221e;
  --line:      #38322c;

  --text:      #f6f1e8;
  --text-dim:  #a89e91;

  --gold:      #f0b323;   /* primary action */
  --gold-dark: #b8851a;
  --green:     #4ec36f;
  --red:       #ff6b5e;
  --amber:     #ffb547;

  --radius: 14px;
  --tap: 58px;

  --pad-x: 20px;
}

* { box-sizing: border-box; }

/* The app hides screens and conditional buttons with the `hidden` attribute.
 * Several of those elements also carry classes that set `display` (.btn is
 * display:block), which beats the UA stylesheet's `[hidden] { display:none }`.
 * This rule makes `hidden` actually mean hidden. Don't remove it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  min-height: 100dvh;
}

/* Kill the iOS tap-highlight flash, we do our own :active states */
button, input { -webkit-tap-highlight-color: transparent; }

/* ─────────────────────────────────────────────────────────────── layout ── */

#main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px var(--pad-x) calc(48px + env(safe-area-inset-bottom));
}

.screen { animation: fade .22s ease-out; }
.screen-center { text-align: center; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ──────────────────────────────────────────────────────────────── HUD ── */

.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(18,16,14,.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.hud-row {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px var(--pad-x) 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hud-progress {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud-right { display: flex; align-items: center; gap: 10px; }

.hud-timer {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  color: var(--gold);
}

/* Deliberately small and unlabelled — it's an escape hatch, not a feature. */
.hud-reset {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.hud-reset:active { background: var(--bg-raised); }

.hud-bar { height: 3px; background: var(--line); }
.hud-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width .35s ease;
}

/* ───────────────────────────────────────────────────────────────── hero ── */

.hero { text-align: center; padding: 26px 0 22px; }
.hero-finish { padding-top: 12px; }

.hero-kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.hero-title {
  margin: 0;
  font-size: clamp(34px, 11vw, 48px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.hero-sub {
  margin-top: 12px;
  font-size: 17px;
  color: var(--text-dim);
  letter-spacing: .04em;
}

/* ──────────────────────────────────────────────────────────────── facts ── */

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 6px 0 22px;
}

.fact {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fact-label {
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.fact-value { font-size: 16px; font-weight: 700; }

/* ───────────────────────────────────────────────────────────────── card ── */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  margin-bottom: 18px;
}

.card-clue  { border-color: #4a3f2c; background: #1f1a12; }
.card-success { border-color: #2f4d38; background: #16251b; }
.card-failure { border-color: #5c2f2b; background: #251615; }

.card-eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

.card-title { margin: 0 0 12px; font-size: 20px; font-weight: 800; }

/* Puzzle / clue body text — deliberately large. */
.prose {
  font-size: 19px;
  line-height: 1.6;
  white-space: pre-wrap;   /* keeps the \n\n paragraph breaks from content.js */
  word-break: break-word;
}

.prose + .prose { margin-top: 14px; }

.howto {
  margin: 0;
  padding-left: 20px;
  font-size: 17px;
  line-height: 1.5;
}
.howto li { margin-bottom: 10px; }
.howto li:last-child { margin-bottom: 0; }

.hint-cost-note {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--text-dim);
}

/* ───────────────────────────────────────────────────────── stop photos ── */

.stop-figure {
  margin: 0 0 18px;
  padding: 0;
}

.stop-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #000;
  cursor: zoom-in;
}

.stop-figure figcaption {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-dim);
  text-align: center;
  font-style: italic;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(20,18,16,.9);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

/* ─────────────────────────────────────────────────────── preview banner ── */

.preview-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #4a3a8f;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  line-height: 1.4;
}

/* ───────────────────────────────────────────────────────────── stop head ── */

.stop-head { margin: 4px 0 18px; }

.stop-num {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
}

.stop-teaser {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.arrival-note {
  margin: -6px 0 16px;
  font-size: 16px;
  font-style: italic;
  color: var(--text-dim);
}

/* ─────────────────────────────────────────────────────────── task timer ── */

.task-timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -4px 0 16px;
}

.task-timer {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.task-timer::before {
  content: "⏱";
  font-size: 15px;
}

#taskTimerValue {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
}

.task-timer-target {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

/* Past the target time: still fine, but the clock is now visibly ticking
 * against them. Past the decay window: it's bottomed out at the floor. */
.task-timer.task-timer-warn #taskTimerValue { color: var(--amber); }
.task-timer.task-timer-bad #taskTimerValue { color: var(--red); }

/* Live points readout — a running preview of "if you solved it right now,
 * this is what you'd get", so hint/time penalties are visible as they
 * happen instead of being a surprise on the solved screen. Same warn/bad
 * colour thresholds as the timer, driven by the same elapsed time, so the
 * two chips always agree about how much trouble you're in. */
.task-points {
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  background: var(--bg-raised);
  white-space: nowrap;
}
.task-points.task-points-warn { color: var(--amber); border-color: #6b5117; }
.task-points.task-points-bad  { color: var(--red);   border-color: #5c2f2b; }

/* ────────────────────────────────────────────────────────── photo capture ── */

.photo-capture {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
}

.photo-capture-box { text-align: center; }

.btn-photo {
  display: inline-block;
  width: auto;
  min-width: 220px;
  margin-bottom: 0;
}

.btn-photo-fallback {
  display: block;
  width: auto;
  margin: 10px auto 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  min-height: auto;
  padding: 8px;
}

.photo-capture-preview {
  margin: 0;
  text-align: center;
}

.photo-capture-preview img {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #000;
  cursor: zoom-in;
  margin-bottom: 12px;
}

.photo-capture .footnote {
  margin: 12px 0 0;
  text-align: center;
}

/* Hides the two file inputs WITHOUT display:none. iOS Safari has a known
 * quirk where a synthetic .click() on a display:none <input type=file> can
 * silently fail to open the native camera/photo picker at all — no error,
 * no sheet, nothing happens. This keeps the element genuinely in the layout
 * (0x0, clipped, transparent) so WebKit still honours the click. Do not
 * switch these back to the `hidden` attribute. */
.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

/* ──────────────────────────────────────────────────────────── then & now ── */

.then-now-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

.then-now-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
/* A lone image (no earlier stop photo to pair with) shouldn't stretch to
 * fill a whole grid column's width — cap and centre it instead. */
.then-now-grid:has(> :only-child) {
  grid-template-columns: minmax(0, 220px);
  justify-content: center;
}

.then-now-grid figure { margin: 0; }

.then-now-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.then-now-grid figcaption {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

/* ────────────────────────────────────────────────────────── points badge ── */

.points-badge {
  display: inline-block;
  margin: 0 auto 18px;
  padding: 8px 18px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 16px;
  background: #1a2a1c;
  border: 1px solid #2f4d38;
  color: var(--green);
}

.points-badge-full {
  background: #241c0c;
  border-color: var(--gold-dark);
  color: var(--gold);
}

.points-badge-skipped {
  background: #2a1917;
  border-color: #5c2f2b;
  color: var(--red);
}

/* ──────────────────────────────────────────────────────────────── badge ── */

.badge {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 16px;
}

.badge-warn {
  background: #2e2312;
  border: 1px solid #6b5117;
  color: var(--amber);
}

/* ──────────────────────────────────────────────────────────────── hints ── */

.hint-zone { margin-bottom: 22px; display: flex; flex-direction: column; gap: 10px; }

.hint-btn {
  width: 100%;
  min-height: var(--tap);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  padding: 14px;
  cursor: pointer;
}
.hint-btn:active { background: var(--bg-raised); }

/* Hints beyond the next one in line — visible so the group knows more exist,
 * but not revealable until every earlier hint has been opened. */
.hint-btn-locked {
  opacity: .4;
  cursor: not-allowed;
  filter: grayscale(60%);
}
.hint-btn-locked:active { background: transparent; }

.hint-revealed {
  background: #241f14;
  border: 1px solid #4a3f2c;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 17px;
  line-height: 1.5;
}
.hint-revealed .hint-tag {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}

/* ─────────────────────────────────────────────────────────────── answer ── */

.answer-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.answer-input {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg-input);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 20px;           /* >=17px so iOS doesn't zoom on focus */
  font-weight: 600;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.answer-input::placeholder { color: #6d6459; font-weight: 400; }
.answer-input:focus { outline: none; border-color: var(--gold); }
.answer-input.shake { animation: shake .32s; border-color: var(--red); }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.feedback {
  min-height: 26px;
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}
.feedback.bad  { color: var(--red); }
.feedback.good { color: var(--green); }

/* ─────────────────────────────────────────────────────────────── buttons ── */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 16px;
  cursor: pointer;
  margin-bottom: 12px;
}

.btn-huge { min-height: 64px; font-size: 20px; letter-spacing: .06em; }

.btn-primary {
  background: var(--gold);
  color: #1a1408;
  box-shadow: 0 3px 0 var(--gold-dark);
}
.btn-primary:active { transform: translateY(3px); box-shadow: none; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.btn-ghost:active { background: var(--bg-raised); }

.btn-danger-ghost {
  background: transparent;
  border: 1px solid #5c2f2b;
  color: var(--red);
  font-size: 16px;
}
.btn-danger-ghost:active { background: #2a1917; }

.btn-small { min-height: 48px; font-size: 15px; font-weight: 600; letter-spacing: 0; }

/* Deliberately quiet — always present, but shouldn't compete visually with
 * the actual answer/confirm controls above it. See jumpSkipStop() in app.js. */
.btn-jump-skip {
  margin-top: 18px;
  border-color: transparent;
  color: var(--text-dim);
  opacity: .7;
}
.btn-jump-skip:active { opacity: 1; }

/* ─────────────────────────────────────────────────── multiple choice ── */

.choice-zone { margin-bottom: 18px; }
.choice-zone .answer-label { margin-bottom: 10px; }

.btn-choice {
  background: var(--bg-input);
  border: 2px solid var(--line);
  color: var(--text);
  text-align: left;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  min-height: 62px;
  white-space: normal;   /* long options wrap instead of overflowing */
}
.btn-choice:active { background: var(--bg-raised); border-color: var(--gold); }
.btn-choice.shake { animation: shake .32s; border-color: var(--red); }

/* ────────────────────────────────────────────────── picker (branch) ── */

.picker-zone { margin-bottom: 18px; }
.picker-zone .answer-label { margin-bottom: 10px; }

.btn-picker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--bg-input);
  border: 2px solid var(--line);
  text-align: left;
  min-height: 62px;
  white-space: normal;
  position: relative;
  overflow: hidden;
}
.btn-picker:active { background: var(--bg-raised); border-color: var(--gold); }

.picker-option-label {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--picker-color, var(--text));
}
.picker-option-desc {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-dim);
}

/* Optional per-option "draw the eye here" shimmer — subtle, not flashy. */
@keyframes picker-shimmer {
  0%   { background-position: -150% 0; }
  100% { background-position: 250% 0; }
}
.btn-picker-animated {
  border-color: var(--picker-color, var(--gold));
  background-image: linear-gradient(100deg,
    transparent 30%, rgba(255, 255, 255, .16) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: picker-shimmer 2.6s ease-in-out infinite;
}

/* ───────────────────────────────────────────── sequence (sub-tasks) ── */

.sequence-zone { margin-bottom: 18px; text-align: center; }

.sequence-sub-label { margin: 0 0 10px; font-size: 24px; font-weight: 900; }

.sequence-zone .prose { text-align: left; margin-bottom: 18px; }

.sequence-countdown {
  font-size: 56px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  letter-spacing: .02em;
}

.sequence-skip-btn { margin-top: 22px; }

/* ──────────────────────────────────────────── locked-until-photo state ── */

/* Applied to whichever "move on" control a stop uses, while it still needs
 * photo proof. Deliberately still legible rather than near-invisible — it
 * should read as "not yet", not as "broken". */
.btn-locked,
.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(60%);
}
.btn-locked:active { transform: none; }

.photo-gate-note {
  margin: -4px 0 18px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--amber);
}

/* ────────────────────────────────────────────────────────────── solved ── */

.big-tick { font-size: 64px; line-height: 1; margin: 26px 0 12px; }
.solved-title { margin: 0 0 20px; font-size: 28px; font-weight: 900; }
.failed-title { color: var(--red); }
#screen-solved .prose { text-align: left; }

/* ───────────────────────────────────────────────────────────── stag card ── */

.stag-card {
  background: linear-gradient(160deg, #241c0c, #1d1a17);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  padding: 26px 22px;
  margin-bottom: 20px;
  text-align: center;
}

.stag-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.stag-level {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -.01em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.stag-points {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}

.stag-bar {
  height: 10px;
  border-radius: 6px;
  background: var(--bg-input);
  overflow: hidden;
  margin-bottom: 16px;
}
.stag-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  transition: width .5s ease;
}

.stag-blurb {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

/* ─────────────────────────────────────────────────────────── scoreboard ── */

.scoreboard { margin-bottom: 20px; }

.score {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.score-hero {
  border-color: var(--gold-dark);
  background: #241c0c;
  padding: 22px 14px;
  margin-bottom: 10px;
}
.score-hero .score-value {
  font-size: 44px;
  color: var(--gold);
  letter-spacing: -.02em;
}

.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.score-label {
  display: block;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.score-value {
  display: block;
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* ──────────────────────────────────────────────────────────────── recap ── */

.recap {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}
.recap summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  min-height: 30px;
}
.recap-list { margin: 14px 0 4px; padding-left: 22px; font-size: 16px; line-height: 1.6; }
.recap-list li { margin-bottom: 6px; }

/* ───────────────────────────────────────────────────────────── footnote ── */

.footnote {
  margin: 2px 0 20px;
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

/* ─────────────────────────────────────────── reduced motion / a11y ── */

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