/* Walking route planner.
   Every rule lives here. There is not one style="" attribute in the templates
   or in the JS-generated markup, because under style-src 'self' a style
   attribute is silently dropped and the result just looks broken. */

:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #17251c;
  --ink-soft: #5a6b60;
  --line: #d9e0da;
  --accent: #2f6b45;
  --accent-soft: #e8f1eb;
  --warn: #8a5a12;
  --warn-soft: #fdf3e0;
  --danger: #9b2c2c;
  --danger-soft: #fdeaea;
  --start: #1a7f45;
  --finish: #a8341f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23, 37, 28, .12), 0 6px 18px rgba(23, 37, 28, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12160f;
    --panel: #1b211a;
    --ink: #e8efe8;
    --ink-soft: #9fb0a4;
    --line: #2c352c;
    --accent: #6fbf8b;
    --accent-soft: #1f2d24;
    --warn: #e0b364;
    --warn-soft: #2e2617;
    --danger: #e08585;
    --danger-soft: #2e1b1b;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* --- header ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.01em;
}

.topbar h1 .sub {
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 8px;
  font-size: 13px;
}

.spacer { flex: 1 1 auto; }

.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* --- usage meter -------------------------------------------------------- */

.usage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 260px;
}

.usage-figures { line-height: 1.25; }

.usage-headline {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
}

.usage-detail {
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.meter {
  flex: 1 1 auto;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  min-width: 70px;
}

.meter-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}

.usage.is-warn { border-color: var(--warn); background: var(--warn-soft); }
.usage.is-warn .meter-fill { background: var(--warn); }
.usage.is-stop { border-color: var(--danger); background: var(--danger-soft); }
.usage.is-stop .meter-fill { background: var(--danger); }

/* --- banner ------------------------------------------------------------- */

.banner {
  display: none;
  padding: 10px 16px;
  font-size: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border-bottom: 1px solid var(--danger);
}

.banner.is-shown { display: block; }

/* --- layout ------------------------------------------------------------- */

.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.panel {
  width: 330px;
  flex: 0 0 330px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px;
}

.map {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg);
}

.field { margin-bottom: 18px; }

.field > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

input[type="text"], input[type="search"], input[type="password"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button:disabled { opacity: .5; cursor: not-allowed; }

.results { list-style: none; margin: 8px 0 0; padding: 0; }

.results li { border-bottom: 1px solid var(--line); }

.results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  border-radius: 0;
  padding: 8px 4px;
}

.results button:hover { background: var(--accent-soft); }

.result-name { font-weight: 600; }

.result-meta { font-size: 12px; color: var(--ink-soft); }

.endpoints { display: grid; gap: 8px; }

.endpoint {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.endpoint .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}

.endpoint.start .dot { background: var(--start); }
.endpoint.finish .dot { background: var(--finish); }
.endpoint .value { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.endpoint .value.is-set { color: var(--ink); }

.hint { font-size: 12px; color: var(--ink-soft); margin: 6px 0 0; }

.note {
  font-size: 12px;
  color: var(--ink-soft);
  border-left: 3px solid var(--line);
  padding-left: 10px;
  margin-top: 20px;
}

/* --- login -------------------------------------------------------------- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 20px; color: var(--ink-soft); font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card button { width: 100%; }

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* --- small screens ------------------------------------------------------ */

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .panel { width: auto; flex: 0 0 auto; border-right: 0; border-bottom: 1px solid var(--line); max-height: 45vh; }
  .map { min-height: 55vh; }
  .usage { min-width: 0; flex: 1 1 100%; }
}

/* --- itinerary ---------------------------------------------------------- */

.days { list-style: none; margin: 8px 0 0; padding: 0; }

.days li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--panel);
}

.days li:hover { background: var(--accent-soft); }

.days li.is-active { border-color: var(--accent); background: var(--accent-soft); }

.day-no {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  min-width: 1.6em;
}

.day-body { flex: 1 1 auto; min-width: 0; }

.day-route { font-size: 13px; }

.day-dist { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.legend { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.legend .swatch {
  display: inline-block;
  width: 22px;
  height: 3px;
  vertical-align: middle;
  margin-right: 5px;
  border-radius: 2px;
}

.swatch-main {
  /* Dotted to match the line on the map. A repeating gradient rather than a
     border-style, so the dots sit at the same rhythm as the polyline. */
  background: repeating-linear-gradient(to right,
              #6a3d9a 0 2px, transparent 2px 6px);
}
.swatch-alt { background: #e08214; }

.return-leg {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.return-leg.is-set { border-color: var(--accent); }
.return-leg strong { color: var(--ink); font-weight: 600; }

/* --- beds and getting back ---------------------------------------------- */

.day-beds { margin-top: 5px; font-size: 12px; color: var(--ink-soft); }

.day-beds ul { list-style: none; margin: 3px 0 0; padding: 0; }

.day-beds li {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 1px 0;
  border: 0;
  margin: 0;
  background: none;
  cursor: default;
}

.bed-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.bed-off { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.bed-none { font-style: italic; }

.return-leg ul { list-style: none; margin: 6px 0 0; padding: 0; }

.return-leg li { padding: 1px 0; display: flex; gap: 6px; align-items: baseline; }

.mode {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 999px;
  white-space: nowrap;
  color: #fff;
}

.mode-rail { background: #1f4e9c; }
.mode-bus { background: #2f6b45; }
.mode-ferry { background: #0f6f80; }

.return-leg a {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 600;
}

.day-time { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.day-time.is-late { color: var(--danger); font-weight: 600; }

.tent-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 999px;
  margin-left: 5px;
  white-space: nowrap;
}

.tent-yes { background: var(--accent-soft); color: var(--accent); }
.tent-likely { background: var(--accent-soft); color: var(--ink-soft); }
.tent-unknown { background: var(--warn-soft); color: var(--warn); }

label.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 0;
}

label.check input { width: auto; margin: 0; }

/* --- map pins ----------------------------------------------------------- */

.walk-pin { background: none; border: 0; }

.walk-pin svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35));
}

.return-option {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px !important;
  margin: 0 -4px;
}

.return-option:hover { background: var(--accent-soft); }

.return-option.is-active {
  background: var(--accent-soft);
  outline: 1px solid var(--accent);
}

/* --- elevation profile -------------------------------------------------- */

/* The series colour is a CSS custom property so dark mode gets its OWN
   validated step rather than an automatic flip of the light one. Both pairs
   were checked with the palette validator: light #1f4e9c/#c2410c and dark
   #5288c9/#d9763c clear the lightness band, the chroma floor, colour-vision
   separation and contrast against their surface.

   The MAP keeps the light values in both themes: OS tiles are always a light
   sheet, so a "dark mode" line colour would be the wrong choice on top of
   them. Only the chart, which sits on the panel, follows the theme. */

.profile-wrap { margin-top: 6px; }

.profile { display: block; width: 100%; height: auto; }

.profile.day-0 { --series: #1f4e9c; }
.profile.day-1 { --series: #c2410c; }

@media (prefers-color-scheme: dark) {
  .profile.day-0 { --series: #5288c9; }
  .profile.day-1 { --series: #d9763c; }
}

.profile-area { fill: var(--series); opacity: .16; }

.profile-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Recessive: the baseline is a reference, not a mark. */
.profile-base { stroke: var(--line); stroke-width: 1; }

.profile-peak { fill: var(--series); }

/* Text wears text tokens, never the series colour. */
.profile-label {
  font: 600 9px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  fill: var(--ink-soft);
}

.profile-cross {
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.profile-dot { fill: var(--panel); stroke: var(--series); stroke-width: 2; }

.profile-hit { cursor: crosshair; }

.profile-readout {
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-height: 1.15em;
}

/* --- picking the parking spot ------------------------------------------- */

/* Leaflet's default is a grab hand, which says "drag me", not "click a
   precise point". While no start is set the map is in picking mode and wears
   a crosshair; once a start exists it goes back to the hand, because then
   panning is what you want. The ID+class selector is what beats Leaflet's
   own .leaflet-grab rule. */

#map.is-picking,
#map.is-picking .leaflet-grab,
#map.is-picking .leaflet-tile-pane,
#map.is-picking .leaflet-interactive {
  cursor: url('../cursor-cross.svg') 16 16, crosshair;
}

/* Dragging still shows the closed hand: the map is moving, not being picked. */
#map.is-picking.leaflet-dragging,
#map.is-picking.leaflet-dragging .leaflet-grab,
#map.is-picking.leaflet-dragging .leaflet-interactive {
  cursor: grabbing;
}

/* --- choosing where to stay --------------------------------------------- */

.day-options { margin-top: 4px; }

.day-options > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  list-style: none;
  padding: 2px 0;
}

.day-options > summary::-webkit-details-marker { display: none; }

.day-options > summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 5px;
  transition: transform .15s ease;
}

.day-options[open] > summary::before { transform: rotate(90deg); }

.day-options > summary:hover { text-decoration: underline; }

.day-options ul { list-style: none; margin: 5px 0 0; padding: 0; }

.day-options li.option {
  display: block;
  padding: 5px 6px;
  margin: 0 -6px 2px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.day-options li.option:hover { background: var(--accent-soft); }

.day-options li.option.is-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

.option-name { font-size: 13px; color: var(--ink); }

.option-chosen {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  font-weight: 700;
}

.option-meta {
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.option-contact { font-size: 11px; }

.option-contact a { color: var(--accent); }

/* --- live buses ---------------------------------------------------------- */

.live-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 2px;
}

.live-dot.is-on { display: inline-block; animation: livepulse 2s ease-in-out infinite; }

@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* A moving vehicle is a filled disc; a fixed stop is an outline. The
   difference should be obvious without reading the key. */
.bus-pin svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }

/* --- services that link both ends --------------------------------------- */

.services-head { margin-top: 8px; font-size: 12px; color: var(--ink); font-weight: 600; }

ul.services { list-style: none; margin: 5px 0 0; padding: 0; }

li.service {
  display: flex;
  gap: 7px;
  align-items: baseline;
  padding: 3px 5px;
  margin: 0 -5px 2px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

li.service:hover { background: var(--accent-soft); }

li.service.is-active { background: var(--accent-soft); border-color: var(--accent); }

.service-where { font-size: 12px; color: var(--ink-soft); }

.day-crossing {
  margin-top: 4px;
  font-size: 11px;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 6px;
  padding: 4px 6px;
}

.journey { display: flex; gap: 7px; align-items: baseline; margin-top: 6px; }
.journey-text { font-size: 12px; color: var(--ink); }
.journey-when { font-size: 11px; color: var(--ink-soft); margin-top: 5px; }

.day-closure {
  margin-top: 5px;
  font-size: 11px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 5px 7px;
}
.day-closure strong { display: block; }
.day-closure a { color: var(--danger); font-weight: 600; }

/* --- saved trips --------------------------------------------------------- */

ul.trips { list-style: none; margin: 6px 0 0; padding: 0; }

ul.trips li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 6px;
  margin: 0 -6px 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  background: var(--panel);
}

ul.trips li:hover { background: var(--accent-soft); }

.trip-name { font-size: 13px; font-weight: 600; flex: 1 1 auto; min-width: 0; }

.trip-meta { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.trip-del {
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 3px;
}

.trip-del:hover { color: var(--danger); }

.trip-print {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 15px;
  line-height: 1;
  padding: 0 3px;
}

.trip-print:hover { color: var(--accent); }

.print-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
}

.changes {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  font-size: 12px;
  color: var(--warn);
}

.changes strong { display: block; margin-bottom: 3px; }
.changes ul { list-style: disc; margin: 0; padding-left: 16px; }

/* Print this one day, at the foot of its card. */
.day-foot {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  text-align: right;
}

.day-print {
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
}

.day-print:hover { text-decoration: underline; }

/* --- pinned nights -------------------------------------------------------- */

.option-pin {
  margin-top: 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
}

.option-pin:hover { border-color: var(--accent); }

.option-pin.is-pinned {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.option-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--warn);
}

.pin-tag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.option-chosen.is-yours { background: var(--accent); color: #fff; }

/* --- "route created" / "route restored" ---------------------------------- */

/* The banner is a warning by default; this is the same bar saying something
   went right. */
.banner.is-good {
  background: var(--accent-soft);
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* A one-shot flash on the itinerary, so the eye lands on the thing that just
   changed after the panel scrolls to it. */
@keyframes just-planned {
  from { background: var(--accent-soft); }
  to   { background: transparent; }
}

ol.days.just-planned {
  animation: just-planned 1.4s ease-out 1;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  ol.days.just-planned { animation: none; }
}
