/* Orange Passes crew roadbook. Mobile first, readable in sunlight, big tap targets. */
:root {
  --orange: #ff6a00;
  --orange-ink: #a84500;
  --ink: #1a1a1a;
  --muted: #555;
  --paper: #faf6f1;
  --card: #ffffff;
  --line: #e4dbd0;
  --km: #1a1a1a;
  --km-ink: #ffffff;
  --stop: #24584a;
  --warn-bg: #fff4cc;
  --warn-line: #e0b400;
  --sos: #c62828;
  --sos-ink: #ffffff;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --orange: #ff8a33;
    --orange-ink: #ffb27a;
    --ink: #f3f1ee;
    --muted: #b9b4ad;
    --paper: #111111;
    --card: #1d1d1d;
    --line: #333;
    --km: #000000;
    --km-ink: #ffffff;
    --stop: #2f7a66;
    --warn-bg: #3a3000;
    --warn-line: #d1a700;
    --sos: #e53935;
  }
}

* { box-sizing: border-box; }
/* No smooth scrolling: jumping to Emergency from the top must be instant. */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--orange-ink); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
section, article { scroll-margin-top: 72px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 1rem; }
.mono, .coords { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: 0.9rem; }
.muted { color: var(--muted); }

/* Header and sticky section nav */
.top { background: var(--km); color: var(--km-ink); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: inherit; text-decoration: none; font-weight: 800; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand small { display: block; font-weight: 500; font-size: 0.8rem; opacity: 0.8; }

.chips {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.chips .wrap { display: flex; gap: 0.4rem; align-items: center; padding: 0.5rem 1rem; }
.chip-scroll { display: flex; gap: 0.4rem; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chips a {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.9rem;
  border-radius: 999px; border: 1.5px solid var(--ink); color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 0.95rem; background: var(--card);
}
/* Emergency sits outside the scrolling strip, so it is always on screen. */
.chips a.sos { background: var(--sos); border-color: var(--sos); color: var(--sos-ink); }

/* Sections */
main > section { padding: 1.25rem 0 0.5rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.section-title h2 { font-size: 1.45rem; }
.section-title .badge { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
h3 { font-size: 1.2rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: 0 0 0.9rem;
}
.card > h3 { margin-bottom: 0.4rem; }
.card p { margin: 0.35rem 0; }

.hero { padding-top: 1rem; }
.kicker { margin: 0; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--orange-ink); font-size: 0.85rem; }
.hero h1 { font-size: 1.75rem; margin: 0.15rem 0 0.35rem; }
.hook { margin: 0 0 0.9rem; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0 0 0.9rem; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.7rem; }
.stats dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.stats dd { margin: 0; font-weight: 800; font-size: 1.05rem; }

.alert {
  background: var(--warn-bg); border: 2px solid var(--warn-line); border-radius: 10px;
  padding: 0.75rem 0.9rem; margin: 0 0 0.9rem;
}
.alert ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.alert p { margin: 0; }
.net { background: var(--km); color: var(--km-ink); border-radius: 8px; padding: 0.6rem 0.9rem; font-weight: 700; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 0.2rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 48px; padding: 0.55rem 1rem; border-radius: 10px;
  background: var(--orange); color: #111; border: 2px solid var(--orange);
  font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; text-align: center;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.6; }
.legs { display: grid; gap: 0.5rem; margin: 0.6rem 0; }
.legs .btn { justify-content: space-between; text-align: left; }
.legs .btn span { font-weight: 600; font-size: 0.9rem; opacity: 0.85; }

/* Ride preview */
.preview-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.8rem 0; }
.preview-controls label { font-weight: 800; }
.preview-controls select { min-height: 48px; padding: 0.4rem; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--ink); border-radius: 8px; }
.preview-map-wrap { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #e8e4dc; }
#preview-map { display: block; width: 100%; aspect-ratio: 800 / 450; touch-action: none; cursor: grab; }
#preview-map:active { cursor: grabbing; }
.preview-route { fill: none; stroke: #e65100; stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.preview-waypoint { fill: #fff; stroke: #292929; stroke-width: 2; }
.preview-label { fill: #111; stroke: #fff; stroke-width: 4; paint-order: stroke; font: bold 13px sans-serif; }
.preview-rider { fill: #0069c0; stroke: #fff; stroke-width: 3; }
.preview-zoom { position: absolute; top: 0.5rem; left: 0.5rem; display: grid; }
.preview-zoom button { width: 44px; height: 44px; font-size: 1.4rem; font-weight: 800; background: #fff; color: #111; border: 1px solid #555; cursor: pointer; }
.preview-attribution { position: absolute; right: 0; bottom: 0; padding: 0 0.25rem; background: #fff; color: #222; font-size: 0.7rem; }
.preview-progress { display: block; margin-top: 0.75rem; font-weight: 700; }
.preview-progress span { display: flex; justify-content: space-between; gap: 0.5rem; }
.preview-progress input { width: 100%; min-height: 44px; accent-color: var(--orange); }
.preview-follow { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.preview-follow input { width: 1.2rem; height: 1.2rem; }

/* Time plan */
.times { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.times th, .times td { text-align: left; vertical-align: top; padding: 0.45rem 0.5rem; border-top: 1px solid var(--line); }
.times th { white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
.times tr.key td, .times tr.key th { background: var(--warn-bg); }

/* Rally roadbook strip */
.rb { list-style: none; margin: 0 0 0.9rem; padding: 0; border: 2px solid var(--km); border-radius: 10px; overflow: hidden; background: var(--card); }
.rb li { display: grid; grid-template-columns: 5.4rem 1fr; border-top: 1px solid var(--line); }
.rb li:first-child { border-top: 0; }
.rb .km { background: var(--km); color: var(--km-ink); text-align: right; padding: 0.5rem 0.6rem; font-variant-numeric: tabular-nums; }
.rb .km b { display: block; font-size: 1.35rem; line-height: 1.1; }
.rb .km span { font-size: 0.82rem; opacity: 0.8; }
.rb .ins { padding: 0.5rem 0.75rem; }
.rb .ins strong { display: block; font-size: 1.04rem; }
.rb .ins p { margin: 0.15rem 0 0; font-size: 0.92rem; color: var(--muted); }
.rb .ins a { font-weight: 700; }
.rb li.pass .km { background: var(--orange); color: #111; }
.rb li.stop .km { background: var(--stop); color: #fff; }
.rb li.warn .ins { background: var(--warn-bg); }
.rb li.turnaround .ins strong::before { content: "↩ "; }

/* Waypoint / pass cards: the label pill carries the type, hero passes get a full outline */
.wp.hero-pass { border: 2px solid var(--orange); }
.wp .tag {
  display: inline-block; margin: 0 0 0.35rem; padding: 0.15rem 0.55rem; border-radius: 6px;
  font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--orange); color: #111;
}
.wp.town .tag { background: var(--stop); color: #fff; }
.wp.bonus .tag { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.wp h3 small { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.coords { display: flex; flex-wrap: wrap; gap: 0.15rem 0.9rem; margin: 0.3rem 0; font-size: 0.95rem; }
.coords .dec { font-weight: 700; }
.coords .dms { color: var(--muted); }
.facts { margin: 0.6rem 0 0; }
.facts dt { font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 0.55rem; }
.facts dd { margin: 0.1rem 0 0; }
.shots { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.shots li { margin: 0.2rem 0; }
.shots b { color: var(--orange-ink); }
details { margin-top: 0.6rem; border-top: 1px dashed var(--line); padding-top: 0.4rem; }
summary { cursor: pointer; font-weight: 800; min-height: 40px; display: flex; align-items: center; }
details > *:not(summary) { margin: 0.3rem 0; }

/* Lists and tables */
.list { margin: 0.3rem 0; padding-left: 1.2rem; }
.list li { margin: 0.25rem 0; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.grid-table th, .grid-table td { text-align: left; vertical-align: top; padding: 0.45rem 0.4rem; border-top: 1px solid var(--line); }
.grid-table thead th { border-top: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* Locate me */
.locate-out { margin-top: 0.75rem; }
.locate-out .big { font-size: 1.3rem; font-weight: 800; }
.hosp-near { list-style: none; padding: 0; margin: 0.25rem 0 0; }
.hosp-near li { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.hosp-near .actions { margin-top: 0.5rem; }

/* Emergency */
.sos-section .section-title h2 { color: var(--sos); }
.calls { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0 0 0.9rem; }
.calls a {
  display: flex; flex-direction: column; justify-content: center; min-height: 72px; padding: 0.5rem 0.75rem;
  border-radius: 12px; background: var(--sos); color: var(--sos-ink); text-decoration: none;
}
.calls a b { font-size: 1.4rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.calls a span { font-size: 0.85rem; opacity: 0.95; }
.calls a.primary { grid-column: 1 / -1; min-height: 84px; }
.calls a.primary b { font-size: 2rem; }
.steps { margin: 0.3rem 0; padding-left: 1.3rem; }
.steps li { margin: 0.35rem 0; }
.say { background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; padding: 0.6rem 0.75rem; }
.hosp h3 small { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.hosp .tel { font-weight: 800; }

footer { padding: 1.5rem 0 2.5rem; font-size: 0.85rem; color: var(--muted); }
footer .actions { margin-top: 0.5rem; }

@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .calls { grid-template-columns: repeat(3, 1fr); }
  .legs { grid-template-columns: 1fr 1fr; }
}

@media print {
  :root { --paper: #fff; --card: #fff; }
  body { font-size: 11pt; }
  .chips, .actions, .legs, #locate, #ride-preview, footer .actions, .net { display: none !important; }
  .card, .rb li, .hosp { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .calls a { background: #fff; color: #000; border: 2px solid #000; min-height: 0; }
}
