/* ═══════════════════════════════════════════════════════════════════════════
   APEX-1 · 3D GLOBE — "cinematic stage" design system (subtraction pass)
   Default view is a polished video: globe + ONE sentence + replay bar +
   wordmark + two icon buttons. Everything else lives in the Details panel.
   Friendly type: Nunito (rounded, humanist). Accents: cyan / amber / green.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  /* palette */
  --bg: #020810;
  --cyan: #00e5ff;
  --amber: #ffb300;
  --green: #3ddc84;
  --text: #eaf6ff;
  --muted: #8fb0c4;
  --faint: #46687d;

  /* glass (one recipe) */
  --glass-bg: rgba(5, 14, 26, 0.72);
  --glass-bg-strong: rgba(4, 11, 21, 0.9);
  --glass-brd: rgba(0, 229, 255, 0.16);
  --glass-brd-hi: rgba(0, 229, 255, 0.42);
  --glass-blur: 12px;
  --glow-cyan: 0 0 14px rgba(0, 229, 255, 0.14);
  --e1: 0 4px 18px rgba(0, 0, 0, 0.45), var(--glow-cyan);
  --e2: 0 10px 34px rgba(0, 0, 0, 0.6), var(--glow-cyan);

  /* shape + spacing */
  --r-s: 8px; --r-m: 14px; --r-lg: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;

  /* type */
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-head: "Nunito", "Segoe UI", system-ui, sans-serif;
  --fs-xs: 11px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 17px;
  --fs-sentence: 21px;

  /* z-index scale (never cross these bands) */
  --z-globe: 0;
  --z-fb: 1;
  --z-chrome: 20;   /* wordmark, top actions, sentence */
  --z-ui: 40;       /* replay bar */
  --z-details: 50;  /* slide-over */
  --z-loading: 80;  /* loading overlay */
}

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

html, body {
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Cesium host ─────────────────────────────────────────────────────────── */
#cesium {
  position: absolute; inset: 0;
  z-index: var(--z-globe);
  background: var(--bg);
}
#cesium .cesium-viewer-bottom,
#cesium .cesium-credit-container { color: var(--faint); }
#cesium .cesium-credit-leftContainer { background: transparent; }
#cesium .cesium-widget-credits { display: none; }
/* Cesium's default "pick" cursor is fussy; keep the stage calm */
#cesium canvas { cursor: default; }

/* ─── Loading overlay ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: absolute; inset: 0; z-index: var(--z-loading);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3);
  background: radial-gradient(ellipse at 50% 45%, #071627 0%, var(--bg) 70%);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.loading-overlay.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-ring {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid rgba(0, 229, 255, 0.15);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
  position: relative;
}
.loading-ring-dot {
  position: absolute; inset: 0; margin: auto;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan); opacity: 0.7;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: 3px; color: var(--muted); text-transform: uppercase;
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ─── Wordmark (top-left) ─────────────────────────────────────────────────── */
.wordmark {
  position: absolute; z-index: var(--z-chrome);
  top: 14px; left: 16px;
  display: flex; align-items: baseline; gap: 8px;
  pointer-events: none;
  user-select: none;
}
.wm-name {
  font-weight: 800; font-size: 17px; letter-spacing: 3px;
  color: #eaffff;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}
.wm-sub {
  font-weight: 600; font-size: 10.5px; letter-spacing: 0.6px;
  color: var(--faint);
  white-space: nowrap;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 11px; letter-spacing: 1.5px;
  color: var(--green);
  padding: 4px 10px;
  border: 1px solid rgba(61, 220, 132, 0.5);
  border-radius: var(--r-lg);
  background: rgba(3, 16, 10, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.hidden { display: none !important; }

/* ─── Icon buttons (top-right) ────────────────────────────────────────────── */
.top-actions {
  position: absolute; z-index: var(--z-chrome);
  top: 12px; right: 14px;
  display: flex; align-items: center; gap: 8px;
}
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: 50%;
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--e1);
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}
.icon-btn:hover {
  color: var(--cyan); border-color: var(--glass-brd-hi);
  background: rgba(0, 229, 255, 0.08);
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.icon-btn-text {
  width: auto; padding: 0 14px; border-radius: var(--r-lg);
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
  text-decoration: none; color: var(--muted);
}
.icon-btn-text:hover { color: var(--cyan); }

/* ─── The ONE friendly sentence ───────────────────────────────────────────── */
.sentence-wrap {
  position: absolute; z-index: var(--z-chrome);
  bottom: 88px; left: 50%; transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  pointer-events: none;
  display: flex; justify-content: center;
}
.sentence {
  font-weight: 700;
  font-size: var(--fs-sentence);
  line-height: 1.35;
  letter-spacing: 0.1px;
  color: var(--text);
  text-align: center;
  padding: 14px 26px;
  border: 1px solid rgba(234, 246, 255, 0.14);
  border-radius: var(--r-lg);
  background: rgba(4, 12, 22, 0.55);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s ease;
}
.sentence .hl { color: var(--cyan); font-weight: 800; }
.sentence .hl-a { color: var(--amber); font-weight: 800; }

/* ─── Replay bar (bottom-center, video-player style) ──────────────────────── */
.replay-bar {
  position: absolute; z-index: var(--z-ui);
  bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-lg);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: var(--e2);
  max-width: calc(100vw - 28px);
}

.rp-play {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 50%;
  color: #041018; background: var(--cyan);
  border: none;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
  transition: transform 0.1s, box-shadow 0.15s;
}
.rp-play:hover { box-shadow: 0 0 18px rgba(0, 229, 255, 0.6); }
.rp-play:active { transform: scale(0.94); }
.rp-play .ic-pause { display: none; }
.rp-play.paused .ic-play { display: none; }
.rp-play.paused .ic-pause { display: block; }
.rp-play:disabled { background: var(--faint); box-shadow: none; cursor: default; }

.rp-time {
  font-weight: 700; font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 84px; text-align: center;
}

.rp-track {
  position: relative; flex: 1 1 auto; min-width: 130px;
  display: flex; align-items: center; height: 20px;
}
#rp-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 5px; cursor: pointer;
  background: linear-gradient(90deg,
    var(--cyan) 0%, var(--cyan) var(--fill, 0%),
    rgba(234, 246, 255, 0.16) var(--fill, 0%), rgba(234, 246, 255, 0.16) 100%);
  border-radius: 3px; outline: none;
}
#rp-slider:hover { box-shadow: 0 0 10px rgba(0, 229, 255, 0.25); }
#rp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.8);
  transition: transform 0.1s;
}
#rp-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
#rp-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.8);
}

.rp-speed { display: flex; border: 1px solid var(--glass-brd); border-radius: var(--r-s); overflow: hidden; }
.rp-sp {
  font-weight: 800; font-size: 10.5px; letter-spacing: 0.3px;
  padding: 6px 9px; cursor: pointer;
  border: none; border-right: 1px solid var(--glass-brd);
  color: var(--muted); background: transparent;
  transition: color 0.15s, background 0.15s;
}
.rp-sp:last-child { border-right: none; }
.rp-sp:hover { color: var(--cyan); background: rgba(0, 229, 255, 0.06); }
.rp-sp.on { color: #041018; background: var(--cyan); }

.rp-landing {
  font-weight: 800; font-size: 11.5px; letter-spacing: 0.3px;
  padding: 7px 12px; cursor: pointer;
  color: var(--amber);
  background: rgba(255, 179, 0, 0.08);
  border: 1px solid rgba(255, 179, 0, 0.4);
  border-radius: var(--r-lg);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}
.rp-landing:hover { border-color: var(--amber); background: rgba(255, 179, 0, 0.16); }
.rp-landing:active { transform: scale(0.96); }

/* ─── Details slide-over (right) ──────────────────────────────────────────── */
.details {
  position: absolute; z-index: var(--z-details);
  top: 0; right: 0; bottom: 0;
  width: min(360px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  background: var(--glass-bg-strong);
  border-left: 1px solid var(--glass-brd);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.5);
  transform: translateX(105%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.details.open { transform: translateX(0); }
.details-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(93, 139, 160, 0.18);
}
.details-title {
  font-weight: 800; font-size: 12px; letter-spacing: 3.5px;
  color: var(--cyan);
}
.details-x {
  width: 28px; height: 28px; cursor: pointer; font-size: 12px;
  color: var(--muted); background: none;
  border: 1px solid var(--glass-brd); border-radius: var(--r-s);
  transition: color 0.15s, border-color 0.15s;
}
.details-x:hover { color: var(--cyan); border-color: var(--glass-brd-hi); }
.details-body {
  flex: 1; overflow-y: auto;
  padding: 6px 18px 22px;
  scrollbar-width: thin; scrollbar-color: rgba(0, 229, 255, 0.3) transparent;
}
.details-body::-webkit-scrollbar { width: 8px; }
.details-body::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.25); border-radius: 4px; }

.d-sec { padding: 14px 0; border-bottom: 1px dashed rgba(93, 139, 160, 0.18); }
.d-sec:last-child { border-bottom: none; }
.d-h {
  font-weight: 800; font-size: 10px; letter-spacing: 2.5px;
  color: var(--faint); margin-bottom: 10px;
}
.d-row {
  display: flex; align-items: center; gap: 10px;
  font-size: var(--fs-sm); color: var(--text);
  padding: 4px 0;
}
.d-k { width: 92px; flex: 0 0 92px; color: var(--muted); font-weight: 600; }
.d-v { font-weight: 800; font-size: var(--fs-sm); color: var(--text); font-variant-numeric: tabular-nums; }
.d-v.ok { color: var(--green); }
.d-v.warn { color: var(--amber); }
.d-model {
  font-size: var(--fs-sm); line-height: 1.55; color: var(--text);
  background: rgba(61, 220, 132, 0.06);
  border: 1px solid rgba(61, 220, 132, 0.25);
  border-radius: var(--r-s);
  padding: 9px 12px; margin-bottom: 10px;
}
.d-model .ok { color: var(--green); font-weight: 800; }
.d-model.off {
  background: rgba(255, 179, 0, 0.06);
  border-color: rgba(255, 179, 0, 0.3);
}
.d-model.off .ok { color: var(--amber); }

.d-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.d-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(93, 139, 160, 0.18);
  border-radius: var(--r-s);
  padding: 8px 10px;
}
.d-cell span {
  display: block; font-size: 10px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--faint); margin-bottom: 3px;
}
.d-cell b { font-size: var(--fs-md); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

.d-wind { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
#d-compass { width: 52px; height: 52px; flex: 0 0 52px; }
.d-wind-txt { display: flex; flex-direction: column; gap: 2px; }
.d-note {
  font-size: 11px; line-height: 1.55; color: var(--muted);
  margin-top: 8px;
}
.d-note b { color: var(--text); font-weight: 700; }
.d-note a { color: var(--cyan); text-decoration: none; }
.d-note a:hover { text-decoration: underline; }

/* legend swatches (inside details only now) */
.sw { width: 18px; height: 10px; flex: 0 0 18px; position: relative; border-radius: 2px; display: inline-block; }
.sw-line { height: 3px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 6px rgba(0, 229, 255, 0.6); }
.sw-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; margin-left: 4px; box-shadow: 0 0 8px rgba(0, 229, 255, 0.9); }
.sw-circle {
  width: 16px; height: 10px; margin-left: 1px;
  border-radius: 50%;
  background: rgba(255, 179, 0, 0.25);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
}
.sw-actual {
  width: 9px; height: 9px; margin-left: 5px; border-radius: 50%;
  background: #fff; border: 1.5px solid rgba(255, 179, 0, 0.9);
}

/* camera & map controls */
.d-tgl-row { align-items: center; }
.d-switch {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: var(--fs-sm); font-weight: 700; color: var(--text);
  cursor: pointer; user-select: none;
}
.d-switch input { position: absolute; opacity: 0; pointer-events: none; }
.d-switch-ui {
  width: 38px; height: 21px; flex: 0 0 38px;
  border-radius: var(--r-lg);
  background: rgba(93, 139, 160, 0.3);
  border: 1px solid var(--glass-brd);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.d-switch-ui::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.d-switch input:checked + .d-switch-ui {
  background: rgba(0, 229, 255, 0.25);
  border-color: var(--glass-brd-hi);
}
.d-switch input:checked + .d-switch-ui::after {
  transform: translateX(17px);
  background: var(--cyan);
}
.d-switch input:focus-visible + .d-switch-ui { outline: 2px solid var(--cyan); outline-offset: 2px; }
.d-pill {
  font-weight: 800; font-size: var(--fs-xs); letter-spacing: 0.5px;
  padding: 7px 14px; cursor: pointer;
  color: var(--muted); background: transparent;
  border: 1px solid var(--glass-brd); border-radius: var(--r-lg);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.d-pill:hover { color: var(--cyan); border-color: var(--glass-brd-hi); background: rgba(0, 229, 255, 0.07); }
.d-imagery { margin-left: auto; font-size: 10.5px; letter-spacing: 1.2px; color: var(--faint); font-weight: 700; }
.d-imagery.offline { color: var(--muted); }
.d-imagery.sat { color: var(--cyan); }
.d-imagery.osm { color: var(--green); }

/* active state for the tiny satellite-map button (top-right) */
.icon-btn.on {
  color: var(--cyan);
  border-color: var(--glass-brd-hi);
  background: rgba(0, 229, 255, 0.10);
  box-shadow: var(--e1), 0 0 10px rgba(0, 229, 255, 0.22);
}

/* scrim: click-outside closes (mobile mainly; pointer-events pass-through off) */
.details-scrim {
  position: absolute; inset: 0; z-index: 45;
  background: transparent;
}

/* ─── Toast (fail-silent imagery fallbacks; same glass as the sentence) ─── */
.toast {
  position: absolute; z-index: 70;
  bottom: 150px; left: 50%; transform: translateX(-50%) translateY(8px);
  font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: 0.2px; color: var(--text);
  padding: 10px 20px;
  border: 1px solid rgba(234, 246, 255, 0.14);
  border-radius: var(--r-lg);
  background: rgba(4, 12, 22, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ─── 2-D fallback ────────────────────────────────────────────────────────── */
#fb {
  position: absolute; inset: 0; z-index: var(--z-fb);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
#fb.hidden { display: none; }
#fb-map {
  border: 1px solid var(--glass-brd); border-radius: var(--r-m);
  max-width: min(94vw, 980px); max-height: 72vh; width: auto;
  background: #020a14;
}

/* ═══ Responsive (phone 390×844 and up) ════════════════════════════════════ */
@media (max-width: 640px) {
  :root { --fs-sentence: 16.5px; }
  .wordmark { top: 10px; left: 12px; gap: 6px; }
  .wm-sub { display: none; }
  .top-actions { top: 10px; right: 10px; }
  .icon-btn { width: 34px; height: 34px; }
  .sentence-wrap { bottom: 76px; }
  .sentence { padding: 11px 18px; }
  .replay-bar {
    left: 10px; right: 10px; transform: none;
    flex-wrap: wrap; justify-content: center;
    border-radius: var(--r-m); gap: 8px; bottom: 10px;
  }
  .rp-track { order: 5; flex-basis: 100%; min-width: 0; }
  .rp-time { min-width: 0; }
  .details { width: min(340px, calc(100vw - 12px)); }
}
