/* Per-airport statistics page (SPEC §M-11 T8, ADR-0044).
 *
 * Linked only from `pages/airport_statistics.html`. The page's measure is
 * the shared centred column every reading page gets from base.html's
 * `main` — wide enough for the departure tables, narrow enough to leave
 * air left and right (owner, 2026-10-06: the About measure was "a bit too
 * narrow", this page's old 62rem stretch "too large and difficult to
 * read"; one column between the two is the template for all pages). This
 * file therefore no longer widens `main` at all; what makes the lists
 * readable inside the column is that every box below sizes to its own
 * content rather than to the column.
 *
 * This file extends the light article theme from base.html and deliberately
 * does not import the map shell's dark tokens: the page is read, not
 * hovered, and inheriting the popup's dark theme would make it look like a
 * card that escaped.
 */

.aspm-sub {
  color: var(--muted);
  margin: -0.6rem 0 2rem;
  font-size: 0.95rem;
}

.aspm-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.aspm-empty {
  color: var(--muted);
  font-style: italic;
}

/* The parenthetical that qualifies a headline figure, e.g. "Airlines with
 * a route here". Kept quieter than the label so the label still scans. */
.aspm-qual {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

/* The summary block: two label/value pairs per row, so the eight figures
 * the popup already showed fit on four lines and can be scanned against
 * the lists below. */
table.aspm-facts {
  width: 100%;
  max-width: 44rem;
}

table.aspm-facts th {
  width: 1%;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 600;
  background: #f6f7fa;
}

table.aspm-facts td {
  width: 24%;
  font-variant-numeric: tabular-nums;
}

/* The group list shares one width — the widest closed summary row, never
 * the column — so every box ends at the same edge and the tallies sit in
 * one vertical pair of columns down the page (owner, 2026-10-06, second
 * ruling: with each box hugging only its own summary the numbers zigzagged
 * row to row, "not vertically aligned … should be in one line underneath
 * each other"). `fit-content` on the wrapper measures that widest summary;
 * the boxes stretch to it. `max-width: 100%` keeps a long airline name
 * wrapping inside the column on a narrow window instead of overflowing. */
.aspm-groups {
  width: fit-content;
  max-width: 100%;
}

/* One airline's collapsed group. The border and the summary row are the
 * only chrome: with sixty-odd groups on a busy airport, anything heavier
 * turns the page into a stack of boxes. */
details.aspm-airline {
  border: 1px solid var(--line);
  border-radius: 4px;
  margin: 0.4rem 0;
  background: #fff;
  width: 100%;
}

/* Code | name | tally. The name is the only flexible track, so the tally —
 * and the two number columns inside it — starts at the same x in every
 * row, which is the alignment the shared box width exists for. */
details.aspm-airline > summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  list-style-position: outside;
}

details.aspm-airline > summary:hover {
  background: #f2f1fa;
}

details.aspm-airline[open] > summary {
  border-bottom: 1px solid var(--line);
}

.aspm-airline-code {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  /* Fixed box wider than any 2- or 3-letter code, so the code cannot grow
   * the summary row unevenly and every airline name starts at the same x
   * position — the straight vertical line the owner asked for (§0.39).
   * min-width (not a fixed width) so a long code would still show rather
   * than clip; at 0.9rem bold, three capitals stay under 2.4em. */
  display: inline-block;
  min-width: 2.4em;
  white-space: nowrap;
}

.aspm-airline-name {
  font-weight: 600;
}

/* The tally is two fixed tracks — weekly departures right-aligned, the
 * pattern count left-aligned beside it — so each airline's "/wk" figure
 * sits directly above the next airline's and the pattern counts above
 * each other, one under the other down the list (owner, 2026-10-06,
 * second ruling). Fixed tracks rather than content width because a
 * four-digit week and a two-digit one must occupy the same column or the
 * stack drifts. The whole tally rides the summary grid's third track, one
 * gap away from the name: close to it, as the first ruling asked, but in
 * a column, as the second one asked. */
.aspm-airline-tally {
  display: grid;
  grid-template-columns: 7ch 13ch;
  column-gap: 0.6rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.aspm-tally-wk {
  text-align: right;
  white-space: nowrap;
}

.aspm-tally-pat {
  text-align: left;
  white-space: nowrap;
}

/* Opening one airline's schedule must not resize every box on the page.
 * The wrapper reports an intrinsic size as if empty, so the group list's
 * shared width stays the widest *summary*; the table inside still lays
 * out normally against the wrapper's used width and wraps within it
 * (`max-width` below) when it is the wider of the two. Browsers without
 * `contain` fall back to the list widening on open — ugly, not broken. */
.aspm-dep-wrap {
  contain: intrinsic-size;
}

/* Width auto (the table default) rather than 100%: the columns hug what
 * they carry, which is the difference between a schedule and a spreadsheet
 * stretched across the column. */
table.aspm-dep {
  margin: 0;
  font-size: 0.9rem;
  max-width: 100%;
}

table.aspm-dep th {
  background: #f6f7fa;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

table.aspm-dep td,
table.aspm-dep th {
  border-left: none;
  border-right: none;
  border-bottom: 1px solid #eef1f5;
}

table.aspm-dep tbody tr:last-child td {
  border-bottom: none;
}

.aspm-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.aspm-fno {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.aspm-arr-iata {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.aspm-arr-name {
  color: var(--muted);
}

/* Next-day arrival marker. Carried as text rather than colour alone so it
 * survives greyscale and colour-blind reading (§28.5). */
.aspm-nextday {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8em;
  margin-left: 0.15em;
}

.aspm-days {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Merged destinations/origins table (owner §0.39): one row per country,
 * To on the left, From on the right. Fixed layout so the two IATA-code
 * columns keep the same width and the arrow-count columns stay put no
 * matter how many airports a country carries — this is the alignment the
 * two-list layout could not hold when a country appeared on one side only. */
table.aspm-matrix {
  width: 100%;
  font-size: 0.88rem;
  border-collapse: collapse;
  table-layout: fixed;
}

table.aspm-matrix th,
table.aspm-matrix td {
  border-bottom: 1px solid #f0f2f6;
  padding: 0.22rem 0.5rem;
  text-align: left;
  vertical-align: baseline;
}

table.aspm-matrix thead th {
  background: #f6f7fa;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* # and the two arrow-count columns hug the right of their cell so the
   digits line up under their header; the two code columns wrap. */
table.aspm-matrix th.aspm-num,
table.aspm-matrix td.aspm-num {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.aspm-matrix td.aspm-codes {
  width: 34%;
  line-height: 1.7;
  word-spacing: 0.15em;
}

/* Country column: fixed so the count/case columns line up down the page. */
table.aspm-matrix td:nth-child(2) {
  width: 14rem;
}

table.aspm-matrix tfoot th,
table.aspm-matrix tfoot td {
  border-top: 2px solid var(--line);
  border-bottom: none;
  font-weight: 700;
  padding-top: 0.5rem;
}

/* Placeholder for a country with no airports in one direction. Muted so
 * an empty side reads as "none", not as a gap in the layout. */
.aspm-none {
  color: var(--muted);
}

/* Aircraft ICAO code in the departure table; the full type name rides in
 * the title so the column stays narrow. */
.aspm-ac {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.aspm-cc {
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.aspm-cn {
  font-weight: 600;
}

.aspm-code {
  display: inline-block;
  min-width: 2.6em;
  font-variant-numeric: tabular-nums;
}

.aspm-back {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
