/* Shared instrument-panel look for all five signal sites. */

:root {
  --bg: #070b11;
  --bg-panel: #0e141d;
  --bg-raised: #141c28;
  --border: #1e2937;
  --border-bright: #2b3a4d;
  --text: #ccd6e2;
  --text-dim: #6d7f96;
  --text-faint: #465468;
  --accent: #4dd4ff;
  --good: #3fd68a;
  --warn: #ffb454;
  --bad: #ff5f6d;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "DejaVu Sans Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ chrome */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: rgba(10, 15, 22, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar .home {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  text-transform: uppercase;
  white-space: nowrap;
}
.topbar .home:hover { color: var(--accent); text-decoration: none; }

.topbar h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.topbar .sub {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .spacer { flex: 1; }

/* connection state pill */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}
.status[data-state="live"] { color: var(--good); border-color: rgba(63, 214, 138, 0.3); }
.status[data-state="live"] .dot { background: var(--good); box-shadow: 0 0 8px var(--good); animation: pulse 2s infinite; }
.status[data-state="connecting"] { color: var(--warn); border-color: rgba(255, 180, 84, 0.3); }
.status[data-state="connecting"] .dot { background: var(--warn); animation: pulse 1s infinite; }
.status[data-state="error"] { color: var(--bad); border-color: rgba(255, 95, 109, 0.35); }
.status[data-state="error"] .dot { background: var(--bad); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ------------------------------------------------------------------ panels */

.panel {
  background: rgba(14, 20, 29, 0.94);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 12px 6px;
}

/* big readouts */
.readout { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.readout .value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.readout .unit { font-size: 11px; color: var(--text-faint); letter-spacing: 0.1em; text-transform: uppercase; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.stat-grid > div { background: var(--bg-panel); padding: 10px 12px; }

button, .btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button:hover, .btn:hover { background: #1b2532; border-color: var(--accent); color: var(--accent); text-decoration: none; }
button[aria-pressed="true"] { background: rgba(77, 212, 255, 0.14); border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { background: var(--bg-raised); border-color: var(--border-bright); color: var(--text); }

/* scrollbars stay out of the way but remain visible on dark */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #22303f; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #31445a; }

.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #22303f transparent; }

/* ------------------------------------------------------------------- lists */

.row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(30, 41, 55, 0.6);
  font-size: 12px;
  cursor: default;
}
.row:last-child { border-bottom: 0; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: rgba(77, 212, 255, 0.07); }
.row .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dim { color: var(--text-dim); }
.row .faint { color: var(--text-faint); font-size: 11px; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- leaflet */

.leaflet-container { background: #070b11 !important; font-family: var(--sans) !important; outline: none; }
.leaflet-control-attribution {
  background: rgba(7, 11, 17, 0.8) !important;
  color: var(--text-faint) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-bar a {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar a:hover { background: var(--bg-raised) !important; color: var(--accent) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-bright);
  box-shadow: var(--shadow) !important;
}
.leaflet-popup-content { margin: 12px 14px !important; font-size: 12px !important; line-height: 1.55 !important; }
.leaflet-popup-content b { color: #fff; }
.leaflet-popup-close-button { color: var(--text-faint) !important; }

/* full-bleed map under the fixed topbar */
.map { position: fixed; inset: 48px 0 0 0; }

/* ------------------------------------------------------------ site switcher */

.nav-toggle {
  display: flex; flex-direction: column; justify-content: center; gap: 3.5px;
  width: 30px; height: 30px; padding: 0 6px; border-radius: 6px; flex: none;
  background: transparent; border: 1px solid transparent;
}
.nav-toggle span { display: block; height: 1.5px; background: var(--text-dim); border-radius: 2px; transition: background 0.15s; }
.nav-toggle:hover { background: var(--bg-raised); border-color: var(--border-bright); }
.nav-toggle:hover span { background: var(--accent); }

.sitenav {
  position: fixed; top: 48px; left: 0; z-index: 950;
  width: 264px; max-width: calc(100vw - 16px);
  background: rgba(12, 18, 26, 0.98); border: 1px solid var(--border);
  border-top: 0; border-radius: 0 0 10px 0; box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transform: translateY(-8px); opacity: 0; pointer-events: none;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.sitenav.on { transform: translateY(0); opacity: 1; pointer-events: auto; }
.sitenav a {
  display: flex; align-items: baseline; gap: 10px; padding: 11px 14px;
  color: var(--text); text-decoration: none; border-bottom: 1px solid rgba(30, 41, 55, 0.7);
  border-left: 2px solid transparent;
}
.sitenav a:last-child { border-bottom: 0; }
.sitenav a:hover { background: var(--bg-raised); text-decoration: none; border-left-color: var(--tint); }
.sitenav a.current { background: rgba(255, 255, 255, 0.04); border-left-color: var(--tint); }
.sitenav .num { font-family: var(--mono); font-size: 10px; color: var(--tint); letter-spacing: 0.1em; }
.sitenav .nm { font-size: 13px; }

.icon-btn {
  padding: 5px 9px; font-size: 10.5px; flex: none; min-width: 30px;
}

/* -------------------------------------------------------------- about panel */

.about {
  position: fixed; inset: 0; z-index: 1100; display: none;
  background: rgba(3, 6, 10, 0.82); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.about.on { display: flex; }
.about-card {
  position: relative; max-width: 520px; width: 100%; max-height: 84vh; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--border-bright);
  border-radius: 14px; padding: 26px 26px 20px; box-shadow: var(--shadow);
}
.about-card h2 { margin: 0 0 14px; font-size: 20px; color: #fff; letter-spacing: -0.01em; }
.about-card p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.75; color: var(--text-dim); }
.about-card p:last-of-type { margin-bottom: 0; }
.about-card b { color: var(--text); font-weight: 600; }
.about-card code {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  background: var(--bg-raised); padding: 1px 5px; border-radius: 4px;
}
.about-card ul { margin: 0 0 12px; padding-left: 18px; }
.about-card li { font-size: 13.5px; line-height: 1.7; color: var(--text-dim); margin-bottom: 5px; }
.about-close {
  position: absolute; top: 14px; right: 14px; padding: 4px 9px; font-size: 11px;
}
.about-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 12px;
}

/* --------------------------------------------------------------- responsive */

.sheet-handle { display: none; }

@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 10px; }
  .topbar .sub { display: none; }
  .topbar h1 { font-size: 13px; }
  .topbar .home { display: none; }
  .status { padding: 3px 8px; font-size: 10px; }
  .status .label { display: none; }
  .icon-btn { padding: 5px 8px; }

  /* Panels dock to the bottom and peek by their handle, so the map keeps the
     screen and the numbers are one tap away. */
  .panel.sheet {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    width: auto !important; max-width: none !important;
    max-height: 72vh; display: flex; flex-direction: column;
    border-radius: 14px 14px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
    transform: translateY(calc(100% - 46px));
    transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 600;
  }
  .panel.sheet.open { transform: translateY(0); }

  .sheet-handle {
    display: flex; align-items: center; gap: 10px;
    width: 100%; height: 46px; flex: none;
    background: transparent; border: 0; border-radius: 14px 14px 0 0;
    padding: 0 16px; justify-content: flex-start;
  }
  .sheet-handle .grip {
    position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 34px; height: 3px; border-radius: 2px; background: var(--border-bright);
  }
  .sheet-handle .sheet-label {
    font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-dim);
  }
  .panel.sheet > .scroll, .panel.sheet > .list { overscroll-behavior: contain; }

  /* touch targets */
  button, .btn { padding: 9px 13px; }
  .row { padding: 11px 12px; }
}

@media (max-width: 760px) and (display-mode: browser) {
  /* leave room for mobile browser chrome that overlays the bottom edge */
  .panel.sheet { padding-bottom: env(safe-area-inset-bottom); }
}
