/* GLOGO° Monitoring System at GOLD MERCURY — black & gold, dark-first. */

:root {
  --font-display: "Poppins", "Century Gothic", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, -apple-system, sans-serif;

  --bg: #f6f4ef;
  --bg-raised: #fffdf8;
  --ink: #17140e;
  --ink-soft: #5f594c;
  --ink-faint: #9b937f;
  --line: rgba(23, 20, 14, 0.13);
  --ring: rgba(23, 20, 14, 0.11);
  --band: rgba(23, 20, 14, 0.03);
  --sweep: rgba(159, 124, 55, 0.07);
  --accent: #9f7c37;
  --gold: #9f7c37;
  --shadow: 0 24px 70px -30px rgba(30, 25, 14, 0.45);

  /* GLOGO degree scale */
  --d1: #6aa823;
  --d2: #1f97d4;
  --d3: #e3bf07;
  --d4: #e56f1d;
  --d5: #d81f14;
}

html.dark {
  --bg: #060605;
  --bg-raised: #12100c;
  --ink: #f0ede6;
  --ink-soft: #a89f8d;
  --ink-faint: #6b6350;
  --line: rgba(240, 237, 230, 0.13);
  --ring: rgba(240, 237, 230, 0.13);
  --band: rgba(240, 237, 230, 0.03);
  --sweep: rgba(201, 162, 75, 0.09);
  --accent: #c9a24b;
  --gold: #c9a24b;
  --shadow: 0 24px 70px -30px rgba(0, 0, 0, 0.9);

  /* GLOGO degree scale */
  --d1: #76b82a;
  --d2: #2fa8dc;
  --d3: #f7d117;
  --d4: #ef7d26;
  --d5: #e3271b;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
  overflow-x: hidden;
}

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 40px) 10px;
}
.brand { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.brand h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  display: flex; align-items: flex-start; gap: 12px;
}
.brand h1 .deg-mark { font-size: 0.52em; line-height: 1; margin: 0.06em 0 0 -8px; }
.brand-sub {
  align-self: center;
  font-family: var(--font-display);
  font-size: clamp(11px, 1.15vw, 13.5px);
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.35;
  color: var(--ink-soft);
  text-transform: uppercase;
  border-left: 2px solid var(--gold);
  padding-left: 12px;
}
.brand-at {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700; letter-spacing: 0.24em;
  color: var(--gold); text-transform: uppercase;
  margin-top: 7px;
}
.tagline { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; max-width: 60ch; }

.controls { display: flex; align-items: center; gap: 10px; flex: none; padding-top: 4px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding: 5px 11px; border-radius: 999px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: livepulse 1.8s ease-out infinite; }
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  cursor: pointer; transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; }
#refresh-btn.spinning svg { animation: spin 0.9s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

#theme-btn svg { display: none; }
html[data-theme="light"] #theme-btn .th-light { display: block; }
html[data-theme="dark"] #theme-btn .th-dark { display: block; }
html[data-theme="system"] #theme-btn .th-system { display: block; }

/* ── Status line ─────────────────────────────────────────── */
.statusline {
  padding: 2px clamp(16px, 4vw, 40px) 0;
  font-size: 12.5px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-height: 18px;
}
.statusline strong { color: var(--ink-soft); font-weight: 600; }
.statusline .err { color: var(--d5); }
.statusline button {
  font: 600 12px var(--font-ui); color: var(--accent);
  background: none; border: 0; cursor: pointer; text-decoration: underline; padding: 0;
}

/* ── Degree scale legend (GLOGO 1°–5°) ───────────────────── */
main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 12px; }
.legend {
  display: grid; grid-template-columns: repeat(5, minmax(64px, 128px));
  gap: 3px; padding: 14px 8px 0; width: min(92vw, 660px);
}
.legend .deg { min-width: 0; }
.legend .deg i {
  display: flex; align-items: center;
  font-family: var(--font-display); font-style: normal; font-weight: 800;
  font-size: clamp(15px, 2vw, 21px); color: #fff;
  background: var(--dc); padding: 4px 10px; height: 38px;
}
.legend .deg span {
  display: block; font-size: 11px; line-height: 1.3; color: var(--ink-soft);
  padding-top: 6px;
}

/* ── Radar ───────────────────────────────────────────────── */
.radar-wrap {
  position: relative;
  width: min(96vw, calc(100dvh - 240px), 980px);
  min-width: min(96vw, 340px);
  aspect-ratio: 1;
  margin: 4px auto 0;
}
.radar-wrap svg.radar { width: 100%; height: 100%; display: block; }

.loader {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: var(--ink-faint);
  font-size: 13.5px;
}
.loader svg { width: 84px; height: 84px; }
.loader-needle { transform-origin: 32px 32px; animation: needlespin 1.4s linear infinite; }
@keyframes needlespin { to { transform: rotate(360deg); } }

.ring-line { fill: none; stroke: var(--ring); stroke-width: 1; }
.ring-band { stroke: none; }
.wedge-line { stroke: var(--ring); stroke-width: 0.7; opacity: 0.55; }
.horizon-label {
  font: 600 15px var(--font-ui); letter-spacing: 0.22em;
  fill: var(--ink-faint); text-anchor: middle;
}
.rim-label {
  font: 700 13.5px var(--font-display); letter-spacing: 0.2em;
  fill: var(--gold); text-anchor: middle; opacity: 0.85;
}
.axis-line { stroke: var(--ink-faint); stroke-width: 4; opacity: 0.5; stroke-linecap: round; }

.sweep-group { transform-origin: 500px 500px; animation: sweep 14s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .sweep-group { animation: none; display: none; }
  .blip { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* Blips */
.blip { cursor: pointer; opacity: 0; transform: scale(0.3); transform-origin: center; transform-box: fill-box; animation: blipin 0.55s cubic-bezier(0.22, 1.4, 0.36, 1) forwards; }
@keyframes blipin { to { opacity: 1; transform: scale(1); } }
.blip circle.core { transition: r 0.25s ease, filter 0.2s ease; }
.blip:hover circle.core, .blip.selected circle.core { filter: brightness(1.25); }
.blip.swept circle.core { filter: brightness(1.6) saturate(1.2); }
.blip text {
  font: 500 13px var(--font-ui);
  fill: var(--ink-soft); text-anchor: middle; pointer-events: none;
}
.blip.active text { fill: var(--ink); }
.blip.quiet circle.core { fill: transparent; stroke: var(--ink-faint); stroke-width: 1.2; opacity: 0.55; }
.blip.quiet text { fill: var(--ink-faint); opacity: 0.75; font-size: 11.5px; }
.blip .ping {
  fill: none; stroke-width: 1.5;
  animation: ping 2.6s cubic-bezier(0, 0.5, 0.4, 1) infinite;
  transform-origin: center; transform-box: fill-box;
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.85; }
  70%, 100% { transform: scale(2.4); opacity: 0; }
}
.blip .count-label {
  font: 600 10.5px var(--font-ui); fill: #fff; text-anchor: middle; pointer-events: none;
}

/* Center globe */
.globe-meridian { fill: none; stroke: var(--ink-soft); stroke-width: 1; opacity: 0.7; }
.globe-sphere { fill: color-mix(in srgb, var(--accent) 14%, var(--bg-raised)); stroke: var(--ink-soft); stroke-width: 1.2; }
.globe-spin { transform-origin: 500px 500px; animation: globespin 26s linear infinite; }
@keyframes globespin { to { transform: rotate(360deg); } }

/* Tooltip */
.tip {
  position: fixed; z-index: 30; pointer-events: none;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 12px; max-width: 300px;
  opacity: 0; transform: translateY(4px); transition: opacity 0.15s, transform 0.15s;
}
.tip.show { opacity: 1; transform: none; }
.tip .t-name { font: 600 13px var(--font-ui); }
.tip .t-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.tip .t-head { font-size: 12px; color: var(--ink-soft); margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }

.about {
  max-width: 68ch; text-align: center; color: var(--ink-faint);
  font-size: 12.5px; line-height: 1.55; padding: 14px 16px 6px;
}

/* ── Detail panel ────────────────────────────────────────── */
.panel {
  position: fixed; z-index: 40; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--bg-raised); border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 40px));
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column;
}
.panel.open { transform: none; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 22px 14px; border-bottom: 1px solid var(--line); }
.panel-cat {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--panel-accent, var(--accent));
}
.panel h2 { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; }
.panel-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.panel-list { list-style: none; padding: 10px 8px 24px; overflow-y: auto; }
.panel-list li a {
  display: block; padding: 12px 14px; border-radius: 10px;
  text-decoration: none; color: var(--ink);
  transition: background 0.15s;
}
.panel-list li a:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.panel-list .h-title { display: block; font-size: 14px; line-height: 1.4; font-weight: 500; }
.panel-list .h-meta { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; }
.panel-empty { padding: 24px 22px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; }

.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(8, 10, 15, 0.4); opacity: 0; transition: opacity 0.3s; }
.scrim.show { opacity: 1; }

/* ── Ticker ──────────────────────────────────────────────── */
.ticker {
  display: flex; align-items: center; gap: 0;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  overflow: hidden;
}
.ticker-label {
  flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); padding: 12px 14px 12px clamp(16px, 4vw, 40px);
  border-right: 1px solid var(--line); white-space: nowrap;
}
.ticker-viewport { overflow: hidden; flex: 1; mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent); }
.ticker-track {
  display: inline-flex; gap: 44px; white-space: nowrap; padding-left: 20px;
  animation: tick 70s linear infinite; will-change: transform;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes tick { to { transform: translateX(-50%); } }
.ticker-track a {
  color: var(--ink-soft); text-decoration: none; font-size: 13px; padding: 12px 0; display: inline-flex; align-items: center; gap: 9px;
}
.ticker-track a:hover { color: var(--ink); }
.ticker-track i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.ticker-track .src { color: var(--ink-faint); font-size: 11px; }

footer {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
  padding: 14px 16px 20px; font-size: 12px; color: var(--ink-faint);
  border-top: 1px solid var(--line);
}
footer a { color: var(--ink-soft); text-decoration: none; }
footer a:hover { color: var(--ink); }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar { flex-direction: column; }
  .controls { align-self: flex-end; margin-top: -6px; }
  .radar-wrap { width: 96vw; }
  .panel {
    top: auto; left: 0; right: 0; width: 100%;
    max-height: 72dvh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(calc(100% + 40px));
  }
  .panel.open { transform: none; }
  .blip text { font-size: 15px; }
  .blip.quiet text { font-size: 13px; }
  .horizon-label { font-size: 17px; }
}
