/* ============================================================
   Shared type
   ============================================================ */
.eyebrow {
  display: block;
  font: 400 10px/1 var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow--wide {
  letter-spacing: 0.1em;
}

.mono-meta {
  font: 400 11px/1 var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.topbar__status,
.topbar__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font: 500 11px/1 var(--font-mono);
}

.pill__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
}

.pill--online {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.pill--offline {
  background: var(--off-bg);
  color: var(--off-fg);
}

.btn {
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: 500 11px/1.45 var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.btn:hover {
  background: var(--bg-raised);
  border-color: var(--text-faint);
}

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

.btn--primary:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}

.btn--quiet {
  border-color: transparent;
  color: var(--accent-soft);
  padding-inline: 0;
  /* "Details →" must not break between the word and its arrow. */
  white-space: nowrap;
}

.btn--quiet:hover {
  background: transparent;
  border-color: transparent;
  color: var(--text);
}

/* One shared switch for both map providers' base layers. */
.segmented {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented__option {
  padding: 5px 12px;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-dim);
  font: 500 11px/1.45 var(--font-sans);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.segmented__option:first-child {
  border-left: 0;
}

.segmented__option:hover {
  color: var(--text);
}

.segmented__option[aria-pressed="true"] {
  background: var(--line);
  color: var(--text);
}

/* A real checkbox, restyled — not a div pretending to be one, so it keeps
   its keyboard behaviour and label association for free. */
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font: 500 11px/1.45 var(--font-sans);
  cursor: pointer;
  user-select: none;
}

.check:hover {
  color: var(--text);
  background: var(--bg-raised);
}

.check input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check:has(input:checked) {
  color: var(--text);
}

/* ============================================================
   Zoom area — its own bordered zone beside the Details action
   ============================================================ */
.location-card__controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

/* Its own panel above the card, matching the card's surface treatment. */
.zoom-area {
  min-width: 0;
  padding: 9px 11px 10px;
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  box-shadow: var(--panel-shadow);
}

.zoom-area__label {
  margin-bottom: 7px;
}

/* Fifteen discrete levels rather than a menu: wraps instead of overflowing
   once the card gets narrow. */
.zoom-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.zoom-strip__step {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font: 500 10px/1 var(--font-mono);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.zoom-strip__step:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.zoom-strip__step[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============================================================
   Setup panel
   ============================================================ */
.panel {
  padding: 1.25rem;
}

.setup__label {
  display: block;
  font: 500 12px/1.4 var(--font-sans);
  color: var(--text-soft);
}

#session-input {
  width: 100%;
  max-width: 24rem;
  padding: 0.5rem;
  margin: 0.4rem 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: inherit;
  font: 400 13px/1.4 var(--font-mono);
}

.hint {
  max-width: 32rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ============================================================
   1a — instrument panel
   ============================================================ */
main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Both map containers are flex, so #map is always a stretched flex item and
   never needs a percentage height resolved against an indefinite parent —
   that chain collapsed the map to zero height. */
.map-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

#map {
  position: relative;
  flex: 1;
  min-width: 0;
  background: var(--bg-sunken);
}

/* One container per map stack, stacked in the same box: switching source
   shows one and hides the other, so neither library has to give up the
   element it owns. Absolute rather than a second flex item so a hidden
   engine's container cannot claim any of the row. */
.map-engine {
  position: absolute;
  inset: 0;
}

.map-engine[hidden] {
  display: none;
}

/* A disabled source button is mid-switch — its library is still loading. */
.segmented__option:disabled {
  cursor: progress;
  opacity: 0.6;
}

/* Leaflet paints its own light attribution chrome; align it with the panel. */
.leaflet-container {
  background: var(--bg-sunken);
  font-family: var(--font-sans);
}

.leaflet-control-attribution {
  background: var(--panel-bg) !important;
  color: var(--text-faint) !important;
  font: 400 10px/1.5 var(--font-mono) !important;
}

.leaflet-control-attribution a {
  color: var(--text-dim) !important;
}

/* One bottom-left anchor for the zoom strip and the card, so the strip stays
   directly above the card no matter how tall the card's content makes it. */
.map-overlay {
  position: absolute;
  left: var(--gap-inset);
  bottom: var(--gap-inset);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  max-width: calc(100% - 2 * var(--gap-inset));
}

.location-card {
  width: 392px;
  max-width: 100%;
  padding: 18px 20px 16px;
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  box-shadow: var(--panel-shadow);
}

.location-card__place {
  margin: 8px 0 0;
  font: 700 30px/1.1 var(--font-sans);
  letter-spacing: -0.5px;
  /* Place names arrive from an upstream and can be long. */
  overflow-wrap: break-word;
}

.location-card__address {
  margin: 4px 0 0;
  color: var(--text-soft);
  font: 400 13px/1.45 var(--font-sans);
}

.location-card__nearest {
  margin: 8px 0 0;
  color: var(--text-dim);
  font: 400 12px/1.4 var(--font-sans);
}

.location-card__nearest strong {
  color: var(--text-soft);
  font-weight: 500;
}

.location-card__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* 2x2 inside the card: the four figures worth reading at a glance. */
.stat-pairs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 14px 0 0;
}

.stat-pairs dt {
  font: 400 9.5px/1 var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-pairs dd {
  margin: 4px 0 0;
  font: 500 15px/1 var(--font-mono);
  color: var(--text);
  overflow-wrap: break-word;
}

.inline-pairs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
}

.inline-pairs > div {
  font: 400 11px/1.4 var(--font-sans);
  color: var(--text-dim);
}

.inline-pairs dt {
  display: inline;
}

.inline-pairs dd {
  display: inline;
  margin: 0 0 0 4px;
  color: var(--text);
  font-family: var(--font-mono);
}

.geocode-status {
  display: block;
  margin-top: 8px;
  font: 400 10px/1 var(--font-mono);
  color: var(--text-faint);
}

.admin-panel {
  position: absolute;
  right: var(--gap-inset);
  top: var(--gap-inset);
  z-index: 1000;
  width: 236px;
  max-width: calc(100% - 2 * var(--gap-inset));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.admin-panel__head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.admin-panel__rows {
  margin: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rows > div,
.admin-panel__rows > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font: 400 11.5px/1.3 var(--font-sans);
}

.rows dt,
.admin-panel__rows dt {
  color: var(--text-dim);
}

.rows dd,
.admin-panel__rows dd {
  margin: 0;
  color: var(--text);
  text-align: right;
}

.rows dd a {
  color: var(--accent-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.rows dd a:hover {
  color: var(--text);
  border-bottom-color: var(--text-faint);
}

.map-readout {
  position: absolute;
  right: var(--gap-inset);
  bottom: calc(var(--gap-inset) + 18px);
  z-index: 1000;
  max-width: calc(100% - 2 * var(--gap-inset));
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: var(--panel-bg);
  color: var(--text-dim);
  font: 400 10.5px/1 var(--font-mono);
}

/* ============================================================
   1b — detail view
   ============================================================ */
.detail__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 56px;
  border-bottom: 1px solid var(--line);
}

.detail__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 34px;
  padding: 34px 28px 28px;
}

.detail__place {
  margin: 12px 0 0;
  /* The mockup's 56px headline, but it has to survive a 320px screen. */
  font: 700 clamp(2rem, 1.2rem + 4vw, 3.5rem) / 1.02 var(--font-sans);
  letter-spacing: -1.6px;
  text-wrap: pretty;
}

.detail__lede {
  margin: 14px 0 0;
  max-width: 38ch;
  color: var(--text-soft);
  font: 400 15px/1.5 var(--font-sans);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 32px 0 0;
  border-top: 1px solid var(--line);
}

.stat-grid > div {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  min-width: 0;
}

/* Flush the left edge of each row rather than every cell. */
.stat-grid > div:nth-child(3n + 1) {
  padding-left: 0;
  border-left: 0;
}

.stat-grid dt {
  font: 400 9.5px/1 var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-grid dd {
  margin: 7px 0 0;
  font: 500 18px/1.15 var(--font-mono);
  color: var(--text);
  overflow-wrap: break-word;
}

.stat-grid .stat-grid__note {
  display: block;
  margin-top: 5px;
  color: var(--text-dim);
  font: 400 11px/1.3 var(--font-sans);
}

.detail__lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  margin-top: 30px;
}

.detail__list h3 {
  margin: 0;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
}

.detail__rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* The map element is relocated into here, so this container stretches it the
   same way .map-wrap does. */
.detail__inset {
  display: flex;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.detail__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail__actions .btn {
  padding: 11px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  text-align: center;
}

.detail__source {
  margin: 2px 0 0;
  color: var(--text-faint);
  font: 400 10.5px/1.5 var(--font-mono);
}

/* ============================================================
   Focus — designed, not the browser default ring
   ============================================================ */
:where(button, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Narrow screens. The mockup is a 1280px desktop board; floating
   panels over a small map would cover the thing they annotate, so
   below this width they stop floating and stack under it.
   ============================================================ */
@media (max-width: 860px) {
  :root {
    --gap-inset: 12px;
  }

  .detail__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 24px 16px;
  }

  .detail__bar {
    padding: 0 16px;
  }

  .detail__rail {
    /* The inset outgrows its rail once the rail is the full width. */
    order: -1;
  }
}

@media (max-width: 720px) {
  /* Panels move below the map here, so the map takes a fixed share of the
     screen and the page scrolls instead of the panels covering the map. */
  .viewer {
    display: block;
  }

  /* The overlays below stop being absolutely positioned at this width, which
     would make them flex siblings of the map in a row and squeeze it to zero
     width. Block layout lets them stack under it instead. */
  .map-wrap {
    display: block;
    flex: none;
  }

  #map {
    height: 46vh;
    min-height: 240px;
  }

  .map-overlay,
  .admin-panel,
  .map-readout {
    position: static;
    width: auto;
    max-width: none;
    margin: 12px 16px 0;
    backdrop-filter: none;
    box-shadow: none;
  }

  .map-overlay {
    align-items: stretch;
  }

  .location-card,
  .zoom-area {
    width: auto;
    max-width: none;
    border: 1px solid var(--line);
    backdrop-filter: none;
    box-shadow: none;
  }

  .map-readout {
    display: block;
    margin-bottom: 16px;
  }

  .location-card__place {
    font-size: 24px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid > div:nth-child(3n + 1) {
    padding-left: 16px;
    border-left: 1px solid var(--line);
  }

  .stat-grid > div:nth-child(2n + 1) {
    padding-left: 0;
    border-left: 0;
  }

  .detail__lists {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding: 0.75rem 1rem;
  }

  .stat-pairs {
    gap: 10px 12px;
  }

  .location-card__foot {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Fifteen steps plus the action do not share a 320px row. */
  .location-card__controls {
    flex-direction: column;
    align-items: stretch;
  }

  /* Left-aligned so a wrapped second row reads as a continuation rather
     than two levels flung to opposite edges. */
  .zoom-strip {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0ms !important;
  }
}
