/* ==========================================================================
   Lastentautien artikkelien viikkokooste — tyylit
   --------------------------------------------------------------------------
   Periaate: hillitty ja tiivis ammattikäyttöön. Yksi kirjaintyyppi, pieni
   perusfonttikoko, matala kontrasti pinnoissa ja hierarkia pelkästään koon,
   painon ja värin kautta — ei koristeita.

   Rakenne: 1) tokenit  2) perusta  3) apuluokat  4) navigaatio  5) hero
            6) etusivu  7) kooste (prose)  8) tietosivu  9) alatunniste
           10) responsiivisuus 11) tulostus
   Reunaehdot: CSP kieltää inline-tyylit, JavaScriptin ja ulkoiset fontit
   (ks. vercel.json) — siksi vain järjestelmäfontit ja CSS-only-ratkaisut.
   ========================================================================== */

/* --- 1) Tokenit ---------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Mitat */
  --w: 46rem;              /* sivun leveys */
  --measure: 70ch;         /* luettavan tekstin rivinpituus */
  --gutter: 1.25rem;
  --radius: 8px;

  /* Kaksi kirjaintyyppiä, molemmat järjestelmästä (CSP kieltää fonttilataukset).
     Serif = toimituksellinen sisältö (otsikot, ingressit). Sans = käyttöliittymä. */
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype",
           Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;

  /* Värit — vaalea tila */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #14181d;          /* otsikot */
  --ink-2: #3b434e;        /* leipäteksti */
  --muted: #646e7b;        /* metatiedot */
  --line: #e6e9ed;         /* hienovarainen erotin */
  --line-2: #d3d8de;
  --border-ui: #8b95a1;    /* interaktiivisten rajat: 3:1 taustaan (WCAG 1.4.11) */
  --accent: #0f6f68;       /* ensisijainen: painikkeet, linkit */
  --accent-ink: #0b5851;   /* linkit ja korostettu teksti */
  --accent-bg: #eef4f3;
  --on-accent: #ffffff;
  --accent-2: #9c3d22;     /* toissijainen: osiotunnisteet ja niiden viiva */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #14181e;
    --surface-2: #171c23;
    --ink: #e8ecf1;
    --ink-2: #bfc7d1;
    --muted: #8f99a6;
    --line: #232931;
    --line-2: #333b45;
    --border-ui: #5c6774;
    --accent: #35b3a4;
    --accent-ink: #5fd4c4;
    --accent-bg: #14322e;
    --on-accent: #06221f;
    --accent-2: #e08a63;
  }
}

/* --- 2) Perusta ---------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;   /* ankkurit eivät jää tarttuvan navin alle */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.9375rem;         /* 15 px */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.24;
  letter-spacing: -.006em;
  font-weight: 700;
  text-wrap: balance;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent-bg); color: var(--accent-ink); }
time { font-variant-numeric: tabular-nums; }

/* --- 3) Apuluokat -------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: .6rem 1rem;
  font-size: .8125rem;
  font-weight: 600;
}
.skip-link:focus { left: 0; text-decoration: none; }

/* Osiotunniste: lyhyt värillinen viiva + harvennettu versaaliteksti. */
.section-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
  margin: 0 0 .9rem;
  font-family: var(--sans);   /* myös kun elementti on <h2> (globaali sääntö = serif) */
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.section-label::before {
  content: "";
  flex: 0 0 auto;
  width: 1.75rem;
  height: 2px;
  background: currentcolor;
}

/* Pikkumerkki osiotunnisteen perässä (esim. artikkelimäärä). */
.pill {
  padding: .18rem .55rem;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sep { padding: 0 .45rem; color: var(--line-2); }

/* --- 4) Navigaatio ------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

@supports (backdrop-filter: blur(1px)) {
  .nav {
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: saturate(150%) blur(12px);
    backdrop-filter: saturate(150%) blur(12px);
  }
}

.nav-inner {
  max-width: var(--w);
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: 3.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.wordmark {
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.wordmark .wm-soft {
  margin-left: .4rem;
  color: var(--muted);
  font-family: var(--sans);
  font-weight: 400;
  font-size: .8125rem;
}
.wordmark:hover { color: var(--accent-ink); text-decoration: none; }

.nav-links { display: flex; align-items: center; gap: .1rem; flex: 0 0 auto; }
.nav-links a {
  color: var(--muted);
  font-size: .8125rem;
  padding: .35rem .55rem;
  border-radius: 6px;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
/* Aktiivinen sivu merkitään alleviivauspalkilla (kuten mallissa). */
.nav-links a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-radius: 0;
  box-shadow: inset 0 -2px 0 var(--ink);
}
.nav-links a[aria-current="page"]:hover { background: transparent; }

/* --- 5) Hero ------------------------------------------------------------- */

.hero {
  padding: clamp(1.75rem, 4vw, 2.75rem) 0 clamp(1.25rem, 2.5vw, 1.75rem);
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  margin: 0 0 .7rem;
  font-size: clamp(1.625rem, 1.25rem + 1.7vw, 2.125rem);
  line-height: 1.18;
  letter-spacing: -.012em;
}

/* Ingressi on toimituksellista tekstiä → serif, kuten mallissa. */
.hero .lede {
  margin: 0 0 1.1rem;
  max-width: 46ch;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .085em;
  text-transform: uppercase;
}

/* --- 6) Etusivu: uusin kooste + arkisto --------------------------------- */

main.page { padding-bottom: clamp(3rem, 6vw, 4.5rem); }

.featured { padding: clamp(1.75rem, 4vw, 2.5rem) 0 0; }

/* Nosto on litteä: ei laatikkoa eikä varjoa, erottelu tapahtuu viivoilla. */
.feature-card { padding: 0; }

.feature-title {
  margin: 0 0 .5rem;
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.5rem);
  line-height: 1.25;
}
.feature-title a { color: var(--ink); }
.feature-title a:hover { color: var(--accent-ink); text-decoration: none; }

.feature-date {
  margin: 0 0 1.1rem;
  padding-bottom: .95rem;
  border-bottom: 1px solid var(--line);
  font-size: .8125rem;
  color: var(--muted);
}

.feature-excerpt {
  margin: 0 0 1.35rem;
  max-width: 50ch;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.feature-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.feature-actions .btn { justify-content: center; padding: .7rem 1.15rem; font-size: .875rem; }

.archive { padding: clamp(1.75rem, 4vw, 2.5rem) 0 0; }
.year-group + .year-group { margin-top: 1.5rem; }

.year-label {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin: 0 0 .3rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.year-count {
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}

.digest-list { list-style: none; margin: 0; padding: 0; }

.digest-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--line);
}
.digest-row:last-child { border-bottom: 0; }

.row-main {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  padding: .7rem .15rem;
}
.row-main:hover { text-decoration: none; }
.row-main:hover .row-title { color: var(--accent-ink); }

.row-title {
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1rem;
}
.row-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .8125rem;
}

.row-pdf {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .05em;
  padding: .22rem .45rem;
  border: 1px solid var(--border-ui);
  border-radius: 5px;
}
.row-pdf:hover { color: var(--accent-ink); border-color: var(--accent); text-decoration: none; }

/* Painikkeet */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border: 1px solid var(--border-ui);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.3;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--accent-ink); border-color: var(--line-2); }

.empty {
  margin-top: 2rem;
  padding: 2.5rem 1.25rem;
  border: 1px dashed var(--border-ui);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* --- 7) Koostesivu ------------------------------------------------------ */

.prose { max-width: var(--measure); margin: 0 auto; padding: 0 0 1rem; }

.doc-top { padding: clamp(1.25rem, 3vw, 2rem) 0 .85rem; }
.backlink { color: var(--muted); font-size: .8125rem; }
.backlink::before { content: "← "; }
.backlink:hover { color: var(--accent-ink); text-decoration: none; }

.prose h1 {
  margin: 0 0 .5rem;
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 1.9375rem);
  line-height: 1.2;
  letter-spacing: -.012em;
}

.doc-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .8125rem;
}
.doc-meta .pdf-link { font-weight: 600; }

/* Sisällysluettelo */
.toc {
  margin: 0 0 2rem;
  padding: .85rem 1.1rem .95rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toc-title {
  margin: 0 0 .5rem;
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .085em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc > ul > li + li { margin-top: .25rem; }
.toc > ul > li > a { color: var(--ink); font-weight: 600; font-size: .875rem; }
.toc ul ul {
  margin: .2rem 0 .45rem;
  padding-left: .8rem;
  border-left: 1px solid var(--line-2);
}
.toc ul ul li { margin-bottom: .05rem; line-height: 1.45; }
.toc ul ul a { color: var(--muted); font-size: .8125rem; }
/* Sisällys on osa .prose-sisältöä — kumotaan leipätekstin linkkityyli.
   Valitsimessa on oltava .prose mukana: pelkkä `.toc a` häviää myöhemmin
   tulevalle `.prose a` -säännölle samalla spesifisyydellä. */
.prose .toc a { text-decoration: none; }
.prose .toc a:hover {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Otsikot sisällössä. h2 on versaalitunniste → sans; h3 on toimituksellinen → serif. */
.prose h2 {
  margin: 2.25rem 0 .85rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .095em;
  text-transform: uppercase;
  color: var(--accent-ink);
  scroll-margin-top: 4.5rem;
}
.prose h3 {
  margin: 1.65rem 0 .7rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink);
  scroll-margin-top: 4.5rem;
}

.prose p { margin: 0 0 .9rem; }
.prose strong { color: var(--ink); font-weight: 650; }
.prose em { color: var(--ink-2); }
.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.prose a:hover { text-decoration-color: var(--accent); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.75rem 0; }
.prose ul, .prose ol { margin: 0 0 .9rem; padding-left: 1.25rem; }
.prose li { margin-bottom: .3rem; }
.prose li::marker { color: var(--muted); }

.prose .lede {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink-2);
}

/* Merkinnät: nostot ja julkaisurivit */
.prose .entry {
  margin: 0 0 1rem;
  padding: 0 0 0 .9rem;
  border-left: 2px solid var(--line);
}
.prose .entry > strong:first-child {
  display: block;
  margin-bottom: .2rem;
  color: var(--accent-ink);
  font-weight: 650;
  font-size: .9375rem;
  line-height: 1.35;
  text-wrap: pretty;
}
.prose .entry em { font-size: .9em; color: var(--muted); font-style: normal; }
.prose .entry em a { color: var(--muted); }
.prose .entry em a:hover { color: var(--accent-ink); }

/* Huomautuslaatikot */
.disclaimer, .note {
  margin: 1.75rem 0 0;
  padding: .85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .875rem;
}
.disclaimer em { font-style: normal; color: var(--muted); }
.note { color: var(--ink-2); }
.note strong { color: var(--ink); }

/* Lähdeluettelo */
ol.sources { margin: 0; padding-left: 1.35rem; }
ol.sources li { margin-bottom: .8rem; }
ol.sources li::marker { color: var(--muted); font-size: .8125rem; }
.src-title { display: block; font-size: .875rem; }
.src-title a { color: var(--ink); font-weight: 550; text-decoration: none; }
.src-title a:hover { color: var(--accent-ink); text-decoration: underline; }
.src-meta { display: block; margin-top: .1rem; color: var(--muted); font-size: .8125rem; }

.doc-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .6rem;
  max-width: var(--measure);
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

/* --- 8) Tietosivu ------------------------------------------------------- */

.steps { list-style: none; margin: 0 0 1.25rem; padding: 0; counter-reset: step; }
.steps li {
  position: relative;
  counter-increment: step;
  margin-bottom: .8rem;
  padding-left: 2rem;
}
.steps li::before {
  content: counter(step) ".";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--muted);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.journal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: .85rem;
  margin: 0 0 1.25rem;
}
.journal-card {
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.journal-card h3 {
  margin: 0 0 .45rem;
  font-family: var(--sans);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.journal-card ul { list-style: none; margin: 0; padding: 0; }
.journal-card li {
  margin: 0;
  padding: .22rem 0;
  font-size: .875rem;
  color: var(--ink-2);
}

/* --- 9) Alatunniste ----------------------------------------------------- */

.footer { border-top: 1px solid var(--line); background: var(--surface-2); }
.footer-inner {
  max-width: var(--w);
  margin: 0 auto;
  padding: 1.75rem var(--gutter) 2.5rem;
  color: var(--muted);
  font-size: .8125rem;
}
.footer-cols {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.footer-name { margin: 0; color: var(--ink); font-weight: 600; font-size: .875rem; }
.footer-tag { margin: .15rem 0 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent-ink); }
.footer-fine { margin: 0; max-width: 74ch; line-height: 1.55; }

/* --- 10) Responsiivisuus ------------------------------------------------ */

@media (max-width: 34rem) {
  :root { --gutter: 1rem; }
  .nav-inner { min-height: 2.9rem; gap: .5rem; padding-block: .3rem; }
  .wordmark { font-size: 1rem; }
  .nav-links a { padding: .3rem .4rem; font-size: .78125rem; }
  /* Nostopainikkeet täysleveinä ja pinottuina, kuten mallissa. */
  .feature-actions { flex-direction: column; }
  .feature-actions .btn { width: 100%; }
}

/* Kaikkein kapeimmilla näytöillä tunnuksesta jää vain lyhenne, jotta
   navigaatiolinkit mahtuvat samalle riville ilman vaakavieritystä. */
@media (max-width: 22rem) {
  .wordmark .wm-soft { display: none; }
}

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

/* --- 11) Tulostus (selaimen tulostustoiminto) --------------------------- */

@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --ink: #000; --ink-2: #1a1a1a; --muted: #444;
    --line: #ccc; --line-2: #aaa; --border-ui: #888;
    --accent: #0f6f68; --accent-ink: #0b5851; --accent-bg: #fff;
  }
  .nav, .doc-foot, .footer-links, .skip-link, .toc { display: none !important; }
  body { font-size: 10pt; }
  .prose, .doc-foot { max-width: none; }
  .prose .entry { border-left: 1.5pt solid #ddd; break-inside: avoid; }
  .prose a { text-decoration: none; color: #000; }
  .feature-card, .journal-card, .disclaimer, .note { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}
