/* Trailcraft — field UI, paper edition.
   Warm paper ground, cream cards with a real border, moss for the primary
   action, one ember accent, serif headlines. Built for gloves, rain and full
   sun: 56px touch targets, 8pt spacing, light theme only. */

:root {
  --paper: #F4EFE6;
  --card: #FFFDF8;
  --border: #DDD5C6;
  --ink: #17201A;
  --moss: #2F4A3A;
  --moss-deep: #1E3328;
  --ember: #D9662B;
  --muted: #6E7468;

  --r: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--body);
  overscroll-behavior: none;
}

#map { position: fixed; inset: 0; }

/* ── Screens ─────────────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; z-index: 10; }
.screen.paper { background: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen.glass { pointer-events: none; }        /* chrome over the live map */
.screen.glass > * { pointer-events: auto; }
.screen.tutorial { background: var(--moss-deep); display: flex; flex-direction: column; }

.page {
  max-width: 560px; margin: 0 auto; min-height: 100%;
  padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 24px);
  display: flex; flex-direction: column; gap: 12px;
}
.page-bottom { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; gap: 10px; }

/* ── Type ────────────────────────────────────────────────────────── */
.display {
  margin: 0; font-family: var(--display); font-weight: 700;
  font-size: 34px; line-height: 1.12; letter-spacing: -0.5px;
}
.display.big { font-size: 40px; }
.label {
  display: block; margin-top: 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.body { margin: 0; font-size: 16px; }
.body.small { font-size: 13.5px; }
.body.center { text-align: center; }
.muted { color: var(--muted); }
.greet { font-size: 15px; font-weight: 500; color: var(--muted); }

.field-label { display: block; font-size: 14px; font-weight: 600; margin: 8px 0 6px; }
.field-label b { font-variant-numeric: tabular-nums; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  min-height: 56px; padding: 12px 20px; border: none; border-radius: 999px;
  font: 600 17px var(--body); cursor: pointer; color: var(--ink);
  background: var(--card); border: 1px solid var(--border);
  transition: transform 130ms var(--ease-out), filter 130ms ease;
}
.btn:active { transform: scale(0.97); filter: brightness(0.96); }
.btn.moss { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.ember { background: var(--ember); border-color: var(--ember); color: #fff; }
.btn.danger { background: var(--card); color: #B3372B; border-color: #E4B9B2; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.small { min-height: 44px; font-size: 14px; padding: 8px 16px; }
.btn.card-btn { border-radius: 16px; text-align: center; }
.btn.grow { flex: 1; }
.btn.moss-on-dark { background: rgba(255, 255, 255, 0.14); border-color: transparent; color: #fff; width: 100%; }

.btn.big {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 76px; border-radius: 22px; width: 100%;
}
.btn.big b { font-family: var(--display); font-weight: 600; font-size: 24px; }
.btn.big i { font-style: normal; font-size: 13px; font-weight: 500; opacity: 0.85; }

.row-gap { display: flex; gap: 10px; align-items: center; }
.row-gap .btn { flex: 1; }

/* ── Inputs ──────────────────────────────────────────────────────── */
input[type="text"], input[type="number"], input[type="datetime-local"], select {
  width: 100%; min-height: 56px; padding: 0 16px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--border); border-radius: 14px;
  font: 500 17px var(--body);
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--moss); outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: var(--moss); height: 40px; }

/* ── Chips (home rows) ───────────────────────────────────────────── */
.chip-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 8px 18px 8px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font: 600 15px var(--body); color: var(--ink); cursor: pointer;
  transition: transform 130ms var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip.selected { background: var(--moss); border-color: var(--moss); color: #fff; }
.chip.selected i { color: rgba(255, 255, 255, 0.75); }
.chip.plain { padding: 8px 18px; display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; }
.chip.plain b { font-family: var(--display); font-weight: 600; font-size: 16px; }
.chip.plain i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--muted); }
.chip.ghost { border-style: dashed; background: transparent; padding: 8px 18px; color: var(--muted); }
.chip i.sub { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--muted); display: block; }
.chip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }

/* ── Avatars ─────────────────────────────────────────────────────── */
.ava {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: #E4DCC9 center/cover no-repeat;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 16px var(--body); color: var(--muted); overflow: hidden;
}
.ava.big { width: 72px; height: 72px; font-size: 26px; }
.ava.has-photo { color: transparent; }
.ava-btn, .photo-pick { background: none; border: 0; padding: 0; cursor: pointer; }
.photo-row { display: flex; align-items: center; gap: 14px; margin: 8px 0; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.recent { display: flex; flex-direction: column; gap: 10px; }
.recent .card { cursor: pointer; }
.recent .card:active { filter: brightness(0.97); }
.card .meta {
  display: flex; justify-content: space-between; gap: 10px;
  font: 600 13px var(--body); color: var(--muted); letter-spacing: 0.02em;
}
.card .story { font-size: 15.5px; line-height: 1.45; }

/* ── Radio cards (dog level) ─────────────────────────────────────── */
.radio-cards { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  align-items: center; text-align: left;
  min-height: 60px; padding: 10px 16px; border-radius: 16px;
  background: var(--card); border: 1.5px solid var(--border);
  font: inherit; cursor: pointer;
}
.radio-card b { font-size: 16px; font-weight: 700; }
.radio-card i { font-style: normal; font-size: 13px; color: var(--muted); grid-column: 1; }
.radio-card .radio-dot {
  grid-row: 1 / span 2; grid-column: 2;
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border);
}
.radio-card.selected { background: var(--moss); border-color: var(--moss); color: #fff; }
.radio-card.selected i { color: rgba(255, 255, 255, 0.75); }
.radio-card.selected .radio-dot { border-color: #fff; background: radial-gradient(circle at center, #fff 42%, transparent 46%); }

/* ── Tutorial ────────────────────────────────────────────────────── */
.tut-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-t) + 16px) 24px 12px;
}
.tut-dots { display: flex; gap: 6px; }
.tut-dot { width: 8px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.25); transition: width 200ms var(--ease-out); }
.tut-dot.on { width: 24px; background: var(--ember); }
.tut-skip { background: none; border: 0; font: 600 16px var(--body); color: rgba(255, 255, 255, 0.7); cursor: pointer; min-height: 44px; }
.tut-card { flex: 1; padding: 40px 24px 0; display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 0 auto; width: 100%; }
.tut-k { font: 600 14px var(--body); letter-spacing: 2px; color: var(--ember); }
.tut-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 40px; line-height: 1.1; letter-spacing: -1px; color: #fff; }
.tut-body { margin: 0; font-size: 19px; line-height: 1.58; color: rgba(255, 255, 255, 0.78); }
.tut-bottom { padding: 16px 24px calc(var(--safe-b) + 20px); max-width: 560px; margin: 0 auto; width: 100%; }

/* ── Home ────────────────────────────────────────────────────────── */
.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.home .btn.big { margin-top: 6px; }

/* ── Glass screens (over the map) ────────────────────────────────── */
.hud-pill {
  position: fixed; top: calc(var(--safe-t) + 14px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 12px 20px; font: 700 15px var(--body); text-align: center;
  box-shadow: 0 6px 18px rgba(23, 32, 26, 0.14);
  font-variant-numeric: tabular-nums; max-width: calc(100vw - 24px);
  border-radius: 22px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #C43C2B; flex: none; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.glass-bottom {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 14px 16px calc(var(--safe-b) + 16px);
  display: flex; flex-direction: column; gap: 10px;
  max-width: 560px; margin: 0 auto;
}
.glass-caption { margin: 0; text-align: center; font: 600 13px var(--body); color: var(--card); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55); }
/* Over bright imagery a transparent button disappears — paper behind it. */
.glass .btn.ghost { background: var(--card); }

.wp-row { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.wp-row::-webkit-scrollbar { display: none; }
.wp-pill {
  flex: none; min-height: 48px; padding: 8px 16px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font: 600 14px var(--body); cursor: pointer;
  transition: transform 120ms var(--ease-out);
}
.wp-pill:active { transform: scale(0.94); background: var(--moss); color: #fff; }

.contam-form { gap: 4px; }

/* ── Share ───────────────────────────────────────────────────────── */
.minimap { width: 100%; height: auto; background: #E7EBDD; border-radius: 12px; }
.qr-card { align-items: center; }
.qr-plate { background: #fff; border-radius: 16px; padding: 14px; width: min(70vw, 300px); aspect-ratio: 1; }
.qr-plate svg { width: 100%; height: 100%; display: block; }

.scan-video { width: 100%; max-height: 52vh; border-radius: var(--r); background: #000; object-fit: cover; }

/* ── Result ──────────────────────────────────────────────────────── */
.grid2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 4px;
}
.grid2 > div {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px;
}
.grid2 b { display: block; font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.grid2 b .ok { color: var(--moss); }
.grid2 b .no { color: var(--ember); }
.grid2 i { display: block; margin-top: 4px; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.grid2 .sub-line { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Settings ────────────────────────────────────────────────────── */
.set-card { margin-bottom: 10px; }
.set-row { display: flex; align-items: center; gap: 12px; min-height: 52px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font: inherit; padding: 4px 0; }
.set-row .who b { display: block; font-weight: 600; font-size: 16px; }
.set-row .who i { font-style: normal; font-size: 13px; color: var(--muted); }
.advanced { margin-top: 4px; }
.advanced summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 45%; z-index: 60;
  background: var(--ink); color: var(--paper); border-radius: 999px;
  padding: 13px 22px; font: 600 15px var(--body); pointer-events: none;
  box-shadow: 0 12px 34px rgba(23, 32, 26, 0.3);
  opacity: 0; transform: translateX(-50%) translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
  visibility: hidden; max-width: calc(100vw - 40px); text-align: center;
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
  transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out);
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .btn:active, .chip:active, .wp-pill:active { transform: none; }
  .toast, .toast.show { transition: opacity 150ms ease; transform: translateX(-50%); }
  .tut-dot { transition: none; }
  .rec-dot { animation: none; }
}
@media (prefers-contrast: more) {
  .card, .btn, .chip, .hud-pill { border-color: var(--muted); }
}

/* ── The relay: draw, countdown, guided walk, wait ───────────────── */
.age-row { display: flex; gap: 8px; }
.age-chip {
  flex: 1; min-height: 48px; border-radius: 999px;
  background: var(--paper); border: 1.5px solid var(--border);
  font: 700 15px var(--body); color: var(--ink); cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: transform 120ms var(--ease-out);
}
.age-chip:active { transform: scale(0.95); }
.age-chip.selected { background: var(--moss); border-color: var(--moss); color: #fff; }

/* The two countdown screens borrow the tutorial's deep moss: the biggest,
   most legible thing a phone can show across a field in full sun. */
.center-card { justify-content: center; align-items: center; text-align: center; }
.tut-title.huge {
  font-size: 84px; line-height: 1; letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}
.tut-title.huge.ready { color: #F0B429; }
.tut-body.center { text-align: center; }
.tut-body.small-note { font-size: 14px; line-height: 1.5; opacity: 0.75; }
.wide-btn { width: 100%; }
.wait-qr { width: min(58vw, 240px); margin-top: 8px; }

/* A verdict graded against a drawn line says so, in ember, right under the
   sentence it qualifies — not in a footnote nobody reads. */
.provisional {
  color: var(--ember);
  margin: -6px 0 14px;
  line-height: 1.45;
}

/* A GPS verdict is either reassurance or an instruction. Colour says which
   before the sentence is read. */
.gps-good { color: var(--moss); }
.gps-bad  { color: var(--ember); }
#gpsReport { line-height: 1.5; margin-top: -4px; }

/* ── Navigation ───────────────────────────────────────────────────────
   The banner a person reads at a glance while walking: one number big
   enough to see at arm's length in sun, the instruction under it, and the
   clock quieter still. Moss, not the blue of every other maps app. */
.nav-banner {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 10px; right: 10px;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px;
  background: var(--moss-deep);
  color: #FFFDF8;
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(23, 32, 26, 0.34);
  transition: background 240ms ease;
}
.nav-banner.off-line { background: #8A4318; }   /* drifting: ember, not alarm */

.nav-dist { display: flex; align-items: baseline; gap: 5px; flex: 0 0 auto; }
.nav-dist b {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700; font-size: 44px; line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.nav-dist i { font-style: normal; font-size: 17px; font-weight: 600; opacity: 0.75; }

.nav-say { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nav-say > span { font-size: 16px; font-weight: 600; line-height: 1.25; }
.nav-say .nav-sub { font-size: 13px; font-weight: 500; opacity: 0.72; }

/* Re-centre: the control that gives the camera back. It only appears once
   following has started, and nudges when the user has panned away. */
.map-fab {
  position: absolute; right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 118px);
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: var(--card); color: var(--moss);
  box-shadow: 0 6px 18px rgba(23, 32, 26, 0.28);
  cursor: pointer;
  transition: transform 140ms ease, background 200ms ease;
}
.map-fab:active { transform: scale(0.94); }
.map-fab.nudge { background: var(--ember); color: #FFFDF8; }

@media (prefers-reduced-motion: reduce) {
  .map-fab, .nav-banner { transition: none; }
}
