/* aprs.now: the sister sites' look (aprsthursday.com, spaceaprs.com), with aprs.now's own
   raspberry where they have amber. Light by default; the dark look is space round the globe.
   The layout stamps the reader's choice on <html data-theme> before anything is drawn.

   Every colour on the site is one of these, so the two looks differ in this block and nowhere
   else. "-rgb" tokens are the three numbers of a colour, for rgba(var(--x-rgb), 0.1). --tint is
   the ink laid thinly over a ground: white on dark, slate on light. */
:root {
    --bg: #0a0d12;
    --bg-rgb: 10, 13, 18;
    --panel: rgba(var(--panel-rgb), 0.86);
    --panel-rgb: 14, 18, 26;
    --panel-solid: #11161f;
    --tint: 255, 255, 255;
    --line: rgba(var(--tint), 0.08);
    --line-strong: rgba(var(--tint), 0.16);
    --text: #e8ecf2;
    --text-soft: #c9d0db;
    --muted: #8e98aa;
    --faint: #6a7386;
    --accent: #ff7a9c;
    --accent-rgb: 255, 122, 156;
    --accent-mark: #ff7a9c;
    --link: #8fc1ff;
    --ok: #5fd39a;
    --ok-rgb: 95, 211, 154;
    --warn: #f2b84b;
    --bad: #ff6b6b;
    --sky: radial-gradient(ellipse at 30% 20%, rgba(40, 60, 110, 0.25), transparent 60%), radial-gradient(ellipse at 70% 80%, rgba(110, 40, 60, 0.14), transparent 55%);
    --sun: none;
    --glint: none;
    --shade: 1;
    --invert: 1;
    --radius: 12px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
    color-scheme: dark;
}
/* The light look. Text on white: --text 16, --muted 6.0, --faint 4.6, --accent 5.2, --link 6.1 to 1. */
:root[data-theme="light"] {
    --bg: #f4f5f7;
    --bg-rgb: 244, 245, 247;
    --panel: rgba(var(--panel-rgb), 0.92);
    --panel-rgb: 255, 255, 255;
    --panel-solid: #ffffff;
    --tint: 16, 24, 40;
    --line: rgba(var(--tint), 0.1);
    --line-strong: rgba(var(--tint), 0.2);
    --text: #151a22;
    --text-soft: #343c4a;
    --muted: #586273;
    --faint: #6b7586;
    --accent: #c2335f;
    --accent-rgb: 194, 51, 95;
    --accent-mark: #c2335f;
    --link: #0b5fb8;
    --ok: #177a4a;
    --ok-rgb: 23, 122, 74;
    --warn: #b97c00;
    --bad: #c62a2f;
    /* Daylight behind the globe, as on the sister sites: blue at the top paling down, a white
       bloom behind the globe, and the sun the script moves (stars.js). */
    --sky: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.9), transparent 58%), linear-gradient(180deg, #9cc5f2 0%, #c9e0f8 48%, #eef4fb 100%);
    --sun: radial-gradient(circle closest-side, rgba(255, 254, 246, 1) 0, rgba(255, 249, 226, 0.96) 3.5%, rgba(255, 236, 182, 0.62) 9%, rgba(255, 228, 164, 0.3) 24%, rgba(255, 228, 170, 0.11) 50%, rgba(255, 232, 184, 0) 100%);
    --glint: radial-gradient(circle closest-side, rgba(255, 255, 255, 0.72) 0, rgba(255, 255, 255, 0.4) 11%, rgba(255, 255, 255, 0.17) 34%, rgba(255, 255, 255, 0.05) 66%, rgba(255, 255, 255, 0) 100%);
    --shade: 0.3;
    --invert: 0;
    color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { overflow-x: hidden; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 var(--font);
    font-feature-settings: "tnum" 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.top {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 9px 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(to bottom, rgba(var(--bg-rgb), 0.97), rgba(var(--bg-rgb), 0.85));
    backdrop-filter: blur(10px);
}
.brand { color: var(--text); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand .dot { color: var(--accent-mark); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav a.on, .nav a:hover { color: var(--text); background: rgba(var(--tint), 0.05); text-decoration: none; }
.menu-btn { display: none; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; place-items: center; }
.menu-btn svg { width: 18px; height: 18px; }
.powered-top { margin-left: auto; display: inline-flex; align-items: center; gap: 9px; padding: 4px 12px 4px 5px; border-radius: 999px; border: 1px solid rgba(var(--accent-rgb), 0.35); background: rgba(var(--accent-rgb), 0.07); color: var(--text); font-size: 13px; }
.powered-top:hover { text-decoration: none; border-color: var(--accent); }
.powered-top img { width: 24px; height: 24px; border-radius: 6px; }
.powered-top span { color: var(--muted); }
.powered-top b { color: var(--accent); font-weight: 650; }
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.ok .dot { background: var(--ok); box-shadow: 0 0 10px rgba(var(--ok-rgb), 0.6); }
.status.warn .dot { background: var(--warn); }
.status.bad .dot { background: var(--bad); }
.theme-btn { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; margin-right: -8px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.theme-btn:hover { color: var(--text); background: rgba(var(--tint), 0.06); }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .ic-moon, :root[data-theme="light"] .theme-btn .ic-sun { display: none; }
:root[data-theme="light"] .theme-btn .ic-moon { display: block; }
.theme-btn.in-menu, .theme-btn[hidden] { display: none; }

/* Footer, on the ordinary pages. The map page has its own line on the map. */
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
.foot a, .legal a { color: var(--muted); }
.powered a { color: var(--accent); font-weight: 600; }

/* ---------- The map page: the map fills the window under the header ---------- */
body.map-page { height: 100vh; height: 100dvh; overflow: hidden; }
.map-main { position: relative; flex: 1; min-height: 0; }
/* The sky behind the globe (stars.js): space and stars in the dark, daylight and the sun in the light. */
.map {
    position: absolute; inset: 0;
    background-color: var(--bg);
    background-image: var(--stars, none), var(--sky);
    background-repeat: repeat, no-repeat, no-repeat, no-repeat;
    background-size: 1024px 1024px, auto, auto, auto;
}
.map .maplibregl-canvas { outline: none; }
.map .sun, .map .glint { position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none; opacity: 0; will-change: transform, opacity; }
.map .sun { background-image: var(--sun); }
.map .glint { overflow: hidden; }
.map .glint i { position: absolute; left: 0; top: 0; border-radius: 50%; background-image: var(--glint); }
.map .empty { padding: 40px; color: var(--muted); }

.maplibregl-ctrl-top-right { top: 6px; right: 6px; }
.maplibregl-ctrl-group { background: var(--panel-solid); border: 1px solid var(--line-strong); box-shadow: 0 6px 20px rgba(0, 0, 0, calc(0.4 * var(--shade))); }
.maplibregl-ctrl-group button { background-color: transparent; display: grid; place-items: center; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(calc(0.85 * var(--invert))); }
.maplibregl-ctrl-group svg { width: 16px; height: 16px; color: var(--text); }
.maplibregl-ctrl-group .ic-flat, .maplibregl-ctrl-group[data-view="flat"] .ic-globe { display: none; }
.maplibregl-ctrl-group[data-view="flat"] .ic-flat { display: block; }
.maplibregl-ctrl-group { position: relative; overflow: visible; }
.maplibregl-ctrl-attrib { background: rgba(var(--panel-rgb), 0.9) !important; border-radius: 8px; font-size: 11px; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib-inner, .maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(calc(0.8 * var(--invert))); }

/* The options menu, opening to the left of its button. */
.map-menu { position: absolute; right: calc(100% + 8px); top: 0; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; white-space: nowrap; box-shadow: 0 10px 30px rgba(0, 0, 0, calc(0.45 * var(--shade))); font-size: 13px; color: var(--text); }
.map-menu[hidden] { display: none; }
.map-menu label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.map-menu label.check { justify-content: flex-start; gap: 7px; }
.map-menu select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 7px; padding: 3px 6px; }
.map-menu input { accent-color: var(--accent-mark); margin: 0; }

/* The search box, top left on the map. */
.search { position: absolute; z-index: 4; top: 12px; left: 12px; width: min(360px, calc(100% - 70px)); }
.search input {
    width: 100%; height: 40px; padding: 0 12px 0 36px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
    font: 14px var(--font); backdrop-filter: blur(10px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, calc(0.35 * var(--shade)));
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--accent); }
.search-ic { position: absolute; z-index: 1; left: 11px; top: 11px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, calc(0.45 * var(--shade))); max-height: min(60vh, 440px); overflow: auto; }
.results[hidden] { display: none; }
.results li { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.results li.on, .results li:hover { background: rgba(var(--tint), 0.06); }
.results li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.results li.ask { color: var(--muted); }
.results li.ask b { color: var(--text); font-weight: 600; }
.results li.ask .muted { margin-left: auto; }
.results li.note { color: var(--muted); cursor: default; }
.results li.note:hover { background: none; }
.results .muted { color: var(--faint); font-size: 12px; white-space: nowrap; }
.results .pin { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50% 50% 50% 0; transform: rotate(-45deg) scale(0.7); background: var(--accent-mark); }
.sym { display: inline-block; width: 20px; height: 20px; flex-shrink: 0; background-repeat: no-repeat; }

/* The station card, under the search box. */
.card {
    position: absolute; z-index: 3; top: 62px; left: 12px; width: min(360px, calc(100% - 70px));
    max-height: calc(100% - 110px); overflow: auto;
    background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius);
    padding: 14px 16px; backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, calc(0.45 * var(--shade)));
}
.card[hidden] { display: none; }
.card-close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.card-close:hover { background: rgba(var(--tint), 0.06); color: var(--text); }
.card-close svg { width: 14px; height: 14px; }
.card-head { display: flex; align-items: center; gap: 9px; padding-right: 28px; margin-bottom: 8px; }
.card-head h2 { font-family: var(--mono); font-size: 18px; overflow-wrap: anywhere; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; }
.card .said { margin: 0 0 10px; color: var(--text-soft); overflow-wrap: anywhere; }
.facts { display: grid; gap: 7px; margin: 0; }
.facts div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: baseline; }
.facts dt { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts code { font-size: 12px; color: var(--text-soft); }
.card .muted, .muted { color: var(--muted); }
.card p.muted { margin: 10px 0 0; font-size: 12.5px; }
button.link { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-family: var(--mono); }
button.link:hover { text-decoration: underline; }

/* The line along the bottom: how many stations, and the small print. */
.map-foot { position: absolute; z-index: 2; left: 12px; bottom: 10px; right: 60px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; pointer-events: none; font-size: 12px; }
.map-foot > * { pointer-events: auto; background: rgba(var(--panel-rgb), 0.85); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; backdrop-filter: blur(8px); }
.map-foot .count { color: var(--text); font-weight: 500; }
.map-foot .legal { color: var(--faint); }
.map-foot .legal a:last-child { color: var(--accent); font-weight: 600; }

/* ---------- Ordinary pages ---------- */
.page { width: min(1080px, 100% - 32px); margin: 0 auto; padding: 28px 0 40px; flex: 1; }
.page-head { margin-bottom: 20px; }
.crumb { color: var(--faint); font-size: 12.5px; margin: 0 0 6px; }
.crumb a { color: var(--muted); }
.page h1 { font-size: 26px; }
.lede { color: var(--muted); margin: 6px 0 0; }
.prose { max-width: 720px; }
.prose p { color: var(--text-soft); line-height: 1.6; }
.prose h2 { font-size: 15px; margin: 22px 0 6px; color: var(--text); }

/* ---------- Phones ---------- */
@media (max-width: 720px) {
    .top { gap: 10px; padding: 8px 12px; }
    .menu-btn { display: grid; order: 3; }
    .nav { display: none; position: absolute; top: 100%; right: 8px; flex-direction: column; min-width: 180px; padding: 6px; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, calc(0.45 * var(--shade))); }
    .nav.open { display: flex; }
    .nav a { padding: 9px 10px; }
    .theme-btn { display: none; }
    .theme-btn.in-menu:not([hidden]) { display: flex; width: auto; height: auto; gap: 8px; justify-content: flex-start; margin: 4px 0 0; padding: 9px 10px; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
    .powered-top { padding: 3px 9px 3px 4px; font-size: 12px; }
    .powered-top span { display: none; }
    .status .label { display: none; }
    .search { top: 8px; left: 8px; width: calc(100% - 62px); }
    /* On a phone the card is a sheet along the bottom, so the map above it stays to be seen. */
    .card { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 48%; border-radius: 14px 14px 0 0; border-bottom: 0; }
    .map-foot { left: 8px; bottom: 6px; right: 50px; }
    .map-foot .legal { display: none; }
}
