/* SKY.TUTI.LT — Airport database explorer (Round 36).
   Self-contained: same design tokens as css/base.css / endlessatc / trajectory.
   Flat-file data (sharded JSON) — no SQL anywhere. Map: Leaflet + OSM. */
:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg2: #11151f;
  --panel: #141926;
  --panel2: #1a2032;
  --line: #232b40;
  --line2: #2e3854;
  --txt: #dbe4f3;
  --txt2: #8fa0bd;
  --txt3: #8494b3;
  --acc: #4da3ff;
  --acc2: #7fd4a8;
  --warn: #fbbf24;
  --bad: #ef4444;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--txt);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font-family: inherit; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
code { font-family: var(--mono); font-size: .92em; background: var(--panel2);
       border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* ── header / footer chrome (mirrors the site's sub-apps) ─────────────── */
header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(12px, 3vw, 24px);
  background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 7px; color: var(--txt);
         font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--acc); }
.brand .sep { color: var(--line2); }
.brand span:last-child { color: var(--txt2); }
.spacer { flex: 1; }
.hdr-note { color: var(--txt3); font-size: 12px; white-space: nowrap; }
footer {
  margin-top: 34px; padding: 18px clamp(12px, 3vw, 24px) 26px;
  border-top: 1px solid var(--line); background: var(--bg2);
  color: var(--txt3); font-size: 12.5px;
}
footer .nav { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
footer .nav a { color: var(--txt2); }

main { max-width: 1160px; margin: 0 auto; padding: 0 clamp(12px, 3vw, 24px) 10px; }
h1 { font-size: clamp(1.45rem, 4.6vw, 2rem); margin: 22px 0 6px; }
.lede { color: var(--txt2); margin: 0 0 16px; max-width: none; }

.banner {
  display: none; margin: 14px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--bad); color: var(--txt);
}
.banner.warn-show { display: block; }

/* ── hero stats ───────────────────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
        gap: 10px; margin: 0 0 16px; }
.stat { background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 10px 12px; }
.stat .k { color: var(--txt3); font-size: 11.5px; text-transform: uppercase;
           letter-spacing: .04em; }
.stat .v { color: var(--acc); font-weight: 700; font-size: 19px;
           font-variant-numeric: tabular-nums; }

/* ── controls ─────────────────────────────────────────────────────────── */
.controls { margin: 0 0 10px; }
.rowtop { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#q {
  flex: 1 1 260px; min-width: 0; padding: 9px 12px; font-size: 14.5px;
  background: var(--panel); color: var(--txt);
  border: 1px solid var(--line2); border-radius: var(--radius);
}
#q::placeholder { color: var(--txt3); }
#sort { padding: 8px 10px; background: var(--panel2); color: var(--txt);
        border: 1px solid var(--line2); border-radius: var(--radius); font-size: 13px; }
.count { color: var(--txt3); font-size: 12.5px; white-space: nowrap;
         font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--panel); color: var(--txt2);
  border: 1px solid var(--line); cursor: pointer;
}
.chip:hover { color: var(--txt); border-color: var(--line2); }
.chip.on { background: var(--acc); border-color: var(--acc); color: #06121f; }

.deepnote {
  margin: 0 0 8px; padding: 7px 12px; font-size: 12.5px; color: var(--warn);
  background: var(--panel); border: 1px dashed var(--line2); border-radius: var(--radius);
}

/* ── vicinity search (ported from airportmap's vicinity page) ─────────── */
.nearby {
  margin: 0 0 10px; padding: 10px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.nb-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nb-row input {
  width: 150px; padding: 7px 10px; font-size: 13px;
  background: var(--bg2); color: var(--txt);
  border: 1px solid var(--line2); border-radius: 8px;
}
.nb-row input::placeholder { color: var(--txt3); }
.nb-row select {
  padding: 7px 8px; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line2); border-radius: 8px; font-size: 12.5px;
}
.nb-hint { color: var(--txt3); font-size: 12px; margin: 8px 0 0; max-width: none; }
.row .dist { color: var(--acc2); font-variant-numeric: tabular-nums; font-size: 12px; }
.row .tcell { display: flex; align-items: center; gap: 7px; }
.ticon { width: 17px; height: 17px; flex: 0 0 auto; opacity: .92; }
.dhead .ticon { width: 24px; height: 24px; }

/* ── stage: list + detail ─────────────────────────────────────────────── */
/* Round 41: the stage holds THREE children (#list, #pager, #detail) but the
   old 2-column auto-placement dropped #pager into the right column beside
   the list and pushed #detail (with the map) below — the pagination looked
   like a side panel. Named areas pin the pager under the list and the
   detail/map beside them, on one grid. */
.stage {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, 1fr);
  grid-template-areas: "list detail" "pager detail";
  gap: 12px; align-items: start; margin: 0 0 12px;
}
#list { grid-area: list; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#pager { grid-area: pager; }
#detail { grid-area: detail; }
.row {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer; min-width: 0;
}
.row:hover { border-color: var(--acc); }
.row.sel { border-color: var(--acc); background: var(--panel2); }
.row .code { font-family: var(--mono); font-weight: 700; color: var(--acc);
             font-size: 13px; word-break: break-all; line-height: 1.25; }
.row .code small { display: block; color: var(--txt3); font-weight: 400; font-size: 10.5px; }
.row .nm { min-width: 0; }
.row .nm b { display: block; white-space: nowrap; overflow: hidden;
             text-overflow: ellipsis; font-size: 13.5px; }
.row .nm span { color: var(--txt3); font-size: 11.5px; display: block;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--bg2);
  border: 1px solid var(--line2); color: var(--txt2); white-space: nowrap;
}
.badge.large { color: var(--acc); border-color: var(--acc); }
.badge.medium { color: var(--acc2); border-color: var(--acc2); }
.badge.small { color: var(--txt2); }
.badge.heliport { color: var(--warn); border-color: var(--warn); }
.badge.seaplane { color: #67e8f9; border-color: #67e8f9; }
.badge.closed, .badge.bad { color: var(--bad); border-color: var(--bad); }
.list-end { color: var(--txt3); font-size: 12px; text-align: center; padding: 6px 0 2px; }

/* ── detail panel ─────────────────────────────────────────────────────── */
.detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; min-width: 0;
}
.placeholder { color: var(--txt3); font-size: 13.5px; }
.placeholder .ph-hint { margin-top: 10px; }
.linklike {
  background: none; border: none; color: var(--acc); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}
.dhead { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.dhead .flag { width: 26px; height: 18px; border-radius: 3px; margin-top: 3px;
               object-fit: cover; border: 1px solid var(--line2); flex: 0 0 auto; }
.dhead h2 { margin: 0; font-size: 17px; line-height: 1.3; min-width: 0; }
.dhead h2 .codes { font-family: var(--mono); color: var(--acc); }
.dhead h2 .codes small { color: var(--txt3); font-family: var(--font); font-weight: 400; }
.dsub { color: var(--txt3); font-size: 12.5px; margin: 4px 0 0; }
.dfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
          gap: 8px; margin: 12px 0; }
.cell { background: var(--bg2); border: 1px solid var(--line);
        border-radius: 8px; padding: 6px 10px; min-width: 0; }
.cell .k { color: var(--txt3); font-size: 10.5px; text-transform: uppercase;
           letter-spacing: .05em; white-space: nowrap; }
.cell .v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13.5px;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .v.wrap { white-space: normal; overflow: visible; text-overflow: clip;
                line-height: 1.4; }
.cell .v small { color: var(--txt3); font-weight: 400; font-size: 10.5px; }
#apMap { height: 240px; border-radius: 8px; border: 1px solid var(--line);
         margin: 4px 0 14px; }
#apMap .leaflet-container { border-radius: 8px; }
.dsec { margin: 0 0 14px; }
.dsec h3 { font-size: 12.5px; margin: 0 0 6px; color: var(--acc2);
           text-transform: uppercase; letter-spacing: .05em; }
.tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.rt { width: 100%; border-collapse: collapse; font-size: 12.5px;
           font-variant-numeric: tabular-nums; }
table.rt th, table.rt td {
  padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.rt tr:last-child td { border-bottom: none; }
table.rt th { color: var(--txt3); font-size: 10.5px; text-transform: uppercase;
              letter-spacing: .05em; background: var(--bg2); position: sticky; top: 0; }
table.rt td b { font-family: var(--mono); color: var(--acc); }
table.rt .rwy-end { color: var(--txt2); }
table.rt .muted { color: var(--txt3); }
.freqchip { display: inline-block; min-width: 46px; text-align: center;
            font-family: var(--mono); font-size: 12px; font-weight: 700;
            background: var(--bg2); border: 1px solid var(--line2);
            border-radius: 6px; padding: 1px 7px; color: var(--acc2); }
.dlinks { display: flex; gap: 14px; flex-wrap: wrap; margin: 2px 0 0; font-size: 13px; }

/* ── pagination (10 results per page) ─────────────────────────────────── */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  flex-wrap: wrap; margin: 12px 0 4px; font-size: 12.5px; color: var(--txt2);
}
/* the author `display: flex` above used to defeat the `hidden` attribute —
   an empty pager box kept occupying a grid row; restore the semantics */
.pager[hidden] { display: none; }
.pager button {
  padding: 5px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line2);
  cursor: pointer; font-family: var(--font);
}
.pager button:hover:not(:disabled) { border-color: var(--acc); color: var(--acc); }
.pager button.on { background: var(--acc); color: #06121f; border-color: var(--acc); }
.pager button:disabled { opacity: .38; cursor: default; }
.pager .pinfo { font-variant-numeric: tabular-nums; margin: 0 4px; }

/* ── schematic runway diagram (airport-diagram port, dark theme) ──────── */
.diag { margin: 12px 0 0; }
.diag svg { width: min(100%, 340px); height: auto; display: block; margin: 0 auto; }
.diag .runway-rect { fill: #2a3346; stroke: #8b969a; stroke-width: 1; }
.diag .runway-text { font: 13px sans-serif; fill: #dbe4f3; }
.diag .runway-line { stroke: #37d17c; stroke-width: 3; }
.diag figcaption { color: var(--txt3); font-size: 11.5px; text-align: center; margin: 6px 0 0; }

/* Leaflet overrides to sit inside the dark theme */
.leaflet-container { font: 12px/1.4 var(--font); }
.leaflet-tooltip.ap-tip {
  background: var(--panel2); border: 1px solid var(--line2); color: var(--txt);
  box-shadow: var(--shadow); border-radius: 7px; padding: 4px 8px; font-size: 12px;
}
.leaflet-tooltip.ap-tip::before { display: none; }
.leaflet-control-attribution { background: rgba(11,14,20,.75) !important; color: var(--txt3) !important; }
.leaflet-control-attribution a { color: var(--txt2) !important; }
.leaflet-bar a { background: var(--panel2) !important; color: var(--txt) !important;
                 border-color: var(--line2) !important; }
.leaflet-bar a:hover { background: var(--panel) !important; }
.rwy-label {
  background: var(--panel2); border: 1px solid var(--line2); color: var(--txt);
  border-radius: 5px; padding: 0 5px; font-size: 10.5px; font-family: var(--mono);
  box-shadow: none;
}

/* ── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; grid-template-areas: "list" "pager" "detail"; }
}
@media (max-width: 560px) {
  .hdr-note { display: none; }
  .row { grid-template-columns: 64px 1fr auto; padding: 7px 10px; }
  #apMap { height: 200px; }
  .detail { padding: 12px; }
}
