/* Weerballonnen live v1.2 */
:root {
  --night: #101a2e;
  --panel: #172440;
  --panel2: #1d2c4d;
  --line: #2b3c60;
  --text: #e3e8f2;
  --muted: #97a3bd;
  --up: #6cc4e8;
  --down: #f2b84b;
  --landed: #7fd39b;
  --ground: #b9a6e8;
  --lost: #8a93a8;
  --pred: #f08bc9;
  --font: "DejaVu Sans", "Bitstream Vera Sans", Verdana, Geneva, sans-serif;
  --font-cond: "DejaVu Sans Condensed", "DejaVu Sans", "Arial Narrow", Verdana, sans-serif;
  --gap: 12px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html { background: var(--night); }
body { margin: 0; background: var(--night); color: var(--text); font: 14px/1.4 var(--font); padding: 0 clamp(8px, 1.5vw, 18px) 8px; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
a { color: var(--up); }

/* Kop */
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 2px 8px; border-bottom: 1px solid var(--line); margin-bottom: var(--gap); }
.title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.title h1 { font-size: 1.4rem; }
.sub { color: var(--muted); font-size: 0.9rem; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clock { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.btn { font: inherit; font-size: 0.84rem; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 5px 10px; cursor: pointer; }
.btn:hover { background: var(--panel2); }
.btn:focus-visible { outline: 2px solid var(--up); outline-offset: 2px; }
.btn[hidden] { display: none; }
.btn-accent { background: var(--up); border-color: var(--up); color: var(--night); font-weight: bold; }
.btn-back { margin-bottom: 10px; }
.btn-back::before { content: "‹ "; }

/* Indeling: telefoon onder elkaar */
.layout { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
.map-wrap { position: relative; height: 60vh; min-height: 320px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#map { position: absolute; inset: 0; background: #0b1322; }
.side { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
#view-list, #view-detail { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
#view-list[hidden], #view-detail[hidden] { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; min-width: 0; }
.panel h2 { font-size: 0.92rem; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; }
.count { color: var(--text); font-weight: normal; }
.status { color: var(--muted); font-size: 0.8rem; }

/* Legenda op de kaart */
.legend { position: absolute; left: 10px; bottom: 22px; z-index: 500; display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: calc(100% - 20px); background: rgba(16, 26, 46, 0.85); border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; font-size: 0.76rem; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.lg-up::before { background: var(--up); }
.lg-down::before { background: var(--down); }
.lg-landed::before { background: var(--landed); }
.lg-lost::before { background: var(--lost); }
.lg-pred::before { width: 14px; height: 0; border-radius: 0; border-top: 2px dashed var(--pred); vertical-align: 3px; }

/* Lanceerplaatsen */
.sites { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sites li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; font-size: 0.86rem; cursor: pointer; padding: 3px 4px; border-radius: 3px; }
.sites li:hover, .sites li:focus-visible { background: rgba(255, 255, 255, 0.05); outline: none; }
.sites .s-name { font-weight: bold; }
.sites .s-dist { color: var(--muted); font-size: 0.8rem; text-align: right; }
.sites .s-next { grid-column: 1 / -1; color: var(--muted); font-size: 0.8rem; }
.sites .s-next b { color: var(--text); font-weight: normal; }

/* Ballonlijst */
.list { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--muted); font-size: 0.86rem; padding: 4px 0; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; padding: 7px 8px 7px 10px; border-left: 3px solid var(--c, var(--lost)); border-radius: 2px; cursor: pointer; }
.item + .item { margin-top: 4px; }
.item:hover, .item:focus-visible { background: rgba(255, 255, 255, 0.05); outline: none; }
.item:focus-visible { box-shadow: inset 0 0 0 1px var(--up); }
.i-serial { font-weight: bold; }
.i-alt { text-align: right; font-variant-numeric: tabular-nums; }
.i-sub { color: var(--muted); font-size: 0.82rem; }
.i-vv { color: var(--muted); font-size: 0.82rem; text-align: right; font-variant-numeric: tabular-nums; }
.i-land { grid-column: 1 / -1; font-size: 0.82rem; color: var(--pred); }
.badge { display: inline-block; font-size: 0.72rem; font-weight: bold; padding: 1px 6px; border-radius: 3px; margin-left: 6px; color: var(--night); background: var(--c, var(--lost)); vertical-align: 1px; }

/* Detail */
.d-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.d-head h3 { font-size: 1.25rem; }
.d-type { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.d-big { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.d-big div { background: var(--panel2); border-radius: 4px; padding: 8px 10px; }
.d-big .k { display: block; color: var(--muted); font-size: 0.76rem; }
.d-big .v { font-family: var(--font-cond); font-size: 1.4rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.d-land { background: rgba(240, 139, 201, 0.1); border: 1px solid rgba(240, 139, 201, 0.35); border-radius: 4px; padding: 9px 10px; margin-bottom: 12px; font-size: 0.88rem; }
.d-land strong { color: var(--pred); }
.d-land a { display: inline-block; margin-top: 6px; font-size: 0.84rem; }
.d-facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; font-size: 0.86rem; }
.d-facts dt { color: var(--muted); }
.d-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.d-chart-h { font-size: 0.8rem; color: var(--muted); margin: 14px 0 4px; }
.d-chart { width: 100%; height: 130px; display: block; }

/* Kaartmarkeringen */
.bl-wrap { background: none; border: 0; }
.bl { position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; pointer-events: auto; cursor: pointer; }
.bl svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7)); }
.bl-lab { position: absolute; left: 100%; top: 0; margin-left: 2px; white-space: nowrap; font: 11px/1.25 var(--font); color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.bl-lab b { display: block; font-weight: normal; color: #dfe6f3; }
.z-low .bl.quiet .bl-lab { display: none; }
.bl.sel svg { filter: drop-shadow(0 0 6px #fff); }
.site-ic { width: 10px; height: 10px; background: var(--night); border: 1.5px solid rgba(185, 166, 232, 0.8); transform: rotate(45deg); }
.site-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(185, 166, 232, 0.6); }
.z-far .site-dot { display: none; }
/* Donkere kaart: OpenStreetMap omgekeerd en gedempt */
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.92) saturate(0.55); }
.home-ic { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--up); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5); }
.land-ic { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--pred); background: rgba(240, 139, 201, 0.25); position: relative; }
.land-ic::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--pred); }

/* Leaflet donker */
.leaflet-container { font: 12px/1.4 var(--font); background: #0b1322; }
.leaflet-bar a, .leaflet-control-layers { background: var(--panel); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--panel2); }
.leaflet-control-layers-expanded { color: var(--text); padding: 6px 10px; }
.leaflet-control-attribution { background: rgba(16, 26, 46, 0.8) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--up); }
.leaflet-tooltip { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.leaflet-tooltip-top::before { border-top-color: var(--line); }

/* Voet */
.foot { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 2px 0; font-size: 0.74rem; color: var(--muted); }
.foot .ver { margin-left: auto; color: var(--up); }

/* Groot scherm: alles op één pagina */
@media (min-width: 900px) and (min-height: 520px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .top, .foot { flex: none; }
  .layout { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
  .map-wrap { height: auto; min-height: 0; }
  .side { min-height: 0; }
  #view-list, #view-detail { flex: 1; }
  .panel-grow { flex: 1; min-height: 0; overflow-y: auto; }
  .side .panel:not(.panel-grow) { flex: none; }
}

@media (display-mode: standalone) { .top { padding-top: 6px; } }
@media (max-width: 560px) {
  .sub { display: none; }
  .foot .ver { margin-left: 0; }
}

/* Laadscherm (v1.2) */
.loader { position: absolute; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(11, 19, 34, 0.82); transition: opacity 0.4s ease; }
.loader[hidden] { display: none; }
.loader.fade { opacity: 0; pointer-events: none; }
.loader-box { text-align: center; padding: 18px 24px; background: rgba(23, 36, 64, 0.92); border: 1px solid var(--line); border-radius: 8px; max-width: 86%; }
.loader-anim { position: relative; width: 84px; height: 84px; margin: 0 auto 12px; }
.loader-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--up); border-right-color: var(--pred); animation: wb-spin 1.1s linear infinite; }
.loader-balloon { position: absolute; left: 50%; top: 50%; margin: -23px 0 0 -15px; animation: wb-float 1.8s ease-in-out infinite; }
.loader-text { font-size: 1rem; font-weight: bold; }
.loader-sub { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.loader-sub a { color: var(--up); }
.dots::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: wb-dots 1.4s steps(4, end) infinite; }
.loading-line { animation: wb-pulse 1.4s ease-in-out infinite; }
@keyframes wb-spin { to { transform: rotate(360deg); } }
@keyframes wb-float { 0%, 100% { transform: translateY(5px); } 50% { transform: translateY(-5px); } }
@keyframes wb-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }
@keyframes wb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .loader-ring, .loader-balloon, .loading-line { animation: none; }
  .dots::after { animation: none; content: "..."; }
}
