/* Trails: a pale rail on the left, one dark mass for the map. Tokens come from site.css. */

.trails {
  --slant: clamp(28px, 5vw, 64px);
  --grain-opacity: 0.07;
  --ctrl-icon: none;
  /* Everything below the sticky top bar (3.5rem + its 1px border). */
  min-height: calc(100vh - 3.5rem - 1px);
  min-height: calc(100dvh - 3.5rem - 1px);
  display: flex;
  flex-direction: column;
}

@media (prefers-color-scheme: dark) {
  .trails {
    --ctrl-icon: invert(0.9);
  }
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 376px) minmax(0, 1fr);
  min-height: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 32px 24px 24px clamp(16px, 4vw, 40px);
}

.trails h1 {
  font: 400 clamp(1.6rem, 3vw, 2.2rem) / 1.15 var(--font-display);
}

.intro .cap {
  margin-top: 8px;
}

.cap {
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 500;
  color: var(--ink-2);
}

.notice {
  margin-top: 24px;
}

.notice .btn {
  margin-top: 12px;
}

/* Mist panel */
.mist {
  display: grid;
  gap: 24px;
  padding: 24px;
  border-radius: var(--r-control);
  background: var(--surface);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  margin: 0;
}

.stats dd {
  margin: 0;
  font: 400 1.35rem / 1.1 var(--font-display);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stats dt {
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 500;
  color: var(--ink-2);
}

.controls {
  display: grid;
  gap: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  min-height: 40px;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font: 500 0.9375rem var(--font-body);
  cursor: pointer;
  transition:
    background-color var(--t-state) var(--ease),
    border-color var(--t-state) var(--ease),
    transform var(--t-press) var(--ease);
}

.chip-btn:hover {
  border-color: var(--action);
}

.chip-btn:active {
  transform: translateY(1px);
}

.chip-btn[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  font-weight: 500;
  font-size: 0.9375rem;
}

.select {
  position: relative;
}

.select::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 1.5px solid var(--ink-2);
  border-bottom: 1.5px solid var(--ink-2);
  transform: rotate(45deg);
  pointer-events: none;
}

.select select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 2.5rem 0.7rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-control);
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem var(--font-body);
  cursor: pointer;
}

.select select:hover {
  border-color: var(--sea);
}

.mini {
  min-height: 36px;
  padding: 0.5rem 0.8rem;
  font-size: 0.8125rem;
}

/* The dark mass: map plus legend, slanted top edge, faint grain */
.mapcol {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--mass);
  color: var(--on-mass);
  clip-path: polygon(0 var(--slant), 100% 0, 100% 100%, 0 100%);
}

.mapcol::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image: var(--grain);
  opacity: var(--grain-opacity);
  mix-blend-mode: screen;
  pointer-events: none;
}

.mapbox {
  position: relative;
  flex: 1;
  min-height: 360px;
  background: var(--sky);
}

#map {
  position: absolute;
  inset: 0;
  background: #171811;
  opacity: 0;
  transition: opacity var(--t-reveal) var(--ease);
}

#map.is-ready {
  opacity: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 16px 24px;
  color: var(--on-mass-2);
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 500;
}

.legend i {
  display: inline-block;
  width: 28px;
  height: 4px;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: middle;
}

.legend .heat {
  display: inline-block;
  width: 120px;
  height: 6px;
  margin: 0 8px;
  border-radius: 2px;
  background: linear-gradient(90deg, #5f8896, #8fb4c0, #edeff1);
  vertical-align: middle;
}

.legend a {
  margin-left: auto;
  color: var(--sand);
}

.mass :focus-visible {
  outline-color: var(--sand);
}

/* Map chrome */
.trails .maplibregl-ctrl-group {
  border-radius: var(--r-control);
  background: var(--surface);
  box-shadow: none;
}

.trails .maplibregl-ctrl-group button {
  width: 44px;
  height: 44px;
}

.trails .maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--line);
}

.trails .maplibregl-ctrl-group .maplibregl-ctrl-icon {
  filter: var(--ctrl-icon);
}

.trails .maplibregl-ctrl-attrib {
  background: rgba(35, 36, 27, 0.82) !important;
  color: var(--on-mass-2) !important;
  font: 500 0.75rem var(--font-body);
}

.trails .maplibregl-ctrl-attrib a {
  color: inherit !important;
}

.acts-popup {
  max-width: none !important;
}

.acts-popup .maplibregl-popup-content {
  min-width: 248px;
  padding: 16px;
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  font: 400 0.9375rem / 1.5 var(--font-body);
}

.acts-popup .maplibregl-popup-tip {
  display: none;
}

.acts-popup .maplibregl-popup-close-button {
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--r-control);
  color: var(--ink-2);
  font-size: 1.25rem;
}

.acts-head {
  margin: 0 32px 8px 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-2);
}

.acts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.acts li {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.acts li:first-child {
  padding-top: 0;
  border-top: 0;
}

.acts .what {
  font-weight: 600;
}

.acts .when {
  display: flex;
  gap: 16px;
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.acts-more {
  margin-top: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-2);
}

@media (max-width: 760px) {
  .stage {
    display: flex;
    flex-direction: column;
  }

  .rail {
    display: contents;
  }

  .intro {
    order: 1;
    padding: 24px 16px;
  }

  .mapcol {
    order: 2;
    height: min(64vh, 560px);
    min-height: 420px;
  }

  .mist {
    order: 3;
    margin: 24px 16px 32px;
  }
}

/* Plain admin pages (/trails/admin/...) */
.admin-note {
  max-width: 38rem;
  padding-block: 3rem;
}

.admin-note p {
  margin-top: 1rem;
}

.admin-note pre {
  padding: 12px;
  overflow: auto;
  border-radius: var(--r-control);
  background: var(--surface);
}

.legend i.ride {
  background: #8fb4c0;
}

.legend i.hike {
  background: #d3bc9c;
}

.legend i.ski {
  background: #e59a3a;
}
