@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700;9..144,900&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --tabla: #14251b;
  --tabla-2: #1c3226;
  --tabla-3: #24402f;
  --creta: #f4efe1;
  --creta-dim: #c9c2ac;
  --carton: #efe4c8;
  --carton-2: #e6d8b4;
  --cerneala: #2a2016;
  --cerneala-dim: #5b4f3c;
  --caramida: #c05b37;
  --caramida-dim: #8f432a;
  --lemn: #d1a256;
  --lemn-dim: #9c7a44;
  --var-line: #5c7768;
  --focus: #e7c766;
  --max-w: 46rem;
  --wide-w: 62rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--tabla);
  color: var(--creta);
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

img, svg { max-width: 100%; }

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 700; line-height: 1.18; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-weight: 900; }

a { color: inherit; }
a:not(.btn) { text-decoration-thickness: 1px; text-underline-offset: 0.14em; }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.shell { max-width: var(--wide-w); margin: 0 auto; padding: 0 1.25rem; }
.prose { max-width: var(--max-w); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem;
  max-width: var(--wide-w); margin: 0 auto;
  font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  color: var(--creta-dim);
}
.topbar .brand { color: var(--creta); text-decoration: none; }
.langsw a { color: var(--creta-dim); text-decoration: none; padding: 0.2rem 0.4rem; }
.langsw a[aria-current="page"] { color: var(--focus); border-bottom: 1px solid var(--focus); }

/* ---------- hero ---------- */
.hero { padding: 1.5rem 0 3rem; }
.hero .kicker {
  font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--lemn); margin: 0 0 1rem;
}
.hero h1 { font-size: clamp(2.1rem, 5.4vw, 3.4rem); max-width: 20ch; }
.hero .standfirst { font-size: 1.18rem; color: var(--creta-dim); max-width: 42ch; margin: 1rem 0 0; }

.statline {
  display: flex; flex-wrap: wrap; gap: 1.5rem 2.2rem;
  margin: 2rem 0 0; padding: 1.1rem 0 0;
  border-top: 1px solid var(--var-line);
}
.statline .stat { min-width: 8rem; }
.statline .stat b {
  display: block; font-family: "IBM Plex Mono", monospace; font-size: 1.7rem; font-weight: 600;
  color: var(--creta);
}
.statline .stat span { display: block; font-size: 0.85rem; color: var(--creta-dim); margin-top: 0.15rem; }

/* ---------- grid instrument ---------- */
.instrument {
  margin: 2.75rem 0 0;
  background: var(--tabla-2);
  border: 1px solid var(--var-line);
  border-radius: 4px;
  padding: 1.5rem 1.25rem 1.75rem;
}
.instrument .readout {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.instrument .readout .year { font-family: "Fraunces", serif; font-weight: 700; font-size: 2.1rem; }
.instrument .readout .count { text-align: right; }
.instrument .readout .count b {
  font-family: "IBM Plex Mono", monospace; font-size: 1.9rem; font-weight: 600; color: var(--caramida);
  transition: color 0.2s;
}
.instrument .readout .count span { display: block; font-size: 0.82rem; color: var(--creta-dim); }

.deskgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13px, 1fr));
  gap: 3px;
  padding: 0.9rem 0.2rem;
  min-height: 4rem;
}
.deskgrid i {
  display: block;
  aspect-ratio: 1;
  border-radius: 1.5px;
  background: var(--lemn);
  opacity: 1;
  transition: opacity 0.25s, background-color 0.25s;
}
.deskgrid i[data-empty="1"] { background: transparent; border: 1px solid var(--caramida-dim); opacity: 0.55; }
@media (prefers-reduced-motion: reduce) { .deskgrid i { transition: none; } }

.instrument .scalecap { font-size: 0.8rem; color: var(--creta-dim); margin: 0.75rem 0 0; }

.slider-row { margin-top: 1.25rem; }
.slider-row label { display: block; font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; color: var(--creta-dim); margin-bottom: 0.5rem; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 2px;
  background: var(--var-line); border-radius: 2px; margin: 0.6rem 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--focus); border: 3px solid var(--tabla-2); cursor: grab; margin-top: -9px;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--focus); border: 3px solid var(--tabla-2); cursor: grab;
}
.slider-ticks { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--creta-dim); font-family: "IBM Plex Mono", monospace; }
.noscript-note { display: none; }
.js-only { display: none; }
.has-js .js-only { display: block; }
.has-js .noscript-note { display: none; }
.no-js .instrument .readout .count b::after { content: ""; }

/* ---------- sections ---------- */
section.block { padding: 3.25rem 0; }
section.block h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); max-width: 24ch; }
section.block p { margin: 0 0 1.05rem; }
section.block p:last-child { margin-bottom: 0; }
.lede { font-size: 1.08rem; color: var(--creta); }

.divider { border: none; border-top: 1px solid var(--var-line); margin: 0; }

/* ---------- composition bars (arondare section) ---------- */
.compbars { margin: 1.75rem 0 0.5rem; }
.compbar { margin-bottom: 1.15rem; }
.compbar .lbl {
  display: flex; justify-content: space-between; font-family: "IBM Plex Mono", monospace; font-size: 0.82rem;
  color: var(--creta-dim); margin-bottom: 0.35rem;
}
.compbar .track { display: flex; height: 1.9rem; border-radius: 3px; overflow: hidden; background: var(--tabla-3); }
.compbar .seg { display: flex; align-items: center; }
.compbar .seg.independent { background: var(--lemn); }
.compbar .seg.arondat { background: var(--caramida-dim); }
.compbar .seg.gone { background: transparent; border-right: 1px dashed var(--var-line); }
.barlegend { display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--creta-dim); margin-top: 0.6rem; }
.barlegend .sw { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-right: 0.4rem; vertical-align: -1px; }
.sw.independent { background: var(--lemn); }
.sw.arondat { background: var(--caramida-dim); }

/* ---------- small comparison chart ---------- */
.miniline { width: 100%; height: auto; margin: 1.4rem 0 0.5rem; }
.miniline text { font-family: "IBM Plex Mono", monospace; font-size: 9px; fill: var(--creta-dim); }

/* ---------- sources (ledger scene) ---------- */
.ledger { background: var(--carton); color: var(--cerneala); }
.ledger a { color: var(--cerneala); }
.ledger h2 { color: var(--cerneala); }
.ledger .kicker { color: var(--caramida-dim); }
.ledger .lede { color: var(--cerneala); }
.ledger p { color: var(--cerneala-dim); }
.srcrow { border-top: 1px solid var(--carton-2); padding: 1rem 0; }
.srcrow:first-of-type { border-top: none; }
.srcrow .tag {
  font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--caramida-dim);
}
.srcrow p { margin: 0.3rem 0 0; color: var(--cerneala); }
.srcrow .meta { color: var(--cerneala-dim); font-size: 0.88rem; }

/* ---------- footer ---------- */
footer.site {
  background: var(--carton); color: var(--cerneala-dim);
  padding: 2rem 1.25rem 2.5rem; font-size: 0.88rem;
}
footer.site .shell { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; }
footer.site a { color: var(--cerneala); }

/* ---------- back to top ---------- */
.totop {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 20;
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--focus); color: var(--tabla); border: none; cursor: pointer;
  font-size: 1.1rem; text-decoration: none;
}
.totop.show { display: flex; }
@media print { .totop { display: none !important; } }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .statline { gap: 1.1rem 1.6rem; }
  .instrument .readout { align-items: flex-start; }
  .instrument .readout .count { text-align: left; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
