/* Legroom — "Golden Hour Road Trip".
   A family EV trip planned at the warm edge of the day: dusk-ink surfaces, a
   sodium-lamp amber accent, a mint charge / clay rest signal pair, and the
   journey rendered as one glowing ribbon down the page (the signature element).
   Dark = dusk, light = dawn-haze. Metric units, every constraint a slider. */

/* ---- Type ---- */
/*  Bricolage Grotesque — characteristic display (used with restraint)
    Hanken Grotesk     — humanist body
    JetBrains Mono     — instrument readouts: times, %, km (tabular) */

:root {
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  /* Golden-hour signals shared across themes */
  --accent: #ffb24c;          /* sodium lamp */
  --accent-strong: #f59324;   /* amber for text/edges that need contrast */
  --charge: #34d39a;          /* mint — charging */
  --rest: #f0855d;            /* clay — family rest break */

  /* Dawn-haze (light) */
  --bg: #efe7d8;
  --bg-glow: radial-gradient(120% 80% at 80% -10%, #f7ddb0 0%, rgba(247, 221, 176, 0) 55%);
  --surface: #fbf6ec;
  --surface-2: #f3ebda;
  --text: #221c2b;
  --text-dim: #6c6477;
  --border: #e5dcc9;
  --spine: rgba(245, 147, 36, 0.42); /* the glowing road, dawn */
  --accent-soft: rgba(245, 147, 36, 0.14);
  --on-accent: #2a1c08;
  --shadow: 0 1px 2px rgba(74, 55, 25, 0.06), 0 14px 34px rgba(74, 55, 25, 0.10);

  --radius: 16px;
  --radius-sm: 11px;
  --gap: 18px;

  color-scheme: light;
  font-family: var(--body);
}

[data-theme="dark"] {
  /* Dusk-ink */
  --bg: #131019;
  --bg-glow: radial-gradient(130% 90% at 85% -20%, rgba(255, 178, 76, 0.16) 0%, rgba(255, 178, 76, 0) 55%);
  --surface: #1b1825;
  --surface-2: #241f31;
  --text: #f4eee2;
  --text-dim: #a79eb2;
  --border: #2e2840;
  --spine: rgba(255, 178, 76, 0.34); /* the glowing road, dusk */
  --accent-strong: #ffb24c;
  --accent-soft: rgba(255, 178, 76, 0.14);
  --on-accent: #221404;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 18px 40px rgba(0, 0, 0, 0.40);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { overflow-x: hidden; }
body {
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 32px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand__mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  /* a half-risen sun at the horizon */
  background:
    linear-gradient(var(--surface), var(--surface)) bottom/100% 50% no-repeat,
    radial-gradient(circle at 50% 62%, var(--accent) 0 46%, transparent 47%),
    var(--accent-strong);
  box-shadow: 0 0 0 1px var(--border), 0 0 14px -2px var(--accent);
}
.brand__word {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}
.topnav { display: flex; align-items: center; gap: 12px; }
.topnav__units {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.ghost-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  width: 38px; height: 38px;
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.ghost-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ---- Layout ---- */
.layout {
  flex: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: clamp(16px, 3vw, 28px);
  padding: clamp(18px, 3vw, 30px);
  align-items: start;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---- Control panel ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 84px;
}
@media (max-width: 880px) { .panel { position: static; } }
.panel__eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 8px;
}
.panel__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.panel__hint { margin: 0 0 22px; color: var(--text-dim); font-size: 0.86rem; }

/* ---- Sliders ---- */
.slider { display: block; margin-bottom: 20px; }
.slider:last-child { margin-bottom: 4px; }
.slider__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.slider__label { font-size: 0.85rem; color: var(--text-dim); }
.slider__value {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; border-radius: 999px;
  /* amber fill up to the thumb (--fill set per-input by sliders.js) */
  background: linear-gradient(to right,
    var(--accent-strong) var(--fill, 50%), var(--surface-2) var(--fill, 50%));
  outline-offset: 4px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

/* EV-only sliders are grayed out until the user says they're driving an EV. */
.slider--disabled { opacity: 0.42; }
.slider--disabled input[type="range"] { cursor: not-allowed; }

/* ---- Mode controls (EV toggle + default break) ---- */
.moderow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.moderow__label { font-size: 0.9rem; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.moderow__hint { font-size: 0.74rem; color: var(--text-dim); }

.breakpicker { margin-bottom: 22px; }
.breakpicker__label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; }

/* Selectable chips (default-break picker + per-break selector on the ribbon). */
.chip--choice { cursor: pointer; font: inherit; font-size: 0.74rem; line-height: 1.1; }
.chip--choice:hover { border-color: var(--accent-strong); }
.chip--choice.chip--on {
  background: color-mix(in srgb, var(--accent-strong) 18%, transparent);
  border-color: var(--accent-strong);
  color: var(--text);
  font-weight: 500;
}
.chip--choice:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* Inline per-break selector on the journey ribbon. */
.breakpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---- Journey ---- */
.journey { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 30px);
  box-shadow: var(--shadow);
}
.hero__eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hero__eyebrow .sun {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px -1px var(--accent);
}
.hero__route {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.7rem, 4.4vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 12px 0 0;
}
.status { color: var(--rest); font-size: 0.85rem; min-height: 0; }
.status:not(:empty) { margin-top: 10px; }

/* ---- Stat band (trip summary) ---- */
.statband {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 22px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
@media (max-width: 560px) { .statband { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat__label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.stat__value {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.2rem, 1rem + 1.1vw, 1.5rem);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat__sub { font-size: 0.74rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---- Map ---- */
.map {
  height: clamp(300px, 42vh, 420px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---- Map markers ---- */
.mapmarker {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2.5px solid var(--surface);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3);
}
.mapmarker--start { background: var(--accent-strong); }
.mapmarker--end { background: var(--accent-strong); box-shadow: 0 0 0 1.5px rgba(0,0,0,.25), 0 0 12px -1px var(--accent); }
.mapmarker--charge { background: var(--charge); }
.mapmarker--break { background: var(--rest); }

/* ---- The journey ribbon (signature) ---- */
.ribbon {
  list-style: none;
  margin: 0;
  padding: 22px clamp(16px, 3vw, 26px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stn, .seg {
  display: grid;
  grid-template-columns: 56px 26px minmax(0, 1fr);
  align-items: start;
}
.stn { padding: 2px 0; }

/* time gutter */
.stn__time, .seg__time {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  text-align: right;
  padding-right: 12px;
  padding-top: 1px;
  white-space: nowrap;
}

/* the rail column draws the continuous spine + a node dot */
.stn__rail, .seg__rail { position: relative; align-self: stretch; min-height: 22px; }
.stn__rail::before, .seg__rail::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: var(--spine);
  border-radius: 3px;
}
.seg__rail { min-height: 44px; }
.stn--depart .stn__rail::before { top: 9px; }   /* spine starts at the node */
.stn--arrive .stn__rail::before { bottom: calc(100% - 9px); } /* spine ends at the node */

.stn__dot {
  position: absolute;
  left: 50%; top: 2px;
  width: 14px; height: 14px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--spine);
  /* surface ring lifts each stop off the glowing road */
  box-shadow: 0 0 0 3px var(--surface);
  z-index: 1;
}
.stn--depart .stn__dot, .stn--arrive .stn__dot {
  border-color: var(--accent-strong);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface), 0 0 14px 0 var(--accent);
}
.stn--charge .stn__dot { border-color: var(--charge); background: var(--charge); }
.stn--break .stn__dot { border-color: var(--rest); background: var(--rest); }

/* station content */
.stn__content { padding: 0 0 6px 6px; min-width: 0; }
.stn__meta, .seg__meta { overflow-wrap: anywhere; }
.stn--depart .stn__content, .stn--arrive .stn__content { padding-bottom: 0; }
.stn__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stn__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.04rem;
  letter-spacing: -0.01em;
}
.stn--depart .stn__name, .stn--arrive .stn__name { font-size: 1.18rem; }
.stn__kind {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
}
.stn--charge .stn__kind { color: var(--charge); background: color-mix(in srgb, var(--charge) 14%, transparent); }
.stn--break .stn__kind { color: var(--rest); background: color-mix(in srgb, var(--rest) 16%, transparent); }
.stn--depart .stn__kind, .stn--arrive .stn__kind { color: var(--accent-strong); background: var(--accent-soft); }
.stn__meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* segment (a driving leg between stops) */
.seg__meta {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  padding: 10px 0 10px 6px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* amenity chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 0.74rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--text);
}

/* ---- Footer ---- */
.sitefooter {
  border-top: 1px solid var(--border);
  padding: 18px clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.linkbtn {
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-strong);
  padding: 4px;
}
.linkbtn:hover { color: var(--accent-strong); }

/* ---- Cookie consent ---- */
.consent {
  position: fixed;
  left: 50%;
  bottom: clamp(12px, 3vw, 24px);
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 100vmax rgba(10, 7, 16, 0.18);
  padding: 20px 22px;
  z-index: 60;
  animation: consent-rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes consent-rise {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.consent__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.consent__text { margin: 0; font-size: 0.86rem; color: var(--text-dim); }
.consent__text a, .consent__inline {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--accent-strong);
}
.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.consent__actions .btn { flex: 1 1 auto; }
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}
.btn--ghost { background: transparent; }

/* preference toggles */
.consent__prefs { margin-top: 16px; display: none; }
.consent__prefs[data-open="true"] { display: block; }
.pref {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.pref__name { font-weight: 600; font-size: 0.9rem; }
.pref__desc { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }
.pref__locked {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charge);
  white-space: nowrap;
  padding-top: 2px;
}

/* accessible switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch input:checked + .switch__track { background: var(--accent-soft); border-color: var(--accent-strong); }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: var(--accent-strong); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* ---- Motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
