/* Kimberley Town Heritage Trail — styles
   Design tokens match the heritage boards and the design canvas. */
:root {
  --bg: #F5EEDC;          /* parchment ground */
  --surface: #FFFCF4;     /* cards, sheets */
  --sunken: #EADFC6;      /* segmented controls, chips */
  --line: #E2D6BC;
  --ink: #241F16;
  --muted: #5B5244;
  --gold: #7A5712;        /* eyebrows, section headings */
  --red: #B81E27;         /* trail markers, calories */
  --green: #2E6439;       /* GNR path, positive */
  --blue: #2B6CB0;        /* user location */
  --radius: 14px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: Montserrat, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: #E9DFC7; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); }
a:hover { color: #5A400D; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* App frame: phone width, centred on larger screens */
.app { position: relative; max-width: 520px; height: 100%; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 40px rgba(36,31,22,.15); }
.view { flex: 1; min-height: 0; overflow-y: auto; outline: none; padding-bottom: 24px; }
.view.full { overflow: hidden; padding-bottom: 0; position: relative; display: flex; flex-direction: column; }
.loading, .empty { padding: 40px 20px; color: var(--muted); text-align: center; }

/* Tab bar */
.tabbar { flex-shrink: 0; height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 1000; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--red); font-weight: 700; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Type */
.eyebrow { margin: 0; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 34px; line-height: 1; }
.h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 25px; color: var(--gold); }
.label { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.story { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.45; white-space: pre-line; }
.small { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Headers */
.topbar { padding: 16px 16px 10px; display: flex; align-items: center; gap: 12px; }
.topbar .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.crest { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--surface); }
.page-head { padding: 20px 16px 8px; display: flex; flex-direction: column; gap: 10px; }

/* Buttons */
.btn { min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--ink); background: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { color: var(--ink); background: rgba(36,31,22,.05); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover { background: #3a3224; color: var(--surface); }
.btn.accent { background: var(--red); border-color: var(--red); color: #fff; min-height: 52px; font-size: 14px; }
.btn.accent:hover { background: #9c1820; color: #fff; }
.btn svg, .icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; box-shadow: 0 2px 8px rgba(36,31,22,.15); }
.icon-btn[aria-pressed="true"] { color: var(--red); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }

/* Segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 12px; }
.segmented button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(36,31,22,.15); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 32px; padding: 6px 12px; border-radius: 999px; background: var(--sunken); border: 0; font-size: 12px; font-weight: 600; color: var(--ink); }
button.chip { cursor: pointer; border: 1px solid #D5C7A6; background: var(--surface); }
button.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* Number badge (trail marker) */
.badge { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.badge.lg { width: 40px; height: 40px; font-size: 16px; }

/* Map screen */
.map-wrap { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; background: #E3EAD1; }
.map-controls { position: absolute; right: 12px; top: 12px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.pin { width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; border: 2px solid #fff; font: 700 11px var(--sans); display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(36,31,22,.35); }
.pin.on { width: 34px; height: 34px; background: var(--ink); font-size: 13px; }
.leaflet-div-icon.pin-icon { background: none; border: 0; }
.leaflet-container { font-family: var(--sans); }
.leaflet-container a { color: var(--gold); }

.sheet { position: relative; z-index: 600; margin-top: -18px; background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 20px rgba(36,31,22,.12); padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.sheet::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: #DCCFB1; align-self: center; }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head .grow { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sheet-title { margin: 0; font-family: var(--serif); font-size: 23px; font-weight: 700; line-height: 1.05; }
.sheet p.summary { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* Place screen */
.hero { position: relative; height: 300px; background: var(--sunken); flex-shrink: 0; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero .noimg { height: 100%; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 120px; font-weight: 700; color: rgba(122,87,18,.25); }
.hero .icon-btn { position: absolute; top: 16px; }
.hero .back { left: 16px; }
.hero .save { right: 16px; }
.hero .badge { position: absolute; left: 16px; bottom: -22px; width: 48px; height: 48px; font-size: 20px; border: 3px solid var(--bg); }
.place-body { padding: 34px 20px 8px; display: flex; flex-direction: column; gap: 14px; }
.section { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gallery img { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; }
.gallery img:only-child { grid-column: span 2; height: 200px; }
.note { padding: 14px 16px; border-radius: var(--radius); background: var(--sunken); font-size: 13px; line-height: 1.5; color: var(--muted); }

/* Lists & cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none; }
a.card:hover { color: var(--ink); border-color: #CDBE9C; }
.card-title { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.05; }
.card-row { display: flex; align-items: center; gap: 10px; }
.card-row .grow { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats.divided { border-top: 1px solid var(--sunken); padding-top: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 17px; }
.stat.kcal b { color: var(--red); }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-tile b { font-size: 20px; }
.stat-tile.dark { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.stat-tile.dark .small { color: var(--line); }
.stat-tile .year { font-family: var(--serif); font-size: 26px; line-height: 1; }
.pill { padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill.easy { background: #DCEBD6; color: #1F4D29; }
.pill.moderate { background: #F6E2C2; color: #6B4A0E; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.list-item:hover { color: var(--ink); background: rgba(36,31,22,.03); }
.list-item .grow { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.stack { padding: 4px 16px; display: flex; flex-direction: column; gap: 12px; }

/* Travel mode: Walk / Bike toggle and the round icon on route lists */
.segmented.modes button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.segmented.modes svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.segmented.modes button[aria-pressed="true"][data-mode="walk"] { color: var(--green); }
.segmented.modes button[aria-pressed="true"][data-mode="bike"] { color: var(--gold); }
.segmented button .small { display: block; font-size: 10px; font-weight: 600; color: inherit; opacity: .7; }
.mode-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--sunken); color: var(--green); display: inline-flex; align-items: center; justify-content: center; }
.mode-icon.bike { color: var(--gold); }
.mode-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mode-icon.route { color: var(--red); }
.mode-rows { border-top: 1px solid var(--sunken); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.mode-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.mode-row b { font-size: 17px; min-width: 64px; }
.mode-row .kcal { color: var(--red); font-weight: 700; font-size: 13px; min-width: 64px; }
.mode-row .grow { flex: 1; min-width: 0; text-align: right; }
.modes-inline svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; margin-right: 3px; }
.choose-mode .label { color: var(--gold); }

/* Route screen */
.walk-map { margin: 8px 16px 0; height: 240px; border-radius: 16px; overflow: hidden; position: relative; z-index: 0; }
.calc { margin: 14px 16px 0; }
.calc label, .calc .lbl { font-size: 13px; font-weight: 600; }
.calc input[type=range] { width: 100%; accent-color: var(--red); height: 28px; margin: 0; }
.spread { display: flex; justify-content: space-between; align-items: baseline; }
.pad-x { padding-left: 16px; padding-right: 16px; }
.mt { margin-top: 14px; }
.center { text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Live location, map controls & in-app navigation ---------- */
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.sm { width: 36px; height: 36px; box-shadow: none; }
.icon-btn[aria-pressed="true"] svg { fill: none; }
.map-controls .icon-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.map-controls.bottom { top: auto; bottom: 30px; }
@media (pointer: coarse) { .map-controls.bottom { display: none; } } /* phones pinch to zoom */
.map-toast { position: absolute; left: 12px; right: 68px; top: 12px; z-index: 550; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 600; box-shadow: 0 4px 14px rgba(36,31,22,.25); }
.is-satellite .pin { border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.4); }

/* Blue "you are here" dot with pulse and direction cone */
.leaflet-div-icon.me-icon { background: none; border: 0; }
.me { position: relative; width: 60px; height: 60px; pointer-events: none; }
.me-dot { position: absolute; left: 21px; top: 21px; width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.me-dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--blue); animation: me-pulse 2s ease-out infinite; }
.me-cone { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from -28deg, rgba(43,108,176,.45) 0 56deg, transparent 56deg); -webkit-mask: radial-gradient(circle, #000 0 70%, transparent 71%); mask: radial-gradient(circle, #000 0 70%, transparent 71%); transition: transform .4s ease; }
@keyframes me-pulse { from { transform: scale(1); opacity: .8; } to { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .me-dot::after { animation: none; } .me-cone { transition: none; } }

/* Distance-from-you line (map sheet + place page) */
.from-you { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--blue); }
.from-you svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.from-you b { color: var(--ink); }
.sort-btn { width: 100%; margin: 4px 0 8px; min-height: 40px; }
.sort-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Navigation screen */
.app.nav-mode .tabbar { display: none; }
.go { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.go-map-wrap { position: relative; flex: 1; min-height: 0; }
.go .map { position: absolute; inset: 0; }
.map-wrap .leaflet-bottom, .go-map-wrap .leaflet-bottom { bottom: 18px; }
.go-top { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; z-index: 700; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.instr { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; background: var(--ink); color: var(--surface); box-shadow: 0 8px 24px rgba(36,31,22,.35); }
.instr .grow { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.instr b { font-size: 22px; line-height: 1.1; }
.instr span#instr-text { font-size: 15px; font-weight: 600; color: #E9DFC7; }
.instr-icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: var(--blue); display: flex; align-items: center; justify-content: center; }
.instr-icon svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s; }
.go-note { pointer-events: auto; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; box-shadow: 0 4px 14px rgba(36,31,22,.2); }
.go-controls { top: auto; bottom: 30px; }
.go-panel { position: relative; z-index: 700; margin-top: -18px; max-height: 55%; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 20px rgba(36,31,22,.15); padding: 14px 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.go-progress { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.go-progress span { display: block; height: 100%; width: 0; background: var(--red); transition: width .4s; }
.go-dest { display: flex; align-items: center; gap: 10px; }
.go-dest .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.go-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.go-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 4px; border-radius: 12px; background: var(--bg); }
.go-stats b { font-size: 18px; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.steps li.done { opacity: .4; }
.steps li.now { color: var(--blue); }
.steps .grow { flex: 1; min-width: 0; }
.step-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* Arrival card */
.arrived { position: absolute; inset: 0; z-index: 900; background: rgba(36,31,22,.45); display: flex; align-items: flex-end; animation: fade .2s; }
.arrived-card { width: 100%; background: var(--surface); border-radius: 22px 22px 0 0; padding: 22px 18px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; animation: rise .3s ease-out; }
.arrived-card .summary { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.arrived .btn-row .btn { min-height: 52px; }

/* Route legend under the stats, and the "which line am I following" colour */
.go-mode { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.swatch { width: 22px; height: 5px; border-radius: 3px; flex-shrink: 0; background: var(--blue); }
.swatch.red { background: var(--red); }
.on-trail .steps li.now { color: var(--red); }
.badge-btn { border: 0; padding: 0; cursor: pointer; font-family: inherit; }

/* Story sheet: tap a pin while walking to read about that place */
.story-sheet { z-index: 950; }
.story-card { max-height: 86%; overflow-y: auto; gap: 14px; }
.story-head { display: flex; align-items: flex-start; gap: 12px; }
.story-head .grow { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.story-head .h1 { margin: 0; line-height: 1.05; }
.story-photo { width: 100%; max-height: 200px; object-fit: cover; border-radius: 14px; }
.story-text { display: flex; flex-direction: column; gap: 8px; }
.story-text .h2 { margin: 6px 0 0; }
.story-text .story { font-size: 16px; }
.story-text .note { margin: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

/* "You're here" opening page */
.stack-tight { display: flex; flex-direction: column; gap: 10px; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 12px; flex-shrink: 0; }
.btn.accent.sm { min-height: 38px; font-size: 12px; }
.here-status { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.here-status .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.here-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: var(--blue); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.here-icon.off { background: var(--sunken); color: var(--muted); }
.here-icon.pulse { animation: here-pulse 1.4s ease-in-out infinite; }
.here-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes here-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(43,108,176,.45); } 50% { box-shadow: 0 0 0 10px rgba(43,108,176,0); } }
.here-card { padding: 0; overflow: hidden; }
.here-photo { width: 100%; height: 170px; object-fit: cover; background: var(--sunken); }
.here-photo.noimg { display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 84px; font-weight: 700; color: rgba(122,87,18,.25); }
.here-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.here-body .card-title { font-size: 26px; }
.here-body .summary { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.here-walk .grow { display: flex; flex-direction: column; gap: 2px; }
.here-walk .chev { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
