/* kouluhaku.fi · Tilasto — Direction A design system
   Libre Franklin · pure neutral · hairline rules · tabular numerals */

:root {
  --ink: #161616;
  --ink-2: #555555;
  --ink-3: #8a8a8a;
  --rule: #e4e4e4;
  --rule-strong: #161616;
  --bg: #ffffff;
  --bg-2: #f6f6f6;
  --max: 1200px;
  --pad: clamp(20px, 4vw, 56px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Libre Franklin", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.wrap { max-width: var(--max); margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }

/* ===== nav ===== */
.tnav { border-bottom: 1px solid var(--rule); }
.tnav__in {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 24px; padding-top: 20px; padding-bottom: 20px;
}
.tnav__brand { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.tnav__brand small { font-weight: 400; color: var(--ink-3); font-size: 17px; }
.tnav__links { display: flex; gap: clamp(14px, 2.4vw, 28px); font-size: 13.5px; color: var(--ink-2); align-items: baseline; flex-wrap: wrap; }
.tnav__links a:hover { color: var(--ink); }
.tnav__links a.is-active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); padding-bottom: 2px; }
.tnav__lang { font-size: 12px; color: var(--ink-3); letter-spacing: 0.04em; display: inline-flex; gap: 4px; align-items: baseline; }
.tnav__lang button { font: inherit; font-size: 12px; letter-spacing: 0.04em; background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-3); }
.tnav__lang button.is-active { color: var(--ink); font-weight: 600; }
.tnav__lang button:hover { color: var(--ink); }

/* ===== type ===== */
.eyebrow {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-2); margin: 0 0 16px;
}
h1.display {
  margin: 0; font-size: clamp(28px, 4.4vw, 46px); font-weight: 600;
  letter-spacing: -0.025em; line-height: 1.08; text-wrap: balance;
}
.sub { margin: 18px 0 0; font-size: 16px; line-height: 1.55; color: var(--ink-2); max-width: 560px; text-wrap: pretty; }
h2.section-h {
  margin: 0 0 4px; font-size: 13px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
}

/* ===== stat blocks ===== */
.stats { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.stat { border-top: 1px solid var(--rule-strong); padding-top: 10px; flex: 1; min-width: 90px; }
.stat__v { font-size: clamp(26px, 3vw, 34px); font-weight: 300; letter-spacing: -0.01em; line-height: 1; }
.stat__l { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; line-height: 1.4; }

/* ===== gpa strip ===== */
.gpa-strip {
  padding: 16px 24px; background: var(--bg-2);
  display: flex; align-items: center; gap: 20px; font-size: 14px; flex-wrap: wrap;
}
.gpa-strip__title { font-weight: 600; white-space: nowrap; }
.gpa-strip__slider { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 220px; }
.gpa-strip__slider input[type="range"] { flex: 1; accent-color: var(--ink); height: 14px; }
.gpa-strip__bound { font-size: 13px; color: var(--ink-3); }
.gpa-strip__out { white-space: nowrap; }
.gpa-strip__out b { font-weight: 700; }

/* ===== ranking table (grid rows) ===== */
.rt { width: 100%; }
.rt__head {
  display: grid; gap: 18px; align-items: end;
  padding-bottom: 9px; border-bottom: 2px solid var(--rule-strong);
  font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2);
}
.rt__row {
  display: grid; gap: 18px; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--rule);
}
a.rt__row:hover { background: var(--bg-2); }
.rt--rank .rt__head, .rt--rank .rt__row { grid-template-columns: 44px 1fr 90px 230px 80px; }
.rt__r { font-size: 14px; color: var(--ink-3); }
.rt__name { font-size: 15.5px; font-weight: 500; line-height: 1.25; }
.rt__name small { color: var(--ink-3); font-weight: 400; font-size: 13.5px; }
.rt__score { text-align: right; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.rt__yo { text-align: right; font-size: 14px; color: var(--ink-2); }
.t-right { text-align: right; }

/* dot strip */
.dotstrip { display: flex; align-items: center; gap: 10px; }
.dotstrip__v { font-size: 14px; font-weight: 600; min-width: 34px; }
.dotstrip__track { position: relative; width: 150px; height: 12px; flex: none; }
.dotstrip__line { position: absolute; left: 0; right: 0; top: 5px; height: 1px; background: var(--rule); }
.dotstrip__median { position: absolute; top: 2px; width: 1px; height: 7px; background: var(--ink-3); }
.dotstrip__dot { position: absolute; top: 2.5px; width: 6px; height: 6px; border-radius: 99px; background: var(--ink); margin-left: -3px; }

/* ===== controls (leaderboard) ===== */
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.controls input[type="text"], .controls select {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--ink);
  border-radius: 0; padding: 9px 12px;
}
.controls input[type="text"] { flex: 1; min-width: 200px; }
.controls input[type="text"]::placeholder { color: var(--ink-3); }
.controls select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%23161616' fill='none'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; }

/* ===== buttons / links ===== */
.lnk { font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--ink); padding-bottom: 1px; }
.lnk:hover { color: var(--ink-2); border-color: var(--ink-2); }
.btn {
  display: inline-block; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; padding: 12px 22px; border: 0; cursor: pointer; font-family: inherit;
  white-space: nowrap; flex: none;
}
.btn:hover { background: #333; }
.btn--ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--ink); }
.btn--ghost:hover { background: var(--bg-2); }

/* ===== histogram ===== */
.hist { display: flex; align-items: flex-end; gap: 3px; }
.hist__bar { flex: 1; background: #d4d4d4; min-height: 3px; }
.hist__bar.is-hl { background: var(--ink); }
.hist__axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.06em; }

/* ===== key-value rows / detail ===== */
.kv { border-top: 1px solid var(--rule-strong); }
.kv__row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.kv__row dt { color: var(--ink-2); margin: 0; }
.kv__row dd { margin: 0; font-weight: 500; text-align: right; white-space: nowrap; }
.kv__row dt small { display: block; font-weight: 400; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; letter-spacing: 0; text-transform: none; }

/* expandable detail (curated default + full data behind toggle) */
details.expand { border-top: 2px solid var(--rule-strong); margin-top: 36px; }
details.expand > summary { cursor: pointer; list-style: none; padding: 14px 0 16px; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
details.expand > summary::-webkit-details-marker { display: none; }
details.expand > summary::after { content: "Näytä +"; font-size: 12px; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
details.expand[open] > summary::after { content: "Piilota –"; }
details.expand > summary:hover::after { color: var(--ink); }

/* lens / component bars (reuse .wbar grid) */
.lens-grid { margin-top: 4px; }

/* ===== leaderboard weighting panel ===== */
.weights { border: 1px solid var(--rule); padding: 18px 20px 20px; margin-bottom: 24px; }
.weights__hd { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.weights__title { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.weights__presets { display: flex; gap: 6px; flex-wrap: wrap; }
.weights__presets button { font: inherit; font-size: 12.5px; color: var(--ink-2); background: var(--bg); border: 1px solid var(--rule); padding: 6px 12px; cursor: pointer; }
.weights__presets button:hover { border-color: var(--ink-3); color: var(--ink); }
.weights__presets button.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.weights__sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 28px; }
.wslider { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 4px 10px; }
.wslider__l { font-size: 13.5px; font-weight: 500; }
.wslider__v { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.wslider input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); height: 14px; }
.lb-sort { background: none; border: 0; font: inherit; cursor: pointer; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.lb-sort.is-sorted { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ===== generic data table (content pages) ===== */
.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
.dt thead th { text-align: left; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; padding: 0 14px 9px 0; border-bottom: 2px solid var(--rule-strong); }
.dt thead th.t-right { text-align: right; }
.dt tbody td { padding: 11px 14px 11px 0; border-bottom: 1px solid var(--rule); }
.dt tbody td.t-right { text-align: right; }
.dt tbody tr:hover { background: var(--bg-2); }
.dt .dt__rank { color: var(--ink-3); width: 40px; }
.dt .dt__name { font-weight: 500; }
.dt .dt__name small { color: var(--ink-3); font-weight: 400; }
.crumb { font-size: 12.5px; color: var(--ink-3); }
.crumb a { border-bottom: 1px solid var(--rule); }
.crumb a:hover { color: var(--ink); border-color: var(--ink); }

/* bar chart (history) */
.bars { display: flex; gap: 14px; align-items: flex-end; }
.bars__item { flex: 1; text-align: center; }
.bars__bar { background: var(--ink); width: 100%; }
.bars__bar.is-muted { background: #d4d4d4; }
.bars__v { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.bars__l { font-size: 11.5px; color: var(--ink-3); margin-top: 7px; }

/* ===== striped placeholder (map / imagery) ===== */
.placeholder {
  background: repeating-linear-gradient(45deg, #fafafa, #fafafa 10px, #f1f1f1 10px, #f1f1f1 20px);
  border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  letter-spacing: 0.06em; text-align: center; padding: 20px;
}

/* ===== note / footer ===== */
.note { font-size: 12px; color: var(--ink-3); }
.tfoot { border-top: 1px solid var(--rule); margin-top: 56px; }
.tfoot__in { padding-top: 24px; padding-bottom: 36px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.tfoot__in a { border-bottom: 1px solid var(--rule); }

/* ===== responsive table collapse ===== */
@media (max-width: 760px) {
  .rt--rank .rt__head { display: none; }
  .rt--rank .rt__row { grid-template-columns: 30px 1fr auto; }
  .rt--rank .rt__row .dotstrip, .rt--rank .rt__row .rt__yo { display: none; }
  .rt__name { font-size: 14.5px; }
  .rt__score { font-size: 18px; }
}

/* ===== city tabs ===== */
.city-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.city-tabs a { font-size: 13.5px; color: var(--ink-2); padding: 8px 14px; border: 1px solid var(--rule); }
.city-tabs a:hover { border-color: var(--ink-3); color: var(--ink); }
.city-tabs a.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }

/* ===== osoitehaku layout ===== */
.haku-main { display: grid; grid-template-columns: 1fr 440px; min-height: calc(100vh - 67px); }
.haku-map { min-height: 360px; }
.haku-panel { border-left: 1px solid var(--rule); padding: 32px 36px 48px; }
.haku-search { display: flex; border: 1px solid var(--ink); }
.haku-search input { flex: 1; border: 0; font: inherit; font-size: 14.5px; padding: 12px 14px; min-width: 0; }
.haku-search input:focus { outline: none; background: var(--bg-2); }
.haku-search button { border: 0; background: var(--ink); color: var(--bg); font: inherit; font-size: 14px; font-weight: 600; padding: 0 20px; cursor: pointer; }
.haku-block { border-top: 1px solid var(--rule-strong); margin-top: 32px; padding-top: 14px; }
.haku-school { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.haku-school__n { font-size: 14.5px; font-weight: 500; line-height: 1.3; }
.haku-school__n small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.haku-school__d { font-size: 13px; color: var(--ink-2); }
.haku-tabs { display: flex; gap: 0; margin-top: 12px; border-bottom: 1px solid var(--rule); }
.haku-tabs button { font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 0; padding: 8px 0; margin-right: 20px; cursor: pointer; }
.haku-tabs button.is-active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); margin-bottom: -1px; }
@media (max-width: 980px) {
  .haku-main { grid-template-columns: 1fr; }
  .haku-panel { border-left: 0; border-top: 1px solid var(--rule); }
}

/* ===== document pages (menetelma) ===== */
.doc { max-width: 760px; }
.doc h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 18px; padding-top: 14px; border-top: 2px solid var(--rule-strong); }
.doc section { margin-top: 44px; }
.doc p { margin: 0 0 14px; font-size: 15px; line-height: 1.65; color: var(--ink-2); text-wrap: pretty; }
.doc p strong, .doc li strong { color: var(--ink); font-weight: 600; }
.doc ol, .doc ul { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); font-size: 15px; line-height: 1.65; }
.doc li { margin-bottom: 10px; }
.wbar { display: grid; grid-template-columns: 1fr 56px 120px; gap: 16px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.wbar__l { font-size: 14.5px; font-weight: 500; line-height: 1.35; }
.wbar__l small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.wbar__v { font-size: 15px; font-weight: 600; text-align: right; }
.wbar__track { height: 10px; background: var(--bg-2); }
.wbar__fill { height: 100%; background: var(--ink); display: block; }
.faq dt { font-size: 15px; font-weight: 600; margin: 22px 0 6px; }
.faq dd { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
@media (max-width: 600px) {
  .wbar { grid-template-columns: 1fr 48px; }
  .wbar__track { display: none; }
}

/* ===== hakuohjeet path ===== */
.path { max-width: 860px; }
.path-step { display: grid; grid-template-columns: 150px 1fr; gap: 36px; padding: 26px 0; border-bottom: 1px solid var(--rule); }
.path-step:first-of-type { border-top: 2px solid var(--rule-strong); }
.path-step__age { font-size: 21px; font-weight: 300; letter-spacing: -0.01em; line-height: 1.2; }
.path-step__age small { display: block; font-size: 11.5px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-top: 5px; }
.path-step h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.path-step p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); text-wrap: pretty; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.quick span, .quick a { font-size: 12px; padding: 5px 10px; border: 1px solid var(--rule); color: var(--ink-2); }
.quick a { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.note-band { padding: 14px 18px; background: var(--bg-2); font-size: 13.5px; color: var(--ink-2); max-width: 860px; }
.src-list { margin: 14px 0 0; padding: 0; list-style: none; }
.src-list li { padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.src-list a { border-bottom: 1px solid var(--rule); }
.src-list a:hover { color: var(--ink-2); }
@media (max-width: 640px) {
  .path-step { grid-template-columns: 1fr; gap: 10px; }
}

/* ===== katsaukset article list ===== */
.art-list { border-top: 2px solid var(--rule-strong); }
.art-item { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: baseline; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.art-item__t { font-size: 16.5px; font-weight: 500; line-height: 1.3; }
.art-item__t small { display: block; font-weight: 400; font-size: 13.5px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; max-width: 560px; }
.art-item__m { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
a.art-item:hover .art-item__t { text-decoration: underline; text-underline-offset: 3px; }

/* ===== production additions (not in the preview) ===== */

/* FI/EN block toggling — pages with structurally different language blocks
   (long FAQ answers, document prose) use .lang-fi/.lang-en wrappers; short
   strings use data-i18n-* attributes handled by js/lang.js. */
html[lang="fi"] .lang-en { display: none; }
html[lang="en"] .lang-fi { display: none; }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 0.92em; }

/* details-based FAQ (index) */
.faq details { border-bottom: 1px solid var(--rule); }
.faq details:first-of-type { border-top: 2px solid var(--rule-strong); }
.faq details summary { cursor: pointer; list-style: none; padding: 14px 0; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.faq details summary::-webkit-details-marker { display: none; }
.faq details summary::after { content: "+"; color: var(--ink-3); font-weight: 400; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 16px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); max-width: 700px; }
