/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: "Ubuntu", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --sidebar-w: 260px;
  --group-1a: #1f77b4;
  --group-1b: #2ca02c;
  --group-2a: #ff7f0e;
  --group-2b: #d62728;
  --group-x: #7f7f7f;
  --db-tiny: #9b59b6;
  --db-small: #3498db;
  --db-medium: #e67e22;
  --db-large: #e74c3c;
  --db-1bit: #17becf;

  /* Light theme */
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --bg-card: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --link: #0969da;
  --shadow: rgba(31,35,40,0.08);
  --overlay: rgba(0,0,0,0.7);
  --sidebar-bg: #f6f8fa;
  --sidebar-active: #ffffff;
  --nav-hover: #eaeef2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --bg-card: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --link: #58a6ff;
    --shadow: rgba(0,0,0,0.3);
    --overlay: rgba(0,0,0,0.85);
    --sidebar-bg: #161b22;
    --sidebar-active: #21262d;
    --nav-hover: #21262d;
  }
}

html { scroll-padding-top: 24px; }
html.smooth { scroll-behavior: smooth; }
/* Hide content until charts render (prevents anchor-scroll jank) */
.content.loading { opacity: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a {
  display: block;
  padding: 7px 20px;
  font-size: 13px;
  color: var(--text-muted);
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar nav a:hover {
  background: var(--nav-hover);
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--sidebar-active);
  color: var(--text);
  border-left-color: var(--link);
  font-weight: 600;
}
.sidebar nav .divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

/* ── Hamburger ───────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 1px 3px var(--shadow);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 90;
}

/* ── Content ─────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  padding: 40px 48px 80px;
  max-width: 1200px;
}

section { margin-bottom: 56px; }
hr.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}
section > h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 8px;
}
section > .subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 24px;
}
h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 32px 0 12px;
}
section > h2 > a,
h3 > a,
h4 > a {
  color: inherit;
  text-decoration: none;
}
section > h2 > a:hover,
h3 > a:hover,
h4 > a:hover {
  text-decoration: none;
}
h4 {
  font-size: 19px;
  font-weight: 600;
  margin: 34px 0 2px;
}

/* ── Chart Containers ───────────────────────────────── */
.chart-container {
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  overflow-anchor: none;
  margin: 16px 0;
  min-height: 350px;
  min-width: 0;
}
.chart-container.wide {
  min-height: 700px;
  overflow-x: auto;
}
.chart-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 16px 0;
}
.chart-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 16px;
  line-height: 1.5;
}
.badge-legend {
  font-style: italic;
}

/* ── Radar Tabs & Grid ──────────────────────────────── */
.radar-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.radar-tab {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.radar-tab:hover {
  background: var(--nav-hover);
  color: var(--text);
}
.radar-tab.active {
  background: var(--bg-alt);
  color: var(--text);
  font-weight: 600;
  border-color: var(--link);
  box-shadow: 0 1px 3px var(--shadow);
}
.radar-mode-tabs {
  display: none;
  justify-content: center;
  margin: 18px 0 6px;
}
.radar-mode-tabs-inner {
  display: inline-flex;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.radar-mode-tab {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.radar-mode-tab:hover:not(.active) {
  background: var(--bg-alt);
}
.radar-mode-tab.active {
  background: var(--link);
  color: #fff;
  font-weight: 500;
}
.radar-tier-legend {
  display: none;
}
.radar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 16px;
  row-gap: 40px;
  margin-top: 24px;
}

/* ── Dimension Filters (DB size + Entry size) ─────────── */
.dim-tabs-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 16px;
}
.dim-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dim-filter-label {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 62px;
  transition: color 0.15s;
}
.dim-filter-row.has-active .dim-filter-label {
  color: var(--text);
}
.dim-filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dim-filter-btn {
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 11px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.dim-filter-btn:hover {
  background: var(--nav-hover);
  color: var(--text);
}
.dim-filter-btn.active {
  background: var(--bg-alt);
  color: var(--text);
  font-weight: 600;
  border-color: var(--link);
}
.rank-explainer-toggle {
  margin: 4px 0 8px;
}
.rank-explainer-toggle summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #555;
  list-style: none;
  text-align: center;
}
/* Metric note (collapsible) */
.metric-note {
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}
.metric-note summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--group-1a);
  list-style: none;
  display: flex;
  align-items: center;
}
.metric-note summary::before {
  content: '▸';
  font-size: 30px;
  margin-right: 6px;
  margin-top: -4px;
  flex-shrink: 0;
}
.metric-note[open] summary::before {
  content: '▾';
  font-size: 30px;
  margin-top: -4px;
}
.metric-note summary::-webkit-details-marker { display: none; }
.metric-note p {
  margin: 10px 0 8px;
  padding: 0 8px;
}
.evidence-table {
  margin: 10px 8px 12px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.evidence-table th,
.evidence-table td {
  padding: 4px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.evidence-table th {
  background: var(--bg-alt);
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .metric-note summary { color: var(--group-1a); }
}

.rank-explainer-toggle summary::before {
  content: '▸ ';
  font-size: 16px;
}
.rank-explainer-toggle[open] summary::before {
  content: '▾ ';
  font-size: 16px;
}
.rank-explainer-toggle summary::-webkit-details-marker { display: none; }
@media (prefers-color-scheme: dark) {
  .rank-explainer-toggle summary { color: #aaa; }
}
.rank-explainer {
  margin: 8px 0 4px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.rank-explainer p { margin: 0 0 8px; }
.rank-explainer ol { margin: 0 0 8px; padding-left: 20px; }
.rank-explainer li { margin-bottom: 4px; }
.rank-explainer code {
  font-size: 11.5px;
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
}
.construction-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 8px;
  align-items: center;
}
.construction-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.construction-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.db-size-pill {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin: 0 1px;
  border: 1px solid;
  white-space: nowrap;
}
.radar-cell {
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  min-height: 300px;
  min-width: 0;
}

/* ── Filter Row ─────────────────────────────────────── */
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 16px;
}
.filter-row-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-pill {
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 12px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0.4;
  text-decoration: line-through;
}
.filter-pill.active {
  background: var(--bg-alt);
  color: var(--text);
  font-weight: 600;
  opacity: 1;
  text-decoration: none;
}
.filter-pill:hover {
  opacity: 0.8;
}
.filter-clear {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 2px;
  padding: 4px 8px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
}
.filter-clear:hover {
  background: var(--nav-hover);
  color: var(--text);
  text-decoration: none;
}

/* ── Focus & Accessibility ────────────────────────────── */
a:focus-visible, button:focus-visible, .radar-tab:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* ── Loading ─────────────────────────────────────────── */
.chart-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Tables ──────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 12px 0 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--bg-alt);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  z-index: 1;
  user-select: none;
  cursor: pointer;
}
thead th:hover {
  background: var(--nav-hover);
}
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
tbody tr:nth-child(even) { background: var(--bg-alt); }
tbody tr:hover { background: var(--nav-hover); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Inline Table (no outer border) ──────────────────── */
.inline-table {
  width: auto;
  margin: 8px 0 4px;
  border: none;
}
.inline-table thead th {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: default;
}
.inline-table thead th:hover {
  background: transparent;
}
.inline-table tbody td {
  font-size: 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.inline-table tbody tr:nth-child(even) { background: transparent; }
.inline-table tbody tr:last-child td { border-bottom: none; }

/* ── Group Dot (catalog) ────────────────────────────── */
.group-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── Tier Legend (inline, catalog) ───────────────────── */
.tier-legend-inline {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 16px;
}
.tier-legend-inline strong {
  color: var(--text);
  margin-right: 3px;
}

/* ── Data Sources Toggle ────────────────────────────── */
.data-sources-toggle {
  margin: 0 0 4px;
  font-size: 14px;
}
.data-sources-toggle summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  padding: 4px 0;
  line-height: 1.6;
}
.data-sources-toggle summary:hover {
  color: var(--text);
}
.data-sources-toggle .table-wrap {
  margin: 8px 0 4px;
}

/* ── Description ─────────────────────────────────────── */
.desc {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 82ch;
  line-height: 1.7;
}
.links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 13px;
}
.links a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: background 0.15s;
}
.links a:hover { background: var(--bg-alt); text-decoration: none; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 960px) {
  .chart-pair { grid-template-columns: 1fr; }
  .radar-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: block; }
  .content {
    margin-left: 0;
    padding: 60px 16px 80px;
  }
  .chart-container {
    min-height: 280px;
  }
  .chart-container.wide {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 400px;
  }
  /* Larger touch targets for filter pills & tabs */
  .filter-pill {
    font-size: 13px;
    padding: 8px 14px;
    min-height: 36px;
  }
  .radar-tab {
    font-size: 13px;
    padding: 10px 14px;
    min-height: 40px;
  }
  .dim-tab {
    font-size: 12px;
    padding: 6px 10px;
    min-height: 32px;
  }
  /* Stack tier legend vertically */
  .tier-legend-inline {
    flex-direction: column;
    gap: 4px;
  }
  /* Smaller table text */
  table { font-size: 12px; }
  thead th { padding: 8px 8px; }
  tbody td { padding: 6px 8px; }
  /* Radar cells shorter on mobile */
  .radar-cell { min-height: 260px; }
  /* Description text */
  .desc { font-size: 14px; }
  section > .subtitle { font-size: 14px; }
  h3 { font-size: 18px; }
  /* Dim tabs: stack tab groups vertically */
  .dim-tabs-container { flex-direction: column; gap: 10px; }
  /* Secondary pills: larger touch targets */
  .secondary-pill { font-size: 12px; padding: 5px 12px; min-height: 30px; }
  /* Evidence table: horizontal scroll on narrow screens */
  .metric-note { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .evidence-table { min-width: 420px; }
  /* Page nav tiles */
  .page-nav-tiles { flex-wrap: wrap; }
  .page-nav-tile { font-size: 12px; padding: 12px 16px; }
  .page-nav-tile.home { font-size: 18px; padding: 12px 14px; }
  .page-nav-tiles.overview-grid { grid-template-columns: repeat(2, 1fr); }
  .page-nav-tiles.overview-grid .page-nav-tile { padding: 20px 16px; font-size: 13px; }
}

@media (max-width: 480px) {
  section > h2 { font-size: 22px; }
  .content { padding: 56px 12px 60px; }
  .filter-pill {
    font-size: 12px;
    padding: 6px 10px;
  }
  .links { gap: 8px; }
  .links a { padding: 8px 12px; font-size: 12px; }
  .chart-note { font-size: 12px; }
  .data-sources-toggle summary { font-size: 14px; }
  /* Dim tabs: smaller on very narrow screens */
  .dim-tab { font-size: 11px; padding: 5px 8px; }
  /* Overview grid: single column */
  .page-nav-tiles.overview-grid { grid-template-columns: 1fr; }
  .page-nav-tiles.overview-grid .page-nav-tile { padding: 16px 12px; font-size: 13px; }
  /* Metric note toggle text */
  .metric-note summary { font-size: 13px; }
  .metric-note summary::before { font-size: 22px; }
  .metric-note[open] summary::before { font-size: 22px; }
}

/* ── Nav Sections (shared sidebar) ─────────────────────── */
.nav-section {
  margin-bottom: 2px;
}
.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.nav-section-link {
  display: block;
  flex: 1;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.nav-section-link:hover {
  color: var(--text);
  text-decoration: none;
}
.nav-section.active .nav-section-link {
  color: var(--text);
}
.nav-arrow {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.15s;
}
.nav-arrow:hover {
  background: var(--nav-hover);
  color: var(--text);
}
.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.nav-submenu.open {
  max-height: 400px;
}
.nav-submenu .nav-link {
  display: block;
  padding: 5px 20px 5px 48px;
  font-size: 13px;
  color: var(--text-muted);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-submenu .nav-link:hover {
  background: var(--nav-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-submenu .nav-link.active {
  background: var(--sidebar-active);
  color: var(--text);
  border-left-color: var(--link);
  font-weight: 600;
}
.nav-nested-group {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.nav-nested-group.open {
  max-height: 300px;
}
.nav-submenu .nav-nested {
  padding-left: 64px;
  font-size: 12px;
}
.nav-coming-soon {
  display: block;
  padding: 5px 20px 5px 48px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.7;
}
.nav-bottom-link {
  display: block;
  padding: 7px 20px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-bottom-link:hover {
  background: var(--nav-hover);
  color: var(--text);
  text-decoration: none;
}

/* ── Section Cards (landing page) ──────────────────────── */
.section-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 32px 0;
}
.section-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.section-card:hover {
  border-color: var(--link);
  box-shadow: 0 4px 12px var(--shadow);
  text-decoration: none;
}
.section-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.section-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}
.card-status {
  margin-top: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--link);
}
.coming-soon-label {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}


/* ── Page Navigation Tiles ──────────────────────────────── */
.page-nav-tiles {
  display: flex;
  gap: 12px;
  margin: 48px 0 24px;
}
.page-nav-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 24px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.page-nav-tile:hover {
  background: var(--bg-alt);
  border-color: var(--link);
  text-decoration: none;
}
.page-nav-tile.home {
  font-size: 22px;
  padding: 14px 18px;
  line-height: 1;
}
.page-nav-tile.prev::before { content: '\2190\00a0'; }
.page-nav-tile.next::after { content: '\00a0\2192'; }

/* Overview page: grid of all sub-page tiles */
.page-nav-tiles.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 32px 0 24px;
}
.page-nav-tiles.overview-grid .page-nav-tile {
  padding: 28px 24px;
  font-size: 15px;
}
/* ── Coming Soon Message ───────────────────────────────── */
.coming-soon-msg {
  text-align: center;
  font-size: 24px;
  color: var(--text-muted);
  opacity: 0.5;
  margin: 80px 0;
  font-style: italic;
}

/* ── Responsive — cards ───────────────────────────────── */
@media (max-width: 900px) {
  .section-cards {
    grid-template-columns: 1fr;
  }
}
