/* dailydigest theme
   Shared by every source. Pages are built by scripts/build.py from data/<source>/<date>.json.
   Based on the approved 2026-10-02 HN Daily reference page. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1b1f27;
  --muted: #5d6573;
  --rule: #dfe2e8;
  --accent: #c4501a;
  --accent-soft: #fbeee6;
  --panel: #eceef2;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-latin: "IBM Plex Sans", "Noto Sans TC", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  /* Light only: the site has no dark mode, even when the OS is set to dark. */
  color-scheme: only light;
}

/* Per-source brand color. build.py sets these on each source's wrapper from
   sources/<id>/source.json "color":
     --src-brand  the brand color (used as-is for bars, stripes and tints)
     --src-on     text color that sits on the brand color
   --src is the color for borders and tints; --src-text is a darker shade for small
   text, since bright brand colors (e.g. #ff6600) are too light to read on white. */
.digest, .toc-group {
  --src: var(--src-brand, var(--accent));
  --src-text: color-mix(in srgb, var(--src) 78%, #000000);
  --src-bar-bg: var(--src);
  --src-bar-ink: var(--src-on, #ffffff);
}

* { box-sizing: border-box; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}
.page { max-width: 60rem; margin: 0 auto; padding: 1.25rem 16px 3rem; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* Top bar: breadcrumb back to the archive */
.topbar {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted);
  padding-bottom: 1rem;
}
.topbar a { color: var(--muted); text-decoration: none; }
.topbar a:hover { color: var(--accent); }

/* Header */
.masthead { display: grid; gap: 0.35rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--rule); }
.eyebrow {
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin: 0;
}
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0; font-weight: 700; text-wrap: balance; }
.overview { margin: 0.25rem 0 0; }
.source { margin: 0; font-size: 0.875rem; color: var(--muted); }

/* Index of items */
.index { padding-block: 1.1rem; border-bottom: 1px solid var(--rule); }
.toc-group + .toc-group { margin-top: 0.9rem; }
.toc-group h2 {
  display: flex; align-items: baseline; gap: 0.6rem;
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 500; margin: 0 0 0.35rem;
}
.toc-group h2 a { color: var(--src-text); text-decoration: none; font-weight: 600; }
.toc-group { border-left: 3px solid var(--src); padding-left: 0.75rem; }
.toc-count { color: var(--muted); letter-spacing: 0; text-transform: none; }
.index ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.index li a {
  display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 0.5rem;
  align-items: baseline; padding: 0.2rem 0.5rem; margin-inline: -0.5rem;
  border-radius: 6px; color: var(--ink); text-decoration: none;
}
.index li a:hover { background: var(--surface); }
.index .rank { font-family: var(--font-mono); color: var(--src-text, var(--accent)); font-variant-numeric: tabular-nums; }
.index .t { font-family: var(--font-latin); font-weight: 500; line-height: 1.35; }
.index .pts { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Items */
.story {
  display: grid; gap: 0.6rem; margin-top: 0.75rem; padding: 1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--src, var(--accent));
  border-radius: 10px; scroll-margin-top: 3.25rem;
}
.story-head { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: 0.2rem 0.75rem; }
.story-rank {
  font-family: var(--font-mono); font-size: 1.4rem; line-height: 1.3; color: var(--src-text, var(--accent));
  font-variant-numeric: tabular-nums; grid-row: span 2;
}
.story-title {
  font-family: var(--font-latin); font-size: 1.2rem; line-height: 1.35; font-weight: 600;
  margin: 0; text-wrap: balance; overflow-wrap: anywhere;
}
.meta {
  display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; align-items: center;
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.meta a {
  display: inline-block; padding: 0.1rem 0.6rem; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink); text-decoration: none; font-family: var(--font-body); font-size: 0.8rem; background: var(--surface);
}
.meta a:hover { border-color: var(--src, var(--accent)); color: var(--src-text, var(--accent)); }
.lede { font-size: 1.02rem; font-weight: 500; margin: 0; }

.block { display: grid; gap: 0.25rem; min-width: 0; }
.label {
  font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0; font-weight: 500;
}
.label span { font-family: var(--font-body); letter-spacing: 0.04em; }
.block p { margin: 0; }
.block ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.2rem; }
.block li::marker { color: var(--muted); }
.block.panel { background: var(--panel); border-radius: 8px; padding: 0.7rem 0.95rem; }
.note {
  font-size: 0.85rem; color: var(--muted); background: var(--accent-soft);
  padding: 0.3rem 0.6rem; border-radius: 6px; margin: 0 0 0.25rem;
}
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--panel); padding: 0.05em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
.panel code { background: var(--surface); }

/* One source inside an edition page */
.digest { margin-top: 1.75rem; scroll-margin-top: 0; }
.digest-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: 0.45rem 1rem; border-radius: 8px; white-space: nowrap;
  background: var(--src-bar-bg); color: var(--src-bar-ink);
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.digest-head a { color: var(--src-text); }
.digest-bar .name { font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.digest-bar span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.digest-head {
  display: grid; gap: 0.3rem; margin-top: 0.75rem; padding: 0.9rem 1.15rem;
  background: color-mix(in srgb, var(--src) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--src) 25%, var(--rule)); border-radius: 10px;
}
.digest-title { font-size: 1.35rem; line-height: 1.3; margin: 0; font-weight: 700; }
.digest-title span { font-size: 0.95rem; font-weight: 500; color: var(--muted); }

/* Curation log at the end of a source: skipped and merged articles */
.curation {
  margin-top: 0.75rem; padding: 0.75rem 1rem; border: 1px dashed var(--rule); border-radius: 10px;
  font-size: 0.85rem; color: var(--muted);
}
.curation ul { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.curation li { line-height: 1.45; }
.curation a { color: var(--ink); text-decoration: none; }
.curation a:hover { color: var(--src-text, var(--accent)); text-decoration: underline; }
.note-type {
  display: inline-block; margin-right: 0.4rem; padding: 0 0.4rem; border-radius: 4px;
  background: var(--panel); color: var(--ink); font-size: 0.75rem;
}
.note-rank { font-family: var(--font-mono); font-size: 0.78rem; }
.note-reason { display: block; padding-left: 0.1rem; }

/* Previous / next day */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; padding-top: 1.25rem;
  font-size: 0.9rem;
}
.pager a, .pager > span {
  display: grid; gap: 0.1rem; padding: 0.55rem 0.9rem; border: 1px solid var(--rule);
  border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager > span { visibility: hidden; }
.pager .dir { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.pager .next { text-align: right; }

.foot { padding-top: 1.1rem; font-size: 0.85rem; color: var(--muted); }

/* Archive (site/index.html): one section per month, one row per edition */
.archive { padding-block: 0.5rem 1.1rem; }
.month { padding-top: 1.1rem; scroll-margin-top: 1rem; }
.month + .month { margin-top: 0.6rem; border-top: 1px solid var(--rule); }
.month-title {
  display: flex; align-items: baseline; gap: 0.6rem;
  font-size: 1.15rem; line-height: 1.3; margin: 0 0 0.6rem; font-weight: 700;
}
.month-count { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 400; color: var(--muted); }
.months { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.9rem; }
.months a {
  padding: 0.15rem 0.7rem; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.85rem;
}
.months a:hover { border-color: var(--accent); color: var(--accent); }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.days a {
  display: grid; gap: 0.15rem; padding: 0.55rem 0.9rem; border: 1px solid var(--rule);
  border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none;
}
.days a:hover { border-color: var(--accent); }
.days .d { font-weight: 700; color: var(--accent); }
.days .o b { color: var(--ink); font-weight: 500; }
.days .o {
  font-size: 0.9rem; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

/* Wide screens: two-column table of contents (fills down, then across) */
@media (min-width: 900px) {
  .index ol { display: block; columns: 2; column-gap: 2.5rem; }
  .index li a { margin-inline: 0; }
  .index li { break-inside: avoid; }
}

@media (max-width: 480px) {
  .story { padding: 0.85rem 0.85rem 0.9rem; }
  .digest-head { padding: 0.8rem 0.9rem; }
  /* Phones: source name on the first line, date and count on the second */
  .digest-bar { flex-direction: column; align-items: flex-start; gap: 0.05rem;
    padding: 0.4rem 0.75rem; font-size: 0.75rem; line-height: 1.35; white-space: normal; }
  .digest-bar span:last-child { overflow: visible; }
  .story { scroll-margin-top: 4rem; }
  h1 { font-size: 1.6rem; }
  /* Phones: rank on its own line above the title, so the title uses the full width */
  .story-head { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
  .story-rank { grid-row: auto; font-size: 1rem; line-height: 1.2; }
  .index li a { grid-template-columns: 1.6rem minmax(0, 1fr); }
  .index .pts { grid-column: 2; }
}
