/* Public dataset explorer. Tokens and shared components come from /assets/base.css. */

:root {
  /* Discrepancy counts use one warm hue so they read apart from coverage (accent). */
  --chart-flag: #b5562b;
  --chart-track: var(--surface-sunken);
}

html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: calc(var(--sticky-top) + 12px); }

.live-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--text-sm); font-weight: 500; white-space: nowrap; }
.live-indicator span { width: 7px; height: 7px; background: var(--success); border-radius: 50%; box-shadow: 0 0 0 3px var(--success-soft); }

/* Sections */
.section-shell { max-width: 1320px; margin: auto; padding: 36px 32px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 20px; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: clamp(26px, 3vw, 34px); font-weight: 600; letter-spacing: -0.02em; }
.section-heading > p { max-width: 460px; margin: 0; color: var(--muted); font-size: var(--text-md); }
.panel-kicker { margin: 0 0 4px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

/* Headline metrics */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.metric { min-height: 132px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius-lg); }
.metric-label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.metric strong { display: block; margin: 10px 0 6px; font-family: var(--font-mono); font-size: clamp(30px, 3vw, 40px); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1; }
.metric p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.skeleton { background: linear-gradient(100deg, var(--surface-sunken) 30%, var(--surface-muted) 50%, var(--surface-sunken) 70%); background-size: 300% 100%; animation: shimmer 1.6s infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* Charts */
.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-wide { grid-column: 1 / -1; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 20px; }
.panel-heading h3 { margin: 0; font-size: var(--text-lg); }
.panel-note, .chart-caption { color: var(--muted); font-size: var(--text-xs); }
.chart-caption { margin: 18px 0 0; }
.coverage-chart { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.coverage-item { padding: 14px 16px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--radius); }
.coverage-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.coverage-top strong { font-size: var(--text-sm); font-weight: 600; text-transform: capitalize; }
.coverage-top span { font-family: var(--font-mono); font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
.track { height: 6px; overflow: hidden; background: var(--chart-track); border-radius: 999px; }
.track > span { display: block; width: var(--value); height: 100%; background: var(--accent); border-radius: inherit; animation: grow 0.7s ease-out both; }
@keyframes grow { from { width: 0; } }
.bar-chart { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 145px) 1fr 52px; align-items: center; gap: 12px; font-size: var(--text-sm); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; overflow: hidden; background: var(--chart-track); border-radius: 999px; }
.bar-fill { display: block; width: var(--value); height: 100%; background: var(--accent); border-radius: inherit; animation: grow 0.7s ease-out both; }
.bar-count { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); font-variant-numeric: tabular-nums; text-align: right; }
.warm .bar-fill { background: var(--chart-flag); }

/* Dataset review */
.analysis-review { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--line); }
.review-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.review-heading h2 { margin: 0; font-size: clamp(22px, 2.5vw, 28px); font-weight: 600; letter-spacing: -0.02em; }
.review-heading p { margin: 10px 0 0; color: var(--muted); }
.review-heading code { padding: 1px 5px; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); font-size: var(--text-xs); }
.review-heading > span { max-width: 360px; color: var(--muted); font-size: var(--text-xs); text-align: right; }
.review-source { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.review-stat { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--warning-line); border-radius: var(--radius); }
.review-stat span { display: block; min-height: 32px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; line-height: 1.35; text-transform: uppercase; }
.review-stat strong { display: inline-block; margin-top: 6px; font-family: var(--font-mono); font-size: var(--text-2xl); font-weight: 500; font-variant-numeric: tabular-nums; }
.review-stat small { margin-left: 6px; color: var(--warning); font-family: var(--font-mono); font-size: var(--text-xs); }
.review-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(240px, 1fr); gap: 14px; align-items: start; }
.review-pillars { display: grid; gap: 8px; }
.review-pillar { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.review-pillar summary { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 18px; cursor: pointer; list-style: none; }
.review-pillar summary::-webkit-details-marker { display: none; }
.review-pillar summary:hover { background: var(--surface-muted); }
.review-pillar-title { display: flex; align-items: center; gap: 10px; font-size: var(--text-lg); font-weight: 600; text-transform: capitalize; }
.review-chevron { display: grid; place-items: center; width: 22px; height: 22px; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 15px; transition: transform 0.15s; }
.review-pillar[open] .review-chevron { transform: rotate(45deg); }
.review-rate { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; }
.review-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.review-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.review-table th, .review-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.review-table th { color: var(--muted); background: var(--surface-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.review-table tbody tr:last-child td { border-bottom: 0; }
.review-table tbody tr:hover td { background: var(--surface-muted); }
.review-table td:first-child { color: var(--ink); font-family: var(--font-mono); font-size: var(--text-xs); }
.review-table .numeric { width: 80px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.review-table .review-note { max-width: 280px; color: var(--muted); }
.review-sidebar { position: sticky; top: calc(var(--sticky-top) + 16px); display: grid; gap: 10px; }
.review-aside-card { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.review-aside-card h3 { margin: 0 0 12px; font-size: var(--text-base); }
.platform-review-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.platform-review-row:last-child { border-bottom: 0; }
.platform-review-row span { color: var(--ink-soft); }
.platform-review-row strong { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.platform-review-row small { display: block; color: var(--muted); font-family: var(--font-mono); text-align: right; }
.limitation-card { border-left: 3px solid var(--warning-line); }
.limitation-card p { margin: 0; color: var(--muted); font-size: var(--text-sm); }

/* Location map */
.location-section { max-width: 1320px; margin: auto; padding: 36px 32px; }
.section-heading.inverse > p { color: var(--muted); }
.map-frame { position: relative; min-height: 520px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
#location-map { display: block; width: 100%; height: 520px; cursor: crosshair; }
.map-key { position: absolute; right: 14px; bottom: 14px; padding: 6px 11px; color: var(--ink-soft); background: rgb(255 255 255 / 92%); border: 1px solid var(--line); border-radius: var(--radius); font-size: var(--text-xs); }
.map-key strong { font-family: var(--font-mono); font-weight: 600; }
.map-key span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; background: var(--accent); border-radius: 50%; }
.map-tooltip { position: absolute; z-index: 2; width: min(260px, 70vw); padding: 9px 11px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: var(--text-xs); pointer-events: none; }
.map-tooltip strong { display: block; margin-bottom: 2px; font-size: var(--text-sm); }

/* Record explorer */
.explorer-section { padding-bottom: 96px; }
.filters {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.filters label { gap: 4px; }
.filters label > span { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.filters input, .filters select { min-height: 38px; }
.search-field { position: relative; }
.search-field svg { position: absolute; bottom: 10px; left: 11px; width: 18px; fill: none; stroke: var(--faint); stroke-width: 1.8; }
.filters .search-field input { padding-left: 36px; }
.clear-button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: var(--text-md);
  font-weight: 600;
}
.clear-button:hover { background: var(--surface-muted); border-color: var(--faint); }
.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.record-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 18px 18px 54px;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.record-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.platform-badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; color: var(--ink-soft); background: var(--surface-sunken); border-radius: 999px; font-size: var(--text-xs); font-weight: 600; }
.platform-badge::before { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; content: ""; }
.claim-id { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.record-card h3 { margin: 0 0 12px; font-size: var(--text-base); font-weight: 600; line-height: 1.4; }
.record-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 14px; color: var(--muted); font-size: var(--text-sm); }
.record-meta span::before { margin-right: 5px; color: var(--faint); content: "•"; }
.flag-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-right: 44px; }
.flag { max-width: 100%; padding: 1px 8px; overflow: hidden; color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: 999px; font-size: var(--text-xs); font-weight: 600; text-overflow: ellipsis; text-transform: capitalize; white-space: nowrap; }
.no-flags { margin-top: auto; color: var(--success); font-size: var(--text-xs); }
.completion { position: absolute; right: 16px; bottom: 14px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--chart-track) 0); }
.completion::before { position: absolute; inset: 4px; background: var(--surface); border-radius: 50%; content: ""; }
.completion span { position: relative; font-family: var(--font-mono); font-size: 10px; font-weight: 600; }
.empty-state { margin-top: 14px; padding: 56px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.empty-state > span { color: var(--faint); font-size: 44px; }
.empty-state h3 { margin: 4px 0 0; font-size: var(--text-xl); }
.empty-state p { color: var(--muted); }
.empty-state button { min-height: 36px; padding: 7px 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); font-weight: 600; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 5px; margin-top: 24px; }
.pagination button, .pagination span {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.pagination span { background: transparent; border-color: transparent; }
.pagination button:hover:not(:disabled) { background: var(--surface-muted); }
.pagination button[aria-current="page"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.pagination button:disabled { cursor: default; opacity: 0.4; }

footer { display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 26px 32px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line); font-size: var(--text-sm); }
.footer-brand { color: var(--ink); }
footer a { color: var(--accent); text-decoration: none; }

/* Record detail dialog */
.record-dialog { width: min(1180px, calc(100vw - 28px)); max-width: none; height: min(880px, calc(100vh - 28px)); max-height: none; overflow: hidden; background: var(--bg); }
.dialog-bar { display: flex; justify-content: space-between; align-items: center; height: 52px; padding: 0 14px 0 22px; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--line); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.dialog-bar button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); font-size: 20px; line-height: 1; }
.dialog-bar button:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.dialog-content { height: calc(100% - 52px); overflow: auto; }
.detail-hero { padding: 28px clamp(20px, 4vw, 48px); background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-hero h2 { max-width: 920px; margin: 10px 0 14px; font-size: clamp(22px, 2.6vw, 30px); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.detail-media { padding: 20px clamp(18px, 4vw, 48px); color: #fff; background: #0d1117; }
.detail-video-frame { display: grid; place-items: center; min-height: 240px; overflow: hidden; background: #000; border: 1px solid rgb(255 255 255 / 12%); border-radius: var(--radius); }
.detail-video-frame video { display: block; width: 100%; max-height: min(52vh, 520px); background: #000; }
.detail-media-caption { display: flex; justify-content: space-between; gap: 20px; padding-top: 10px; color: rgb(255 255 255 / 65%); font-size: var(--text-xs); }
.detail-media-caption strong { margin-right: 6px; color: #8fd3dc; font-weight: 600; }
.detail-video-error { margin: 10px 0 0; padding: 8px 10px; color: #ffd6d1; background: rgb(177 53 43 / 30%); border-radius: var(--radius-sm); font-size: var(--text-xs); }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font-size: var(--text-sm); }
.detail-meta a { color: var(--accent); }
.detail-body { padding: 24px clamp(18px, 4vw, 48px) 56px; }
.comparison-grid { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 14px; align-items: start; }
.detail-panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.detail-panel-title { display: flex; justify-content: space-between; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.detail-panel-title h3 { margin: 0; font-size: var(--text-lg); }
.dataset-label { padding: 1px 8px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; font-size: var(--text-xs); font-weight: 600; }
.original-content { padding: 18px; }
.fact-rating { display: inline-block; margin-bottom: 14px; padding: 2px 10px; color: var(--on-accent); background: var(--accent); border-radius: 999px; font-size: var(--text-xs); font-weight: 600; }
.original-content h4 { margin: 0 0 6px; color: var(--muted); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; }
.original-content p { margin: 0 0 18px; color: var(--ink-soft); font-size: var(--text-md); }
.external-link { display: inline-flex; margin-bottom: 18px; color: var(--accent); font-size: var(--text-sm); font-weight: 600; }
details { border-top: 1px solid var(--line); }
details summary { padding: 11px 0; cursor: pointer; color: var(--accent); font-size: var(--text-sm); font-weight: 600; }
.article-content { max-height: 280px; overflow: auto; padding-right: 8px; white-space: pre-line; }
.pillar-list { display: grid; }
.pillar { border-bottom: 1px solid var(--line); }
.pillar:last-child { border-bottom: 0; }
.pillar summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; color: var(--ink); list-style: none; }
.pillar summary::-webkit-details-marker { display: none; }
.pillar summary::before { display: grid; place-items: center; width: 22px; height: 22px; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); content: "+"; }
.pillar[open] summary::before { content: "−"; }
.pillar-name { color: var(--ink); font-size: var(--text-base); font-weight: 600; text-transform: capitalize; }
.pillar-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; padding: 0 18px 16px 52px; }
.field { min-width: 0; padding: 9px 0; border-top: 1px solid var(--line); }
.field dt { margin-bottom: 3px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.field dd { margin: 0; overflow-wrap: anywhere; font-size: var(--text-md); }
.field a { color: var(--accent); }
.null-value { color: var(--faint); font-style: italic; }
.value-list { display: flex; flex-wrap: wrap; gap: 4px; }
.value-chip { padding: 1px 7px; background: var(--surface-sunken); border-radius: var(--radius-sm); font-size: var(--text-xs); }
.raw-json { margin-top: 14px; padding: 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.raw-json pre { max-height: 400px; overflow: auto; font-size: var(--text-xs); white-space: pre-wrap; }
.dialog-loading { display: grid; place-items: center; height: 100%; color: var(--muted); }

@media (max-width: 1050px) {
  .metrics, .review-source { grid-template-columns: 1fr 1fr; }
  .coverage-chart { grid-template-columns: repeat(3, 1fr); }
  .review-layout { grid-template-columns: 1fr; }
  .review-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 2fr 1fr 1fr; }
  .clear-button { width: 100%; }
  .record-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app-header-end .live-indicator { display: none; }
  .section-shell, .location-section { padding: 28px 14px; }
  .section-heading, .review-heading { display: block; }
  .section-heading > p { margin-top: 10px; }
  .review-heading > span { display: block; margin-top: 10px; text-align: left; }
  .insight-grid, .comparison-grid, .review-sidebar, .pillar-fields, .record-grid { grid-template-columns: 1fr; }
  .panel-wide { grid-column: auto; }
  .coverage-chart, .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  #location-map { height: 380px; }
  .map-frame { min-height: 380px; }
  footer { flex-direction: column; align-items: start; padding: 24px 14px; }
}
@media (max-width: 460px) {
  .metrics, .coverage-chart, .review-source, .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .bar-row { grid-template-columns: 90px 1fr 42px; }
}
