/* Visual language from cipher-inbox-ufmg-2026 (doiim.com): white field, near-black ink, Faktum, 6-column grid. */
@font-face { font-family: 'Faktum'; src: url('fonts/faktum-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Faktum'; src: url('fonts/faktum-semibold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Faktum'; src: url('fonts/faktum-bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Faktum'; src: url('fonts/faktum-extrabold.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --paper: #ffffff;
  --ink: #091311;
  --ink-hover: #193630;
  --tint: rgba(9, 19, 17, 0.07);
  --muted: rgba(9, 19, 17, 0.62);
  --gap: 48px;
  --pad: 72px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

/* Dark: same ink, inverted. a11y.js resolves "system" to light or dark on the root. */
:root[data-theme='dark'] {
  --paper: #091311;
  --ink: #f2f5f4;
  --ink-hover: #c4d3ce;
  --tint: rgba(242, 245, 244, 0.09);
  --muted: rgba(242, 245, 244, 0.68);
  color-scheme: dark;
}

* { margin: 0; box-sizing: border-box; }

body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gap);
  align-content: start;
  padding: var(--pad);
  background: var(--paper);
  color: var(--ink);
  font-family: 'Faktum', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.3125;
  overflow-wrap: break-word;
}

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid; }
a:hover { color: var(--ink-hover); }

header { grid-column: 1 / 7; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
header .logo { font-weight: 800; border: 0; margin-right: auto; }
header nav { display: flex; flex-wrap: wrap; gap: 8px 20px; font-weight: 600; font-size: 0.9375rem; }
header nav a { border: 0; }
header nav a:hover { border-bottom: 1px solid; }

.hero { grid-column: 1 / 6; }
.hero h1 { font-size: 4rem; font-weight: 700; line-height: 1.125; max-width: 22ch; margin-bottom: 0.5em; }
.hero h2 { font-size: 1.125rem; font-weight: 400; max-width: 75ch; }

main { grid-column: 1 / 7; display: grid; gap: var(--gap); }

fieldset { border: 0; border-top: 1px solid var(--ink); padding: 24px 0 0; min-width: 0; }
legend { font-size: 1.5rem; font-weight: 600; padding-right: 12px; }
fieldset > p, .prose p, .prose ul, .prose ol { max-width: 75ch; margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li { margin-bottom: 6px; }
h3 { font-size: 1.0625rem; font-weight: 600; margin: 24px 0 8px; }

.hint { font-size: 0.875rem; font-weight: 600; color: var(--muted); }
code, pre { font-family: var(--mono); }
code { font-size: 0.875em; background: var(--tint); padding: 1px 4px; }

/* Headline numbers: one stat per tile, no chart. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0 24px; }
.kpi { background: var(--tint); padding: 18px 20px; }
.kpi .label { font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.kpi .value { font-size: 2rem; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 0.8125rem; color: var(--muted); }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 12px 0 24px; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--tint); white-space: nowrap; }
th { font-weight: 600; border-bottom-color: var(--ink); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { background: var(--tint); }
th[aria-sort='ascending']::after { content: ' ↑'; }
th[aria-sort='descending']::after { content: ' ↓'; }
td.num, th.num { text-align: right; }
td .range { display: block; font-size: 0.75rem; color: var(--muted); }
tr.highlight td { font-weight: 700; }
tr.best td:first-child::before { content: '● '; }

/* Small multiples of single-series bars: ink bars, direct labels, rounded data end. */
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 32px 48px; margin: 18px 0 12px; }
.chart h4 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 2px; }
.chart .sub { font-size: 0.8125rem; color: var(--muted); margin-bottom: 10px; }
.bars { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; align-items: center; }
.bars .name { font-size: 0.875rem; font-weight: 600; }
.bars .track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bars .bar { height: 12px; background: var(--ink); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .track:hover .bar { background: var(--ink-hover); }
.bars .val { font-size: 0.8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .track.na .val { color: var(--muted); }

/* Controls */
button {
  font: inherit; font-weight: 600; color: var(--paper); background: var(--ink);
  border: 0; padding: 8px 16px; margin: 0; cursor: pointer;
}
button:hover { background: var(--ink-hover); }
button.secondary { color: var(--ink); background: transparent; box-shadow: inset 0 0 0 1px var(--ink); }
button.secondary:hover { background: var(--tint); }
button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.segmented { display: inline-flex; flex-wrap: wrap; margin: 12px 0 4px; }
.segmented button + button { margin-left: -1px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; margin: 12px 0 18px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; font-weight: 600; }
select { font: inherit; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; padding: 6px 0; min-width: 120px; }

/* Case viewer */
.quote-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 24px; padding: 18px 20px; background: var(--tint); margin-bottom: 12px; }
.quote-card dt { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.quote-card dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
pre { font-size: 0.8125rem; background: var(--tint); padding: 12px 16px; margin-top: 8px; white-space: pre; overflow: auto; max-height: 560px; }
.failures { font-size: 0.875rem; margin: 8px 0; }
.failures li { margin-bottom: 4px; }

.callout { border-left: 3px solid var(--ink); padding: 4px 0 4px 16px; margin: 12px 0 18px; max-width: 80ch; }
.callout p { margin-bottom: 6px; }
blockquote { font-style: italic; }

/* Tooltip shared by every chart mark and table cell with data-tip. */
#tip {
  position: fixed; z-index: 20; pointer-events: none; display: none;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 12px; font-size: 0.8125rem; max-width: 320px; white-space: pre-line;
}

.hero-cta { margin-top: 18px; font-weight: 600; }

/* Sponsor call: text on the left, a tinted card with reference amounts and the email button. */
.sponsor { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 32px 48px; align-items: start; margin-top: 12px; }
.sponsor-card { background: var(--tint); padding: 24px; }
.sponsor-card h3 { font-size: 1.5rem; font-weight: 700; margin: 0 0 8px; }
.sponsor-card p { margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.chips span { border: 1px solid var(--ink); padding: 6px 12px; font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
a.button { display: block; text-align: center; border: 0; background: var(--ink); color: var(--paper); font-weight: 700; padding: 12px 20px; margin-bottom: 8px; }
a.button:hover { background: var(--ink-hover); color: var(--paper); }
.donate-title { font-size: 0.9375rem; font-weight: 700; margin: 18px 0 8px; }
.donate { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.donate li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.donate .coin { font-weight: 700; font-size: 0.8125rem; }
.donate a { font-family: var(--mono); font-size: 0.75rem; word-break: break-all; border: 0; }
.donate a:hover { text-decoration: underline; }
button.small { padding: 4px 10px; font-size: 0.75rem; }

/* Header ● dark/light switch (as on afa7789.github.io) and the floating accessibility panel. */
.theme-flip { position: fixed; top: 20px; right: 20px; z-index: 30; font-family: var(--mono); padding: 6px 10px; line-height: 1; }
.a11y { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.a11y-toggle { width: 52px; height: 52px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: var(--paper); box-shadow: inset 0 0 0 1px var(--ink); }
.a11y-toggle:hover { background: var(--tint); }
.a11y-toggle .figure { stroke: var(--paper); }
.a11y-toggle .figure circle { fill: var(--paper); }
.a11y-panel { display: grid; gap: 8px; width: 240px; padding: 16px; background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.a11y-panel[hidden] { display: none; }
.a11y-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.a11y-label + .a11y-row { margin-bottom: 8px; }
.a11y-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.a11y-row button { min-height: 44px; padding: 6px; font-variant-numeric: tabular-nums; }

footer { grid-column: 1 / 7; border-top: 1px solid var(--ink); padding-top: 18px; font-size: 0.875rem; color: var(--muted); }

@media (max-width: 1199px) { .hero h1 { font-size: 3rem; } }
@media (max-width: 767px) {
  :root { --gap: 24px; --pad: 40px 16px; }
  body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  header, .hero, main, footer { grid-column: 1 / 3; }
  header nav { order: 1; }
  .theme-flip { position: static; }
  .sponsor { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
}
