/* Readout — an engineering pad for the day's reading.
   Graphite ink on pad-green paper. Yellow highlighter means "new since your last visit";
   ballpoint blue means "you can press this". Nothing else gets colour. */

@font-face { font-family: 'Barlow'; src: url('fonts/barlow-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url('fonts/barlow-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Semi Condensed'; src: url('fonts/barlow-semi-condensed-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Semi Condensed'; src: url('fonts/barlow-semi-condensed-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light dark;
  --paper:  light-dark(#edf3e7, #131b16);
  --grid:   light-dark(#e1eada, #18211c);
  --field:  light-dark(#f6f9f2, #19231d);
  --ink:    light-dark(#1c2620, #e2e9de);
  --ink-2:  light-dark(#36433b, #c3cdbf);
  --pencil: light-dark(#56645b, #9aa79e);
  --rule:   light-dark(#c9d6c0, #2b372f);
  --marker: light-dark(#ffe45c, rgb(255 221 64 / 0.3));
  --pen:    light-dark(#2447a6, #97b4ff);
  --red:    light-dark(#b3261e, #ff8f80);
  --amber:  light-dark(#875600, #e3b450);

  --f-title: 'Barlow Semi Condensed', 'Barlow', ui-sans-serif, system-ui, sans-serif;
  --f-text: 'Barlow', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabs-h: 46px;
}
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  /* the grid printed on the back of an engineering pad, showing through */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  font: 400 1rem/1.5 var(--f-text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 20; padding: 8px 12px; background: var(--paper); color: var(--pen); }
.skip:focus { left: 8px; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.app { display: flex; flex-direction: column; min-height: 100vh; }
.rail { display: contents; }
.masthead { order: 1; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 16px 16px 8px; }
.tabs { order: 2; }
main { order: 3; padding: 4px 16px 40px; min-width: 0; }
.rail-foot { order: 4; padding: 8px 16px 48px; }

.wordmark {
  font: 700 1.75rem/1 var(--f-title);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.dateline { grid-column: 1 / -1; margin: 5px 0 0; color: var(--pencil); font-size: 0.875rem; }
.dateline .upd::before { content: ', '; }
.dateline.is-stale { color: var(--red); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; margin: -6px -8px -6px 0;
  border: 0; border-radius: 8px; background: none; color: var(--pencil); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }

/* ── Topic tabs ─────────────────────────────────────────────────────────── */

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 2px; overflow-x: auto; overscroll-behavior-x: contain;
  padding: 0 8px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 13px 8px 10px;
  border-bottom: 3px solid transparent;
  color: var(--pencil); text-decoration: none; white-space: nowrap;
  font: 600 0.9375rem/1 var(--f-title);
}
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { color: var(--ink); border-bottom-color: var(--pen); }
.tab-long { display: none; }
.count {
  min-width: 1.4em; padding: 3px 4px 2px; border-radius: 3px;
  background: var(--marker); color: var(--ink);
  font: 600 0.75rem/1 var(--f-text); text-align: center; font-variant-numeric: tabular-nums;
}
.count.plain { background: none; color: var(--pencil); padding: 0; min-width: 0; }

/* ── Intro + toolbar ────────────────────────────────────────────────────── */

.intro { padding-top: 16px; }
.intro h1 { margin: 0 0 4px; font: 700 1.5rem/1.1 var(--f-title); letter-spacing: -0.005em; }
.intro p { margin: 0 0 6px; max-width: 60ch; color: var(--pencil); font-size: 0.9375rem; line-height: 1.45; }
.intro code { font-size: 0.9em; }
.also { margin-top: 8px; color: var(--pencil); font-size: 0.9375rem; }
.also summary { cursor: pointer; color: var(--pen); font-weight: 600; width: fit-content; }
.also ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.also li a { color: var(--pen); font-weight: 600; }
.also li span { color: var(--pencil); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 14px 0 4px; }
.toolbar[hidden] { display: none; }
.search { position: relative; flex: 1 1 100%; }
.search svg { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--pencil); pointer-events: none; }
.search input {
  width: 100%; padding: 9px 12px 9px 36px;
  border: 1.5px solid var(--rule); border-radius: 6px;
  background: var(--field); color: var(--ink);
  font: 400 1rem/1.2 var(--f-text);
}
.search input::placeholder { color: var(--pencil); opacity: 1; }
.search input:focus { outline: none; border-color: var(--pen); }
.seg { display: inline-flex; border: 1.5px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { padding: 7px 11px; border: 0; background: none; color: var(--pencil); font-weight: 600; font-size: 0.875rem; cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--pencil); font-size: 0.875rem; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--pen); }
.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--pen); font-weight: 600; font-size: 0.875rem;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.toolbar .link-btn { display: none; margin-left: auto; }
.list-end { margin: 22px 0 0; text-align: center; }

.filter-note, .result-note { margin: 12px 0 0; color: var(--pencil); font-size: 0.9375rem; }
.filter-note strong { color: var(--ink); }
.filter-note .link-btn, .result-note .link-btn { margin-left: 8px; font-size: inherit; }

/* ── Timeline ───────────────────────────────────────────────────────────── */

.day-group { margin-top: 14px; }
.day {
  position: sticky; top: var(--tabs-h); z-index: 2;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 0 6px;
  background: var(--paper);
  box-shadow: -8px 0 0 var(--paper), 8px 0 0 var(--paper);
  border-bottom: 1.5px solid var(--ink);
}
.day h2 { margin: 0; font: 700 1.0625rem/1.1 var(--f-title); }
.day span { color: var(--pencil); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

.item { padding: 16px 0 18px; }
.item + .item { border-top: 1px solid var(--rule); }
.item-meta { display: flex; align-items: center; gap: 10px; min-height: 24px; color: var(--pencil); font-size: 0.8125rem; }
.item-source { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta time { margin-left: auto; flex: none; font-variant-numeric: tabular-nums; }
.item-title { margin: 3px 0 0; font: 600 1.1875rem/1.24 var(--f-title); letter-spacing: -0.003em; text-wrap: pretty; }
.item-title a { text-decoration: none; }
.item-title a:hover { text-decoration: underline; text-decoration-color: var(--pen); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.item-authors { margin: 4px 0 0; color: var(--pencil); font-size: 0.8125rem; }
.item-summary {
  margin: 6px 0 0; max-width: 68ch; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.5;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.item-extras { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 9px; color: var(--pencil); font-size: 0.8125rem; }
.item-extras a { color: var(--pen); font-weight: 600; text-decoration: none; }
.item-extras a:hover { text-decoration: underline; text-underline-offset: 2px; }
.item.is-read .item-title, .is-read > a { color: var(--pencil); }

.save {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; margin: -6px -9px -6px -4px;
  border: 0; border-radius: 8px; background: none; color: var(--pencil); cursor: pointer;
}
.save:hover { color: var(--ink); }
.save[aria-pressed='true'] { color: var(--pen); --fill: currentColor; }

/* The highlighter. Only ever means "new since your last visit". */
.mark { padding: 0 3px; margin: 0 -3px; border-radius: 2px 4px 3px 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.is-new .mark {
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-position: 0 86%;
  background-size: 100% 64%;
}
@media (prefers-reduced-motion: no-preference) {
  .is-new.draw .mark { animation: highlight 520ms cubic-bezier(0.3, 0.6, 0.2, 1) both; animation-delay: calc(140ms + var(--i, 0) * 65ms); }
}
@keyframes highlight { from { background-size: 0% 64%; } to { background-size: 100% 64%; } }

.more {
  display: block; width: 100%; margin: 20px 0 0; padding: 12px;
  border: 1.5px solid currentColor; border-radius: 6px; background: none;
  color: var(--pen); font-weight: 600; cursor: pointer;
}

/* ── By source ──────────────────────────────────────────────────────────── */

.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 30px 32px; margin-top: 22px; }
.src { padding-top: 10px; border-top: 2px solid var(--ink); }
.src-name { margin: 0; font: 700 1.125rem/1.2 var(--f-title); }
.src-name a { text-decoration: none; }
.src-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.src-meta, .src-status { margin: 2px 0 0; color: var(--pencil); font-size: 0.8125rem; }
.src-status.bad { color: var(--red); font-weight: 600; }
.src-status.stale { color: var(--amber); font-weight: 600; }
.src-items { margin: 10px 0 8px; padding: 0; list-style: none; }
.src-items li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; }
.src-items li + li { border-top: 1px solid var(--rule); }
.src-items a { text-decoration: none; font: 600 1rem/1.3 var(--f-title); }
.src-items a:hover { text-decoration: underline; text-underline-offset: 3px; }
.src-items time { flex: none; color: var(--pencil); font-size: 0.8125rem; }

/* ── Feed health ────────────────────────────────────────────────────────── */

.health { width: 100%; margin-top: 18px; border-collapse: collapse; font-size: 0.9375rem; }
.health th { padding: 8px 10px 8px 0; border-bottom: 1.5px solid var(--ink); color: var(--pencil); font-size: 0.8125rem; font-weight: 600; text-align: left; }
.health td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.health td a { font-weight: 600; text-decoration: none; }
.health td a:hover { text-decoration: underline; }
.health .cat { margin-left: 8px; color: var(--pencil); font-size: 0.8125rem; }
.health .err { display: block; margin-top: 3px; color: var(--pencil); font-size: 0.8125rem; overflow-wrap: anywhere; }
.health .num { text-align: right; font-variant-numeric: tabular-nums; }
.st-ok { color: var(--pencil); }
.st-stale { color: var(--amber); font-weight: 600; }
.st-error { color: var(--red); font-weight: 600; }

/* ── States ─────────────────────────────────────────────────────────────── */

.empty { max-width: 48ch; padding: 36px 0; color: var(--pencil); }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); font: 700 1.1875rem/1.3 var(--f-title); }
.empty p { margin: 0 0 8px; }
.empty .more { width: auto; padding: 10px 18px; }

.loading { display: grid; gap: 12px; padding-top: 36px; }
.loading span { display: block; height: 14px; border-radius: 3px; background: var(--rule); opacity: 0.7; }
.loading span:nth-child(3n + 1) { width: 32%; height: 11px; margin-top: 14px; }
.loading span:nth-child(3n + 2) { width: 88%; height: 18px; }
.loading span:nth-child(3n) { width: 70%; }

.rail-foot { color: var(--pencil); font-size: 0.875rem; }
.rail-foot p { margin: 0 0 8px; }
.rail-foot a { color: var(--pen); font-weight: 600; }
.rail-foot .warn { margin-left: 6px; color: var(--amber); font-weight: 600; }

/* ── Wider screens ──────────────────────────────────────────────────────── */

@media (min-width: 640px) {
  .search { flex: 1 1 260px; }
  .toolbar .link-btn { display: inline; }
  .list-end { display: none; }
  .intro h1 { font-size: 1.875rem; }
  .item-title { font-size: 1.3125rem; }
  .item-summary { font-size: 1rem; }
}

@media (min-width: 1000px) {
  .app {
    display: grid; grid-template-columns: 230px minmax(0, 760px);
    justify-content: center; column-gap: 64px; padding: 0 32px;
  }
  .rail {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 40px 0 28px;
  }
  .masthead { padding: 0 0 24px; }
  .wordmark { font-size: 2.125rem; }
  .dateline span { display: block; }
  .dateline .upd::before { content: none; }
  .dateline .upd::first-letter { text-transform: uppercase; }
  .tabs {
    position: static; flex-direction: column; gap: 0;
    overflow: visible; padding: 0; border: 0; background: none;
  }
  .tab { justify-content: space-between; padding: 9px 12px 9px 13px; border-bottom: 0; border-left: 3px solid transparent; font-size: 1.0625rem; }
  .tab[aria-current='page'] { border-left-color: var(--pen); }
  .tab-long { display: inline; }
  .tab-short { display: none; }
  .rail-foot { margin-top: auto; padding: 28px 0 0; }
  main { padding: 26px 0 96px; }
  .intro h1 { font-size: 2.25rem; }
  .day { top: 0; }
  .item-summary { -webkit-line-clamp: 3; line-clamp: 3; }
}
