/* Numele ăsta se mai dă? — registry/ledger visual language.
   Light is the default theme. Dark is available from day one.
   All colour goes through semantic variables. No hardcoded colours in HTML. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-raise: #f6f4ee;
  --bg-line: #ece7db;
  --text-primary: #1b1915;
  --text-secondary: #4c463b;
  --text-faint: #57503f;
  --accent: #0b4fc4;
  --accent-ink: #0a44a8;
  --rank: #8a4a00;
  --stamp: #9c1f16;
  --ok: #175c28;
  --rule: #d8d1c1;
  --chip: #efe9da;
  --focus: #0b4fc4;
  --bar-track: #e9e2d2;
  --shadow: none;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161511;
  --bg-raise: #201e18;
  --bg-line: #2c2921;
  --text-primary: #f2ede1;
  --text-secondary: #cfc7b4;
  --text-faint: #aaa28d;
  --accent: #9db9ff;
  --accent-ink: #b9ccff;
  --rank: #f0b95a;
  --stamp: #ff9d8f;
  --ok: #8fdc9b;
  --rule: #3a362b;
  --chip: #26231b;
  --focus: #b9ccff;
  --bar-track: #2c2921;
  --shadow: none;
}

* { box-sizing: border-box; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
}

.display, h1, h2, h3 {
  font-family: Georgia, "Times New Roman", Charter, serif;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); margin: 0 0 0.6rem; }
h2 { font-size: clamp(1.4rem, 3.4vw, 2rem); margin: 2.6rem 0 0.7rem; }
h3 { font-size: 1.15rem; margin: 1.6rem 0 0.4rem; }

p { margin: 0 0 1rem; max-width: 42rem; }

a { color: var(--accent-ink); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.mono, .figure, table, .stamp {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1.1rem; }
.prose { max-width: 42rem; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--text-primary); color: var(--bg);
  padding: 0.6rem 1rem; z-index: 50;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* Header: ledger masthead */
.masthead {
  border-bottom: 3px double var(--rule);
  padding: 0.7rem 0;
}
.masthead .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 68rem;
}
.brand { font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.brand a { color: inherit; text-decoration: none; }
.tools { display: flex; gap: 0.6rem; align-items: center; }

.btn {
  font: inherit; font-size: 0.95rem;
  background: var(--bg); color: var(--text-primary);
  border: 1.5px solid var(--text-secondary);
  border-radius: 999px; padding: 0.45rem 1rem;
  cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: var(--text-primary); }
.btn.primary { background: var(--text-primary); color: var(--bg); border-color: var(--text-primary); }
.btn.small { min-height: 36px; padding: 0.25rem 0.8rem; font-size: 0.88rem; }
.langswitch { font-size: 0.9rem; color: var(--text-secondary); white-space: nowrap; }

/* Hero: answer first */
.hero { padding: 2.2rem 0 1rem; border-bottom: 1px solid var(--rule); }
.kicker {
  display: inline-block; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary); border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.2rem 0.8rem; margin-bottom: 1rem; background: var(--bg-raise);
}
.deck { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: var(--text-secondary); max-width: 44rem; }
.trustline { font-size: 0.92rem; color: var(--text-secondary); border-left: 3px solid var(--rule); padding-left: 0.9rem; margin: 1.2rem 0; max-width: 44rem; }

/* Controls: the registry slip */
.slip {
  background: var(--bg-raise);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--text-primary);
  padding: 1.2rem;
  margin: 1.4rem 0;
}
.slip fieldset { border: 0; margin: 0; padding: 0; }
.slip legend { font-family: Georgia, serif; font-weight: 700; font-size: 1.1rem; padding: 0; margin-bottom: 0.8rem; }
.fields { display: grid; gap: 0.9rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .fields { grid-template-columns: 2fr 1fr 1.4fr; } }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.field .hint { font-size: 0.82rem; color: var(--text-faint); margin-top: 0.2rem; }
.field input, .field select {
  font: inherit; width: 100%; min-height: 48px;
  background: var(--bg); color: var(--text-primary);
  border: 1.5px solid var(--text-secondary); border-radius: 4px; padding: 0.5rem 0.7rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.presets { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; align-items: center; }
.presets span { font-size: 0.85rem; color: var(--text-secondary); }

/* Answer card */
.answer {
  border: 1px solid var(--rule);
  border-left: 6px solid var(--accent);
  padding: 1.1rem 1.2rem;
  margin: 1.2rem 0;
  background: var(--bg);
}
.answer h2 { margin-top: 0; font-size: 1.3rem; }
.answer .big { font-family: Georgia, serif; font-size: clamp(1.3rem, 3vw, 1.7rem); line-height: 1.35; margin: 0 0 0.6rem; }
.verdict {
  display: inline-block; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; border: 2px solid var(--stamp); color: var(--stamp);
  border-radius: 4px; padding: 0.15rem 0.6rem; margin-bottom: 0.7rem;
  transform: rotate(-1.2deg);
}
.verdict.calm { border-color: var(--ok); color: var(--ok); }
.meta { font-size: 0.9rem; color: var(--text-secondary); }

/* Charts */
.figure-block { margin: 1.6rem 0; }
.figure-block figcaption { font-size: 0.9rem; color: var(--text-secondary); margin-top: 0.5rem; max-width: 44rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--rule); }
.chart .tick { fill: var(--text-faint); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .bar.pin-a { fill: var(--accent-ink); }
.chart .bar.pin-b { fill: var(--stamp); }
.chart .rankline { fill: none; stroke: var(--rank); stroke-width: 2.5; }
.chart .pin { stroke: var(--text-primary); stroke-dasharray: 4 3; }
.chart text { font-family: ui-monospace, Menlo, Consolas, monospace; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.88rem; color: var(--text-secondary); margin-top: 0.5rem; }
.swatch { display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.35em; vertical-align: baseline; }

/* Crowd lane */
.lane { display: flex; align-items: flex-end; gap: 3px; height: 84px; margin: 0.6rem 0 0; }
.lane i { flex: 1 1 0; background: var(--bar-track); min-width: 4px; position: relative; }
.lane i b { position: absolute; inset: auto 0 0 0; background: var(--accent); display: block; }
.lane i.old b { background: var(--text-faint); }
.lane i.now b { background: var(--stamp); }

/* Data table */
.tablewrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--rule); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
caption { text-align: left; font-family: Georgia, serif; font-weight: 700; padding: 0.7rem; background: var(--bg-raise); }
th, td { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--rule); text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--bg-raise); border-bottom: 2px solid var(--text-primary); }
tbody tr:hover { background: var(--bg-raise); }

/* Graveyard strip */
.graveyard { border-top: 3px double var(--rule); border-bottom: 3px double var(--rule); padding: 1rem 0 1.4rem; margin: 2rem 0; background: var(--bg-raise); }
.grave-grid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); list-style: none; margin: 1rem 0 0; padding: 0; }
.grave-grid button {
  font: inherit; text-align: left; cursor: pointer;
  background: var(--bg); color: var(--text-primary);
  border: 1px solid var(--rule); border-left: 5px solid var(--text-faint);
  border-radius: 3px; padding: 0.5rem 0.65rem; min-height: 44px; width: 100%;
}
.grave-grid button:hover { border-color: var(--text-secondary); }
.grave-grid .gname { font-weight: 700; display: block; }
.grave-grid .gfall { font-size: 0.83rem; color: var(--text-secondary); }

/* Late arrivals */
.late-list { columns: 2; column-gap: 2rem; font-size: 0.95rem; }
@media (min-width: 700px) { .late-list { columns: 3; } }
.late-list li { break-inside: avoid; margin-bottom: 0.3rem; }

/* Method */
.method { border: 1px solid var(--rule); background: var(--bg-raise); padding: 1.1rem 1.2rem; margin: 2rem 0; }
.method h2 { margin-top: 0; }
.method dl { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: 0.3rem 1rem; font-size: 0.93rem; margin: 0; }
.method dt { font-weight: 700; }
.method dd { margin: 0 0 0.5rem; }

/* Unavailable state */
.unavailable {
  border: 2px dashed var(--text-secondary);
  padding: 1.1rem 1.2rem; margin: 1.2rem 0; background: var(--bg);
}
.unavailable h2 { margin-top: 0; font-size: 1.2rem; }

/* Footer */
footer.site { border-top: 3px double var(--rule); margin-top: 3rem; padding: 1.4rem 0 2.5rem; font-size: 0.9rem; color: var(--text-secondary); }
footer.site nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-bottom: 0.8rem; }

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

.backtotop {
  position: sticky; bottom: 1rem; float: right; margin-right: 1rem;
}

/* Yearly top + evolution: the crowd lane ledger */
.topsec {
  border-top: 3px double var(--rule);
  border-bottom: 3px double var(--rule);
  background: var(--bg-raise);
  padding: 1rem 1.1rem 1.4rem;
  margin: 2rem 0;
}
.topsec h2 { margin-top: 0.4rem; }
.top-controls {
  display: flex; flex-wrap: wrap; gap: 0.7rem 1.4rem; align-items: end;
  border: 1px solid var(--rule); background: var(--bg);
  padding: 0.9rem 1rem; margin: 1rem 0;
}
.top-controls .grp { margin: 0; }
.top-controls .grp > span {
  display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem;
}
.seg { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.seg label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1.5px solid var(--text-secondary); border-radius: 999px;
  padding: 0.3rem 0.9rem; min-height: 44px; cursor: pointer; font-size: 0.95rem;
  background: var(--bg); color: var(--text-primary);
}
.seg input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
.seg label:has(input:checked) { border-color: var(--text-primary); border-width: 2.5px; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.yr { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.yr label { font-size: 0.85rem; font-weight: 600; }
.yr output { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; min-width: 3ch; }
.yr input[type="range"] { width: min(16rem, 52vw); accent-color: var(--accent); min-height: 44px; }
.topstatus { flex-basis: 100%; margin: 0; order: 3; }
.top-controls .grp.yr { order: 2; }
.top-controls .cleargrp { order: 4; }
.top-grid { display: grid; gap: 1.6rem; grid-template-columns: 1fr; }
@media (min-width: 1000px) {
  .top-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2.2rem; align-items: start; }
}
.top-list { list-style: none; margin: 0.8rem 0 0; padding: 0; }
.top-list li { margin: 0 0 0.35rem; }
.top-list button {
  display: grid; grid-template-columns: 2.2rem minmax(6rem, 9rem) 1fr auto; gap: 0.6rem; align-items: center;
  width: 100%; min-height: 44px; cursor: pointer; font: inherit; text-align: left;
  background: var(--bg); color: var(--text-primary);
  border: 1px solid var(--rule); border-left: 5px solid var(--text-faint);
  border-radius: 3px; padding: 0.35rem 0.6rem;
}
.top-list button:hover { border-color: var(--text-secondary); }
.top-list button[aria-pressed="true"] { border-left-color: var(--stamp); border-width: 1px 1px 1px 5px; }
.top-list .t-rank { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.top-list .t-name { font-weight: 700; overflow-wrap: anywhere; }
.top-list .t-count { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88rem; }
.t-bar { display: block; height: 0.65rem; background: var(--bar-track); border-radius: 2px; overflow: hidden; }
.t-bar i { display: block; height: 100%; background: var(--accent); }
.top-list button[aria-pressed="true"] .t-bar i { background: var(--stamp); }
.evo-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0 0; padding: 0; }
.evo-legend button {
  font: inherit; font-size: 0.88rem; cursor: pointer; min-height: 44px;
  background: var(--bg); color: var(--text-primary);
  border: 1.5px solid var(--rule); border-radius: 999px; padding: 0.3rem 0.8rem;
}
.evo-legend button:hover { border-color: var(--text-secondary); }
.evo-legend button[aria-pressed="true"] {
  border-color: var(--stamp); color: var(--stamp); font-weight: 700;
}
.evo-legend .mv { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; }
.chart .evoline { fill: none; stroke: var(--text-faint); stroke-width: 1.5; opacity: 0.75; }
.chart .evoline.focus { stroke: var(--stamp); stroke-width: 3; opacity: 1; }
.chart .evomark { stroke: var(--text-primary); stroke-dasharray: 4 3; }
.chart .evoend { fill: var(--text-primary); font-size: 11px; font-weight: 700; }
.chart .evogap { fill: var(--text-faint); font-size: 10px; }
