/* ==========================================================================
   SAMLARC "Where the West Begins Again" — theme + screens (ADR-0004)

   THEME TOKENS: everything brand-tunable is a CSS custom property in :root
   below. To apply Chloe's brand kit, edit ONLY this :root block + swap the
   files in assets/ (logo, map, fonts). No component/Rust changes needed.
   ========================================================================== */

/* SAMLARC brand type — Rosario (SIL OFL), self-hosted for offline-first
   (ADR-0011, no CDN). One variable file per subset covers weights 300–700 and
   is used for BOTH body and display, matching samlarc.org. To change the face,
   swap these files + the @font-face src; that plus the :root tokens is the
   whole brand swap. */
@font-face {
  font-family: "Rosario";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/rosario-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Rosario";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/rosario-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* --- palette (SAMLARC brand — samlarc.org / Great Rancho Campout) ---
     Adopted from SAMLARC's live site: navy #114C72 is the primary (headings,
     CTA edge, deep accents); the event's warm terracotta #CD7036 becomes the
     CTA + warm highlights, on a warm neutral surface.
     WCAG AA (ADR-0013): every text/label pair must clear 4.5:1 (3:1 large).
     The CTA keeps a --gr-ink label on the --gr-gold-hi → --gr-gold terracotta
     gradient — kept light enough that ink-on-terracotta stays ≥ 4.5:1 (≈5.9:1)
     — with a navy (--gr-gold-deep) stamped border/lip. Navy headings clear ~8:1
     on parchment. Preserve these invariants if the palette is retuned. */
  --gr-parchment:  #f4efe6;  /* warm neutral surface (SAMLARC light bg, warmed) */
  --gr-parchment-2:#e7dccb;
  --gr-ink:        #232c36;  /* charcoal-navy body text (SAMLARC #333539/#161A26) */
  --gr-ink-soft:   #51616f;  /* muted slate */
  --gr-gold:       #e0975a;  /* warm terracotta — base of the CTA gradient + fills */
  --gr-gold-hi:    #f0b98a;  /* lighter terracotta — top of the CTA gradient */
  --gr-gold-deep:  #114c72;  /* SAMLARC navy — headings, CTA border/lip, deep accents */
  --gr-rust:       #a8451a;  /* deep terracotta — labels/toasts (AA as text) */
  --gr-pine:       #1c6ea3;  /* SAMLARC blue — spare accent (ADR-0004 palette;
                                unused since ADR-0016 retired the completion clock) */
  --gr-shadow:     rgba(17, 32, 48, .28);

  /* --- type --- */
  /* SAMLARC uses Rosario across its site (headings + body). One family,
     variable weight, self-hosted in the @font-face rules above. */
  --gr-font-display: "Rosario", Georgia, "Times New Roman", serif;
  --gr-font-body:    "Rosario", Georgia, "Times New Roman", serif;

  /* --- metrics --- */
  --gr-radius: 14px;
  --gr-gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--gr-parchment);
  color: var(--gr-ink);
  font-family: var(--gr-font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Parchment texture: layered radial + linear washes (no external image). */
body {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(120% 90% at 50% 120%, rgba(138,90,18,.10), transparent 60%),
    linear-gradient(180deg, var(--gr-parchment), var(--gr-parchment-2));
  background-attachment: fixed;
}

/* --- splash (index.html; removed on mount) --- */
#splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center;
  color: var(--gr-ink-soft);
  font-family: var(--gr-font-body);
}
.splash__spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid var(--gr-gold-deep); border-top-color: transparent;
  animation: gr-spin .9s linear infinite;
}
@keyframes gr-spin { to { transform: rotate(360deg); } }

/* --- app shell --- */
.app { min-height: 100dvh; }
.shell {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* --- base screen --- */
.screen {
  flex: 1;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0) + 22px) 22px calc(env(safe-area-inset-bottom, 0) + 26px);
  display: flex;
  flex-direction: column;
  gap: var(--gr-gap);
}

/* ready-gate fade-in (ADR-0011). Screens that opt in start hidden. */
.screen-intro,
.screen-map { opacity: 0; transition: opacity .28s ease; }
.screen-intro.is-ready,
.screen-map.is-ready { opacity: 1; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  font-family: var(--gr-font-display);
  font-size: 1.05rem;
  letter-spacing: .02em;
  border: none;
  border-radius: var(--gr-radius);
  padding: 14px 20px;
  cursor: pointer;
  color: var(--gr-ink);
  background: transparent;
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn--gold {
  /* AA (ADR-0013): a --gr-ink label on a light-gold → gold gradient. The darkest
     pixel behind the label is --gr-gold (≈5.6:1 with ink); the 3D "stamped" lip
     comes from the gold-deep border + hard shadow, not a dark gradient bottom. */
  background: linear-gradient(180deg, var(--gr-gold-hi), var(--gr-gold));
  color: var(--gr-ink);
  box-shadow: 0 3px 0 var(--gr-gold-deep), 0 6px 14px var(--gr-shadow);
  border: 2px solid var(--gr-gold-deep);
}
.btn--gold:active { box-shadow: 0 1px 0 var(--gr-gold-deep), 0 3px 8px var(--gr-shadow); }

.btn--ghost {
  background: rgba(255,255,255,.35);
  border: 2px solid var(--gr-gold-deep);
  color: var(--gr-ink);
}
.btn--link {
  background: none; border: none; color: var(--gr-ink-soft);
  text-decoration: underline; font-family: var(--gr-font-body);
  font-size: .9rem; padding: 8px;
}
.btn--big { font-size: 1.35rem; padding: 20px; width: 100%; }

/* ==========================================================================
   Intro
   ========================================================================== */
.screen-intro { align-items: center; justify-content: center; text-align: center; }
.intro__logo { width: 190px; height: 190px; filter: drop-shadow(0 6px 12px var(--gr-shadow)); }
.intro__title {
  font-family: var(--gr-font-display);
  font-size: 2.4rem; margin: 6px 0 0; color: var(--gr-gold-deep);
  text-shadow: 1px 1px 0 rgba(255,255,255,.5);
}
.intro__tagline { font-size: 1.1rem; margin: 0; color: var(--gr-ink); }
.intro__preview { font-family: var(--gr-font-display); color: var(--gr-ink-soft); margin: 4px 0 10px; }
.intro__cta { width: 100%; max-width: 340px; font-size: 1.3rem; padding: 18px; }
.intro__attribution,
.done__attribution { margin-top: 18px; font-size: .78rem; color: var(--gr-ink-soft); opacity: .8; }

/* ==========================================================================
   Trail Hub
   ========================================================================== */
.screen-hub { justify-content: flex-start; }
.hub__header { display: flex; justify-content: space-between; align-items: baseline; }
/* An <h1> (ADR-0013 M4) styled to read exactly like the former brand <span>:
   reset the UA heading margin + bold so size/weight/baseline are unchanged. */
.hub__brand { font-family: var(--gr-font-display); font-size: 1.15rem; font-weight: 400; color: var(--gr-gold-deep); margin: 0; }
.hub__progress { font-family: var(--gr-font-display); font-size: .95rem; color: var(--gr-ink-soft); }

.hub__clue-card {
  background: rgba(255,255,255,.45);
  border: 2px dashed var(--gr-gold-deep);
  border-radius: var(--gr-radius);
  padding: 22px 20px;
  margin-top: 8px;
  box-shadow: inset 0 0 24px rgba(138,90,18,.08);
}
.hub__clue-label,
.found__next-label {
  font-family: var(--gr-font-display);
  text-transform: uppercase; letter-spacing: .12em;
  font-size: .8rem; color: var(--gr-rust); margin: 0 0 8px;
}
.hub__clue { font-size: 1.35rem; line-height: 1.4; margin: 0; }
/* First-visit orientation (Chloe's check-in-sheet kickoff, email 2026-07-22). */
.hub__howto { font-size: .95rem; color: var(--gr-ink-soft); margin: 0; }
.hub__scan { margin-top: auto; }
.hub__row { display: flex; gap: 12px; }
.hub__row .btn { flex: 1; }

/* ==========================================================================
   Scan
   ========================================================================== */
.screen-scan { justify-content: flex-start; }
.scan__header { display: flex; align-items: center; gap: 10px; }
.scan__title { font-family: var(--gr-font-display); font-size: 1.4rem; margin: 0; }
.scan__back { min-height: 44px; padding: 10px 14px; } /* ≥44px target (ADR-0013 m2) */
.scan__viewport {
  position: relative;
  width: 100%; aspect-ratio: 3 / 4;
  border-radius: var(--gr-radius);
  overflow: hidden;
  background: #1c130a;
  border: 3px solid var(--gr-gold-deep);
  box-shadow: 0 6px 18px var(--gr-shadow);
}
.scan__video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan__canvas { display: none; }
.scan__reticle {
  position: absolute; inset: 18%;
  border: 3px solid rgba(255,248,230,.85);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.25);
}
.scan__hint { text-align: center; color: var(--gr-ink-soft); margin: 4px 0; }
.scan__toast {
  text-align: center; font-family: var(--gr-font-display);
  background: var(--gr-rust); color: #fff8e6;
  padding: 10px 14px; border-radius: var(--gr-radius); margin: 0;
}
.scan__toast-msg { margin: 0; }
/* Clue replay on an out-of-order refusal (ADR-0015). */
.scan__toast-label {
  margin: 10px 0 2px; font-size: .8rem; letter-spacing: .06em;
  text-transform: uppercase; opacity: .85;
}
.scan__toast-clue { margin: 0 0 10px; font-family: var(--gr-font-body); }
.scan__manual { border-top: 1px dashed var(--gr-gold-deep); padding-top: 12px; margin-top: auto; }
.scan__manual summary { cursor: pointer; color: var(--gr-ink-soft); font-family: var(--gr-font-display); min-height: 44px; padding: 12px 2px; } /* ≥44px target (ADR-0013 m2) */
.scan__manual-row { display: flex; gap: 8px; margin-top: 10px; }
.scan__manual-input {
  flex: 1; padding: 12px; font-size: 1.1rem;
  border: 2px solid var(--gr-gold-deep); border-radius: var(--gr-radius);
  background: rgba(255,255,255,.7); color: var(--gr-ink); font-family: var(--gr-font-body);
}
.scan__error { text-align: center; padding: 20px; }
.scan__error-title { font-family: var(--gr-font-display); font-size: 1.2rem; color: var(--gr-rust); margin: 0 0 8px; }
.scan__error-body { color: var(--gr-ink-soft); margin: 0; }

/* ==========================================================================
   Found (success)
   ========================================================================== */
.screen-found { align-items: center; justify-content: center; text-align: center; }
.found__badge { font-size: 4rem; line-height: 1; animation: gr-pop .4s ease; }
@keyframes gr-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.found__title { font-family: var(--gr-font-display); font-size: 2.1rem; color: var(--gr-gold-deep); margin: 6px 0 0; }
.found__name { font-size: 1.3rem; margin: 0; color: var(--gr-ink); font-style: italic; }
.found__progress { font-family: var(--gr-font-display); color: var(--gr-ink-soft); margin: 2px 0 10px; }
.found__next {
  background: rgba(255,255,255,.45);
  border: 2px dashed var(--gr-gold-deep);
  border-radius: var(--gr-radius);
  padding: 20px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 14px;
}
.found__next-hint { font-size: 1.25rem; line-height: 1.4; margin: 0; }

/* ==========================================================================
   Map (progress)
   ========================================================================== */
.screen-map {
  justify-content: flex-start;
  /* Definite height: pins the screen to the viewport so nothing can scroll
     and gives .map__canvas a definite height to fill. */
  height: 100dvh;
  /* Orientation zoom (ADR-0006 pivot): the parchment renders this many times
     the canvas width, centered on the start pin. The placer's phone preview
     (scripts/mapgen/place_pins.py) reads this token — keep it a bare number. */
  --map-zoom: 2.4;
}
.map__header { display: flex; align-items: center; gap: 12px; height: 52px; }
.map__progress { font-family: var(--gr-font-display); color: var(--gr-ink-soft); }
.map__canvas {
  /* Centered-on-start view (ADR-0006 orientation pivot): the canvas is a
     window onto the zoomed parchment; the art overflows on every side. */
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.map__inner {
  /* The art at zoom: --map-zoom × the canvas width, 1:2 by aspect-ratio.
     left/top put the box's origin at the canvas center; the inline transform
     (set from the pin's % coords in map.rs) then slides the art so the start
     pin lands exactly on that center — no JS measurement, any viewport. */
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--map-zoom) * 100%);
  aspect-ratio: 1 / 2;
}
.map__parchment { display: block; width: 100%; height: 100%; }
.map__start {
  /* Anchor the BADGE's center (48px tall, border-box) on the pin point — the
     label hangs below. A plain -50% would center the whole column and float
     the star ~11px above the real spot. */
  position: absolute; transform: translate(-50%, -24px);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.map__start-badge {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: radial-gradient(circle, var(--gr-gold), var(--gr-gold-deep));
  border: 3px solid var(--gr-parchment);
  box-shadow: 0 3px 10px var(--gr-shadow);
  animation: map-start-pulse 2.4s ease-in-out infinite;
}
.map__start-label {
  font-family: var(--gr-font-display); font-weight: 700; font-size: .8rem;
  color: var(--gr-gold-deep);
  background: var(--gr-parchment);
  border: 1.5px solid var(--gr-gold-deep); border-radius: 10px;
  padding: 0 8px;
}
@keyframes map-start-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ==========================================================================
   Completion
   ========================================================================== */
.screen-completion { align-items: center; justify-content: center; text-align: center; }
.done__burst { font-size: 4.5rem; animation: gr-pop .5s ease; }
.done__title { font-family: var(--gr-font-display); font-size: 2.6rem; color: var(--gr-gold-deep); margin: 4px 0 0; }
.done__sub { font-size: 1.1rem; margin: 4px 0 6px; max-width: 360px; }
/* Chloe's photo call-to-action + sign-off (ADR-0015). */
.done__cta { font-size: 1rem; margin: 2px 0 8px; max-width: 360px; }
.done__signoff {
  font-family: var(--gr-font-display); font-size: 1rem;
  color: var(--gr-rust); margin: 12px 0 0; max-width: 340px;
}
.done__photo { max-width: 340px; }

/* ==========================================================================
   Photo finish (ADR-0016) — the closing family photo at the Western Town.
   Capture screen mirrors the scanner's viewport so the app only ever presents
   the camera one way.
   ========================================================================== */
.screen-photo { justify-content: flex-start; }
.photo__header { display: flex; align-items: center; gap: 10px; }
.photo__title { font-family: var(--gr-font-display); font-size: 1.4rem; margin: 0; }
.photo__back { min-height: 44px; padding: 10px 14px; } /* ≥44px target (ADR-0013 m2) */
.photo__viewport {
  position: relative;
  width: 100%; aspect-ratio: 3 / 4;
  border-radius: var(--gr-radius);
  overflow: hidden;
  background: #1c130a;
  border: 3px solid var(--gr-gold-deep);
  box-shadow: 0 6px 18px var(--gr-shadow);
}
.photo__video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The selfie preview reads as a mirror, like every phone camera app. The
   captured frame is drawn from the unmirrored stream, so the saved photo has
   the world the right way round. */
.photo__video.is-mirrored { transform: scaleX(-1); }
.photo__canvas { display: none; }
.photo__hint { text-align: center; color: var(--gr-ink-soft); margin: 4px 0; }
.photo__controls {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-top: auto;
}
.photo__shutter {
  width: 78px; height: 78px; border-radius: 50%; padding: 0;
  font-size: 2rem; line-height: 1;
  background: linear-gradient(180deg, var(--gr-gold-hi), var(--gr-gold));
  border: 4px solid var(--gr-gold-deep);
  box-shadow: 0 3px 0 var(--gr-gold-deep), 0 6px 14px var(--gr-shadow);
}
.photo__shutter:active { box-shadow: 0 1px 0 var(--gr-gold-deep), 0 3px 8px var(--gr-shadow); }
/* Camera swap — floats over the preview's top-right corner (48px ≥ the 44px
   target, ADR-0013 m2). */
.photo__flip {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 48px; height: 48px; padding: 0;
  border-radius: 50%;
  font-size: 1.4rem; line-height: 1;
  background: rgba(244, 239, 230, .85);
  border: 2px solid var(--gr-gold-deep);
  box-shadow: 0 3px 10px var(--gr-shadow);
}
.photo__error { text-align: center; padding: 20px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.photo__error-title { font-family: var(--gr-font-display); font-size: 1.2rem; color: var(--gr-rust); margin: 0; }
.photo__error-body { color: var(--gr-ink-soft); margin: 0; max-width: 340px; }

.screen-photo-done { align-items: center; justify-content: center; text-align: center; }
.photo__shot {
  width: 100%; max-width: 360px; display: block;
  border-radius: var(--gr-radius);
  border: 3px solid var(--gr-gold-deep);
  box-shadow: 0 6px 18px var(--gr-shadow);
}
.photo-done__title { font-family: var(--gr-font-display); font-size: 2rem; color: var(--gr-gold-deep); margin: 6px 0 0; }
/* The prize-claim line IS this screen — sized to outrank the buttons below.
   --gr-rust on parchment cleared 4.5:1 as body text, so it's safe at any size. */
.photo-done__claim {
  font-family: var(--gr-font-display); font-size: 1.75rem; font-weight: 700;
  line-height: 1.25;
  color: var(--gr-rust); margin: 2px 0 4px; max-width: 380px;
}
.photo-done__save-hint {
  font-size: .95rem; color: var(--gr-ink-soft); margin: 4px 0 0;
}
.photo-done__actions {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 340px;
}

/* ==========================================================================
   Start-over pop-out (ADR-0001) — bottom-right, two taps to reset.
   Hosted by the Hub, Completion and PhotoDone screens; those screens carry
   extra bottom padding so the collapsed pill never sits on their content.
   ========================================================================== */
.screen-hub,
.screen-completion,
.screen-photo-done {
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 84px);
}
.restart {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0) + 14px);
  z-index: 10;
  display: flex;
  justify-content: flex-end;
}
.restart__pill {
  min-height: 44px; /* ≥44px target (ADR-0013 m2) */
  padding: 10px 16px;
  font-size: .9rem;
  color: var(--gr-ink-soft);
  background: rgba(255,255,255,.75);
  border: 2px solid var(--gr-ink-soft);
  border-radius: 999px;
  box-shadow: 0 3px 10px var(--gr-shadow);
}
.restart__bar {
  background: var(--gr-parchment);
  border: 2px solid var(--gr-gold-deep);
  border-radius: var(--gr-radius);
  box-shadow: 0 6px 18px var(--gr-shadow);
  padding: 14px 16px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: gr-pop .18s ease;
}
.restart__msg { margin: 0; font-size: .95rem; color: var(--gr-ink); }
.restart__actions { display: flex; gap: 8px; }
.restart__actions .btn { flex: 1; font-size: .95rem; padding: 10px 12px; min-height: 44px; }

/* ==========================================================================
   Accessibility utilities (ADR-0013)
   ========================================================================== */

/* Visually-hidden but exposed to assistive tech — used for the Map screen's
   <h1> (its title has no natural visible slot; the map is cosmetic, ADR-0006). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Visible keyboard focus — a high-contrast ink ring readable over both the gold
   buttons and the parchment. Interactive controls only. */
.btn:focus-visible,
.scan__manual-input:focus-visible,
.scan__manual summary:focus-visible {
  outline: 3px solid var(--gr-ink);
  outline-offset: 2px;
}
/* The screen <main> is focused by script on route change (M3) for SR
   announcement; it's not in the tab order (tabindex=-1), so suppress its
   container ring — the controls inside keep their own focus-visible ring. */
.screen:focus { outline: none; }

/* ==========================================================================
   Reduced motion (ADR-0013) — neutralize non-essential motion with static
   equivalents: no spinner spin, no pop/burst, no fade-in, no button/marker
   movement. Essential meaning is always also conveyed as text.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  /* Splash spinner → a static full gold ring (no spin, no gap). */
  .splash__spinner {
    animation: none;
    border-top-color: var(--gr-gold-deep);
  }
  /* Badge / burst celebrations → appear in their final state, no pop. */
  .found__badge,
  .done__burst,
  .restart__bar { animation: none; }
  /* Ready-gate fade-in → appear instantly. */
  .screen-intro,
  .screen-map,
  .screen-intro.is-ready,
  .screen-map.is-ready { opacity: 1; transition: none; }
  /* Buttons → no press transform / transition. */
  .btn { transition: none; }
  .btn:active { transform: none; }
  /* Start pin → hold still, no pulse. */
  .map__start-badge { animation: none; }
}
