:root {
  color-scheme: dark;
  --bg: #070707;
  --bg-raised: #121212;
  --text: #f4f1ea;
  --muted: #b7b1a6;
  --dim: #8a847a;
  --line: #262626;
  --red: #e10600;
  --series-a: #f4f1ea;
  --series-b: #7ec8d4;
  --band: rgba(244, 241, 234, 0.08);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: Inter, "Segoe UI", system-ui, sans-serif;
  --pad: 24px;
  --max: 52rem;
  --chart: 70rem;
  --page: 80rem;
  --topbar: 56px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.75;
  letter-spacing: -0.011em;
}

body.nav-open { overflow: hidden; }

::selection {
  background: var(--red);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--text);
  color: #000;
  padding: 8px 12px;
  z-index: 20;
}

.skip:focus { top: 12px; }

.topic-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--red);
  z-index: 12;
  transform-origin: left center;
  transition: width 0.14s linear;
  pointer-events: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar);
  padding: 0 var(--pad);
  background: rgba(7, 7, 7, 0.86);
  backdrop-filter: blur(12px);
}

.brand-bar {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.2;
}

.topics { display: none; }

.menu-button,
.nav-close {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  border: 0;
  z-index: 14;
}

body:not(.nav-open) .backdrop { display: none; }

.side {
  position: fixed;
  z-index: 16;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(86vw, 340px);
  padding: 20px 18px 32px;
  background: #050505;
  border-right: 1px solid var(--line);
  overflow: auto;
  transform: translateX(-105%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

body.nav-open .side { transform: none; }

.side-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.05;
}

.side nav {
  display: flex;
  flex-direction: column;
}

.side a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 4px;
  text-decoration: none;
  color: rgba(244, 241, 234, 0.48);
  border-bottom: 1px solid var(--line);
  transition: color 0.25s ease;
}

.side a:hover,
.side a.is-active { color: #fff; }

.side a span {
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  font-size: 0.8rem;
}

.page {
  padding: 8px var(--pad) 88px;
}

.page-inner {
  max-width: var(--page);
  margin: 0 auto;
}

.hero {
  padding: 28px 0 12px;
}

.hero-kicker {
  margin: 0 0 18px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(5.33rem, 23.4vw, 8.32rem);
  line-height: 0.88;
  letter-spacing: -0.045em;
}

.hero h1 .line { display: block; }

.quebrou {
  position: relative;
  font-style: italic;
  font-weight: inherit;
  display: inline-block;
}

.quebrou::after {
  content: "";
  position: absolute;
  left: 0;
  width: 94%;
  bottom: 0.18em;
  height: 0.065em;
  background: var(--red);
  transform: rotate(-2.2deg) scaleX(0);
  transform-origin: left center;
  animation: strike 1.1s 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}

.howto {
  max-width: var(--max);
  margin: 8px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.7;
}

.howto p { margin: 0 0 1em; }
.howto p:last-of-type { margin-bottom: 0; }

.legend-key {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.95rem;
}

.legend-key li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 22px;
  height: 3px;
  background: var(--series-a);
  display: inline-block;
}

.swatch.b { background: var(--series-b); }
.swatch.mark { width: 3px; height: 16px; background: var(--red); }
.swatch.band {
  width: 22px;
  height: 12px;
  background: var(--band);
  border: 1px solid #3a3a3a;
}

article {
  padding-top: 56px;
  margin-top: 40px;
  scroll-margin-top: 72px;
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.is-in {
  opacity: 1;
  transform: none;
}

.reveal.is-in.is-out {
  opacity: 0.12;
  transform: none;
}

.kicker {
  margin: 0;
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

article h2 {
  margin: 10px 0 18px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 7vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.leitura {
  max-width: var(--max);
  margin: 0 0 1.15em;
}

.hint {
  max-width: var(--max);
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.chart {
  margin: 8px 0 4px;
}

.chart-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.chart-legend { margin: 0; }

.readout {
  margin: 0;
  min-height: 1.5em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.chart text {
  font-family: var(--sans);
  fill: var(--dim);
}

.chart text.mark { fill: var(--red); }

.chart .draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.toggle {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.98rem;
}

caption {
  text-align: left;
  color: var(--muted);
  padding-bottom: 8px;
}

th, td {
  text-align: right;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
}

th:first-child, td:first-child { text-align: left; }

.fonte-linha {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.fonte-linha a { color: var(--text); }

.sources {
  padding: 0;
  list-style: none;
}

.sources li { margin: 10px 0; }

footer {
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  max-width: var(--max);
}

footer h2 {
  color: var(--text);
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
}

#fontes { scroll-margin-top: 72px; }

@keyframes strike {
  to { transform: rotate(-2.2deg) scaleX(1); }
}

@keyframes rise {
  to { opacity: 1; transform: none; }
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

@keyframes hero-out {
  to { opacity: 0.12; transform: translateY(-40px) scale(0.985); }
}

@media (min-width: 900px) {
  :root {
    --pad: 48px;
    --max: 60rem;
    --chart: 84rem;
    --page: 94rem;
    --topbar: 52px;
  }

  html { scroll-padding-top: 64px; }

  .menu-button,
  .brand-bar,
  .backdrop,
  .side { display: none; }

  .topbar {
    position: fixed;
    left: 0;
    right: 0;
    min-height: var(--topbar);
    padding: 0 40px;
    background: transparent;
    backdrop-filter: none;
    opacity: 0;
    pointer-events: none;
    transition: background 0.35s ease;
  }

  .topbar.is-on {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar.is-solid {
    background: rgba(7, 7, 7, 0.9);
    backdrop-filter: blur(16px);
  }

  .topics {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px 14px;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topics::-webkit-scrollbar { display: none; }

  .topics a {
    flex: 0 0 auto;
    color: rgba(244, 241, 234, 0.34);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    padding: 8px 0;
    transition: color 0.3s ease;
  }

  .topics a:hover { color: rgba(244, 241, 234, 0.72); }

  .topics a.is-active {
    color: #fff;
    font-weight: 600;
  }

  .page {
    padding: 0 56px 128px;
  }

  .hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12vh 0;
  }

  .hero-kicker {
    font-size: 0.9rem;
    margin-bottom: 32px;
  }

  .hero h1 {
    font-size: clamp(9.62rem, 17.55vw, 15.6rem);
    max-width: 12ch;
  }

  .howto {
    max-width: var(--max);
    margin: 12px 0 0;
    padding-top: 36px;
    font-size: 1.14rem;
    line-height: 1.75;
  }

  article {
    max-width: none;
    margin: 8vh 0 0;
    padding-top: 72px;
    scroll-margin-top: 80px;
  }

  #fontes { scroll-margin-top: 80px; }

  article h2 {
    font-size: clamp(2.6rem, 4vw, 3.4rem);
    margin-bottom: 28px;
  }

  .leitura {
    font-size: 1.22rem;
    line-height: 1.8;
    margin-bottom: 1.35em;
  }

  .hint { font-size: 1.05rem; }

  .chart-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }

  .readout { text-align: right; }

  .fonte-linha { font-size: 1.05rem; }

  footer {
    max-width: var(--max);
    margin: 16vh 0 0;
  }

  @supports (animation-timeline: view()) {
    .hero {
      animation: hero-out linear both;
      animation-timeline: view();
      animation-range: exit 0% exit 55%;
    }

    article.reveal.is-out,
    footer.reveal.is-out {
      animation: none;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .quebrou::after,
  .howto,
  .chart .draw,
  .hero,
  .reveal {
    animation: none;
  }
  .quebrou::after { transform: rotate(-2.2deg) scaleX(1); }
  .reveal,
  .reveal.is-in.is-out {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .topic-progress { transition: none; }
  .side { transition: none; }
}
