/* cca-aerospace viewer — custom styles layered on the NYC Core (fleet) theme.
   The header, footer, nav, cards, buttons, tables and grid all come from NYC Core
   (theme.css) + FontAwesome, mirroring cca-radiodb. The rules here only cover what the
   fleet theme doesn't: the full-bleed MapLibre surface, the typeahead search dropdown,
   the provenance meta-strip/badges, and the entity hub (headline / kv / timeline).
   Zero third-party assets: every font/icon/map tile comes from a fleet-controlled host. */

:root {
  --ink: #1f2733;
  --ink-dim: #51606f;
  --line: #dde3ea;
  --panel: #ffffff;
  --panel-2: #f3f6fa;
  --accent: #004CBE;
  --accent-ink: #ffffff;
  --good: #2e7d32;
  --warn: #b26a00;
  --bad: #c62828;
  --chip: #eef3fb;
  --link: #0a52c2;
  --link-hover: #06337a;
  --thead-bg: #e7edf5;
  --row-stripe: #f4f7fb;
  --row-hover: #e9f0fa;
  --focus-ring: #1565c0;
  --radius: .5rem;
  --shadow: 0 4px 14px rgba(18, 40, 60, .14);
}

/* Dark theme — full AA-contrast override of the (light-only) fleet surface. Opt-in via
   <html data-theme="dark"> (toggled from the chrome theme button / the map basemap switch).
   The NYC Core chrome bars (top bar / footer) are already dark, so this only retints the
   light content surface, cards, tables, links and badges that live below the chrome. */
[data-theme="dark"] {
  --ink: #e6edf3;
  --ink-dim: #aab7c5;
  --line: #2b3441;
  --panel: #161b23;
  --panel-2: #1d2530;
  --accent: #4d8dff;
  --accent-ink: #08111f;
  --good: #4caf6a;
  --warn: #e0a33a;
  --bad: #ef6a6a;
  --chip: #20293a;
  --link: #8ab4ff;
  --link-hover: #b4ceff;
  --thead-bg: #232c39;
  --row-stripe: #1b222c;
  --row-hover: #263141;
  --focus-ring: #8ab4ff;
  --shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
[data-theme="dark"] body { background: #0e1218; color: var(--ink); }
[data-theme="dark"] .card,
[data-theme="dark"] .map-panel,
[data-theme="dark"] .aero-results,
[data-theme="dark"] .legend { background: var(--panel); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .card { box-shadow: var(--shadow); }
[data-theme="dark"] .nav-more-menu { background: #1d2530; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .nav-more-menu a { color: var(--ink) !important; }
[data-theme="dark"] .nav-more-menu a:hover, [data-theme="dark"] .nav-more-menu a.active { background: var(--row-hover); }
[data-theme="dark"] .omni-kbd { color: var(--ink-dim); background: #232c39; border-color: var(--line); }

/* Sticky-footer column so the map home can fill the viewport and content pages keep the
   footer pinned to the bottom (same pattern as radiodb's styles.css). */
body { min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }
body > footer { flex-shrink: 0; }

.mono, code { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--ink-dim); }
.note { font-size: .85rem; color: var(--ink-dim); }
.err { color: var(--bad); }
/* Loading affordance: a REAL animated spinner before any "Loading…" text, on every page
   (every .spin label the viewer already ships gets one for free). Reduced-motion users get
   a static ring — still a clear in-progress cue, never a bare label that can read as stuck. */
.spin { color: var(--ink-dim); }
.spin::before {
  content: ""; display: inline-block; vertical-align: -0.125em;
  width: 0.85em; height: 0.85em; margin-right: 0.5em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  opacity: 0.6; animation: aero-spin 0.6s linear infinite;
}
@keyframes aero-spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.add { color: var(--good); font-weight: 600; }
.del { color: var(--bad); font-weight: 600; }
.mod { color: var(--warn); font-weight: 600; }

/* Skeleton shimmer — optional richer placeholder for async sections (theme-neutral tint). */
.skeleton { position: relative; overflow: hidden; background: var(--panel-2); border-radius: 6px; min-height: 0.9rem; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(127, 127, 127, 0.14), transparent);
  animation: aero-shimmer 1.2s infinite;
}
.skeleton-line { height: 0.9rem; margin: 0.35rem 0; }
.skeleton-line.w-40 { width: 40%; } .skeleton-line.w-60 { width: 60%; } .skeleton-line.w-80 { width: 80%; }
@keyframes aero-shimmer { to { transform: translateX(100%); } }

/* Click-to-copy chip (idents, coords) — generalises the airport page's .freq-copy affordance
   so every entity hub shares one copy interaction. Built as a real <button> for keyboard a11y. */
.copy-chip {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  color: inherit; font: inherit; display: inline-flex; align-items: center; gap: 0.35rem;
}
.copy-chip .fa-solid { color: var(--ink-dim); font-size: 0.8em; }
.copy-chip:hover, .copy-chip:hover .fa-solid { color: var(--link); }
.copy-chip.copied .fa-solid { color: var(--good); }
/* aria-busy regions read as in-progress to a pointer too. */
[aria-busy="true"] { cursor: progress; }

/* Skip link (NYC Core ships sr-only / sr-only-focusable; this just frames it on focus). */
.skip-menu:focus {
  position: fixed; top: .5rem; left: .5rem; z-index: 1080;
  width: auto; height: auto; padding: .5rem .9rem;
  background: #000; color: #fff; border-radius: .25rem;
}

/* ---- nav: "More" dropdown + mobile hamburger (ported from the fleet chrome) ---- */
.nav-more { position: relative; }
.nav-more-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; color: #212529; border: 1px solid #d5d9dd; border-radius: .3rem;
  min-width: 175px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); z-index: 60; padding: .3rem 0;
}
.nav-more-menu.show { display: block; }
.nav-more-menu a { display: block; padding: .45rem .9rem; color: #212529 !important; white-space: nowrap; }
.nav-more-menu a:hover, .nav-more-menu a.active { background: #eef3fb; text-decoration: none; }
.nav-toggle {
  display: none; background: none; border: 1px solid rgba(255, 255, 255, .45); border-radius: .25rem;
  color: #fff; padding: .25rem .6rem; font-size: 1.05rem;
}
#global-header .extensible-list.horizontal { gap: .25rem 1.1rem; }
#global-header .extensible-list.horizontal > li.active > a { text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 767px) {
  .nav-toggle { display: inline-block; }
  #primary-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: #111; z-index: 70; padding: .4rem 1rem .7rem; box-shadow: 0 6px 14px rgba(0, 0, 0, .4);
  }
  #primary-nav.show { display: block; }
  #primary-nav ul { flex-direction: column; align-items: flex-start !important; gap: 0 !important; }
  #primary-nav li { width: 100%; }
  #primary-nav a { display: block; padding: .55rem .25rem; }
  .nav-more-menu { position: static; box-shadow: none; border: 0; background: transparent; padding: 0 0 0 1.1rem; }
  .nav-more-menu a { color: #fff !important; padding: .45rem .25rem; }
  #nyc-top-header { position: relative; }
}

/* ---- omni / typeahead search (band + floating-over-map) ---- */
.aero-search { position: relative; min-width: 14rem; }
.aero-search .omni-wrap { position: relative; }
.aero-search .omni-wrap input { width: 100%; padding-right: 34px; }
.aero-search .omni-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; user-select: none;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #6c757d; background: #f1f3f5; border: 1px solid #ced4da; border-radius: 4px; padding: 3px 7px;
}
.aero-search .omni-wrap input:focus ~ .omni-kbd { display: none; }
@media (max-width: 767.98px) { .aero-search .omni-kbd { display: none; } }
.aero-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 60vh; overflow: auto; display: none; z-index: 1050;
}
.aero-results.open { display: block; }
/* Reset Bootstrap's .row (negative margins / wrap) for the search result rows. */
.aero-results .row {
  display: block; margin: 0; padding: .5rem .65rem; border-bottom: 1px solid var(--line); cursor: pointer;
}
.aero-results .row:last-child { border-bottom: 0; }
.aero-results .row:hover, .aero-results .row.sel { background: var(--panel-2); }
.aero-results .row .id { font-weight: 600; }
.aero-results .row .sub { color: var(--ink-dim); font-size: .85rem; }
.aero-results .row .kind { float: right; color: var(--ink-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---- full-bleed MapLibre surface (map home) ---- */
.map-main { display: flex; flex-direction: column; flex: 1 0 auto; min-height: 0; }
.map-shell { position: relative; flex: 1 1 auto; min-height: 70vh; }
#map { position: absolute; inset: 0; }
.map-fallback {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  text-align: center; color: var(--ink-dim); padding: 2rem;
}
.map-fallback.show { display: flex; }
/* Top-left floating column: search on top, then the layers panel. */
.map-tl {
  position: absolute; top: .75rem; left: .75rem; z-index: 6;
  width: 18rem; max-width: calc(100vw - 1.5rem);
  display: flex; flex-direction: column; gap: .6rem; max-height: calc(100% - 1.5rem);
}
.map-search .aero-search { min-width: 0; }
.map-search .aero-search input { box-shadow: var(--shadow); }
.map-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; min-height: 0;
}
.map-panel .card-header { padding: .5rem .8rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-dim); }
.map-panel .body { padding: .55rem .8rem; max-height: 46vh; overflow: auto; }
.layer-row { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.layer-row label { flex: 1; cursor: pointer; margin: 0; }
.layer-row .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }

/* ---- nearest-airport map control ---- */
.nearest-panel .body { max-height: 58vh; }
.nearest-mode {
  display: grid; grid-template-columns: 1fr 1fr; margin-bottom: .65rem;
  border: 1px solid var(--line); border-radius: .4rem; overflow: hidden;
}
.nearest-mode input { position: absolute; opacity: 0; pointer-events: none; }
.nearest-mode label {
  margin: 0; padding: .38rem .45rem; text-align: center; cursor: pointer;
  color: var(--ink-dim); background: var(--panel-2); font-size: .78rem; font-weight: 600;
}
.nearest-mode label + input + label { border-left: 1px solid var(--line); }
.nearest-mode input:checked + label { color: var(--accent-ink); background: var(--accent); }
.nearest-mode input:focus-visible + label { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.nearest-label {
  display: block; margin: 0 0 .2rem; color: var(--ink-dim);
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.nearest-coordinate-fields, .nearest-option-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .55rem;
}
.nearest-options { margin-top: .55rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.nearest-options summary { cursor: pointer; color: var(--ink-dim); font-size: .78rem; font-weight: 600; }
.nearest-options[open] summary { margin-bottom: .5rem; }
.nearest-detail-toggle { margin-top: .35rem; font-size: .78rem; }
.nearest-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-top: .65rem; }
.nearest-actions .btn { white-space: nowrap; }
.nearest-results { margin-top: .65rem; border-top: 1px solid var(--line); padding-top: .55rem; }
.nearest-results-head { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .35rem; }
.nearest-results-head .note { overflow-wrap: anywhere; }
.nearest-result-meta { margin: .35rem 0 .45rem; }
.nearest-result-meta .meta-strip { gap: .25rem; }
.nearest-result-meta .badge { padding: .15rem .38rem; font-size: .65rem; }
.nearest-results-list { list-style: none; margin: .25rem 0 0; padding: 0; }
.nearest-result { border-top: 1px solid var(--line); }
.nearest-result-link {
  display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: .15rem .45rem;
  padding: .55rem 0; color: var(--ink); text-decoration: none;
}
.nearest-result-link:hover { color: var(--link); text-decoration: none; }
.nearest-rank {
  grid-row: 1 / span 2; align-self: center; display: inline-flex; align-items: center; justify-content: center;
  width: 1.55rem; height: 1.55rem; border-radius: 50%; color: #fff; background: #e0245e;
  font-size: .72rem; font-weight: 700;
}
.nearest-result-main { min-width: 0; }
.nearest-result-title { display: flex; gap: .35rem; align-items: baseline; min-width: 0; }
.nearest-result-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.nearest-result-sub { display: block; color: var(--ink-dim); font-size: .7rem; overflow-wrap: anywhere; }
.nearest-distance {
  grid-column: 2; color: var(--ink); font-size: .72rem; font-weight: 600;
}
.nearest-result-detail {
  margin: -.25rem 0 .45rem 2.05rem; color: var(--ink-dim); font-size: .7rem;
}
@media (max-width: 767.98px) {
  .map-tl { max-height: calc(100% - 4rem); }
  .nearest-panel .body { max-height: 52vh; }
  .layers-panel .body { max-height: 24vh; }
}

/* ---- advisory / warning map popups (TFR + SIGMET/AIRMET) ---- */
.aero-adv-pop { font-size: .78rem; line-height: 1.35; min-width: 180px; }
.aero-adv-title { font-weight: 700; font-size: .82rem; margin-bottom: .3rem; }
.aero-adv-row { display: flex; justify-content: space-between; gap: .75rem; }
.aero-adv-row .k { color: #64748b; }
.aero-adv-row .v { font-weight: 600; text-align: right; }
.maplibregl-popup.aero-adv-popup .maplibregl-popup-content { padding: .55rem .7rem; border-radius: 8px; }
.legend {
  position: absolute; bottom: .75rem; left: .75rem; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .4rem .6rem; font-size: .8rem; color: var(--ink-dim); box-shadow: var(--shadow);
  max-width: calc(100vw - 1.5rem);
}

/* ---- provenance meta-strip + badges ---- */
.meta-strip { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .82rem; }
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .55rem; border-radius: 999px; background: var(--chip);
  border: 1px solid var(--line); color: var(--ink-dim); white-space: nowrap; font-weight: 500;
}
.badge .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--ink-dim); }
.badge.hit .dot { background: var(--good); }
.badge.miss .dot, .badge.bypass .dot { background: var(--warn); }
.badge.cycle { color: var(--ink); border-color: var(--accent); }
.badge.src { text-transform: uppercase; letter-spacing: .03em; font-size: .72rem; }
.badge.fresh .dot { background: var(--good); }
.badge.due .dot { background: var(--warn); }
.badge.stale .dot, .badge.never .dot { background: var(--bad); }
.badge.continuous .dot { background: var(--accent); }
.badge.disabled .dot { background: var(--ink-dim); }
/* data-vintage (freshness) chip: neutral when fresh, alarming when stale */
.badge.freshness { color: var(--ink); border-color: var(--line); }
.badge.freshness.stale { color: var(--bad); border-color: var(--bad); }
.badge.stale-flag {
  background: var(--bad); color: #fff; border-color: var(--bad);
  text-transform: uppercase; letter-spacing: .04em; font-size: .68rem; font-weight: 700;
  padding: .12rem .4rem;
}
/* "As of" historical cycle selector (Charts + Procedures sections) */
.cycle-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: 0 0 .6rem; }
.cycle-controls-label { font-size: .85rem; font-weight: 600; color: var(--ink-dim); }
.cycle-select { width: auto; min-width: 8rem; }
.cycle-note { margin: 0 0 .6rem; }
.badge.historical { color: var(--ink); border-color: var(--warn); background: var(--chip); font-size: .72rem; }
.cycle-back { padding: 0 .25rem; }

/* ---- airport NOTAM advisories ---- */
.notam-preprod { font-weight: 600; }
.notam-provenance { margin: .3rem 0 .5rem; }
.notam-list { list-style: none; margin: 0; padding: 0; }
.notam-item { padding: .5rem 0; border-top: 1px solid var(--line); }
.notam-item:first-child { border-top: 0; }
.notam-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .25rem; }
.notam-text {
  white-space: pre-wrap; word-break: break-word; margin: .15rem 0 .25rem;
  font-size: .85rem; line-height: 1.35; background: var(--chip);
  border: 1px solid var(--line); border-radius: 6px; padding: .4rem .55rem;
}
.notam-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.notam-detail-head { border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
.notam-header { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.notam-count { font-size: 1.1rem; font-weight: 600; }
.notam-filter-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.notam-filter-cls { width: auto !important; max-width: 10rem; }
.notam-filter-text { width: 14rem !important; }
.notam-cls { text-transform: uppercase; letter-spacing: .03em; font-size: .72rem; font-weight: 600; }
.notam-cls-dom { border-color: var(--good); color: var(--good); }
.notam-cls-intl { border-color: var(--accent); color: var(--accent); }
.notam-cls-fdc { border-color: var(--warn); color: var(--warn); }
.notam-cls-mil { border-color: var(--bad); color: var(--bad); }
.notam-number-link { font-weight: 600; }
.notam-history-link { opacity: .7; text-decoration: none; }
.notam-history-link:hover { opacity: 1; }
.notam-expand { margin-top: .5rem; }
.notam-item.hidden, .notam-expand.hidden { display: none; }

/* ---- entity hub: headline / key-value / timeline ---- */
.headline { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.headline .ident { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.headline .name { color: var(--ink-dim); }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--chip); color: var(--accent); font-size: .8rem; font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .8rem 0 0; }
.kv dt { color: var(--ink-dim); font-weight: 500; }
.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .cyc { font-weight: 600; min-width: 6.5rem; }
.timeline .fields { color: var(--ink-dim); font-size: .88rem; }
.slider-cyc { font-weight: 600; }
input[type="range"] { width: 100%; }

/* ===================================================================================
   Airport detail page — section nav, dark-safe links/tables, data-viz components.
   Most rules below are shared (links, tables, badges, focus) so every page benefits;
   the .airport-* rules are scoped to the airport page's TOC + content scaffold.
   =================================================================================== */

/* ---- accessible link colors (explicit per-theme, not NYC Core's low-contrast violet) ---- */
.card a:not(.btn):not(.pill):not(.badge):not(.chart-link),
.airport-content a:not(.btn):not(.pill):not(.badge):not(.chart-link),
a.aero-link {
  color: var(--link); text-decoration: underline; text-underline-offset: 2px;
}
.card a:not(.btn):not(.pill):not(.badge):not(.chart-link):hover,
.airport-content a:not(.btn):not(.pill):not(.badge):not(.chart-link):hover,
a.aero-link:hover { color: var(--link-hover); }

/* ---- visible keyboard focus everywhere (AA non-text contrast) ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
.toc-link:focus-visible, .chip:focus-visible, .table tbody tr:focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 3px;
}

/* ---- tables: clear stripe / thead / hover in BOTH themes ---- */
.card .table { color: var(--ink); }
.card .table th { color: var(--ink); border-bottom: 2px solid var(--line); }
.card .table thead th { background: var(--thead-bg); }
.card .table.table-striped tbody tr:nth-of-type(odd) { background: var(--row-stripe); }
.card .table.table-hover tbody tr:hover { background: var(--row-hover); }
.card .table td, .card .table th { border-top-color: var(--line); }

/* ---- decoded METAR table: tidy monospace code column + RMK subheader row ---- */
.metar-decoded td:first-child { white-space: nowrap; vertical-align: top; color: var(--ink); }
.metar-decoded tr.rmk-subhead th {
  background: var(--thead-bg); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink-dim);
}

/* ---- decoded NOTAM: plain-language summary + token Code → Explanation table ---- */
.notam-decoded td:first-child { white-space: nowrap; vertical-align: top; color: var(--ink); }
.notam-summary {
  margin: .15rem 0 .5rem; font-size: .9rem; line-height: 1.4;
  border-left: 3px solid var(--accent); padding: .25rem .55rem;
  background: var(--chip); border-radius: 0 6px 6px 0;
}

/* ---- theme toggle button in the chrome top bar ---- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  background: transparent; color: #fff;
  border: 1px solid rgba(255, 255, 255, .45); border-radius: .3rem; cursor: pointer;
  font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .14); }

/* ---- full-width content: lift NYC Core's max-width cap for this dense reference page ---- */
.container-fluid.wide { max-width: none; }

/* ---- 2-column airport layout: sticky TOC (lg+) + content stack ---- */
.airport-toc-col { }
.airport-toc {
  position: sticky; top: 1rem; align-self: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem; box-shadow: var(--shadow);
}
.airport-toc .toc-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); padding: .3rem .55rem .4rem;
}
.airport-toc ol { list-style: none; margin: 0; padding: 0; }
.toc-link {
  display: flex; align-items: center; gap: .55rem;
  padding: .42rem .55rem; border-radius: .35rem;
  color: var(--ink); text-decoration: none; font-size: .9rem;
  border-left: 3px solid transparent;
}
.toc-link .fa-solid { width: 1.1em; text-align: center; color: var(--ink-dim); }
.toc-link:hover { background: var(--row-hover); text-decoration: none; }
.toc-link[aria-current="true"] {
  background: var(--chip); color: var(--accent);
  border-left-color: var(--accent); font-weight: 600;
}
.toc-link[aria-current="true"] .fa-solid { color: var(--accent); }

/* On narrow screens the TOC becomes a horizontal, scrollable scrollspy strip. */
@media (max-width: 991.98px) {
  .airport-toc { position: static; box-shadow: none; padding: .35rem; }
  .airport-toc .toc-title { display: none; }
  .airport-toc ol { display: flex; gap: .25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .toc-link { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; padding: .4rem .6rem; }
  .toc-link[aria-current="true"] { border-left: 0; border-bottom-color: var(--accent); }
}

/* ---- sticky context bar: ident + name never scrolls out of view ---- */
.airport-context {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  padding: .5rem .9rem; margin-bottom: 1rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.airport-context .ctx-ident { font-weight: 700; font-size: 1.05rem; }
.airport-context .ctx-name { color: var(--ink-dim); font-size: .9rem; }

/* ---- consistent vertical rhythm across sections ---- */
.airport-section { scroll-margin-top: 1rem; }
.airport-section > .card { margin-bottom: 1.25rem; }
.airport-content h2.h5 { margin-bottom: .75rem; }

/* ---- back-to-top floating button ---- */
.to-top {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 1040;
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); border: none;
  box-shadow: var(--shadow); cursor: pointer; font-size: 1rem;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { filter: brightness(1.08); }

/* ---- charts & procedures: grouped cards + filter ---- */
.chart-filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .85rem; }
.chart-filter input[type="search"] { max-width: 18rem; }
.chart-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 999px; cursor: pointer;
  font-size: .78rem; font-weight: 600; line-height: 1.4;
  background: var(--chip); color: var(--ink); border: 1px solid var(--line);
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chart-group { margin-bottom: 1rem; }
.chart-group > h3 { font-size: .95rem; margin: 0 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.chart-list { display: grid; grid-template-columns: 1fr; gap: .4rem; }
@media (min-width: 768px) { .chart-list { grid-template-columns: 1fr 1fr; } }
.chart-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2);
}
.chart-row .chart-meta { min-width: 0; flex: 1; }
.chart-row .chart-name { font-weight: 600; font-size: .9rem; }
.chart-row .chart-sub { color: var(--ink-dim); font-size: .78rem; }
.chart-link {
  flex: none; display: inline-flex; align-items: center; gap: .3rem;
  color: var(--bad); text-decoration: none; font-weight: 600; font-size: .82rem;
}
.chart-link:hover { text-decoration: underline; }
.charts-empty-group { color: var(--ink-dim); font-size: .85rem; }

/* ---- CIFP coded instrument procedures: groups + expandable legs ---- */
.proc-group { margin-bottom: 1rem; }
.proc-group > h3 { font-size: .95rem; margin: 0 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.proc-group > h3 .proc-count { color: var(--ink-dim); font-weight: 400; }
.proc-list { display: grid; grid-template-columns: 1fr; gap: .4rem; }
.proc-item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); overflow: hidden; }
.proc-head {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .5rem .65rem; border: 0; background: none; cursor: pointer;
  color: inherit; text-align: left; font: inherit;
}
.proc-head:hover { background: var(--chip); }
.proc-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.proc-ident { font-weight: 700; font-size: .9rem; }
.proc-rwy { font-size: .72rem; color: var(--ink-dim); font-weight: 600; }
.proc-sub { color: var(--ink-dim); font-size: .78rem; }
.proc-chevron { margin-left: auto; color: var(--ink-dim); font-size: .8rem; transition: transform .15s ease; }
.proc-head[aria-expanded="true"] .proc-chevron { transform: rotate(90deg); }
.proc-detail { padding: .3rem .65rem .65rem; border-top: 1px solid var(--line); }
.proc-transition { margin-top: .6rem; }
.proc-transition:first-child { margin-top: .2rem; }
.proc-trans-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin-bottom: .3rem; }
.proc-trans-name { font-weight: 600; font-size: .85rem; }
.proc-trans-meta { color: var(--ink-dim); font-size: .76rem; }
.proc-legs th, .proc-legs td { white-space: nowrap; }
.proc-legs td:nth-child(2) { white-space: normal; }
.proc-pt { display: inline-block; margin-right: .35rem; padding: 0 .3rem; border-radius: .25rem; background: var(--chip); color: var(--accent); font-size: .72rem; font-weight: 700; }
.proc-actions { margin-top: .6rem; }

/* ---- type badges (charts + comms): consistent, AA-contrast palette ---- */
.tbadge {
  display: inline-flex; align-items: center;
  padding: .12rem .5rem; border-radius: .3rem; flex: none;
  font-size: .68rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: #fff; min-width: 3.4rem; justify-content: center;
}
.tb-ils { background: #1565c0; }
.tb-rnav { background: #2e7d32; }
.tb-rnp { background: #00695c; }
.tb-loc { background: #6a1b9a; }
.tb-vor { background: #ad1457; }
.tb-ndb { background: #4e342e; }
.tb-gls { background: #00838f; }
.tb-tacan { background: #455a64; }
.tb-visual { background: #a05f00; }
.tb-copter { background: #5d4037; }
.tb-apd { background: #283593; }
.tb-dp { background: #37474f; }
.tb-star { background: #4527a0; }
.tb-min { background: #546e7a; }
.tb-other { background: #546e7a; }
/* comms function badges reuse the same tinted palette */
.tb-twr { background: #c62828; }
.tb-gnd { background: #2e7d32; }
.tb-app { background: #1565c0; }
.tb-atis { background: #6a1b9a; }
.tb-ground { background: #2e7d32; }

/* ---- runway orientation inline-SVG diagram ---- */
.rwy-fig { display: inline-flex; align-items: center; color: var(--ink-dim); }
.rwy-fig svg { display: block; }
.rwy-strip { stroke: var(--ink-dim); }
.rwy-center { stroke: var(--panel); }
[data-theme="dark"] .rwy-center { stroke: #0e1218; }
.rwy-wind { stroke: var(--bad); fill: var(--bad); }

/* ---- communications: grouped rows + click-to-copy frequency ---- */
.comms-group { margin-bottom: .85rem; }
.comms-group > h3 { font-size: .9rem; margin: 0 0 .35rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .04em; }
.freq-copy {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  color: inherit; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  display: inline-flex; align-items: center; gap: .35rem;
}
.freq-copy .fa-solid { color: var(--ink-dim); font-size: .75rem; }
.freq-copy:hover { color: var(--link); }
.freq-copy.copied .fa-solid { color: var(--good); }
td.freq-cell { text-align: left; }

/* ---- flight-category pill (standard aviation colors, white text >=4.5:1) ---- */
.fcat { color: #fff; font-weight: 700; }
.fcat-vfr { background: #237a35; }
.fcat-mvfr { background: #0a58ca; }
.fcat-ifr { background: #c62828; }
.fcat-lifr { background: #8e24aa; }

/* ---- obstacle lighting legend ---- */
.obs-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--ink-dim); margin-top: .5rem; }
.obs-legend .code { font-weight: 700; color: var(--ink); }

/* ---- empty-state callouts (history / time-travel): informative, on-brand ---- */
.empty-note {
  border: 1px dashed var(--line); border-left: 3px solid var(--accent);
  background: var(--panel-2); border-radius: var(--radius);
  padding: .7rem .85rem; color: var(--ink); font-size: .88rem;
}
.empty-note .fa-solid { color: var(--accent); }
.empty-note a { font-weight: 600; }

/* ---- progressive disclosure: collapsible heavy sections ---- */
.section-disclosure {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2); margin-bottom: .85rem; overflow: hidden;
}
.section-disclosure-toggle {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .65rem .85rem; border: 0; background: none; cursor: pointer;
  color: inherit; text-align: left; font: inherit;
}
.section-disclosure-toggle:hover { background: var(--chip); }
.section-disclosure-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.section-disclosure-chevron {
  margin-left: auto; color: var(--ink-dim); font-size: .8rem;
  transition: transform .15s ease;
}
.section-disclosure-toggle[aria-expanded="true"] .section-disclosure-chevron { transform: rotate(90deg); }
.section-disclosure-summary { font-size: .85rem; color: var(--ink-dim); }
.section-disclosure-summary .disc-count { font-weight: 700; color: var(--ink); font-size: 1rem; }
.section-disclosure-body { padding: .3rem .85rem .85rem; border-top: 1px solid var(--line); }
.section-disclosure-body.hidden { display: none; }
.section-show-all {
  margin-top: .6rem; display: inline-flex; align-items: center; gap: .4rem;
}

/* ---- badge tooltips / legend ---- */
.tbadge[title] { cursor: help; }
.chart-type-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--ink-dim); margin-top: .5rem; }
.chart-type-legend .code { font-weight: 700; color: var(--ink); }
.notam-cls-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .78rem; color: var(--ink-dim); margin-top: .3rem; }
.cifp-pt-legend { display: flex; flex-wrap: wrap; gap: .3rem .7rem; font-size: .75rem; color: var(--ink-dim); margin-top: .4rem; }
.cifp-pt-legend .code { font-weight: 700; color: var(--accent); }

/* ---- respect reduced-motion for all the new transitions/smooth scroll ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .to-top { transition: none; }
  .section-disclosure-chevron { transition: none; }
  .spin::before { animation: none; }
  .skeleton::after { animation: none; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
