/* radar.upsa.org.ua — UPSA Radar.
   Light instrument chrome in the UPSA family: IBM Plex, square corners,
   navy ink on paper, yellow reserved for live/selection marks.
   The dark surface is the globe viewport itself; the flat map is a light
   paper chart. Panels float over the viewport like chart-table bezels. */

:root {
  --paper: #FAFBFD;
  --panel: #FFFFFF;
  --ink: #0B1526;
  --navy: #0B2050;
  --muted: #5A6B85;
  --dim: #8A97AC;
  --line: #D8DEE9;
  --line-strong: #AEB9CC;
  --accent: #FFD400;
  --live: #1F9D5B;
  --space: #02060F;
  --pay: #E6A500;
  --pay-idle: #3D6FD6;
  --rb: #E0561F;
  --deb: #75808F;
  --unk: #9AA7BC;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root {
  --out: cubic-bezier(0.23, 1, 0.32, 1); /* instrument snap: fast out, no bounce */
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
a { color: var(--navy); }
a:hover { background: var(--accent); color: var(--ink); text-decoration: none; }
button {
  font: inherit; color: var(--navy); background: var(--panel);
  border: 1px solid var(--line); cursor: pointer; border-radius: 0;
  transition: background-color 120ms var(--out), border-color 120ms var(--out),
    color 120ms var(--out);
}
button:hover { border-color: var(--line-strong); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }

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

#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ── top bar ─────────────────────────────────────────── */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand:hover { background: none; }
/* the parent-site planet mark is near-white — it sits on a navy chip,
   same as it does in the parent's dark header */
.brand .mark-chip {
  width: 26px; height: 26px; flex: none;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.brand .mark-chip img { width: 20px; height: auto; display: block; }
.brand .mark { font-size: 15px; letter-spacing: 0.14em; font-weight: 400; white-space: nowrap; color: var(--ink); }
.brand .mark b { font-weight: 600; color: var(--navy); }

.view-toggle { display: flex; flex: none; }
.view-toggle button {
  padding: 5px 13px; font: 12px var(--mono); letter-spacing: 0.06em;
  white-space: nowrap;
}
.view-toggle button + button { border-left: 0; }
.view-toggle button.on { color: var(--ink); background: var(--accent); border-color: var(--ink); }

.search { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search .q-ico {
  position: absolute; left: 9px; top: 50%; transform: translateY(-52%);
  font-size: 15px; color: var(--dim); pointer-events: none;
}
.search .q-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font: 11px var(--mono); color: var(--dim);
  border: 1px solid var(--line); padding: 0 5px; line-height: 16px;
  pointer-events: none;
}
.search input:focus ~ .q-kbd, .search input:not(:placeholder-shown) ~ .q-kbd { display: none; }
.search input {
  width: 100%; padding: 7px 26px 7px 28px;
  font: 13px var(--mono); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  outline: none; border-radius: 0; appearance: none;
  transition: border-color 120ms var(--out);
}
.search input:focus { border-color: var(--navy); }
.search input::placeholder { color: var(--dim); }
.q-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line-strong);
  max-height: 320px; overflow: auto;
  box-shadow: 0 8px 24px rgba(11, 21, 38, 0.12);
}
.q-list button {
  display: flex; gap: 10px; align-items: baseline; width: 100%;
  padding: 7px 12px; border: 0; border-bottom: 1px solid var(--line);
  text-align: left; font-size: 13px; color: var(--ink); background: none;
}
.q-list button:hover, .q-list button.sel { background: rgba(255, 212, 0, 0.25); }
.q-list .t { width: 8px; height: 8px; flex: none; align-self: center; }
.q-list .id { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 12px; }

.clock { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.clock .mono { font-size: 13px; color: var(--navy); }
.live {
  font: 600 11px var(--mono); letter-spacing: 0.12em; color: #fff;
  background: var(--live); padding: 2px 7px; display: none;
}
.live.on { display: inline-block; }

/* ── left console panel ──────────────────────────────── */
.panel-toggle {
  position: fixed; left: 16px; top: 56px; z-index: 21;
  padding: 5px 12px; font: 12px var(--mono); letter-spacing: 0.08em;
  color: var(--muted);
}
.panel {
  position: fixed; left: 16px; top: 94px; z-index: 20; width: 252px;
  max-height: calc(100dvh - 140px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(11, 21, 38, 0.14);
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.panel.hidden { display: none; }
.sect { padding: 14px 14px 12px; border-bottom: 1px solid var(--line); }
.sect:last-of-type { border-bottom: 1px solid var(--line); }
.sect h2 {
  font: 500 10.5px var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 9px;
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; user-select: none;
  margin: -6px -6px 3px; padding: 6px 6px; /* larger hit area, same optics */
}
.sect h2::before {
  content: ''; width: 0; height: 0; flex: none;
  border-left: 4px solid var(--dim);
  border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
  transform: rotate(90deg);
  transition: transform 150ms var(--out);
}
.sect h2:hover { color: var(--ink); }
.sect.closed h2 { margin-bottom: -6px; }
.sect.closed h2::before { transform: rotate(0deg); }
.sect.closed > *:not(h2) { display: none; }
.total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.total .mono { font-size: 26px; font-weight: 500; letter-spacing: 0.02em; color: var(--navy); }
.total .lbl { color: var(--muted); font-size: 12.5px; }

.legend { display: grid; gap: 2px; }
.legend button {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 7px; border: 0; font-size: 13px; color: var(--ink); text-align: left;
  background: none;
}
.legend button .sw { width: 9px; height: 9px; flex: none; outline: 1px solid rgba(11,21,38,0.35); }
.legend button .n { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.legend button.off { color: var(--dim); }
.legend button.off .sw { background: transparent !important; outline: 1px solid var(--dim); }
.legend button.off .n { color: var(--dim); }
.legend button:hover { background: var(--paper); }

.shown {
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--navy);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.shown b { color: var(--ink); }
.shown .clr {
  border: 0; padding: 2px 4px; font: 11px var(--mono);
  color: var(--muted); text-decoration: underline; background: none;
}
.shown .clr:hover { color: var(--ink); background: var(--accent); text-decoration: none; }

.owner-select {
  width: 100%; padding: 6px 8px; margin-bottom: 8px;
  font: 12px var(--mono); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 0;
  outline: none; appearance: auto;
}
.owner-select:focus { border-color: var(--navy); }
.owner-chips button {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
}
.owner-chips button .nm {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 168px;
}
.owner-chips button .x2 { font-size: 13px; line-height: 1; opacity: 0.75; }
.owner-chips button:hover .x2 { opacity: 1; }

.wide-btn {
  width: 100%; padding: 6px 10px; font: 12px var(--mono); letter-spacing: 0.05em;
}
.wide-btn.on { color: var(--ink); background: var(--accent); border-color: var(--ink); }
.sky-row { display: flex; gap: 6px; }
.sky-row .wide-btn { flex: 1; width: auto; }
.sq-btn {
  width: 31px; height: 31px; flex: none; padding: 0;
  font-size: 17px; line-height: 1; color: var(--navy);
}
.sq-btn:hover { background: var(--accent); border-color: var(--ink); color: var(--ink); }
.hint { margin-top: 7px; font-size: 11.5px; color: var(--dim); line-height: 1.45; }
.hint.err { color: #B5432E; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  padding: 4px 10px; font: 12px var(--mono); letter-spacing: 0.03em;
  color: var(--muted);
}
.chips button:hover { color: var(--ink); }
.chips button.on { color: var(--ink); background: var(--accent); border-color: var(--ink); }

.age { padding: 11px 14px; font: 11.5px var(--mono); color: var(--muted); line-height: 1.6; }

/* ── object card ─────────────────────────────────────── */
.card {
  position: fixed; right: 16px; top: 94px; z-index: 20; width: 296px;
  background: var(--panel); border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  padding: 14px 16px 16px;
  box-shadow: 0 10px 30px rgba(11, 21, 38, 0.14);
  animation: cardIn 170ms var(--out);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(5px); } }
.card .grid span:last-child { font-variant-numeric: tabular-nums; }
.card .type {
  display: inline-block; padding: 2px 8px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.card .x, dialog .x {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  border: 0; font-size: 17px; line-height: 1; color: var(--muted); background: none;
}
.card .x:hover, dialog .x:hover { color: var(--ink); }
.card .type { font-size: 11px; letter-spacing: 0.14em; margin-bottom: 6px; font-weight: 600; }
.card h2 { font-size: 18px; font-weight: 600; line-height: 1.2; margin-bottom: 4px; padding-right: 18px; color: var(--navy); }
.card .ids { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.cardbtns { display: flex; gap: 6px; margin-bottom: 11px; }
.cardbtns button { padding: 4px 10px; font: 12px var(--mono); letter-spacing: 0.03em; }
.cardbtns button.on { color: var(--ink); background: var(--accent); border-color: var(--ink); }
.card .meta { display: grid; gap: 6px; margin-bottom: 12px; }
.card .meta div { display: flex; justify-content: space-between; gap: 12px; }
.card .meta dt { color: var(--muted); font-size: 12.5px; }
.card .meta dd { font-size: 12.5px; text-align: right; }
.card .grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
}
.card .grid > div {
  background: var(--paper); padding: 7px 9px 6px;
  display: flex; flex-direction: column; gap: 1px;
}
.card .grid .lbl { font-size: 9.5px; letter-spacing: 0.12em; color: var(--muted); }
.card .grid span:last-child { font-size: 14.5px; color: var(--navy); }
.card .note { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ── chart labels: countries and cities on zoom ────────
   Country names read as engraved into the paper — spaced capitals in
   translucent ink, no halo at all (the atlas way). City labels get a
   crisp 1px translucent cut, never a fuzzy glow. */
.labels {
  position: fixed; inset: 0; z-index: 12;
  pointer-events: none; overflow: hidden;
}
.labels > div {
  position: absolute; left: 0; top: 0;
  white-space: nowrap; will-change: transform;
  animation: lblIn 240ms var(--out);
}
@keyframes lblIn { from { opacity: 0; } }
.lbl-country {
  font: 500 12px var(--sans);
  letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(43, 58, 84, 0.55);
}
.lbl-country.r0 { font-size: 13.5px; letter-spacing: 0.3em; color: rgba(43, 58, 84, 0.48); }
.lbl-country.r2 { letter-spacing: 0.16em; }
.lbl-country.r3 { font-size: 10.5px; letter-spacing: 0.12em; }
.lbl-country.r4 { font-size: 10px; letter-spacing: 0.1em; }
.lbl-city {
  font: 400 11px var(--sans); color: #33415C;
  padding-left: 8px;
  text-shadow:
    1px 0 0 rgba(250, 251, 253, 0.65), -1px 0 0 rgba(250, 251, 253, 0.65),
    0 1px 0 rgba(250, 251, 253, 0.65), 0 -1px 0 rgba(250, 251, 253, 0.65);
}
.lbl-city.r0 { font-weight: 500; color: var(--ink); }
.lbl-city i {
  position: absolute; left: 0; top: 50%; margin-top: -1.5px;
  width: 3px; height: 3px; background: #33415C;
  outline: 1px solid rgba(250, 251, 253, 0.85);
}

/* ── viewport rail: instrument keys, bottom-right ────── */
.rail {
  position: fixed; right: 16px; bottom: 44px; z-index: 20;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 30px rgba(11, 21, 38, 0.14);
}
.rail button {
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font: 17px var(--mono); line-height: 1;
}
.rail button + button { border-top: 0; }
.rail button:hover { background: var(--accent); color: var(--ink); border-color: var(--ink); }
.rail button:hover + button { border-top-color: var(--ink); }

/* ── chart marginalia: cursor coords + scale bar ─────── */
.chartinfo {
  position: fixed; left: 16px; bottom: 12px; z-index: 19;
  display: flex; align-items: center; gap: 14px;
  font-size: 11.5px; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line);
  padding: 4px 10px;
  min-height: 26px;
}
.chartinfo #ci-coords { min-width: 128px; font-variant-numeric: tabular-nums; }
.chartinfo .sb { display: inline-flex; align-items: center; gap: 7px; }
.chartinfo .sb[hidden] { display: none; }
.chartinfo .sb i {
  display: block; width: 72px; height: 5px;
  border: 1px solid var(--muted); border-top: 0;
}
.chartinfo .sb b { font-weight: 500; color: var(--navy); }

/* ── first-visit hint ────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 52px; z-index: 30;
  transform: translateX(-50%);
  font-size: 12px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(11, 21, 38, 0.14);
  padding: 8px 16px;
  animation: toastIn 300ms var(--out);
  transition: opacity 600ms;
}
.toast.bye { opacity: 0; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ── selection ring ──────────────────────────────────── */
.selring {
  position: fixed; z-index: 15; width: 22px; height: 22px;
  border: 1.5px solid #C88F00; border-radius: 50%;
  pointer-events: none; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(11, 21, 38, 0.25), 0 0 10px rgba(230, 165, 0, 0.5);
  display: none;
}
.selring::after {
  content: ''; position: absolute; inset: -7px;
  border: 1px solid rgba(200, 143, 0, 0.55); border-radius: 50%;
  animation: ringPulse 2.2s var(--out) infinite;
}
@keyframes ringPulse {
  0% { transform: scale(0.55); opacity: 0.9; }
  70%, 100% { transform: scale(1.1); opacity: 0; }
}

/* ── tooltip, attribution, about ─────────────────────── */
.tip {
  position: fixed; z-index: 25; pointer-events: none;
  font-size: 12px; color: var(--ink);
  background: var(--accent); border: 1px solid var(--ink);
  padding: 3px 8px; transform: translate(12px, -50%);
  white-space: nowrap;
}
.tip.flip { transform: translate(calc(-100% - 12px), -50%); }

.attrib {
  position: fixed; right: 16px; bottom: 12px; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  font: 11.5px var(--mono); color: var(--muted);
  background: var(--paper); border: 1px solid var(--line);
  padding: 5px 10px;
}
.attrib a { color: var(--navy); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.attrib a:hover { background: var(--accent); }
.attrib button { border: 0; font: inherit; color: var(--navy); text-decoration: underline; background: none; }

dialog#about {
  margin: auto; width: min(560px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-strong); border-top: 3px solid var(--accent);
  padding: 26px 30px; position: relative;
}
dialog#about::backdrop { background: rgba(11, 21, 38, 0.45); }
dialog#about h2 { font-size: 20px; margin-bottom: 12px; color: var(--navy); }
dialog#about h3 {
  font: 500 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin: 16px 0 6px;
}
dialog#about p { font-size: 13.5px; color: var(--ink); margin-bottom: 8px; }
dialog#about .upsa { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ── loading ─────────────────────────────────────────── */
.loading {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--paper); transition: opacity 0.5s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading .ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid var(--line-strong); border-top-color: var(--navy);
  animation: spin 1.1s linear infinite;
}
.loading .mono { font-size: 12.5px; color: var(--muted); letter-spacing: 0.06em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── small screens ───────────────────────────────────── */
@media (max-width: 760px) {
  .bar { gap: 10px; padding: 8px 10px; flex-wrap: wrap; }
  .brand .mark { font-size: 13px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .clock .mono { font-size: 11px; }
  .panel-toggle { top: auto; bottom: 12px; left: 10px; z-index: 22; }
  .panel {
    left: 10px; right: 10px; top: auto; bottom: 46px; width: auto;
    max-height: 46dvh;
  }
  .panel:not(.hidden) ~ .attrib { display: none; }
  .card { left: 10px; right: 10px; top: auto; bottom: 46px; width: auto; z-index: 23; }
  .attrib { left: auto; right: 10px; }
  .attrib span { display: none; } /* full credits live in About */
  .rail { right: 10px; bottom: 96px; }
  .rail button { width: 42px; height: 42px; }
  .chartinfo { left: auto; right: 60px; bottom: 96px; }
  .chartinfo #ci-coords { display: none; } /* no cursor on touch */
  .chartinfo:has(#ci-scale[hidden]) { display: none; }
  .toast { bottom: 120px; width: max-content; max-width: 90vw; }
}
