/*
  Station lookup and station pages. Loaded after site.css on /stations/ and on every page
  scripts/build-stations.mjs writes; a page that only has the search box (Home) loads it too.
  Colours, type and spacing come from tokens.css; nothing here sets a colour of its own.
*/

/* ---------- The search box (assets/station-search.js) ---------- */
.station-search { margin: var(--space-5) 0 0; max-width: var(--measure); }
.station-search label { display: block; font-family: var(--font-heading); font-weight: 600; color: var(--color-text); margin-bottom: var(--space-2); }
.station-search-row { display: flex; gap: var(--space-2); }
.station-search input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem; line-height: 1.5; color: var(--color-text); background: var(--color-bg);
  border: 1.5px solid var(--color-text); border-radius: var(--radius-md); padding: 0.6rem 0.75rem; appearance: none;
}
.station-search input::placeholder { color: var(--color-text-muted); }
.station-search input:focus-visible { outline-offset: 2px; }
.station-search button {
  font-family: var(--font-mono); font-size: var(--font-size-small); font-weight: 600; color: var(--color-on-accent); background: var(--color-accent);
  border: 0; border-radius: var(--radius-md); padding: 0 1.25rem; cursor: pointer; transition: background var(--duration-fast) var(--easing);
}
.station-search button:hover { background: var(--color-link-hover); }
.doc .station-search-hint, .station-search-hint { margin: var(--space-2) 0 0; font-size: var(--font-size-small); color: var(--color-text-muted); }

[data-station-results] { max-width: var(--measure); }
.doc .station-status, .station-status { margin: var(--space-3) 0 0; min-height: 1.5em; font-size: var(--font-size-small); color: var(--color-text-muted); }
.doc .station-results, .station-results { list-style: none; margin: var(--space-2) 0 0; padding: 0; border-top: var(--border-width) solid var(--color-border); }
.doc .station-results li, .station-results li { margin: 0; border-bottom: var(--border-width) solid var(--color-border); }
.station-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-4); padding: var(--space-3) var(--space-2); text-decoration: none; color: var(--color-text); line-height: var(--line-height-body); }
a.station-result:hover, a.station-result:focus-visible { background: var(--color-surface); color: var(--color-text); }
a.station-result:focus-visible { outline-offset: -2px; }
.station-result-name { font-weight: 600; }
a.station-result .station-result-name { color: var(--color-link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.station-result-meta { font-size: var(--font-size-small); color: var(--color-text-muted); }

/* ---------- /stations/: countries ---------- */
.doc .country-list { list-style: none; padding: 0; margin: var(--space-4) 0 0; columns: 15rem; column-gap: var(--space-6); }
.doc .country-list li { margin: 0; padding-block: 0.125rem; break-inside: avoid; }
.doc .country-list a { display: inline-block; padding-block: 0.125rem; }   /* a target at least 24px tall */
.country-list .muted, .letters .muted { font-family: var(--font-mono); font-size: var(--font-size-label); font-variant-numeric: tabular-nums; }
.doc .letters { list-style: none; padding: 0; margin: var(--space-4) 0 var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-2); }
.doc .letters li { margin: 0; }
.letters a { display: inline-block; padding: 0.3rem 0.65rem; border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md); text-decoration: none; font-weight: 600; }
.letters a:hover { border-color: var(--color-link); }
.letters a[aria-current] { color: var(--color-text); border-color: var(--color-text); }
.table-wrap table.station-list { min-width: 0; }
.station-list th[scope="row"] { font-weight: 500; }

/* ---------- A station page ---------- */
.doc .crumb { margin: 0 0 var(--space-3); font-family: var(--font-mono); font-size: var(--font-size-label); color: var(--color-text-muted); }
.station-facts code, .set code { overflow-wrap: anywhere; }
.doc dl.station-facts { margin-top: 0; }
.doc .station-calendar { margin: 0 0 var(--space-4); padding-top: var(--space-3); border-top: var(--border-width) solid var(--color-border); }
.doc .station-head { margin: var(--space-4) 0 var(--space-5); }
.doc .station-head > dl.station-facts { margin: 0; }
.doc .station-head:has(+ .station-calendar) { margin-bottom: var(--space-4); }
.station-facts > :is(dt, dd):nth-child(-n + 2) { border-top: 0; }   /* the title's neatline is the rule above the first row */

.doc .set h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-1); }
.set .tag { vertical-align: baseline; }
.doc .set-id { margin: 0 0 var(--space-2); font-size: var(--font-size-small); }
.set-id code { background: none; padding: 0; color: var(--color-text-muted); }
.doc .set > dl { margin-top: var(--space-2); }
.doc .flags { margin: var(--space-1) 0 0; padding-left: 1.1rem; }
.doc .flags li { margin-block: var(--space-1); }

.doc details > summary { cursor: pointer; font-family: var(--font-mono); font-size: var(--font-size-small); font-weight: 600; color: var(--color-link); padding-block: var(--space-1); }
.doc details > summary:hover { color: var(--color-link-hover); }
.doc details .table-wrap { margin-block: var(--space-3) var(--space-4); }
.doc details > p { margin-top: var(--space-3); font-size: var(--font-size-small); }
.set > details { margin-top: var(--space-2); }
.set > details + details { margin-top: 0; }
dd > details { margin-top: var(--space-2); }

/* Number tables are as wide as their numbers, not the column: a reader compares down a column. */
.table-wrap table.constituents { width: auto; min-width: 0; }
.table-wrap table.constituents :is(th, td) { padding-right: var(--space-6); }
.table-wrap table.constituents :is(th, td):last-child { padding-right: 0; }
.table-wrap table.constituents :is(th, td), .levels .table-wrap :is(th, td) { padding-block: var(--space-2); }
.constituents th[scope="row"] { font-family: var(--font-mono); font-weight: 500; }
.bin .table-wrap table.constituents { min-width: 30rem; }
.levels .table-wrap table { min-width: 0; }
.table-wrap table.provenance { min-width: 0; }
.provenance code { white-space: normal; overflow-wrap: anywhere; }
.provenance th[scope="row"] { font-weight: 500; }
.offsets th[scope="row"] { font-weight: 500; }
.offsets td:not(.num) { text-align: right; }
.table-wrap.narrow table { min-width: 0; }

/* The station map (scripts/stations/station-map.mjs): a window of the shared coastline, in the
   chart sheet's colours, framed by a border graduated in degrees, the station a tidal diamond.
   Beside the facts on a wide screen, under them on a narrow one. */
.station-map { margin: var(--space-5) 0 0; max-width: 26rem; }
.station-map svg { display: block; width: 100%; height: auto; }
.station-map .sea { fill: var(--color-d10); }
.station-map .grat { fill: none; stroke: var(--color-grat); stroke-width: 1; vector-effect: non-scaling-stroke; }
.station-map .land { fill: var(--color-land); stroke: var(--color-coast); stroke-width: 0.8; stroke-linejoin: round; }
.station-map .grat-lab { font-family: var(--font-mono); font-style: italic; font-size: 17px; fill: var(--color-sounding);
  paint-order: stroke; stroke: var(--color-d10); stroke-width: 4px; stroke-linejoin: round; }
.station-map .bars { fill: none; stroke: var(--color-text); stroke-width: 6; }
.station-map :is(.neat, .frame) { fill: none; stroke: var(--color-text); stroke-width: 1; vector-effect: non-scaling-stroke; }
.station-map .mark { fill: var(--color-bg); stroke: var(--color-accent); stroke-width: 3.5; }
.station-map .mark-dot { fill: var(--color-accent); }
.doc .station-map figcaption { margin-top: var(--space-2); font-family: var(--font-mono); font-size: var(--font-size-label); color: var(--color-text-muted); }
@media (min-width: 75rem) {
  .doc .station-head { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 0 var(--space-6); align-items: start; }
  .station-map { margin-top: var(--space-3); }
}

@media (max-width: 40rem) {
  .station-list :is(th, td):nth-child(3) { display: none; }   /* the id is on the station's page */
  .station-search button { padding-inline: var(--space-4); }
  .table-wrap table.constituents :is(th, td) { padding-right: var(--space-4); }
}
