/* app.css — AI Energy Index. Venturi light editorial aesthetic.
   WCAG 2.1 AA: >=4.5:1 contrast, focus-visible, prefers-reduced-motion, print-friendly.
   All styling external (style-src 'self'); no inline styles in HTML/JS data. */

:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #52606d;
  --faint: #6b7785;
  --line: #d8dee8;
  --soft-line: #edf1f6;
  --surface: #ffffff;
  --panel: #f7f9fc;
  --panel-strong: #eef4fa;
  --accent: #0f5c6f;
  --accent-2: #7a4b16;
  --bad: #9f1239;
  --good: #146c43;
  --warn: #8a4b00;
  --focus: rgba(15, 92, 111, .32);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f7fa;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: linear-gradient(180deg, #f6f9fc 0%, #ffffff 40%, #f8fafc 100%);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }

/* --- Accessibility primitives --- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px;
  text-decoration: none; font-weight: 700; transition: top .12s ease;
}
.skip-link:focus { top: 8px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}

/* --- Header / nav --- */
.site-header {
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(140%) blur(4px);
}
.site-header-inner {
  width: min(100%, 1320px); margin: 0 auto;
  padding: 14px clamp(16px, 3vw, 40px);
  display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: center; justify-content: space-between;
}
.brand { display: grid; gap: 1px; }
.brand-mark { font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--accent); text-transform: uppercase; }
.brand-title { font-size: 21px; font-weight: 820; line-height: 1.05; }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.main-nav { min-width: 0; }
.nav-list { list-style: none; display: flex; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; }
.nav-list a {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 13px;
  border-radius: 999px; text-decoration: none; color: var(--muted);
  font-size: 14px; font-weight: 680; border: 1px solid transparent;
}
.nav-list a:hover { color: var(--ink); background: var(--panel); text-decoration: none; }
.nav-list a.active {
  color: var(--accent); background: var(--panel-strong);
  border-color: rgba(15, 92, 111, .25); font-weight: 760;
}

/* --- Main layout --- */
.app-main {
  width: min(100%, 1320px); margin: 0 auto;
  padding: clamp(20px, 3vw, 36px) clamp(16px, 3vw, 40px) 56px;
  display: grid; gap: 22px;
}
.app-main:focus { outline: none; }
.loading { color: var(--muted); }

.view-header { display: grid; gap: 6px; }
.view-title { margin: 0; font-size: clamp(26px, 3.2vw, 40px); line-height: 1.05; letter-spacing: -.01em; }
.view-sub { margin: 0; color: var(--muted); max-width: 70ch; font-size: clamp(15px, 1.2vw, 17px); }
.breadcrumb { margin: 0; font-size: 14px; }
.section-h { margin: 8px 0 2px; font-size: 20px; }

/* --- Notices / banners --- */
.notice {
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px;
  background: var(--surface); padding: 13px 16px; font-size: 14.5px; color: var(--ink);
}
.notice-warn { border-left-color: var(--warn); background: #fffaf2; }
.notice-bad { border-left-color: var(--bad); background: #fdf2f5; }
.notice-good { border-left-color: var(--good); background: #f1f9f4; }
.notice strong { color: var(--ink); }

.coverage-banner {
  border: 1px solid rgba(15, 92, 111, .25); background: var(--panel-strong);
  border-radius: 8px; padding: 12px 16px; font-size: 14.5px;
}
.coverage-banner .muted { color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- Filter bar --- */
.filter-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); padding: 16px;
}
.filter-field { display: grid; gap: 5px; min-width: 0; }
.filter-field label { font-size: 12px; font-weight: 760; color: var(--ink); text-transform: uppercase; letter-spacing: .02em; }
.filter-select {
  width: 100%; min-height: 40px; border: 1px solid #c2ccd9; border-radius: 7px;
  padding: 0 30px 0 11px; background: var(--surface); color: var(--ink);
}
.filter-reset { align-content: end; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  font-weight: 740; text-decoration: none; font-size: 14px;
}
.btn:hover { background: #000; text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: #c2ccd9; }
.btn-ghost:hover { background: var(--panel); }
.btn-reset { min-height: 40px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.result-count { font-size: 14px; font-weight: 700; color: var(--muted); }
.downloads { display: flex; gap: 10px; }

/* --- Cards / panels --- */
.chart-card, .table-card, .panel, .metric-card, .equiv-card, .method-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.chart-card { padding: 16px 18px; }
.chart-title { margin: 0 0 2px; font-size: 17px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chart-sub { margin: 0 0 10px; font-size: 13px; }
.chart-legend { margin: 8px 0 0; font-size: 12.5px; }
.panel { padding: 16px 18px; }
.panel-h { margin: 0 0 10px; font-size: 16px; }

/* --- Metric grid / cards --- */
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-card { padding: 16px; display: grid; gap: 6px; border-top: 3px solid var(--accent); }
.metric-card-lg { border-top-color: var(--accent-2); }
.metric-label { font-size: 12.5px; font-weight: 760; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; display: flex; align-items: center; gap: 6px; }
.metric-value { font-size: clamp(26px, 3vw, 38px); line-height: 1; font-weight: 820; font-variant-numeric: tabular-nums; }
.metric-value.metric-null { color: var(--faint); font-weight: 600; }
.metric-unit { font-size: 13px; color: var(--muted); }
.metric-null { color: var(--faint); }

.detail-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* --- Tables --- */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; vertical-align: middle; padding: 10px 12px; border-bottom: 1px solid var(--soft-line); }
thead th { background: #f6f9fc; color: #28333f; font-size: 12px; position: sticky; top: 0; }
.lb-table tbody tr:hover { background: #f9fbfd; }
td.num, th.num, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num { text-align: right; }
.num-null { color: var(--faint); text-align: right; }
.cell-model { min-width: 150px; }
.model-link { font-weight: 720; text-decoration: none; }
.model-link:hover { text-decoration: underline; }
.cell-rating { white-space: nowrap; }
.cell-deriv { display: flex; flex-wrap: wrap; gap: 5px; }
.cell-date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }

.sort-btn {
  background: none; border: 0; cursor: pointer; font: inherit; font-size: 12px;
  font-weight: 740; color: #28333f; text-transform: uppercase; letter-spacing: .02em;
  padding: 2px 2px; display: inline-flex; align-items: center;
}
.sort-btn:hover { color: var(--accent); }
.sort-active { color: var(--accent); }
.sort-arrow { font-size: 10px; }

/* row + tag decoration for non-comparable */
.row-noncomparable td { background: #fcfaf6; }
.row-noncomparable:hover td { background: #faf6ee; }
.tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 740; vertical-align: middle; border: 1px solid;
}
.tag-open { color: var(--good); border-color: rgba(20, 108, 67, .4); background: #f1f9f4; }
.tag-noncomp { color: var(--accent-2); border-color: rgba(122, 75, 22, .4); background: #fbf5ec; }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 680; border: 1px solid var(--line);
  background: var(--panel); white-space: nowrap;
}
.badge-tier { font-weight: 820; color: var(--accent); }
.badge-glyph { letter-spacing: -1px; font-size: 9px; }
.badge-conf-high { color: var(--good); border-color: rgba(20, 108, 67, .35); background: #f1f9f4; }
.badge-conf-medium { color: #1d4ed8; border-color: rgba(29, 78, 216, .3); background: #eef3fe; }
.badge-conf-low { color: var(--warn); border-color: rgba(138, 75, 0, .35); background: #fff8ef; }
.badge-conf-none { color: var(--faint); border-color: var(--line); background: var(--panel); }
.deriv-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* --- Rating inline --- */
.rating-inline { display: inline-flex; align-items: center; gap: 6px; }
.rating-glyph { letter-spacing: 1px; color: var(--accent); font-size: 13px; }
.rating-srtext { font-size: 12px; color: var(--muted); }
.rating-inline-null { color: var(--faint); font-size: 12.5px; }

/* "How is this calculated" affordance */
.how-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 999px; border: 1px solid #c2ccd9;
  background: var(--panel); color: var(--accent); font-size: 11px; font-weight: 820;
  text-decoration: none; line-height: 1; flex: none;
}
.how-link:hover { background: var(--panel-strong); text-decoration: none; }

/* --- Model detail extras --- */
.kv-table th[scope="row"] { font-weight: 640; color: var(--ink); width: 55%; }
.kv-table td { text-align: right; font-variant-numeric: tabular-nums; }
.rating-card { display: grid; gap: 10px; }
.rating-card .chart-svg { max-width: 280px; }
.rating-alttext { margin: 0; font-size: 13.5px; color: var(--muted); }
.aes-info { border: 1px solid var(--soft-line); border-radius: 8px; padding: 4px 12px; }
.aes-info summary { cursor: pointer; font-weight: 700; padding: 8px 0; font-size: 13.5px; }
.aes-info-body p { margin: 6px 0; font-size: 13.5px; color: var(--muted); }
.provenance-text { font-size: 13.5px; color: var(--ink); line-height: 1.55; }
.meta-dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0 0; }
.meta-pair { display: grid; gap: 1px; border: 1px solid var(--soft-line); border-radius: 6px; padding: 7px 10px; }
.meta-pair dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin: 0; }
.meta-pair dd { margin: 0; font-size: 13.5px; font-weight: 640; }
.cta-row { display: flex; gap: 10px; }

/* --- Compare --- */
.compare-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.compare-table th[scope="row"] { background: #f6f9fc; font-weight: 680; }
.compare-table td.num { text-align: right; }
.cell-best { color: var(--good); font-weight: 800; }
.best-tag { color: var(--good); }

/* --- Equivalence grid --- */
.equiv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.equiv-card { padding: 16px; display: grid; gap: 5px; border-top: 3px solid var(--accent-2); }
.equiv-title { font-size: 13px; font-weight: 720; color: var(--ink); min-height: 2.4em; }
.equiv-value { font-size: clamp(22px, 2.4vw, 30px); font-weight: 820; font-variant-numeric: tabular-nums; line-height: 1; }
.equiv-sub { font-size: 12px; }

/* --- Charts (SVG) --- */
.chart-svg { width: 100%; height: auto; display: block; margin-top: 6px; overflow: visible; }
.chart-grid { stroke: #e6ebf1; stroke-width: 1; }
.chart-axis { stroke: #9aa6b6; stroke-width: 1; }
.chart-axis-label { fill: #3e4b5c; font-size: 12px; font-weight: 700; }
.chart-tick { fill: var(--muted); font-size: 11px; }
.chart-tick-note { fill: var(--faint); font-size: 10px; }
.chart-empty { fill: var(--muted); font-size: 14px; }
.bar { fill: var(--accent); }
.bar-noncomparable { fill: var(--accent-2); }
.bar-label { fill: var(--ink); font-size: 11.5px; }
.bar-value { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.whisker { stroke: var(--muted); stroke-width: 1.5; }
.box { fill: rgba(15, 92, 111, .18); stroke: var(--accent); stroke-width: 1; }
.box-median { stroke: var(--accent); stroke-width: 2; }
.dot { fill: var(--accent); stroke: #fff; stroke-width: 1; }
.scatter-label { fill: var(--muted); font-size: 10.5px; }
.ts-line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.ts-dot { fill: var(--accent); }
.ts-series-label { font-size: 11px; font-weight: 680; }
.stack-seg { fill: var(--accent); }
.grouped-bar { fill: var(--accent); }
.grouped-interp { fill: #9fb3bc; }

/* EnergyGuide-style rating label */
.rating-frame { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.rating-title { fill: var(--ink); font-size: 11px; font-weight: 820; letter-spacing: .05em; }
.rating-block { stroke: var(--line); stroke-width: 1; }
.rating-off { fill: #eef2f6; }
.rating-on { fill: var(--accent); }
.rating-num { fill: var(--muted); font-size: 13px; font-weight: 800; }
.rating-num-on { fill: #fff; }
.rating-caption { fill: var(--ink); font-size: 12px; font-weight: 700; }
.rating-foot { fill: var(--muted); font-size: 9.5px; }

/* --- Methodology --- */
.method-section { padding: 18px 20px; }
.method-focus { box-shadow: 0 0 0 3px var(--focus); }
.method-p { color: var(--ink); max-width: 80ch; font-size: 14.5px; line-height: 1.6; }
.method-table th, .method-table td { font-size: 13px; }
.method-table thead th { background: #f6f9fc; }
.license-list { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.license-list li { font-size: 14px; line-height: 1.55; max-width: 90ch; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--line); background: rgba(255, 255, 255, .7); margin-top: 12px; }
.site-footer-inner { width: min(100%, 1320px); margin: 0 auto; padding: 22px clamp(16px, 3vw, 40px) 36px; display: grid; gap: 6px; }
.footer-note { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 92ch; line-height: 1.55; }
.footer-meta { margin: 0; color: var(--faint); font-size: 12.5px; }

/* --- Responsive --- */
@media (max-width: 980px) {
  .metric-grid, .equiv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-cols { grid-template-columns: 1fr; }
  .compare-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .site-header-inner { flex-direction: column; align-items: flex-start; }
  .metric-grid, .equiv-grid, .compare-pick { grid-template-columns: 1fr; }
  .nav-list a { min-height: 40px; }
  .toolbar { flex-direction: column; align-items: flex-start; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* --- Print --- */
@media print {
  .site-header, .main-nav, .skip-link, .downloads, .filter-bar, .how-link, .site-footer, .cta-row { display: none !important; }
  body { background: #fff; }
  .app-main { width: 100%; padding: 0; }
  .chart-card, .table-card, .panel, .metric-card, .equiv-card, .method-section { break-inside: avoid; border-color: #bbb; }
  a { color: #000; text-decoration: none; }
}
