/* VMC Weather: one set of tokens, redefined for night. */

/* Inter, served by us (SIL OFL): the phone doesn't contact Google to draw text. */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url("../lib/inter/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url("../lib/inter/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 600; font-display: swap; src: url("../lib/inter/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 700; font-display: swap; src: url("../lib/inter/inter-latin-700-normal.woff2") format("woff2"); }

:root {
  --page: #e8e1d2;
  --panel: rgba(240, 234, 222, 0.92);
  --panel-border: rgba(74, 66, 55, 0.12);
  --text: #3b342b;
  --muted: #7a6f60;
  --accent: #2f7590;
  --on-accent: #ffffff;
  --track: rgba(74, 66, 55, 0.18);
  --shadow: 0 6px 24px rgba(60, 45, 20, 0.12);
  --gap: 16px;
}
:root[data-theme="night"] {
  --page: #18232f;
  --panel: rgba(27, 38, 51, 0.92);
  --panel-border: rgba(170, 188, 206, 0.16);
  --text: #dde6ef;
  --muted: #8fa1b4;
  --accent: #66c4e4;
  --on-accent: #0f1a24;
  --track: rgba(170, 188, 206, 0.22);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: Inter, system-ui, -apple-system, sans-serif; color: var(--text); background: var(--page); }
button { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; }
#ui > * { z-index: 2; }

.panel {
  position: fixed; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
[hidden] { display: none !important; }

/* --- Disclaimer (every launch) --- */
.disclaimer {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: var(--gap);
  background: rgba(10, 14, 20, 0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.disclaimer-card {
  position: static; width: min(440px, 100%); max-height: calc(100vh - 2 * var(--gap)); overflow: auto;
  padding: 20px 22px; display: grid; gap: 12px;
}
.disclaimer-card h2 { margin: 0; font-size: 18px; }
.disclaimer-card p { margin: 0; font-size: 14px; line-height: 1.5; }
.disclaimer-key { padding: 10px 12px; border-radius: 10px; background: rgba(224, 122, 31, 0.14); }
.disclaimer-ok {
  justify-self: stretch; border: 0; border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
}

/* --- Top left: brand + status --- */
.brand {
  top: calc(var(--gap) + env(safe-area-inset-top)); left: var(--gap); padding: 9px 14px;
  display: flex; align-items: baseline; gap: 8px; cursor: pointer;
}
.brand b { font-size: 17px; letter-spacing: 0.2px; }
.brand span { font-size: 12px; color: var(--muted); }
.pill {
  top: calc(var(--gap) + 52px + env(safe-area-inset-top)); left: var(--gap); padding: 6px 12px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; cursor: pointer;
}
.pill i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.card { left: var(--gap); width: min(320px, calc(100vw - 2 * var(--gap))); padding: 14px 16px; display: grid; gap: 10px; }
.card h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.card p { margin: 0; font-size: 13px; line-height: 1.45; }
.card a { color: var(--accent); }
.status-card { top: calc(var(--gap) + 92px + env(safe-area-inset-top)); max-height: 60vh; overflow: auto; }
.about-card { top: calc(var(--gap) + 52px + env(safe-area-inset-top)); max-height: 70vh; overflow: auto; }
#ui > .about-card { z-index: 3; }
/* Donations: a quiet note above the player, never over the controls. */
.donate-note {
  left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 2 * var(--gap)));
  bottom: calc(var(--gap) + var(--player-h, 104px) + 8px + env(safe-area-inset-bottom));
  padding: 8px 8px 8px 14px; display: flex; align-items: center; gap: 10px; font-size: 12px; line-height: 1.35;
  animation: donate-in .4s ease-out;
}
.donate-note span { flex: 1; color: var(--muted); }
.donate-link { flex: none; color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.donate-close {
  flex: none; width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}
@keyframes donate-in { from { opacity: 0; } }
.about-card .warn { padding: 8px 10px; border-radius: 10px; background: rgba(224, 122, 31, 0.12); }
.status-row { display: flex; gap: 10px; align-items: flex-start; }
.status-row i { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: none; }
.status-row b { display: block; font-size: 14px; }
.status-row small { display: block; font-size: 12px; color: var(--muted); }

/* --- Top right: day/night --- */
.theme {
  top: calc(var(--gap) + env(safe-area-inset-top)); right: var(--gap); width: 42px; height: 42px; border-radius: 50%;
  padding: 0; display: grid; place-items: center; cursor: pointer;
}
.theme svg { width: 20px; height: 20px; }
.theme .moon, :root[data-theme="night"] .theme .sun { display: none; }
:root[data-theme="night"] .theme .moon { display: block; }

/* --- Right: floating layer menu --- */
.rail { position: fixed; right: var(--gap); top: 50%; transform: translateY(-50%); display: grid; gap: 10px; }
.tool { position: relative; }
.tool > button {
  width: 46px; height: 46px; border-radius: 50%; padding: 0; display: grid; place-items: center; cursor: pointer;
  color: var(--muted); background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .15s, color .15s;
}
.tool > button svg { width: 22px; height: 22px; }
.tool.on > button { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.tool > button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.tool .label {
  position: absolute; right: 56px; top: 50%; transform: translateY(-50%); white-space: nowrap; pointer-events: none;
  font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px; opacity: 0; transition: opacity .15s;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
}
@media (hover: hover) { .tool:hover .label { opacity: 1; } }
.tool > button:focus-visible + .label { opacity: 1; }
.rail .divider { height: 1px; margin: 2px 8px; background: var(--panel-border); }
.settings { position: absolute; right: 56px; bottom: 0; width: 240px; max-height: 70vh; overflow: auto; padding: 12px 14px; display: none; gap: 12px; }
.settings.open { display: grid; }
.settings h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.settings .slider { display: grid; gap: 4px; font-size: 13px; }
.settings .slider div { display: flex; align-items: center; gap: 8px; }
.settings .slider.disabled { opacity: 0.4; }
.settings output { width: 34px; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.radar-list { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--panel-border); }
.radar-list:empty { display: none; }
.radar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; cursor: pointer; }
.switch { position: relative; width: 32px; height: 18px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--track); border-radius: 18px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 12px; height: 12px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.site.muted { opacity: 0.35; filter: grayscale(1); }
input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }

/* --- Bottom: radar player + color scale --- */
.timeline {
  left: 50%; transform: translateX(-50%); bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 2 * var(--gap))); padding: 10px 14px; display: grid; gap: 8px;
  grid-template-columns: minmax(0, 1fr);   /* the legend never pushes the player wider than the screen */
}
.timeline.empty { opacity: 0.7; }
.timeline-row { display: flex; align-items: center; gap: 6px; }
.timeline-row input[type="range"] { margin: 0 6px; }
.play {
  width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); cursor: pointer;
}
.play svg { width: 18px; height: 18px; }
.clock { width: 112px; flex: none; text-align: right; line-height: 1.15; }
.clock b { font-size: 18px; font-variant-numeric: tabular-nums; }
.clock small { display: block; font-size: 11px; color: var(--muted); }
.step {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: transparent; color: var(--muted); cursor: pointer;
}
.step:hover { color: var(--text); background: var(--track); }
.step svg { width: 16px; height: 16px; }
.scale-row { display: flex; align-items: center; gap: 12px; }
.speed {
  flex: none; min-width: 44px; height: 24px; padding: 0 8px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--panel-border); background: var(--track); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.scale { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--muted); }
.scale i { flex: 1; height: 6px; border-radius: 3px; }
.credits {
  justify-self: start; border: 0; background: none; padding: 0; cursor: pointer; text-align: left;
  font-size: 9.5px; color: var(--muted); opacity: 0.85; text-decoration: underline dotted; text-underline-offset: 2px;
}
.credits:hover { opacity: 1; }
.bolt-legend { display: flex; align-items: center; gap: 10px; font-size: 10px; color: var(--muted); flex-wrap: wrap; }
.bolt-legend > span:first-child { min-width: 44px; }
.bolt-age { display: inline-flex; align-items: center; gap: 3px; }
.bolt-age svg { width: 13px; height: 13px; }

/* --- Radar sites on the map --- */
.site {
  width: 15px; height: 21px; padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 0.5px 1px rgba(0, 0, 0, 0.4));
}
.site svg { width: 100%; height: 100%; display: block; overflow: visible; }
.site .dot { fill: var(--dot, #888); }
.maplibregl-popup-content {
  background: var(--panel); color: var(--text); border-radius: 10px; font: 13px/1.4 Inter, sans-serif; padding: 8px 12px;
  box-shadow: var(--shadow);
}
.maplibregl-popup-content small { color: var(--muted); }
.maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-bottom-right { bottom: calc(var(--gap) + env(safe-area-inset-bottom)); right: calc(var(--gap) - 10px); }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* --- Distance tool --- */
.range-bar {
  top: calc(var(--gap) + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 999px; font-size: 12px; max-width: calc(100vw - 2 * var(--gap));
}
.range-bar .hint { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.range-bar button {
  flex: none; border: 1px solid var(--panel-border); background: var(--track); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.range-bar .gps { background: var(--accent); color: var(--on-accent); border-color: transparent; }
canvas.measuring { cursor: crosshair; }
.range-center {
  width: 18px; height: 18px; border-radius: 50%; cursor: grab; background: var(--accent);
  border: 3px solid var(--panel); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), var(--shadow);
}
.range-label {
  padding: 4px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none; line-height: 1.2;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow); color: var(--text);
}
.range-label b { font-size: 13px; font-variant-numeric: tabular-nums; }
.range-label small { display: block; font-size: 11px; color: var(--muted); }

/* --- Airports: compact bubble --- */
.airport-pop .maplibregl-popup-content { padding: 8px 10px; display: grid; gap: 4px; font-size: 12px; }
.pop-head { display: flex; align-items: center; gap: 6px; }
.pop-head b { font-size: 14px; letter-spacing: .3px; }
.pop-head small { margin-left: auto; color: var(--muted); font-size: 11px; }
.cat { padding: 1px 6px; border-radius: 5px; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .4px; }
.pop-name { color: var(--muted); font-size: 11px; line-height: 1.3; }
.pop-line { font-weight: 600; font-variant-numeric: tabular-nums; }
.pop-warn { color: #d0453a; font-weight: 700; }
.pop-wx { color: var(--muted); }
.airport-pop .raw {
  margin: 0; padding: 4px 6px; border-radius: 6px; background: var(--track); white-space: pre-wrap; word-break: break-word;
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.airport-pop details { border-top: 1px solid var(--panel-border); padding-top: 4px; }
.airport-pop summary { cursor: pointer; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.airport-pop details .raw, .airport-pop details .cell-row { margin-top: 4px; }
.pop-foot { font-size: 10px; color: var(--muted); }

/* --- Zones --- */
.zone-popup .maplibregl-popup-content { border-left: 3px solid #e0a800; }

/* --- Cell tracking --- */
canvas.picking { cursor: pointer; }
.cell-card { top: calc(var(--gap) + 92px + env(safe-area-inset-top)); width: min(310px, calc(100vw - 2 * var(--gap))); gap: 8px; }
.cell-card > b, .cell-head b { font-size: 14px; }
.cell-card small { display: block; font-size: 12px; color: var(--muted); }
.cell-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cell-summary { display: none; font-size: 13px; font-weight: 600; }
@media (max-width: 700px) { .cell-summary { display: block; } }
.cell-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.cell-row span { color: var(--muted); flex: none; }
.cell-row b { text-align: right; font-weight: 600; }
.cell-row.warn b, .danger { color: #d0453a; }
.cell-note { margin: 0; font-size: 11px; color: var(--muted); }
.spark { width: 100%; height: 26px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark .spark-50 { stroke: #d0453a; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: 0.6; }
.cell-steps { display: flex; gap: 6px; }
.cell-steps button {
  flex: 1; border: 1px solid var(--panel-border); background: var(--track); border-radius: 999px;
  padding: 4px 0; font-size: 12px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums;
}
.cell-steps button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.cell-card .release {
  justify-self: start; border: 1px solid var(--panel-border); background: var(--track); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}

@media (max-width: 700px) {
  .range-bar { top: calc(var(--gap) + 92px + env(safe-area-inset-top)); left: var(--gap); transform: none; }
  /* The cell card becomes a sheet above the player; folded it shows only the title and one line. */
  .cell-card {
    top: auto; left: var(--gap); right: calc(var(--gap) + 58px); width: auto; max-height: 50vh; overflow: auto;   /* clear of the side menu */
    bottom: calc(var(--gap) + var(--player-h, 104px) + 8px + env(safe-area-inset-bottom));
  }
  .cell-card .cell-head { cursor: pointer; padding-top: 6px; position: relative; }
  .cell-card .cell-head::before {
    content: ""; position: absolute; top: -4px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 2px; background: var(--track);
  }
  .cell-card.collapsed > :not(.cell-head):not(.cell-summary) { display: none; }
  .cell-card:not(.collapsed) .cell-summary { display: none; }
  :root { --gap: 12px; }
  .maplibregl-ctrl-group { display: none; }              /* pinch to zoom on phones */
  /* Phone: the player sits on the bottom edge, compact; the map credits button rides just above it on the right
     and the side menu above that, so nothing overlaps (--player-h is measured by timeline.js). */
  .timeline { bottom: calc(var(--gap) + env(safe-area-inset-bottom)); padding: 8px 10px; gap: 5px; }
  .timeline .play { width: 34px; height: 34px; }
  .timeline .step { width: 26px; height: 26px; }
  .timeline-row input[type="range"] { margin: 0 2px; }
  .clock { width: 84px; }
  .clock b { font-size: 15px; }
  .clock small { font-size: 10px; }
  .scale-row { gap: 8px; }
  .speed { min-width: 36px; height: 20px; padding: 0 6px; font-size: 11px; }
  .scale { gap: 5px; font-size: 9px; }
  .scale i { height: 5px; }
  .bolt-legend { gap: 7px; font-size: 9px; }
  .bolt-legend > span:first-child { min-width: 36px; }
  .bolt-age svg { width: 11px; height: 11px; }
  .credits { font-size: 9px; }
  .maplibregl-ctrl-bottom-right { bottom: calc(var(--gap) + var(--player-h, 104px) + 4px + env(safe-area-inset-bottom)); right: calc(var(--gap) - 10px); }
  .rail { top: auto; transform: none; bottom: calc(var(--gap) + var(--player-h, 104px) + 44px + env(safe-area-inset-bottom)); }
  .donate-note { left: var(--gap); right: calc(var(--gap) + 52px); width: auto; transform: none; font-size: 11.5px; }   /* clear of the side menu */
}
