/* ── Content column: a centered, comfortable reading measure ──
   Pico's .container is full-width; constraining it here keeps the
   form and the result cards on the same centered column so the
   cards aren't left-aligned next to a big empty right margin. */
main.container {
  max-width: 48rem;
  /* Keep edge breathing-room at tablet widths where Pico removes its
     side padding (>=576px) but our 48rem max-width still fills the
     viewport, so the content would otherwise touch the edges. */
  padding-left: var(--pico-spacing);
  padding-right: var(--pico-spacing);
  margin-inline: auto;
}

/* ── Brand link: logo + title link back home ── */
.brand {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.brand:hover h1,
.brand:hover p {
  text-decoration: none;
}

/* ── Freshness line (shown above the form, before search) ── */
.freshness {
  color: var(--pico-muted-color);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

/* ── Results table: compact, scannable companion to the map ──
   Replaces the old card list. Columns for the fields the user didn't
   filter by; actions align in a right-hand column. */
.results-table {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--pico-muted-border-color, #ddd);
}

.results-table thead th {
  font-weight: 600;
  color: var(--pico-muted-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom-width: 2px;
}

.results-table tbody tr:hover {
  background-color: rgba(128, 128, 128, 0.08);
}

/* The title is a focus link that pans the map to the spot. */
.results-table a.row-focus {
  text-decoration: none;
  font-weight: 500;
}

.results-table a.row-focus:hover {
  text-decoration: underline;
}

/* Actions column: right-aligned, no wrap, compact secondary links. */
.results-table .actions {
  text-align: right;
  white-space: nowrap;
}

.results-table .actions .action-link {
  margin-left: 0.75rem;
}

.results-table .actions a[role="button"].secondary {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  width: auto;
  display: inline-block;
}

/* Region · type sub-line tucked under the site title; hidden on desktop
   (where dedicated Region/Type columns exist), shown only on mobile. */
.results-table .row-sub {
  display: none;
}

/* ── Mobile: collapse Region/Type columns into the title sub-line ──
   On narrow screens four columns overflow the viewport and force
   horizontal scrolling. Hide the two secondary columns and surface their
   values as a muted sub-line under each site title instead. */
@media (max-width: 576px) {
  .results-table .col-region,
  .results-table .col-type {
    display: none;
  }

  .results-table .row-sub {
    display: block;
    font-size: 0.8rem;
    color: var(--pico-muted-color);
    margin-top: 0.15rem;
  }

  /* Tighten padding so Site + Actions fit comfortably. */
  .results-table th,
  .results-table td {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }
}

/* ── Results map (Leaflet) ───────────────────────────────
   A single map above the results table showing all available spots.
   Fixed height so Leaflet can tile correctly; sits within the same
   centered column as the rest of the app. */
#map {
  height: 360px;
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--pico-border-radius);
  overflow: hidden;
  /* Leave breathing room when the map is scrolled into view (row focus). */
  scroll-margin-top: 1.5rem;
}

/* Leaflet popup links should stay on their own visual rhythm. */
#map .leaflet-popup-content a {
  margin-right: 0;
}

/* Pico's global `img { max-width:100%; height:auto }` (and its reset) fights
   Leaflet's absolutely-positioned marker icons: the auto height resizes the
   pin and max-width can clamp it, which visually mangles the icon. Restore
   Leaflet's expected rendering inside the map so the transparent pin images
   display correctly (no solid block, correct size/offset). */
#map img.leaflet-marker-icon,
#map img.leaflet-tile {
  max-width: none;
  height: auto;
  width: auto;
  border: none;
  background: transparent;
}

/* Leaflet's default pin icon is an inline-block with an alpha PNG; be explicit
   that it must not pick up a background colour or border from the global reset. */
#map .leaflet-marker-icon {
  background: transparent !important;
  border: none !important;
}

/* Pico styles every `a` as a full-width, padded, line-height:1.5 link, which
   shoves Leaflet's fixed-size control buttons (zoom +/-, attribution) off
   their measured box and pushes their glyphs to the bottom-left. Undo those
   Pico additions and give the zoom buttons a touch-friendly, Pico-consistent
   size with centred glyphs. */
#map .leaflet-control a {
  width: auto;
  height: auto;
  padding: 0;
  line-height: inherit;
}

#map .leaflet-bar a {
  width: 40px;
  height: 40px;
  line-height: 40px;
  font-size: 1.5rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-bottom: 1px solid #ccc;
}

/* No divider under the bottom (−) button; keep the container's rounded
   corners clean. */
#map .leaflet-bar a:last-child {
  border-bottom: none;
}

/* Leaflet adds `.leaflet-touch` to the map container on touch/pointer devices
   and draws a subtle 2px rgba halo around the zoom group
   (`.leaflet-touch .leaflet-bar`) as a mobile affordance. It reads as a stray
   border against the clean Pico UI, so drop it in favour of the button's own
   crisp edges. */
#map.leaflet-touch .leaflet-bar {
  border: none;
}

/* ── Status views (warming up / server unreachable) ─────────
   The intro stays at the top; the status card sits below it in the same
   centered column as the rest of the app (not a full-viewport overlay). */
.status-card {
  text-align: center;
  margin-top: var(--pico-spacing);
  padding-block: 2.5rem;
}

.status-card hgroup {
  margin-bottom: 1rem;
}

.status-card h2 {
  margin-bottom: 0.25rem;
}

.status-card .status-note {
  max-width: 36rem;
  margin-inline: auto;
}

.status-card footer {
  margin-top: 1.25rem;
}

/* ── Full-screen server-error view ──────────────────────────
   The error state takes over the whole viewport (hide the intro and center
   the message) so "backend offline" is unmissable — unlike the warmup card,
   which stays below the intro. */
body[data-view="server-error"] .intro {
  display: none;
}

body[data-view="server-error"] main.container {
  padding-block: 0;
}

body[data-view="server-error"] #server-error {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

body[data-view="server-error"] .status-card {
  margin-top: 0;
}
