/*
 * Tolkkua public stylesheet.
 *
 * Implements the design tokens from brand/tolkkua-guide.html v1.0.
 * Editorial principles (MANIFESTO): generous space, quiet typography,
 * substance over decoration. Editor's red is signal, used sparingly.
 *
 * Fonts are self-hosted (static/fonts/) — no Google Fonts request. This
 * removes a third-party dependency, speeds up first paint, and keeps the
 * "no third-party requests" promise on /tietosuoja honest.
 */

/* Newsreader — latin */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/static/fonts/newsreader-300-700-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Newsreader — latin-ext */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/static/fonts/newsreader-300-700-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono 400 — latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/ibmplexmono-400-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono 400 — latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/ibmplexmono-400-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono 500 — latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/ibmplexmono-500-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono 500 — latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/ibmplexmono-500-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono 600 — latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/ibmplexmono-600-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono 600 — latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/ibmplexmono-600-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --tk-cream: #F2EDE2;
  --tk-paper: #EAE4D4;
  --tk-ink: #171411;
  --tk-ink-50: rgba(23, 20, 17, 0.5);
  --tk-ink-30: rgba(23, 20, 17, 0.3);
  --tk-ink-15: rgba(23, 20, 17, 0.15);
  --tk-ink-08: rgba(23, 20, 17, 0.08);
  --tk-accent: #C9341B;

  --tk-serif: 'Newsreader', Georgia, serif;
  --tk-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --tk-s-1: 0.5rem;
  --tk-s-2: 1rem;
  --tk-s-3: 1.5rem;
  --tk-s-4: 2.5rem;
  --tk-s-5: 4rem;
  --tk-s-6: 6rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--tk-cream);
  color: var(--tk-ink);
  font-family: var(--tk-serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--tk-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

a {
  color: var(--tk-ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
a:hover { color: var(--tk-accent); }

/* ── Header ────────────────────────────────────────────────────────── */

.site-header {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--tk-s-5) var(--tk-s-3) var(--tk-s-3);
  border-bottom: 1px solid var(--tk-ink-15);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand masthead"
    "nav   nav";
  column-gap: var(--tk-s-3);
}
.site-header .brand { grid-area: brand; }
.site-header .masthead-right { grid-area: masthead; text-align: right; }
.site-header nav { grid-area: nav; }

.masthead-right .masthead-date {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tk-ink);
  margin: 0;
}
.masthead-right .masthead-count {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  margin: 0.4rem 0 0;
  max-width: 18ch;
  margin-left: auto;
  text-align: right;
  line-height: 1.4;
}
.masthead-right .masthead-almanac {
  font-family: var(--tk-serif);
  font-size: 13px;
  color: var(--tk-ink);
  margin: 0.3rem 0 0;
  max-width: 20ch;
  margin-left: auto;
  text-align: right;
  line-height: 1.35;
}
.brand h1 {
  font-family: var(--tk-serif);
  font-weight: 500;
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
}
.brand h1 a {
  color: var(--tk-ink);
  border-bottom: none;
}
.brand h1 a:hover { color: var(--tk-ink); }

.brand .tagline {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  margin: 0.6rem 0 0;
}

.site-header nav {
  margin-top: var(--tk-s-3);
  display: flex;
  align-items: center;
  gap: var(--tk-s-3);
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  flex-wrap: wrap;
}
.site-header nav a {
  color: var(--tk-ink-50);
  border-bottom: none;
}
.site-header nav a:hover { color: var(--tk-ink); }

/* Search is a tool, not a section — an inline box at the end of the nav row
   rather than a link among the destinations. Pushed right with auto margin. */
.site-header nav .nav-search {
  margin: 0 0 0 auto;
}
.site-header nav .nav-search input {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: normal;
  text-transform: none;
  width: 11rem;
  padding: 0.3rem 0.55rem;
  color: var(--tk-ink);
  background: var(--tk-paper);
  border: 1px solid var(--tk-ink-15);
  border-radius: 3px;
}
.site-header nav .nav-search input::placeholder { color: var(--tk-ink-50); }
.site-header nav .nav-search input:focus {
  outline: none;
  border-color: var(--tk-ink-50);
}

/* Topic navigation — content-level, distinct from the chrome nav above. */
.topic-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.55rem;
  margin: 0 0 var(--tk-s-3);
  padding-bottom: var(--tk-s-2);
  border-bottom: 1px solid var(--tk-ink-15);
}
.topic-nav .topic-nav-label {
  font-family: var(--tk-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  margin-right: 0.35rem;
}
.topic-nav a {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  padding: 0.2rem 0.55rem;
  background: var(--tk-ink-08);
  border-radius: 3px;
  border-bottom: none;
}
.topic-nav a:hover {
  background: var(--tk-ink-15);
  color: var(--tk-ink);
}

/* Week strip — Mo-Su chips, today bold + accent. */
.week-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.55rem;
  margin: 0 0 var(--tk-s-3);
  padding-bottom: var(--tk-s-2);
  border-bottom: 1px solid var(--tk-ink-15);
}
.week-nav-label {
  font-family: var(--tk-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  margin-right: 0.35rem;
}
.week-day {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  padding: 0.2rem 0.55rem;
  background: var(--tk-ink-08);
  border-radius: 3px;
  border-bottom: none;
  min-width: 2rem;
  text-align: center;
}
.week-day:hover { color: var(--tk-ink); background: var(--tk-ink-15); }
.week-day-today {
  color: var(--tk-cream);
  background: var(--tk-accent);
  font-weight: 600;
}
.week-day-today:hover { color: var(--tk-cream); background: var(--tk-accent); }

/* ── Main ──────────────────────────────────────────────────────────── */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--tk-s-3) var(--tk-s-3) var(--tk-s-6);
}

/* Masthead */
.masthead .date {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  margin: 0 0 0.4rem;
}
.masthead .count,
.masthead .empty,
section .count,
section .empty {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  margin: 0 0 var(--tk-s-3);
}

/* Topic sections */
.topic {
  margin: var(--tk-s-5) 0 var(--tk-s-4);
}
.topic h2 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 0 0 var(--tk-s-2);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--tk-ink-30);
}
.topic h2 a {
  color: var(--tk-ink);
  border-bottom: none;
}
.topic h2 a:hover { color: var(--tk-accent); }

/* "Kaikki N juttua →" — link to the full topic page after the capped list. */
.topic-more {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin: var(--tk-s-2) 0 0;
}

/* Front-page digest notes — the empty-day fallback and the filtered count. */
.fallback-note,
.filter-note {
  font-family: var(--tk-mono);
  font-size: 12px;
  color: var(--tk-ink-50);
  margin: 0 0 var(--tk-s-3);
}

.topic-title {
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0.5rem 0 var(--tk-s-3);
}

.back-link {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 var(--tk-s-2);
}
.back-link a { color: var(--tk-ink-50); }
.back-link a:hover { color: var(--tk-ink); }

/* ── Article list ──────────────────────────────────────────────────── */

ul.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.article {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--tk-ink-15);
}
.article:last-child { border-bottom: none; }

.article .headline {
  font-family: var(--tk-serif);
  font-weight: 400;
  font-size: 19px;
  line-height: 1.35;
  color: var(--tk-ink);
  display: inline-block;
  border-bottom: none;
}
.article .headline:hover { color: var(--tk-accent); }

.article .meta {
  margin-top: 0.35rem;
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--tk-ink-50);
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: baseline;
}
.article .meta .source {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--tk-ink);
}
.article .meta .paywall {
  color: var(--tk-accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.article .summary {
  margin: 0.35rem 0 0;
  font-family: var(--tk-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--tk-ink-50);
  /* Clamp to two lines so summaries don't crowd long lists. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.article .tags {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.article .tags .tag {
  font-family: var(--tk-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--tk-ink-50);
  background: var(--tk-ink-08);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  border-bottom: none;
}
.article .tags .tag:hover {
  color: var(--tk-ink);
  background: var(--tk-ink-15);
}
/* The source chip — first in the row, darker so it reads as the outlet
   rather than a topic tag. */
.article .tags .tag-source {
  color: var(--tk-ink);
  font-weight: 500;
}

.article .also {
  margin-top: 0.35rem;
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--tk-ink-50);
}
.article .also a {
  color: var(--tk-ink-50);
  border-bottom: none;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.article .also a:hover { color: var(--tk-ink); }

/* ── Public stats tables ───────────────────────────────────────────── */

.public-stats {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--tk-s-3);
  font-family: var(--tk-serif);
  font-size: 16px;
}
.public-stats td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--tk-ink-15);
}
.public-stats td:nth-child(2),
.public-stats td:nth-child(3) {
  font-family: var(--tk-mono);
  font-size: 13px;
  text-align: right;
  color: var(--tk-ink-50);
  width: 7rem;
}
.public-stats tr:last-child td { border-bottom: none; }
.public-stats strong { color: var(--tk-ink); }
.public-stats .muted-row td { color: var(--tk-ink-50); font-size: 14px; }

.source-stats { font-size: 14px; }
.source-stats th {
  text-align: left;
  font-family: var(--tk-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tk-ink-50);
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--tk-ink-30);
}
.source-stats td {
  padding: 0.45rem 0.5rem;
}
.source-stats td:not(:first-child) {
  width: auto;
  font-family: var(--tk-mono);
  font-size: 12px;
  text-align: right;
  color: var(--tk-ink);
}
.source-stats td .muted {
  display: inline-block;
  color: var(--tk-ink-50);
  margin-left: 0.25rem;
}

.prose .muted, p.muted { color: var(--tk-ink-50); font-size: 14px; }

/* ── Search form ───────────────────────────────────────────────────── */

.search-form {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 var(--tk-s-3);
}
.search-form input[type="search"] {
  flex: 1;
  font-family: var(--tk-serif);
  font-size: 16px;
  padding: 0.55rem 0.75rem;
  background: var(--tk-paper);
  color: var(--tk-ink);
  border: 1px solid var(--tk-ink-30);
  border-radius: 3px;
  outline: none;
}
.search-form input[type="search"]:focus { border-color: var(--tk-ink); }
.search-form button {
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0 1.1rem;
  background: var(--tk-ink);
  color: var(--tk-cream);
  border: 1px solid var(--tk-ink);
  border-radius: 3px;
  cursor: pointer;
}
.search-form button:hover { background: var(--tk-accent); border-color: var(--tk-accent); }

/* ── Dispute form ──────────────────────────────────────────────────── */

.dispute-form { margin: var(--tk-s-3) 0; }
.dispute-form label {
  display: block;
  margin: var(--tk-s-2) 0 0.4rem;
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--tk-ink-50);
}
.dispute-form input[type="text"],
.dispute-form input[type="email"],
.dispute-form textarea {
  width: 100%;
  font-family: var(--tk-serif);
  font-size: 16px;
  padding: 0.55rem 0.75rem;
  background: var(--tk-paper);
  color: var(--tk-ink);
  border: 1px solid var(--tk-ink-30);
  border-radius: 3px;
  outline: none;
}
.dispute-form input:focus,
.dispute-form textarea:focus { border-color: var(--tk-ink); }
.dispute-form textarea { resize: vertical; line-height: 1.5; }
/* Honeypot — kept out of the layout and off-screen, not display:none
   (some bots skip display:none fields). */
.dispute-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
.dispute-form button {
  margin-top: var(--tk-s-2);
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.6rem 1.4rem;
  background: var(--tk-ink);
  color: var(--tk-cream);
  border: 1px solid var(--tk-ink);
  border-radius: 3px;
  cursor: pointer;
}
.dispute-form button:hover { background: var(--tk-accent); border-color: var(--tk-accent); }
.form-error {
  color: var(--tk-accent);
  font-family: var(--tk-mono);
  font-size: 13px;
}

/* ── About / prose ─────────────────────────────────────────────────── */

.prose {
  font-size: 18px;
  line-height: 1.65;
  max-width: 640px;
}
.prose h2 {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0.5rem 0 var(--tk-s-3);
}
.prose h3 {
  font-size: 20px;
  font-weight: 500;
  margin: var(--tk-s-4) 0 var(--tk-s-1);
}
.prose p, .prose li { line-height: 1.7; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: 0.55rem; }
.prose strong { font-weight: 600; }
.prose em { color: var(--tk-ink-50); }

/* ── Footer ────────────────────────────────────────────────────────── */

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--tk-s-4) var(--tk-s-3) var(--tk-s-5);
  border-top: 1px solid var(--tk-ink-15);
  font-family: var(--tk-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--tk-ink-50);
}
.site-footer p { margin: 0.5rem 0; line-height: 1.6; }
.site-footer a { color: var(--tk-ink-50); border-bottom: none; }
.site-footer a:hover { color: var(--tk-ink); }

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .brand h1 { font-size: 38px; }
  .topic h2 { font-size: 18px; }
  .topic-title { font-size: 30px; }
  .article .headline { font-size: 17px; }
  .prose { font-size: 16px; }
  .prose h2 { font-size: 28px; }
  main, .site-header, .site-footer { padding-left: var(--tk-s-2); padding-right: var(--tk-s-2); }
  /* Stack the masthead under the brand on narrow viewports. */
  .site-header {
    grid-template-columns: 1fr;
    grid-template-areas: "brand" "masthead" "nav";
  }
  .site-header .masthead-right { text-align: left; }
  .masthead-right .masthead-count { margin-left: 0; text-align: left; }
  /* Search box wraps to its own full-width line on narrow viewports. */
  .site-header nav .nav-search { margin-left: 0; width: 100%; }
  .site-header nav .nav-search input { width: 100%; }
}
