@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/barlow-condensed-latin-800.woff2") format("woff2");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/dm-sans-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --ink: #23342a;
  --muted: #546459;
  --paper: #f7f6ec;
  --line: #d9ddcf;
  --signal: #f4cb66;
  --ground: #aa5808;
  --low: #38743a;
  --mid: #1b6886;
  --high: #694790;
  --sans: "DM Sans", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", var(--sans);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 500 14px var(--sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
button, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid #225b45; outline-offset: 3px; }
::selection { background: var(--signal); color: var(--ink); }

.masthead,
.toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  background: var(--paper);
  padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right));
}

.masthead {
  gap: 24px;
  min-height: calc(76px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid #b4bdaa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #28372b;
  background: var(--signal);
  border-radius: 10px;
}

.brand-icon svg { width: 24px; height: 24px; fill: currentColor; transform: rotate(33deg); }

.brand h1,
.location-card h2,
.panel h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 0.98;
}

.brand h1 { font-size: 42px; }

.readout,
.feed-status,
.local-time {
  display: flex;
  align-items: center;
}

.readout { gap: 22px; }
.feed-status { gap: 9px; }
.feed-status > div,
.local-time { display: grid; gap: 2px; }
.readout strong { font-size: 13px; }
.feed-count,
.local-time > span { color: var(--muted); font-size: 12px; }
#source { margin-inline-start: 1px; }
.local-time { border-left: 1px solid var(--line); padding-left: 22px; }
#clock { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9b7840;
}

.dot.is-live { background: #378652; }
.dot.is-down { background: #a14a3b; }

.traffic-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #2e4535;
  border-radius: 8px;
  background: #2e4535;
  color: #fffdf0;
  font-weight: 700;
}

.traffic-toggle:hover,
.traffic-toggle[aria-expanded="true"] { background: #405b43; }

.traffic-toggle svg,
.camera svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.airfield { position: relative; isolation: isolate; min-height: 0; }

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #b3c18c;
  background-image: radial-gradient(ellipse at 50% 60%, #c6cc98, #9eaf7d);
  font-family: var(--sans);
}

#map[data-basemap="imagery"],
#map[data-basemap="dark"] { background: #22312c; }

.airfield::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  box-shadow: inset 0 0 46px #34492728;
  pointer-events: none;
}

.location-card,
.panel,
.camera,
.banner {
  position: absolute;
  z-index: 2;
  background: var(--paper);
  border: 1px solid #c9cebd;
  box-shadow: 0 5px 18px #27352724;
}

.location-card {
  display: flex;
  align-items: center;
  gap: 12px;
  top: 20px;
  left: max(24px, env(safe-area-inset-left));
  padding: 12px 17px 12px 12px;
  border-radius: 12px;
  pointer-events: none;
}

.airport-code {
  padding: 8px 7px;
  border-radius: 6px;
  background: #e9ebda;
  color: #41543b;
  font: 700 11px var(--mono);
}

.location-card h2 { font-size: 27px; }
.location-name { display: inline-block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.panel {
  top: 20px;
  right: max(24px, env(safe-area-inset-right));
  width: min(290px, calc(100% - 32px));
  max-height: calc(100% - 190px);
  display: flex;
  flex-direction: column;
  border-radius: 13px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.panel h2 { font-size: 25px; }
.panel-head small { color: var(--muted); font: 600 12px var(--mono); }

#traffic-list {
  list-style: none;
  margin: 0;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #8b9c82 var(--paper);
}

#traffic-list .empty { padding: 12px; color: var(--muted); }
.traffic-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  width: 100%;
  padding: 8px 9px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
}

.traffic-row:hover,
.traffic-row[aria-current="true"] { background: #e9ebda; }
.traffic-row:focus-visible { outline-offset: -3px; }
.traffic-row .cs { font-weight: 700; }
.traffic-row .meta,
.traffic-row .num { color: var(--muted); font-size: 12px; }
.traffic-row .num { text-align: right; font-family: var(--mono); }

.camera {
  display: grid;
  bottom: 33px;
  right: max(24px, env(safe-area-inset-right));
  border-radius: 10px;
}

.camera button {
  width: 43px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
}

.camera button:first-child { border-radius: 9px 9px 0 0; }
.camera button:last-child { border-radius: 0 0 9px 9px; }
.camera button + button { border-top: 1px solid var(--line); }
.camera button:hover { background: #e9ebda; }
.camera button:disabled { opacity: 0.45; cursor: default; }

.compass {
  position: absolute;
  z-index: 1;
  left: max(24px, env(safe-area-inset-left));
  bottom: 30px;
  display: grid;
  justify-items: center;
  width: 36px;
  padding: 6px 0 4px;
  background: #f7f6eced;
  border: 1px solid #bac1ad;
  border-radius: 20px;
  font: 700 11px var(--mono);
  pointer-events: none;
}

.compass svg { width: 25px; height: 25px; fill: #3d5340; transform: rotate(var(--north-angle, 0deg)); }

.banner {
  left: 50%;
  bottom: 31px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 168px);
  padding: 8px 12px;
  border-radius: 8px;
  color: #793b30;
  font-weight: 600;
  font-size: 12px;
}

.toolbar {
  justify-content: space-between;
  gap: 16px;
  min-height: calc(66px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #b4bdaa;
}

.map-mode,
.hud-controls,
.legend { display: flex; align-items: center; }

.map-mode { gap: 10px; }
.map-mode label { color: var(--muted); font-weight: 700; font-size: 12px; }
.map-mode select,
.chip {
  min-height: 37px;
  border: 1px solid #c3cbb9;
  border-radius: 7px;
  background: #eeefe3;
  font-weight: 700;
  font-size: 12px;
}

.map-mode select { padding: 0 8px; }
.hud-controls { gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1px solid #718272; }
.chip[aria-pressed="true"] { background: #e4ead8; border-color: #b6c5a9; }
.chip[aria-pressed="true"]::before { background: #507849; border-color: #507849; }
.chip:hover, .map-mode select:hover { border-color: #718272; }

.legend { gap: 13px; color: var(--muted); font-weight: 700; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

.toolbar-end { display: flex; align-items: center; gap: 13px; }
.source-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 37px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
}
.source-link svg { width: 15px; height: 15px; fill: currentColor; }
.source-link:hover { border-color: #718272; color: var(--ink); }
.source-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.b-ground { --band: var(--ground); }
.b-low { --band: var(--low); }
.b-mid { --band: var(--mid); }
.b-high { --band: var(--high); }
.sw,
.traffic-row .cs::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--band);
}
.traffic-row .cs::before { content: ""; margin-right: 7px; }

.leaflet-container .leaflet-control-attribution {
  background: #f7f6ecf0;
  color: var(--ink);
  font-size: 10px;
}
.leaflet-container .leaflet-control-attribution a { color: #315844; }
.leaflet-tile-pane { filter: saturate(0.8) brightness(0.86); }
.scene-canvas { pointer-events: none; }
.scene-overview { transform-origin: 0 0; }

.airport-label span {
  position: absolute;
  translate: -50% -50%;
  color: #304634;
  -webkit-text-stroke: 2px #ecf3c2;
  paint-order: stroke fill;
  font: 800 14px var(--display);
  letter-spacing: 0.09em;
  white-space: nowrap;
}

.airport-label .runway-label {
  padding: 2px 5px;
  color: #fff9dc;
  background: #424d43;
  border-radius: 3px;
  font: 700 10px var(--mono);
  -webkit-text-stroke: 0;
  letter-spacing: normal;
}

#map:not([data-basemap="illustrated"]) .airport-label span { color: #fff9dc; }

.ac-wrap { cursor: pointer; }
.ac {
  --visual-size: clamp(29px, calc(var(--aircraft-metres, 35) * var(--metre-size, 1px)), 330px);
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--visual-size);
  height: var(--visual-size);
  transform: translate(-50%, -50%);
  transition: opacity 0.3s;
  color: var(--band);
}
.ac.is-vehicle { --visual-size: clamp(15px, calc(var(--aircraft-metres) * var(--metre-size)), 40px); }
.ac canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ac .tag {
  position: absolute;
  left: 50%;
  bottom: 89%;
  transform: translateX(-50%);
  padding: 2px 4px;
  border: 1px solid #d6dacb;
  border-radius: 4px;
  background: #fffdf0ef;
  color: #29362c;
  white-space: nowrap;
  pointer-events: none;
  font: 700 10px var(--mono);
}

.tag.is-hidden { display: none; }
.tag:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--band);
}
.ac .tag .a { color: var(--band); margin-left: 4px; }
.ac.is-missing { opacity: 0.36; }
.ac.is-selected::before {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px dashed #fff6d3;
  border-radius: 50%;
  background: #23342a65;
  box-shadow: 0 1px 4px #23342a85;
}

.leaflet-popup .leaflet-popup-content-wrapper,
.leaflet-popup .leaflet-popup-tip {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 5px 18px #2435283d;
}

.leaflet-popup .leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup .leaflet-popup-content { margin: 12px 15px; min-width: 208px; font-size: 12px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pop-title { display: flex; align-items: baseline; gap: 8px; padding-right: 8px; }
.pop-title b { font: 800 24px var(--display); }
.pop-title span { color: var(--muted); font: 600 10px var(--mono); }
.pop-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-variant-numeric: tabular-nums; }
.pop-grid dt { color: var(--muted); }
.pop-grid dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.leaflet-container a.pop-link { color: #315844; font-weight: 700; text-underline-offset: 3px; }

@media (max-width: 790px) {
  .toolbar .legend { display: none; }
  .masthead, .toolbar { padding-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right)); }
  .location-card, .compass { left: max(14px, env(safe-area-inset-left)); }
  .camera, .panel { right: max(14px, env(safe-area-inset-right)); }
}

@media (max-width: 560px) {
  .masthead { min-height: calc(61px + env(safe-area-inset-top)); gap: 10px; }
  .brand { gap: 7px; margin-right: 0; }
  .brand-icon { width: 30px; height: 30px; border-radius: 7px; }
  .brand-icon svg { width: 19px; height: 19px; }
  .brand h1 { font-size: 32px; }
  .traffic-toggle { min-height: 44px; padding: 0 9px; gap: 5px; font-size: 12px; }
  .traffic-toggle svg { width: 15px; height: 15px; }
  .local-time, #source { display: none; }
  .readout { margin-inline: auto; }
  .feed-status { gap: 5px; }
  .readout strong { font-size: 12px; }
  .feed-count { font-size: 11px; }
  .dot { width: 7px; height: 7px; }
  .location-card { top: 13px; gap: 9px; padding: 8px 11px 8px 8px; border-radius: 9px; }
  .location-card h2 { font-size: 22px; }
  .location-name { margin-top: 2px; font-size: 12px; }
  .airport-code { font-size: 10px; }
  .panel { top: 75px; max-height: calc(100% - 130px); max-height: min(44dvh, calc(100% - 130px)); }
  .camera { bottom: 26px; }
  .compass { bottom: 24px; }
  .banner { bottom: 25px; max-width: calc(100% - 136px); font-size: 11px; }
  .toolbar { min-height: calc(58px + env(safe-area-inset-bottom)); gap: 6px; }
  .map-mode label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .map-mode select { min-height: 40px; padding: 0 2px; }
  .hud-controls { gap: 4px; }
  .chip { min-height: 40px; padding: 0 6px; gap: 4px; }
  .toolbar-end { gap: 0; }
  .source-link { min-height: 40px; padding: 0 6px; }
  .source-link-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

@media (max-width: 350px) {
  .masthead, .toolbar { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .brand h1 { font-size: 30px; }
  .chip { padding-inline: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
