/* ---------------------------------------------------------------------
   Dan Archive -- a reading-room for deep-dive knowledge videos.

   Design direction: an editorial / reference-shelf feel -- ink on paper,
   not a video-hosting-site clone and not a generic SaaS template. Serif
   throughout (headings and body both), warm paper/ink palette in light
   mode, warm charcoal/parchment in dark mode, a single brick-red accent
   borrowed from library due-date stamps and sealing wax rather than a
   default purple/blue gradient. Sharp, minimal radii (2px, not rounded-xl
   pills), hairline rules instead of drop shadows, left-aligned editorial
   layout instead of everything centered.

   Fonts are system stacks only (no Google Fonts / CDN dependency) -- this
   is deliberate: an archive meant to survive independent of any single
   network shouldn't hard-depend on a font CDN's uptime either.
   --------------------------------------------------------------------- */

:root {
  --serif: Charter, "Iowan Old Style", "Sitka Text", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --paper: #f6f1e6;
  --paper-raised: #fffcf5;
  --ink: #201c14;
  --ink-soft: #5c5646;
  --ink-faint: #8b8471;
  --rule: #d9d0ba;
  --accent: #9a3324;
  --accent-ink: #ffffff;
  --teal: #2c5f58;
  --shadow: rgba(32, 28, 20, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15130f;
    --paper-raised: #1d1a14;
    --ink: #ece4d3;
    --ink-soft: #b6ac93;
    --ink-faint: #7d765f;
    --rule: #3a3527;
    --accent: #d8674f;
    --accent-ink: #15130f;
    --teal: #6fada4;
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --paper: #15130f;
  --paper-raised: #1d1a14;
  --ink: #ece4d3;
  --ink-soft: #b6ac93;
  --ink-faint: #7d765f;
  --rule: #3a3527;
  --accent: #d8674f;
  --accent-ink: #15130f;
  --teal: #6fada4;
  --shadow: rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --paper: #f6f1e6;
  --paper-raised: #fffcf5;
  --ink: #201c14;
  --ink-soft: #5c5646;
  --ink-faint: #8b8471;
  --rule: #d9d0ba;
  --accent: #9a3324;
  --accent-ink: #ffffff;
  --teal: #2c5f58;
  --shadow: rgba(32, 28, 20, 0.08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
}

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

img { max-width: 100%; display: block; }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------- masthead ---------------------------- */

.masthead {
  border-bottom: 3px double var(--rule);
  padding: 40px 0 22px;
}

.masthead .kicker {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 10px;
}

.masthead h1 {
  font-size: 40px;
  line-height: 1.1;
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.masthead h1 a { color: var(--ink); }
.masthead h1 a:hover { text-decoration: none; color: var(--accent); }

.masthead .tagline {
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink-soft);
  max-width: 54ch;
  margin: 0;
}

.breadcrumb {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-transform: uppercase;
  padding: 20px 0 0;
}
.breadcrumb a { color: var(--ink-soft); }

/* ---------------------------- filter bar ---------------------------- */

.filterbar {
  font-family: var(--sans);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 22px 0 6px;
}

.filterbar input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filterbar label {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink-soft);
  cursor: pointer;
  background: var(--paper-raised);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.filterbar input:checked + label {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

:root[data-theme="dark"] .filterbar input:checked + label {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .filterbar input:checked + label {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
  }
}

/* ---------------------------- archive list ---------------------------- */

.archive-list {
  list-style: none;
  margin: 18px 0 60px;
  padding: 0;
}

.archive-list .entry {
  display: flex;
  gap: 22px;
  padding: 26px 0;
  border-bottom: 1px solid var(--rule);
  align-items: flex-start;
}

.archive-list .entry .thumb {
  flex: 0 0 220px;
  width: 220px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}

.archive-list .entry .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.archive-list .entry .body { flex: 1; min-width: 0; }

.archive-list .entry .num {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.archive-list .entry h2 {
  font-size: 23px;
  margin: 4px 0 8px;
  line-height: 1.25;
  font-weight: 600;
}

.archive-list .entry h2 a { color: var(--ink); }
.archive-list .entry h2 a:hover { color: var(--accent); text-decoration: none; }

.archive-list .entry p.desc {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 15.5px;
}

.entry-meta, .video-meta {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--teal);
  color: var(--teal);
  border-radius: 2px;
}

.badge.sources {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 620px) {
  .archive-list .entry { flex-direction: column; }
  .archive-list .entry .thumb { width: 100%; flex-basis: auto; }
}

/* ---------------------------- video page ---------------------------- */

.video-page h1 {
  font-size: 32px;
  line-height: 1.2;
  margin: 18px 0 10px;
  font-weight: 600;
}

.video-meta { margin-bottom: 22px; }

.player-frame {
  border: 1px solid var(--rule);
  background: #000;
  margin-bottom: 8px;
}

.player-frame video {
  width: 100%;
  display: block;
}

.watch-elsewhere {
  margin: 10px 0 28px;
  font-family: var(--sans);
  font-size: 13px;
}

.watch-elsewhere a {
  border: 1px solid var(--rule);
  padding: 6px 12px;
  border-radius: 2px;
  color: var(--ink-soft);
}
.watch-elsewhere a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.lede {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 62ch;
  margin: 0 0 30px;
}

.section-label {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
  padding-top: 24px;
  margin: 36px 0 14px;
}

.chapters {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  column-width: 320px;
  column-gap: 32px;
}

.chapters li {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  break-inside: avoid;
  font-size: 15px;
}

.chapters .ts {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  flex: 0 0 auto;
  font-size: 13px;
  padding-top: 3px;
}

.chapters a { color: var(--ink); }
.chapters a:hover { color: var(--accent); }

.sources-group { margin-bottom: 22px; }
.sources-group h3 {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--ink);
}
.sources-group ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.sources-group li { margin-bottom: 4px; }

.index-terms {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.8;
}

/* ---------------------------- footer ---------------------------- */

footer {
  border-top: 3px double var(--rule);
  margin-top: 48px;
  padding: 26px 0 60px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-faint);
}

footer a { color: var(--ink-faint); text-decoration: underline; }

.empty-note {
  font-family: var(--sans);
  color: var(--ink-faint);
  padding: 40px 0;
}
