:root {
  color-scheme: light;
  --run: #e35f28;
  --skimo: #2077b4;
  --ink: #1c2530;
  --muted: #5b6775;
  --line: #e2e6eb;
  --bar-h: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

/* --- Map page layout: fixed top bar, full-bleed map below ----------------- */

body:has(#map) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  min-height: var(--bar-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(20, 30, 45, 0.06);
  flex-wrap: wrap;
  z-index: 1000;
}

#map {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filters input,
.filters select,
.filters button {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.filters input[type="search"] {
  min-width: 180px;
}

.filters input[type="number"] {
  width: 64px;
}

.range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.range label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 2px;
}

.filters button {
  cursor: pointer;
  font-weight: 600;
}

.filters button:hover {
  background: #f4f6f8;
}

.results-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* --- Embed mode ----------------------------------------------------------- */

body.embed {
  overflow: hidden;
}

body.embed #map {
  height: 100vh;
}

.map-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 16px 24px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  color: var(--ink);
  z-index: 1000;
}

/* --- Route popup ---------------------------------------------------------- */

.leaflet-popup-content {
  margin-right: 24px !important;
}

.route-popup {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  border-top: 3px solid var(--muted);
  padding-top: 4px;
}

.route-popup h3 {
  margin: 4px 0 2px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.popup-meta {
  margin: 2px 0 6px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.popup-difficulty {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--muted);
  color: #fff;
}

.popup-region {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.popup-ratings {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 6px 0 8px;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.rating-label {
  width: 48px;
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 500;
}

.rating-bar {
  flex: 1;
  height: 6px;
  background: #e2e6eb;
  border-radius: 3px;
  overflow: hidden;
}

.rating-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--muted);
}

.rating-val {
  width: 16px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
}

.popup-links {
  display: flex;
  gap: 8px;
}

.route-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: #1a6e73;
  background: #e8f4f5;
  transition: background 0.15s, color 0.15s;
}

.route-link:hover {
  background: #d0eaec;
  text-decoration: none;
}

/* Themed popups — RUN */
body.theme-run .route-popup {
  border-top-color: var(--rst-teal);
}

body.theme-run .popup-difficulty {
  background: var(--rst-teal);
}

body.theme-run .rating-fill {
  background: var(--rst-teal);
}

body.theme-run .route-link {
  color: var(--rst-teal-dark);
  background: rgba(30, 134, 141, 0.1);
}

body.theme-run .route-link:hover {
  background: rgba(30, 134, 141, 0.2);
}

/* Themed popups — SKIMO */
body.theme-skimo .route-popup {
  border-top-color: var(--skimo-header-bg);
}

body.theme-skimo .popup-difficulty {
  background: var(--skimo-header-bg);
}

body.theme-skimo .rating-fill {
  background: var(--skimo-header-bg);
}

body.theme-skimo .route-link {
  color: hsl(183.85, 65%, 23.53%);
  background: hsla(183.78, 64.91%, 33.53%, 0.1);
}

body.theme-skimo .route-link:hover {
  background: hsla(183.78, 64.91%, 33.53%, 0.2);
}

/* Leaflet popup wrapper overrides */
body.theme-run .leaflet-popup-content-wrapper,
body.theme-skimo .leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

body.theme-run .leaflet-popup-content,
body.theme-skimo .leaflet-popup-content {
  margin: 10px 14px;
}

/* --- Landing page --------------------------------------------------------- */

body.landing {
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #f4f7fa, #e9eef3);
  padding: 24px;
}

.landing-shell {
  max-width: 760px;
  width: 100%;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}

.landing-header h1 {
  margin: 4px 0 8px;
  font-size: 34px;
}

.landing-header .intro {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 16px;
}

.landing-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.landing-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px;
  border-radius: 16px;
  text-decoration: none;
  color: #fff;
  background: var(--run);
  box-shadow: 0 8px 24px rgba(20, 30, 45, 0.14);
  transition: transform 0.12s ease;
}

.landing-card.skimo {
  background: var(--skimo);
}

.landing-card:hover {
  transform: translateY(-3px);
}

.landing-card-kicker {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.85;
}

.landing-card-title {
  font-size: 24px;
  font-weight: 700;
}

.landing-card-cta {
  margin-top: 6px;
  font-weight: 600;
}

@media (max-width: 560px) {
  .landing-cards {
    grid-template-columns: 1fr;
  }

  .results-count {
    margin-left: 0;
  }
}

/* RUN-14: RUN banner theme (matches runskitirol.com/trails) ----------------
   Brand tokens lifted from the Run.Ski.Tirol Squarespace theme:
   - Font: Poppins (loaded in run.html), site uses 300-700 weights
   - Primary brand teal: #1e868d  (theme "black"/primary swatch)
   - Dark teal:          #155e63  (darkAccent)
   - Accent green:       #76b39d  (accent)
   - White wordmark/nav on the colored banner
   All rules are scoped under body.theme-run so only run.html is affected. */

body.theme-run {
  --rst-sage: #76b39d;
  --rst-sage-dark: #5f9a84;
  --rst-sage-light: #97c5b4;
  --rst-teal: #1e868d;
  --rst-on-brand: #ffffff;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.theme-run .topbar {
  background: var(--rst-sage);
  border-bottom: 1px solid var(--rst-sage-dark);
  box-shadow: 0 2px 12px rgba(95, 154, 132, 0.28);
  gap: 10px 14px;
}

body.theme-run .brand {
  color: var(--rst-on-brand);
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
}

body.theme-run .brand:hover {
  opacity: 0.85;
}

body.theme-run .filters input,
body.theme-run .filters select,
body.theme-run .filters button {
  font-family: "Poppins", sans-serif;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
}

body.theme-run .filters input::placeholder {
  color: var(--muted);
}

body.theme-run .filters input:focus,
body.theme-run .filters select:focus {
  outline: none;
  border-color: var(--rst-sage-dark);
  box-shadow: 0 0 0 3px rgba(95, 154, 132, 0.55);
}

body.theme-run .range label {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
}

body.theme-run .filters .range span[aria-hidden="true"] {
  color: rgba(255, 255, 255, 0.85);
}

body.theme-run .filters button {
  background: var(--rst-sage-dark);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

body.theme-run .filters button:hover {
  background: #4e876e;
}

body.theme-run .results-count {
  color: #fff;
  font-weight: 500;
}

@media (max-width: 560px) {
  body.theme-run .brand {
    font-size: 16px;
  }

  body.theme-run .results-count {
    margin-left: 0;
  }
}

/* RUN-15: SKIMO banner theme (matches /skimo) ----------------------------- */
/* Design tokens lifted from runskitirol.com/skimo (Squarespace "black"
   section theme used by the site header):
     - Header background: hsl(184, 65%, 34%) deep teal (white wordmark on top)
     - Dark accent / borders: hsl(184, 65%, 24%)
     - Brand accent: hsl(158, 28%, 58%) sage green
     - Type: Poppins, headings weight 500-700, white text on the teal header */

body.theme-skimo {
  --skimo-header-bg: hsl(183.78, 64.91%, 33.53%);
  --skimo-header-bg-dark: hsl(183.85, 65%, 23.53%);
  --skimo-accent: hsl(158.36, 28.64%, 58.24%);
  --skimo-accent-light: hsl(157.83, 28.4%, 68.24%);
  --skimo-on-dark: #ffffff;
  --skimo-on-dark-muted: rgba(255, 255, 255, 0.72);
  --skimo-control-bg: rgba(255, 255, 255, 0.14);
  --skimo-control-border: rgba(255, 255, 255, 0.34);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.theme-skimo .topbar {
  gap: 10px 16px;
  padding: 10px 18px;
  background: var(--skimo-header-bg);
  border-bottom: 1px solid var(--skimo-header-bg-dark);
  box-shadow: 0 2px 10px rgba(11, 51, 54, 0.25);
}

body.theme-skimo .brand {
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: var(--skimo-on-dark);
  text-transform: none;
}

body.theme-skimo .brand:hover {
  color: var(--skimo-accent-light);
}

body.theme-skimo .filters input,
body.theme-skimo .filters select,
body.theme-skimo .filters button {
  font-family: "Poppins", system-ui, sans-serif;
  background: var(--skimo-control-bg);
  border: 1px solid var(--skimo-control-border);
  color: var(--skimo-on-dark);
  border-radius: 8px;
}

body.theme-skimo .filters input::placeholder {
  color: var(--skimo-on-dark-muted);
}

body.theme-skimo .filters select option {
  color: var(--ink);
}

body.theme-skimo .filters input:focus,
body.theme-skimo .filters select:focus {
  outline: none;
  border-color: var(--skimo-accent-light);
  box-shadow: 0 0 0 3px rgba(118, 179, 157, 0.45);
}

body.theme-skimo .range label {
  color: var(--skimo-on-dark-muted);
}

body.theme-skimo .filters button {
  background: var(--skimo-accent);
  border-color: var(--skimo-accent);
  color: var(--skimo-header-bg-dark);
  font-weight: 600;
}

body.theme-skimo .filters button:hover {
  background: var(--skimo-accent-light);
  border-color: var(--skimo-accent-light);
}

body.theme-skimo .results-count {
  color: var(--skimo-on-dark-muted);
}

@media (max-width: 560px) {
  body.theme-skimo .brand {
    font-size: 16px;
  }

  body.theme-skimo .topbar {
    padding: 9px 12px;
  }
}

/* RUN-17: Range slider styles */

.range-slider {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.range-slider__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.range-slider__header label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.range-slider__values {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.range-slider__track {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
}

.range-slider__track input[type="range"] {
  position: absolute;
  left: 0;
  width: 100%;
  height: 4px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
  background: transparent;
  outline: none;
}

.range-slider__track input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.range-slider__track input[type="range"]:first-child::-webkit-slider-runnable-track {
  background: var(--line);
}

.range-slider__track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--run);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  margin-top: -6px;
  pointer-events: auto;
  cursor: pointer;
}

.range-slider__track input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  border: none;
}

.range-slider__track input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--run);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  cursor: pointer;
}

.range-slider__track input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(227, 95, 40, 0.35);
}

.range-slider__track input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(227, 95, 40, 0.35);
}

/* Theme: run */

body.theme-run .range-slider__header label {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
}

body.theme-run .range-slider__values {
  color: #fff;
}

body.theme-run .range-slider__track input[type="range"]::-webkit-slider-runnable-track {
  background: rgba(255, 255, 255, 0.25);
}

body.theme-run .range-slider__track input[type="range"]::-moz-range-track {
  background: rgba(255, 255, 255, 0.25);
}

body.theme-run .range-slider__track input[type="range"]::-webkit-slider-thumb {
  background: #fff;
  border-color: var(--rst-sage-dark);
}

body.theme-run .range-slider__track input[type="range"]::-moz-range-thumb {
  background: #fff;
  border-color: var(--rst-sage-dark);
}

body.theme-run .range-slider__track input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(95, 154, 132, 0.55);
}

body.theme-run .range-slider__track input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(95, 154, 132, 0.55);
}

/* Theme: skimo */

body.theme-skimo .range-slider__header label {
  color: var(--skimo-on-dark-muted);
}

body.theme-skimo .range-slider__values {
  color: var(--skimo-on-dark, #e4ebf1);
}

body.theme-skimo .range-slider__track input[type="range"]::-webkit-slider-runnable-track {
  background: var(--skimo-control-border, rgba(255, 255, 255, 0.15));
}

body.theme-skimo .range-slider__track input[type="range"]::-moz-range-track {
  background: var(--skimo-control-border, rgba(255, 255, 255, 0.15));
}

body.theme-skimo .range-slider__track input[type="range"]::-webkit-slider-thumb {
  background: var(--skimo-accent, #4ecdc4);
  border-color: #fff;
}

body.theme-skimo .range-slider__track input[type="range"]::-moz-range-thumb {
  background: var(--skimo-accent, #4ecdc4);
  border-color: #fff;
}

body.theme-skimo .range-slider__track input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(118, 179, 157, 0.45);
}

body.theme-skimo .range-slider__track input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(118, 179, 157, 0.45);
}

@media (max-width: 560px) {
  .range-slider {
    min-width: 120px;
  }
}
