/* Bike construction check — layout & components on top of Pico CSS 2. */

:root {
  --tier-red: #c0392b;
  --tier-orange: #e67e22;
  --tier-info: #95a5a6;
  --route-blue: #2563eb;
  --diversion-purple: #8e44ad;
}

html,
body {
  overflow-x: hidden;
}

/* ---- Header / toolbar ------------------------------------------------- */

body > header.container-fluid {
  padding-block: 1rem 0.25rem;
}

.page-title {
  margin-bottom: 0.75rem;
}

.page-title h1 {
  margin-bottom: 0.1rem;
  font-size: 1.4rem;
}

.page-title p {
  margin: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.toolbar label {
  margin: 0;
}

.toolbar input {
  margin: 0;
}

.toolbar .toolbar-file {
  /* Don't grow: keep all controls (and the submit button) grouped together
     instead of pushing them to the far edge of the page. Fields keep their
     natural width so nothing gets truncated. */
  flex: 0 1 auto;
  min-width: 0;
}

.toolbar button[type="submit"] {
  margin: 0;
  width: auto;
}

.toolbar-options {
  margin: 0;
  flex: 0 0 auto;
  /* Center the "Options" summary against the input row (inputs are ~50px
     tall while the summary is a single text line bottom-aligned to them). */
  padding-bottom: 10px;
}

.toolbar-options summary {
  margin: 0;
  cursor: pointer;
}

.toolbar-options label {
  margin-top: 0.5rem;
}

#radius {
  width: 8rem;
}

/* ---- Notices ---------------------------------------------------------- */

.notice {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.notice ul {
  margin: 0.35rem 0 0 1.1rem;
  padding: 0;
}

.notice-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #842029;
}

.notice-warning {
  background: #fff8e1;
  border: 1px solid #f0d060;
  color: #664d03;
}

.notice-ok {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #1b5e20;
}

@media (prefers-color-scheme: dark) {
  .notice-error {
    background: #3a1418;
    border-color: #7f1d1d;
    color: #f5b5ba;
  }

  .notice-warning {
    background: #3a2f0b;
    border-color: #8a6d1a;
    color: #f0d060;
  }

  .notice-ok {
    background: #0f2f14;
    border-color: #2e7d32;
    color: #a5d6a7;
  }
}

/* ---- Summary line + tier chips ---------------------------------------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.route-info {
  font-weight: 600;
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.1rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  width: auto;
  margin: 0;
  cursor: pointer;
  box-shadow: none;
}

.chip:focus,
.chip:hover {
  box-shadow: none;
  filter: brightness(1.1);
}

.chip-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.chip-red { border-color: var(--tier-red); }
.chip-red .chip-dot { background: var(--tier-red); }
.chip-orange { border-color: var(--tier-orange); }
.chip-orange .chip-dot { background: var(--tier-orange); }
.chip-info { border-color: var(--tier-info); }
.chip-info .chip-dot { background: var(--tier-info); }

.chip-off {
  opacity: 0.4;
  text-decoration: line-through;
}

/* ---- Map + side panel -------------------------------------------------- */

.results {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem);
  gap: 1rem;
  align-items: stretch;
}

#map {
  height: 68vh;
  min-height: 340px;
  border-radius: 0.5rem;
  z-index: 0;
}

.panel {
  height: 68vh;
  min-height: 340px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  min-width: 0;
}

@media (max-width: 900px) {
  .results {
    grid-template-columns: minmax(0, 1fr);
  }

  #map {
    height: 55vh;
    min-height: 280px;
  }

  .panel {
    height: auto;
    min-height: 0;
    max-height: 50vh;
  }
}

.panel-placeholder,
.stats-line {
  color: var(--pico-muted-color, #777);
  font-size: 0.85rem;
  margin: 0.5rem 0.25rem;
}

.stats-line {
  font-size: 0.75rem;
}

/* ---- Hindrance list ---------------------------------------------------- */

.hindrance-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hindrance-list li.row {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--pico-muted-border-color, #e0e0e0);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.hindrance-list li.row:hover,
.hindrance-list li.row:focus {
  background: rgba(127, 127, 127, 0.1);
  outline: none;
}

.hindrance-list li.row[data-tier="info"] {
  opacity: 0.65;
}

.hindrance-list.hide-red li[data-tier="red"] { display: none; }
.hindrance-list.hide-orange li[data-tier="orange"] { display: none; }
.hindrance-list.hide-info li[data-tier="info"] { display: none; }

.row-km {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.row-desc {
  font-weight: 500;
}

.row-meta {
  color: var(--pico-muted-color, #777);
  font-size: 0.85em;
}

/* ---- Badges ------------------------------------------------------------ */

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
  vertical-align: baseline;
}

.badge-red { background: var(--tier-red); }
.badge-orange { background: var(--tier-orange); }
.badge-info { background: var(--tier-info); color: #1f2d3d; }
.badge-severe { background: #343a40; }
.badge-limit { background: #2c3e50; }
.badge-diversion { background: var(--diversion-purple); }

/* ---- km markers --------------------------------------------------------- */

/* Numbered 5-km badge: the div itself is the circle and the number is
   flex-centered inside it -- no separate label layer to (mis)align.
   Width/height come from the divIcon's iconSize; border-box keeps the
   black outline from offsetting the content. */
.km-badge {
  background: #ffd54f;
  border: 2px solid #000;
  border-radius: 50%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font: bold 10px/1 system-ui, sans-serif;
  color: #000;
}

/* ---- Leaflet controls vs Pico ------------------------------------------ */

/* Leaflet's zoom anchors carry role="button", so Pico's button styling
   (padding, border, uniform border-radius) lands on them: the +/- glyphs get
   pushed off-center and the corner rounding shows on the middle seam instead
   of the outside. Reset scoped to Leaflet containers (same clash — and fix —
   as challenge404's frontend/static/app.css). */
.leaflet-container a,
.leaflet-control a {
  color: #333;
  text-decoration: none;
  background-clip: padding-box;
}

.leaflet-bar a {
  display: block;
  width: 26px;
  height: 26px;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  border-bottom: 1px solid #ccc !important; /* Leaflet's seam between + and - */
  line-height: 26px !important;
  text-align: center;
  font-weight: bold;
}

.leaflet-touch .leaflet-bar a {
  width: 30px;
  height: 30px;
  line-height: 30px !important;
}

.leaflet-bar a:first-child {
  border-top-left-radius: 4px !important;
  border-top-right-radius: 4px !important;
}

.leaflet-bar a:last-child {
  border-bottom-left-radius: 4px !important;
  border-bottom-right-radius: 4px !important;
  border-bottom: none !important;
}

.leaflet-bar a:hover {
  background-color: #f4f4f4;
}

/* ---- Leaflet popups ---------------------------------------------------- */

/* Leaflet popups/controls have a white background regardless of theme:
   pin dark text so Pico's dark mode doesn't make them unreadable. */
.leaflet-popup-content,
.leaflet-control-layers {
  color: #212529;
}

.leaflet-popup-content {
  overflow-wrap: break-word;
}

.popup {
  min-width: 200px;
  max-width: 300px;
}

.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.popup-desc {
  margin: 0.2rem 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.popup-meta {
  margin: 0.1rem 0;
  font-size: 0.8rem;
  color: #5a6268;
}

.popup-consequences {
  margin: 0.3rem 0 0.2rem 1.1rem;
  padding: 0;
  font-size: 0.8rem;
}

.popup-consequences .consequence-severe {
  font-weight: 700;
}

.popup-link {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
}

/* ---- Footer ------------------------------------------------------------ */

.page-footer {
  padding-block: 0.75rem;
  color: var(--pico-muted-color, #777);
}
