:root {
  --pine: #14352b;
  --pine-soft: #47635a;
  --lichen: #eef2ec;
  --line: #c6d1c8;
  --sign: #f7c90f;
  --trail: #1557a8;
  --route: #c4163f;
  --paper: #ffffff;
  --panel-width: 400px;
  --surface-paved: #2f6fb5;
  --surface-gravel: #c98a12;
  --surface-natural: #1f9d8a;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  height: 100dvh;
  overflow: hidden;
  background: var(--lichen);
  color: var(--pine);
  font: 400 16px/1.45 Overpass, "Helvetica Neue", Arial, sans-serif;
}

#map { order: 2; height: 100%; background: #dde3dc; }

/* The basemap is quieted so the routes are what the eye lands on. */
.leaflet-tile-pane { filter: saturate(0.55) contrast(0.95) brightness(1.03); }

.panel { order: 1; overflow-y: auto; padding: 24px 20px 40px; }

h1 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; }

h2 { margin: 0; font-size: 19px; font-weight: 800; }

.field { margin-bottom: 20px; }

label { display: block; margin-bottom: 6px; font-weight: 600; }

.search-row { display: flex; gap: 8px; }

input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 11px 12px 8px;
  border: 2px solid var(--pine);
  border-radius: 4px;
  background: var(--paper);
  color: inherit;
  font: inherit;
}

.hint { margin: 8px 0 0; color: var(--pine-soft); font-size: 15px; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--trail);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.start-label { margin: 10px 0 0; font-weight: 600; }

.place-results { margin: 10px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }

.place-results button {
  width: 100%;
  padding: 10px 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.place-results button:hover { background: var(--paper); }

.button {
  padding: 11px 16px 8px;
  border: 2px solid var(--pine);
  border-radius: 4px;
  background: var(--paper);
  color: var(--pine);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover { background: var(--lichen); }

.button-primary {
  width: 100%;
  padding: 14px 16px 11px;
  background: var(--pine);
  color: var(--paper);
  font-weight: 800;
  font-size: 17px;
}

.button-primary:hover { background: #0d2a21; }

.button[disabled] { border-color: var(--line); background: var(--line); color: var(--pine-soft); cursor: not-allowed; }

.length-row { display: flex; align-items: center; gap: 16px; }

input[type="range"] { flex: 1; min-width: 0; height: 32px; accent-color: var(--pine); cursor: pointer; }

/* The one loud thing on the page: a walking signpost blade holding the chosen distance. */
.sign {
  flex: none;
  width: 124px;
  padding: 11px 30px 7px 14px;
  background: var(--sign);
  color: #000;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 50%, calc(100% - 20px) 100%, 0 100%);
}

.group { margin-top: 30px; }

.group-note { margin: 4px 0 0; color: var(--pine-soft); font-size: 15px; }

.status { margin: 10px 0 0; font-size: 15px; }

.status:empty { display: none; }

/* Answers "is it still doing anything?" during a search that can take minutes. */
.progress { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: var(--pine-soft); font-size: 15px; font-variant-numeric: tabular-nums; }

.progress::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--trail);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

.progress[hidden] { display: none; }

#signed-retry { margin-top: 10px; }

.loops { margin: 12px 0 0; padding: 0; list-style: none; }

.loop {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 4px 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.loop:last-child { border-bottom: 1px solid var(--line); }

.loop.is-selected { background: var(--paper); box-shadow: inset 4px 0 0 var(--accent); }

.loop.is-signed { --accent: var(--trail); }

.loop.is-generated { --accent: var(--route); }

.loop-shape { grid-row: span 2; width: 60px; height: 60px; }

.loop-shape path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }

.loop-pick {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.loop-length { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; }

.loop-name { display: block; font-weight: 600; overflow-wrap: anywhere; }

.loop-facts { margin: 0; color: var(--pine-soft); font-size: 15px; }

.loop-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-top: 6px; }

.loop-actions .button { padding: 8px 12px 5px; font-size: 15px; }

.offline { margin: 0 0 14px; padding: 10px 12px 8px; border-left: 4px solid #f6c90e; background: var(--paper); font-size: 15px; }

/* Places along the way */

.poi-marker { display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--pine); border-radius: 50%; background: #ffffff; font-size: 13px; font-weight: 800; line-height: 1; color: var(--pine); box-sizing: border-box; }
.poi-toilets { font-size: 9px; }
.poi-summary { margin: 2px 0 6px; font-size: 15px; line-height: 1.5; }
.poi-list { margin: 0; padding: 0; list-style: none; font-size: 15px; }
.poi-list li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.poi-at { flex: none; color: var(--pine-soft); }

/* Directions */

.directions { margin: 0; padding: 0; list-style: none; font-size: 15px; }
.directions li { display: grid; grid-template-columns: 4.2em 1fr; gap: 8px; padding: 3px 0; }
.directions-at { color: var(--pine-soft); text-align: right; font-variant-numeric: tabular-nums; }

/* Train back */

.trains { margin: 6px 0 0; padding: 0; list-style: none; font-size: 15px; }
.trains li { padding: 3px 0; }
.trains .is-cancelled strong { text-decoration: line-through; }

/* Where to */

.select { width: 100%; padding: 10px 12px 8px; border: 2px solid var(--pine); border-radius: 4px; background: var(--paper); color: var(--pine); font: inherit; }
.back-row { margin-top: 8px; }
.destination-marker { width: 18px; height: 18px; border: 3px solid #ffffff; border-radius: 4px; background: #c4163f; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); box-sizing: border-box; }

/* Length or time */

.length-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.unit-switch { display: flex; gap: 14px; font-size: 15px; }
.unit-switch label { display: flex; align-items: baseline; gap: 5px; font-weight: 400; cursor: pointer; }
.unit-switch input { accent-color: var(--pine); }

/* Route preferences */

.prefs { margin: 18px 0 0; }
.prefs summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.prefs-count { color: var(--pine-soft); font-weight: 400; }
.prefs .hint { margin: 4px 0 6px; }

/* Saved loops */

.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0 6px; border-top: 1px solid var(--line); }
.saved-list a { overflow-wrap: anywhere; }
.saved-meta { color: var(--pine-soft); font-size: 15px; }

/* Filters */

.filters { margin: 22px 0 0; padding: 0; border: 0; }

.filters legend { padding: 0; margin-bottom: 6px; font-weight: 600; }

.check { display: flex; align-items: baseline; gap: 8px; margin: 0; padding: 4px 0; font-weight: 400; cursor: pointer; }

.check input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--pine); transform: translateY(2px); }

.filter-summary { margin: 6px 0 0; font-size: 15px; }

.filter-summary[hidden], .filters[hidden] { display: none; }

/* Details of the selected loop */

.loop-details { grid-column: 1 / -1; margin-top: 12px; padding-top: 2px; }

.details-section { padding: 10px 0; border-top: 1px solid var(--line); }

.details-heading { margin: 0 0 4px; font-size: 15px; font-weight: 800; }

.details-value { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.2; }

.details-note { margin: 4px 0 0; color: var(--pine-soft); font-size: 14px; overflow-wrap: anywhere; }

.details-section .link { font-size: 15px; }

.details-sign { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 15px; }

.details-sign img { width: 30px; height: 30px; object-fit: contain; }

.details-warnings { margin: 0; padding: 0; list-style: none; font-size: 15px; }

.details-warnings li { padding: 2px 0; }

.surface-bar { display: flex; gap: 2px; height: 12px; margin-top: 6px; }

.surface-segment { flex-basis: 0; min-width: 3px; }

.surface-segment:first-child { border-radius: 4px 0 0 4px; }

.surface-segment:last-child { border-radius: 0 4px 4px 0; }

.surface-segment:only-child { border-radius: 4px; }

.surface-paved { background: var(--surface-paved); }

.surface-gravel { background: var(--surface-gravel); }

.surface-natural { background: var(--surface-natural); }

/* Not a category but missing data, so it is a neutral hatch rather than a fourth colour. */
.surface-unknown { background: repeating-linear-gradient(135deg, #aab5ad 0 2px, #e3e8e3 2px 5px); }

.surface-legend { display: flex; flex-wrap: wrap; gap: 3px 14px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; }

.surface-legend li { display: flex; align-items: center; gap: 6px; }

.surface-swatch { display: inline-block; flex: none; width: 11px; height: 11px; margin-top: -3px; border-radius: 3px; }

.profile { position: relative; margin-top: 6px; touch-action: pan-y; cursor: crosshair; }

.profile-chart { display: block; width: 100%; height: 90px; }

.profile-area { fill: var(--pine); opacity: 0.1; }

.profile-line { fill: none; stroke: var(--pine); stroke-width: 2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

.profile-crosshair { stroke: var(--pine-soft); stroke-width: 1px; vector-effect: non-scaling-stroke; }

.profile-tooltip {
  position: absolute;
  top: 0;
  padding: 4px 7px 1px;
  border-radius: 3px;
  background: var(--pine);
  color: var(--paper);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.profile-tooltip[hidden] { display: none; }

.profile-axis { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; color: var(--pine-soft); font-size: 14px; }

.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 20px; }
.lang-switch { flex: none; font-size: 15px; }

.credits { margin: 28px 0 0; color: var(--pine-soft); font-size: 14px; }

.start-marker {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--pine);
  box-shadow: 0 0 0 2px var(--pine);
}

:focus-visible { outline: 3px solid var(--trail); outline-offset: 2px; }

@media (max-width: 760px) {
  body { display: block; height: auto; overflow: auto; }

  /* The map stays in view while the list scrolls under it. */
  #map { position: sticky; top: 0; z-index: 1; height: 40dvh; border-bottom: 2px solid var(--pine); }

  .panel { overflow: visible; padding: 20px 16px 40px; }

  h1 { font-size: 24px; }
}

/* Printing: the map fitted to the chosen loop, then its details. Set by the Print button
   and by the browser's own print command (see beforeprint in app.js). */
body.printing { display: block; height: auto; overflow: visible; background: #ffffff; }
.printing #map { position: static; width: 100%; height: 125mm; border: 1px solid var(--pine); }
.printing .panel { overflow: visible; padding: 12px 0 0; }
.printing #search-form .search-row, .printing #search-form > label, .printing #search-form .hint:not(.weather),
.printing #place-results, .printing .field:not(#search-form), .printing #prefs, .printing #find, .printing #filters,
.printing #offline, .printing .group-note, .printing .status, .printing .progress, .printing #signed-retry,
.printing #saved, .printing .loop:not(.is-selected), .printing .loop-actions, .printing .group:not(:has(.is-selected)),
.printing .leaflet-control-zoom { display: none !important; }
.printing .loop { break-inside: avoid; }
.printing .loop-details { break-inside: auto; }

@media (prefers-reduced-motion: reduce) {
  .progress::before { animation: none; }

  .leaflet-fade-anim .leaflet-popup, .leaflet-zoom-anim .leaflet-zoom-animated { transition: none !important; }
}
