/* ==========================================================================
   Brasileirão — visual system
   Inspirado em impeccable.style: papel neutro, tinta quase-preta,
   um único acento dourado ("kinpaku") e um verde-pátina para estados.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Acentos */
  --gold: oklch(84% .19 80.46);
  --gold-rich: oklch(77% .13 82);
  --gold-pale: oklch(86% .07 84);
  --gold-deep: oklch(61% .085 78);
  --patina: oklch(70% .12 188);
  --patina-pale: oklch(82% .07 188);
  --patina-deep: oklch(45% .1 190);
  --vermilion: oklch(52% .16 35);

  /* Neutros */
  --paper: oklch(97.8% 0 0);
  --paper-raised: oklch(99.5% 0 0);
  --paper-deep: oklch(95% 0 0);
  --gray: oklch(92% 0 0);
  --gray-2: oklch(88% 0 0);
  --ink: oklch(13% 0 0);
  --text: oklch(22% 0 0);
  --text-muted: oklch(46% 0 0);
  --text-faint: oklch(51% 0 0);
  --rule: oklch(13% 0 0 / .08);
  --rule-strong: oklch(13% 0 0 / .16);
  --edge: oklch(13% 0 0 / .45);

  /* Tipografia */
  --font: "Albert Sans", "Avenir Next", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-display: "Alumni Sans", "Albert Sans", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Forma e movimento */
  --radius-sm: 3px;
  --radius-md: 8px;
  --control: 44px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --quick: .12s;
  --settle: .2s;
  --lift: 0 1px 1px oklch(13% 0 0 / .05), 0 2px 3px oklch(13% 0 0 / .04), 0 6px 12px oklch(13% 0 0 / .05);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--patina-deep);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Cabeçalho do site
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: oklch(97.8% 0 0 / .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex: none;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1px oklch(13% 0 0 / .12);
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  line-height: 1;
}

.site-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 64px;
  padding: 0 14px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--quick) var(--ease);
}

.site-nav a:hover { color: var(--ink); }

.site-nav a[aria-current="page"] { color: var(--ink); }

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--gold);
}

.home-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--quick) var(--ease), background-color var(--quick) var(--ease);
}

.home-button svg { color: var(--gold-deep); transition: transform var(--settle) var(--ease); }
.home-button:hover { border-color: var(--ink); }
.home-button:hover svg { transform: translateX(-2px); }
.home-button:active { background: var(--gray); }

/* --------------------------------------------------------------------------
   Página
   -------------------------------------------------------------------------- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px 40px 120px;
}

.page-head {
  display: grid;
  gap: 14px;
  max-width: 760px;
  margin-bottom: 48px;
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.8rem, 5.4vw, 4.6rem);
  line-height: 1;
  color: var(--ink);
}

.lede {
  margin: 4px 0 0;
  max-width: 60ch;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Controles
   -------------------------------------------------------------------------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 20px;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}

.field {
  display: grid;
  gap: 8px;
  min-width: 200px;
}

.field > label,
.field-label {
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.select {
  appearance: none;
  min-height: var(--control);
  padding: 0 40px 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background-color: var(--paper-raised);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none' stroke='%23222222' stroke-width='1.2'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-repeat: no-repeat;
  background-size: 10px 6px;
  font: inherit;
  font-size: .9375rem;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--quick) var(--ease);
}

.select:hover { border-color: var(--edge); }
.select:focus-visible { outline: none; border-color: var(--patina-deep); box-shadow: 0 0 0 3px oklch(70% .12 188 / .25); }

.versus {
  align-self: flex-end;
  height: var(--control);
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-faint);
}

.button {
  min-height: var(--control);
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper-raised);
  font: inherit;
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--quick) var(--ease), transform var(--quick) var(--ease);
}

.button:hover { background: var(--text); border-color: var(--text); }
.button:active { transform: scale(.98); }

.button-arrow {
  width: 14px;
  height: 8px;
  color: var(--gold);
}

/* Toggle (checkbox estilizado) */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control);
  font-size: .9375rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  appearance: none;
  flex: none;
  position: relative;
  width: 40px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--gray);
  cursor: pointer;
  transition: background var(--settle) var(--ease), border-color var(--settle) var(--ease);
}

.toggle input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--settle) var(--ease), background var(--settle) var(--ease);
}

.toggle input:checked {
  border-color: var(--patina);
  background: oklch(48% .08 188 / .2);
}

.toggle input:checked::before {
  background: var(--patina-deep);
  transform: translateX(18px);
}

/* --------------------------------------------------------------------------
   Área do gráfico
   -------------------------------------------------------------------------- */

.chart-panel {
  margin: 0;
  padding: 28px 28px 20px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--lift);
}

.chart-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 16px;
}

.chart-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.chart-note {
  margin: 0;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .08em;
  color: var(--text-faint);
}

#chart {
  min-height: 320px;
  position: relative;
}

#chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

#chart svg text {
  font-family: var(--font);
  fill: var(--text-muted);
}

#chart .axis .domain { stroke: var(--rule-strong); }
#chart .axis .tick line { stroke: var(--rule-strong); }
#chart .axis .tick text { font-size: 11px; }
#chart .axis-y .domain { display: none; }
#chart .axis-y .tick line { display: none; }
#chart .grid line { stroke: var(--rule); shape-rendering: crispEdges; }
#chart .grid .domain { display: none; }

#chart .axis-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  fill: var(--text-faint);
}

#chart .bar {
  transition: opacity var(--quick) var(--ease);
}

#chart .dimmed { opacity: .35; }

#chart .value-label {
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink);
  font-variant-numeric: tabular-nums;
}

#chart .slice-label {
  font-size: 11.5px;
  fill: var(--text);
}

#chart .slice-label tspan.pct {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--text-faint);
}

#chart .donut-total {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 44px;
  fill: var(--ink);
}

#chart .donut-caption {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  fill: var(--text-faint);
}

/* Estado vazio / carregamento */
.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 320px;
  text-align: center;
  color: var(--text-muted);
}

.empty strong {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 2rem;
  color: var(--ink);
}

.empty p { margin: 0; max-width: 44ch; }

/* --------------------------------------------------------------------------
   Tabela
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow: auto;
  max-height: 640px;
  margin: 0 -8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--paper-raised);
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  white-space: nowrap;
}

.data-table .num { text-align: right; }
.data-table td.rank { color: var(--text-faint); width: 1%; }
.data-table tbody tr { transition: background var(--quick) var(--ease); }
.data-table tbody tr:hover { background: var(--paper-deep); }
.data-table td.muted { color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Tooltip
   -------------------------------------------------------------------------- */

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  padding: 10px 12px;
  min-width: 140px;
  background: oklch(24% 0 0);
  color: oklch(93% 0 0);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px oklch(13% 0 0 / .18);
  font-size: .8125rem;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--quick) var(--ease), transform var(--quick) var(--ease);
}

.tooltip.visible { opacity: 1; transform: none; }

.tooltip .tt-title { font-weight: 600; color: #fff; margin-bottom: 4px; }

.tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-variant-numeric: tabular-nums;
}

.tooltip .tt-row span:first-child { color: oklch(68% 0 0); }

/* --------------------------------------------------------------------------
   Página Sobre
   -------------------------------------------------------------------------- */

.prose {
  max-width: 66ch;
  font-size: 1.0625rem;
}

.prose h2 {
  margin: 56px 0 12px;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ink);
}

.prose p { margin: 0 0 16px; }

.prose code {
  font-family: var(--mono);
  font-size: .85em;
  padding: .2em .45em;
  border-radius: var(--radius-sm);
  background: var(--gray);
  color: var(--ink);
}

.view-list {
  display: grid;
  gap: 0;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.view-list li {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.view-list a {
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: oklch(13% 0 0 / .28);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--quick) var(--ease);
}

.view-list a:hover { text-decoration-color: var(--gold); }
.view-list span { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Rodapé
   -------------------------------------------------------------------------- */

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page { width: 100%; flex: 1 0 auto; }

.site-footer {
  border-top: 1px solid var(--rule);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 40px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: oklch(13% 0 0 / .28);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--quick) var(--ease);
}

.footer-link:hover { text-decoration-color: var(--gold); }

/* --------------------------------------------------------------------------
   Responsivo
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .site-header-inner { padding: 0 16px; gap: 16px; height: 56px; }
  .site-nav a { height: 56px; padding: 0 10px; }
  .site-nav a[aria-current="page"]::after { left: 10px; right: 10px; }
  .brand-word { display: none; }
  .home-button { padding: 0 10px; }
  .home-button span { display: none; }
  .page { padding: 40px 16px 80px; }
  .site-footer-inner { padding: 24px 16px; }
  .page-head { margin-bottom: 32px; }
  .field { min-width: 0; flex: 1 1 100%; }
  .versus { display: none; }
  .chart-panel { padding: 16px 12px 12px; margin: 0 -4px; }
  .view-list li { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
