/*
 * shared.css — WCAG 2.1 AA palette for all pages.
 *
 * Contrast ratios on #0d1118 (lum ~0.012):
 *   #b0c4d8 = ~9.5:1   body text
 *   #8fa4b8 = ~6.2:1   secondary
 *   #7a90a8 = ~4.8:1   labels, headers
 *   #e0eaf4 = ~14:1    values, emphasis
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0d1118;
  color: #b0c4d8;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- HEADER + NAV ---- */
#header {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; background: #111820;
  border-bottom: 1px solid #243040; flex-shrink: 0;
  flex-wrap: wrap;
}
#header h1 { font-size: 17px; font-weight: 600; color: #e0eaf4; }
#header h1 a { color: #e0eaf4; text-decoration: none; }
#header h1 a:hover { color: #b0c4d8; }

/* ---- HAMBURGER BUTTON ---- */
#nav-toggle {
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 4px;
  display: flex; flex-direction: column; gap: 4px;
  flex-shrink: 0;
}
#nav-toggle:hover { background: #1a2838; }
#nav-toggle:focus-visible { outline: 2px solid #5090e0; outline-offset: 2px; }
.ham-line {
  display: block; width: 18px; height: 2px;
  background: #7a90a8; border-radius: 1px;
  transition: background 0.15s;
}
#nav-toggle:hover .ham-line { background: #b0c4d8; }

/* Active page label in header */
#nav-active-label {
  font-size: 13px; color: #7a90a8;
  margin-left: 2px;
}

/* ---- NAV OVERLAY ---- */
#nav-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8, 12, 18, 0.60);
  z-index: 400;
  backdrop-filter: blur(1px);
}
#nav-overlay.open { display: block; }

/* ---- NAV SIDEBAR ---- */
#nav-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 260px;
  background: #0f1620;
  border-right: 1px solid #243040;
  z-index: 500;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
#nav-sidebar.open { transform: translateX(0); }

/* Sidebar header row */
#nav-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #1a2838;
  flex-shrink: 0;
}
#nav-sidebar-title {
  font-size: 15px; font-weight: 600; color: #e0eaf4;
}
#nav-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: #4a6070; padding: 4px 6px;
  border-radius: 3px; line-height: 1;
}
#nav-close:hover { color: #b0c4d8; background: #1a2838; }
#nav-close:focus-visible { outline: 2px solid #5090e0; outline-offset: 2px; }

/* Nav groups */
.nav-group {
  padding: 14px 0 6px;
  border-bottom: 1px solid #1a2838;
}
.nav-group:last-child { border-bottom: none; }

.nav-group-label {
  font-size: 10px; font-weight: 700; color: #4a6070;
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 0 16px 6px;
}

/* Nav items */
.nav-item {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 16px;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.nav-item:hover {
  background: #141e2c;
  border-left-color: #3a5060;
}
.nav-item.active {
  background: #111c2c;
  border-left-color: #5090e0;
}
.nav-item:focus-visible { outline: 2px solid #5090e0; outline-offset: -2px; }
.nav-item-label {
  font-size: 14px; color: #b0c4d8; font-weight: 500;
}
.nav-item.active .nav-item-label { color: #e0eaf4; font-weight: 600; }
.nav-item-desc {
  font-size: 12px; color: #4a6070;
}

/* ---- CHARTS ---- */
#charts {
  flex-shrink: 0;
  background: #111820;
  border-bottom: 1px solid #243040;
  padding: 16px 20px 12px;
  display: none;
}
.chart-container { margin-bottom: 14px; }
.chart-container:last-child { margin-bottom: 0; }
.chart-label {
  font-size: 12px; font-weight: 700; color: #7a90a8;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* ---- CONTENT ---- */
#content {
  flex: 1; overflow-y: auto; background: #0d1118;
  padding: 20px; font-size: 15px;
}

#loading {
  padding: 20px; font-size: 15px; color: #8fa4b8;
  text-align: center; display: none;
}

/* ---- RESULT SECTIONS ---- */
.result-section { margin-bottom: 20px; }
.result-section h3 {
  font-size: 13px; font-weight: 700; color: #7a90a8;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid #243040;
}
.summary-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 15px;
}
.summary-key { color: #8fa4b8; }
.summary-val { color: #e0eaf4; font-variant-numeric: tabular-nums; }

.result-row {
  padding: 8px 10px; margin: 3px 0; border-radius: 4px;
  background: #111820; font-size: 14px;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
}
.result-row.warm { border-left: 3px solid #e07050; }
.result-row.cool { border-left: 3px solid #5090e0; }
.result-row.gradient { border-left: 3px solid #90b050; }
.result-row.error { border-left: 3px solid #d0a040; }
.result-loc { color: #b0c4d8; min-width: 130px; }
.result-val { color: #e0eaf4; font-variant-numeric: tabular-nums; }
.result-sig { color: #8fa4b8; font-size: 13px; }
.result-empty { color: #7a90a8; font-style: italic; padding: 6px 0; }

.context-note {
  font-size: 14px; color: #8fa4b8; line-height: 1.6;
  margin-top: 12px; padding: 12px 14px;
  background: #111820; border-radius: 6px;
  border-left: 3px solid #4a6080;
}

/* ---- FOCUS ---- */
:focus-visible {
  outline: 2px solid #5090e0;
  outline-offset: 2px;
}

/* ---- FORCING LINK (Attribution deep link from Event Detection) ---- */
.forcing-link {
  font-size: 12px; color: #7a90a8; text-decoration: none;
  padding: 2px 8px; border-radius: 3px;
  background: #1a2838; margin-left: 6px;
  white-space: nowrap;
}
.forcing-link:hover { color: #b0c4d8; background: #243040; }

/* ---- TIMELINE ---- */
/* Used by: global, global-anomaly, city, events, transport, predict */
#timeline { flex-shrink: 0; }


/* ---- MODE BADGE ---- */
/* Used by: global, global-anomaly, predict */
#mode-badge {
  font-size: 13px; padding: 3px 10px; border-radius: 10px;
  background: #1a2838; color: #7a90a8;
}
#mode-badge.active { background: #1a3050; color: #7cb8e0; }


/* ---- HELP TEXT ---- */
/* Used by: global, global-anomaly */
.help {
  margin-left: auto; font-size: 13px; color: #7a90a8;
}


/* ---- KBD ---- */
/* Used by: global, global-anomaly (accountability uses a darker variant — override in page CSS) */
kbd {
  background: #1a2838; border: 1px solid #304050; border-radius: 3px;
  padding: 2px 6px; font-family: inherit; font-size: 12px; color: #8fa4b8;
}


/* ---- PAGE DESCRIPTION STRIP ---- */
/* Used by: events, transport, predict */
#page-description {
  background: #0d1118;
  padding: 12px 20px 8px;
  flex-shrink: 0;
}


/* ---- DRIVER TAGS ---- */
/* Used by: global, events */
.driver-tag {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 3px;
  margin-left: 4px; vertical-align: middle;
}
.driver-sw   { background: #3a2a10; color: #e0a040; }
.driver-lw   { background: #1a2a3a; color: #60b0e0; }
.driver-both { background: #2a1a30; color: #c080d0; }
.driver-net  { background: #1a2a20; color: #80c090; }


/* ---- LOADING OVERLAY ---- */
/* Used by: global, global-anomaly */
#loading-overlay {
  position: fixed; inset: 0; background: rgba(13,17,24,0.94);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; z-index: 200; gap: 14px;
}
#loading-overlay.hidden { display: none; }


/* ---- SPINNER ---- */
/* Used by: global, global-anomaly, imbalance */
.spinner {
  width: 36px; height: 36px; border: 3px solid #243040;
  border-top-color: #5090e0; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ---- INTRO MODAL ---- */
/* Used by: global, global-anomaly                                    */
/* max-width of .intro-card differs per page — set in page CSS        */
/* city uses .modal-card; events uses .config-card — separate classes */
.intro-card {
  background: #141c28;
  border: 1px solid #304050;
  border-radius: 10px;
  padding: 32px 36px;
  width: 90%;
}
.intro-card h2 {
  font-size: 20px; font-weight: 700; color: #e0eaf4;
  margin-bottom: 14px;
}
.intro-card p {
  font-size: 15px; color: #b0c4d8; line-height: 1.6;
  margin-bottom: 12px;
}
.intro-card .intro-highlight { color: #e0eaf4; font-weight: 600; }
.intro-card .intro-detail {
  font-size: 13px; color: #8fa4b8; line-height: 1.5;
  margin-bottom: 20px;
}
.intro-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #1a4070; border: 1px solid #2a5090;
  color: #e0eaf4; font-size: 16px; font-weight: 600;
  padding: 10px 24px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s;
}
.intro-btn:hover { background: #205090; }
.intro-btn:focus-visible { outline: 2px solid #5090e0; outline-offset: 2px; }
.intro-btn kbd {
  background: #0d1118; border: 1px solid #304050; border-radius: 3px;
  padding: 2px 8px; font-size: 13px; color: #8fa4b8;
}


/* ---- RESOLUTION / CONFIG SLIDER ---- */
/* Used by: global, global-anomaly, events                            */
/* .intro-slider-group is the global/anomaly name;                    */
/* events uses .config-slider-group — same styles, different class    */
.intro-slider-group,
.config-slider-group {
  margin: 16px 0 20px;
  padding: 14px 16px;
  background: #111820;
  border-radius: 6px;
  border: 1px solid #243040;
}
.intro-slider-group label,
.config-slider-group label {
  display: block;
  font-size: 13px; font-weight: 600; color: #8fa4b8;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.slider-row {
  display: flex; align-items: center; gap: 12px;
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: #5090e0;
  height: 6px;
}
.slider-value {
  font-size: 18px; font-weight: 700; color: #e0eaf4;
  min-width: 40px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.slider-hint {
  font-size: 12px; color: #7a90a8; margin-top: 6px;
}
