/* XLNF — xel.css
 * "Xel's room": the /xel/ section, in the Shorts' field-notes look.
 *
 * Two layers live here:
 *   1. The site frame (header + footer) in the site's own terminal look. Its
 *      tokens and rules are duplicated from notes.css on purpose, so /xel/ pages
 *      load one stylesheet. If the frame changes in notes.css, change it here.
 *   2. The room (everything inside <main>): paper, ink, vermilion, highlighter,
 *      Space Grotesk + IBM Plex Mono. Light theme = paper; dark theme = the same
 *      room with the lights off.
 *
 * Pages are generated by xel-build.py from templates/xel-*.html. Don't hand-edit
 * xel/**\/index.html; edit the template or the episode's episode.json.
 */

/* ---------- fonts (self-hosted, subset; OFL texts beside the files) ---------- */
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/SpaceGrotesk-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/SpaceGrotesk-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

/* ---------- tokens ---------- */
:root {
  /* site frame (terminal) — mirrors notes.css */
  --t-font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --t-bg: #0d1117;
  --t-fg: #c9d1d9;
  --t-muted: #8b949e;
  --t-accent: #7ee787;
  --t-border: #30363d;

  /* room — dark by default, matching the site's default theme */
  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --paper: #191816;
  --paper-deep: #22201d;
  --ink: #efeae0;
  --graphite: #a29c90;
  --rule: #3b372f;
  --signal: #ff5a2e;
  --signal-soft: #4a2418;
  --highlighter: rgba(255, 225, 77, 0.32);
  --shadow: #000000;
  --card: #22201d;
  --dot: rgba(239, 234, 224, 0.09);
}
:root[data-theme="light"] {
  --t-bg: #121820;
  --t-border: #363d47;

  --paper: #efeae0;
  --paper-deep: #e5dfd2;
  --ink: #151413;
  --graphite: #6e695f;
  --rule: #cfc7b8;
  --signal: #ff4a1c;
  --signal-soft: #ffd3c2;
  --highlighter: #ffe14d;
  --shadow: #151413;
  --card: #f7f3ea;
  --dot: rgba(21, 20, 19, 0.13);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  display: flex; flex-direction: column; min-height: 100vh;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font-sans); font-weight: 500; font-size: 17px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--signal); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--signal); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--signal); color: #fff; padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- site frame: header + footer (terminal look) ---------- */
header.site-header, footer.site-footer {
  background: var(--t-bg); color: var(--t-fg);
  font-family: var(--t-font); font-weight: 400; font-size: 15px; line-height: 1.55;
}
.frame { max-width: 72ch; margin: 0 auto; padding: 0 20px; }
header.site-header { border-bottom: 1px solid var(--t-border); padding: 20px 0 16px; }
header.site-header a, footer.site-footer a { color: var(--t-accent); text-decoration: none; }
header.site-header a:hover { text-decoration: underline; }
header.site-header .prompt { color: var(--t-muted); margin: 0 0 12px; }
header.site-header .prompt .cursor {
  display: inline-block; width: 0.6ch; background: var(--t-accent); color: transparent;
  animation: blink 1s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.header-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--t-muted); }
#theme-toggle {
  background: transparent; border: 1px solid var(--t-border); color: var(--t-fg);
  font-family: inherit; font-size: inherit; padding: 2px 8px; cursor: pointer;
}
#theme-toggle:hover { border-color: var(--t-accent); }
footer.site-footer { border-top: 1px solid var(--t-border); color: var(--t-muted); padding: 16px 0 24px; font-size: 0.9rem; }
footer.site-footer a { color: var(--t-muted); text-decoration: underline; }

#scroll-top {
  position: fixed; right: 16px; bottom: 16px; z-index: 10;
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--shadow);
  padding: 0.4rem 0.7rem; cursor: pointer;
}
#scroll-top[hidden] { display: none; }

/* ---------- room layout ---------- */
main { flex: 1; padding: 28px 0 56px; }
.room { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.prose { max-width: 68ch; }

h1, h2, h3 { font-family: var(--font-sans); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.1rem); margin: 6px 0 14px; }
h2 { font-size: 1.45rem; margin: 44px 0 14px; }
h3 { font-size: 1.1rem; margin: 22px 0 8px; }
p { margin: 12px 0; }

/* highlighter stroke under key words */
.hl {
  background-image: linear-gradient(var(--highlighter), var(--highlighter));
  background-repeat: no-repeat; background-size: 100% 0.42em; background-position: 0 88%;
  padding: 0 0.08em; -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* small mono label, field-notes style */
.label {
  font-family: var(--font-mono); font-weight: 600; font-size: 0.74rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--graphite);
}
.kicker { margin: 0; }
.kind {
  display: inline-block; font-family: var(--font-mono); font-weight: 600; font-size: 0.72rem;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--signal); color: #fff; padding: 2px 8px; margin-right: 6px;
}
.meta { font-family: var(--font-mono); font-size: 0.82rem; color: var(--graphite); }

.breadcrumb { font-family: var(--font-mono); font-size: 0.8rem; color: var(--graphite); margin: 0 0 18px; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4em; }
.breadcrumb li::after { content: " /"; color: var(--rule); }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb a { color: var(--graphite); text-decoration-color: var(--rule); }

/* card: paper sheet with a hard ink drop shadow */
.card {
  background: var(--card); border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--shadow);
  padding: 20px 22px; margin: 0 8px 8px 0;
}
:root:not([data-theme="light"]) .card { border-color: var(--rule); }

/* ---------- landing ---------- */
/* /xel/ is where Shorts viewers land: on a phone the hero stays compact so the
   newest entry and its links show on first load. */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; }
.hero img { grid-row: span 2; width: 64px; height: 64px; }
.hero h1 { margin: 0; font-size: 2.4rem; }
.hero .kicker { grid-column: 2; }
.hero + p { margin-top: 12px; }
.card > .meta { font-size: 0.76rem; line-height: 1.5; }
.card > .actions { margin-top: 12px; }
.episodes-title { margin-top: 26px; }
.formats { margin-top: 12px; }
@media (max-width: 639px) {
  .room > .breadcrumb { margin-bottom: 12px; }
  .room > .card { padding: 16px 18px; }
  .hero + p { font-size: 1rem; line-height: 1.5; }
}
@media (min-width: 640px) { .hero { gap: 4px 22px; } .hero img { width: 132px; height: 132px; } .hero h1 { font-size: 4rem; } }

.facts { list-style: none; padding: 0; margin: 14px 0; }
.facts li { padding-left: 1.4em; position: relative; margin: 8px 0; }
.facts li::before { content: "→"; position: absolute; left: 0; color: var(--signal); font-family: var(--font-mono); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-weight: 600; font-size: 0.86rem;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  padding: 8px 14px; text-decoration: none; box-shadow: 4px 4px 0 var(--shadow);
}
.btn:hover { color: var(--ink); transform: translate(1px, 1px); box-shadow: 3px 3px 0 var(--shadow); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: #fff; }
:root[data-theme="light"] .btn.primary { border-color: var(--ink); }
.btn.pending { border-style: dashed; color: var(--graphite); box-shadow: none; cursor: default; }
.btn.pending:hover { transform: none; }
:root:not([data-theme="light"]) .btn:not(.primary) { border-color: var(--rule); }

.episodes { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 26px; }
.episode-card { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: start; }
.episode-card .thumb { width: 96px; aspect-ratio: 9 / 16; object-fit: cover; border: 2px solid var(--ink); background: var(--paper-deep); }
.episode-card h3 { margin: 6px 0 6px; font-size: 1.2rem; }
.episode-card h3 a { text-decoration: none; }
.episode-card h3 a:hover { text-decoration: underline; text-decoration-color: var(--signal); }
.episode-card p { margin: 6px 0 0; font-size: 0.96rem; }
.episode-card .kicker .meta { white-space: nowrap; }  /* keep "2026-11-11 · 40.5 s" on one line */
@media (min-width: 640px) { .episode-card { grid-template-columns: 120px 1fr; } .episode-card .thumb { width: 120px; } }
.empty { color: var(--graphite); font-family: var(--font-mono); font-size: 0.9rem; }

/* ---------- episode ---------- */
.ep-head { margin-bottom: 26px; }
.ep-head .summary { font-size: 1.12rem; max-width: 62ch; }
.ep-grid { display: grid; gap: 34px; }
@media (min-width: 860px) {
  .ep-grid { grid-template-columns: 300px minmax(0, 1fr); gap: 44px; align-items: start; }
  .ep-side { position: sticky; top: 20px; }
}

/* the Short: 9:16 */
.short { margin: 0 auto; max-width: 300px; }
.short .frame916 {
  position: relative; aspect-ratio: 9 / 16; width: 100%;
  border: 2px solid var(--ink); box-shadow: 8px 8px 0 var(--shadow);
  background: var(--paper-deep); overflow: hidden;
}
.short iframe, .short .frame916 img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.short .soon {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%) rotate(-2deg);
  white-space: nowrap; background: #151413; color: #efeae0; /* fixed: sits on the poster, which is always paper */
  font-family: var(--font-mono); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 6px 12px; border: 2px solid #151413;
}
.short figcaption { margin-top: 14px; }
.short .actions { margin-top: 18px; }

.transcript { counter-reset: line; list-style: none; padding: 0; margin: 10px 0; }
.transcript li { counter-increment: line; position: relative; padding: 10px 0 10px 2.6em; border-top: 1px dashed var(--rule); }
.transcript li:last-child { border-bottom: 1px dashed var(--rule); }
.transcript li::before {
  content: counter(line, decimal-leading-zero); position: absolute; left: 0; top: 12px;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--graphite);
}
.cite { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.cite a {
  display: inline-block; text-decoration: none; color: var(--ink);
  background: var(--signal-soft); border: 1px solid var(--signal); padding: 0 5px; margin-left: 4px;
}
.cite a:hover { background: var(--signal); color: #fff; }

.body > :first-child { margin-top: 0; }
.body blockquote, .body pre { font-family: var(--font-mono); }
.body code { font-family: var(--font-mono); font-size: 0.9em; background: var(--paper-deep); padding: 0.1em 0.35em; }

/* claims */
.claims { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 26px; }
.claim { scroll-margin-top: 16px; }
.claim:target { outline: 3px solid var(--signal); outline-offset: 4px; }
.claim .claim-id { font-family: var(--font-mono); font-weight: 600; font-size: 0.8rem; color: var(--signal); letter-spacing: 0.08em; }
.claim .statement { margin: 4px 0 12px; font-size: 1.04rem; }
.claim blockquote {
  margin: 10px 0; padding: 10px 14px;
  background: var(--paper-deep); border-left: 4px solid var(--signal);
  font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.claim .source { margin: 10px 0 0; font-family: var(--font-mono); font-size: 0.78rem; color: var(--graphite); overflow-wrap: anywhere; }
.claim .source strong { color: var(--ink); font-weight: 600; }

.disclosure {
  margin: 40px 0 0; padding: 14px 16px; border: 2px dashed var(--rule);
  font-family: var(--font-mono); font-size: 0.82rem; color: var(--graphite);
}
.ep-foot { margin-top: 28px; }

/* problem-first episodes (episode.json has "actions"): applies-to + actions sit under the title */
.applies { margin: 12px 0 0; max-width: 62ch; font-size: 0.98rem; }
.applies .label { display: block; margin-bottom: 2px; }
.ep-actions { margin: 18px 0 0; }
.ep-actions .btn, .entry-actions .btn { min-height: 44px; }
.ep-actions .btn.primary { font-size: 1rem; padding: 10px 20px; min-height: 52px; }
@media (max-width: 520px) { .ep-actions .btn { flex: 1 1 100%; justify-content: center; } }
.refs { padding-left: 1.2em; margin: 10px 0; }
.refs li { margin: 8px 0; overflow-wrap: anywhere; }
.ep-main > .summary { font-size: 1.12rem; margin-top: 0; }
.entry-actions { margin: 10px 0 0; gap: 10px; }
.entry-actions .btn { font-size: 0.8rem; padding: 8px 12px; }

/* series ("series" in episode.json): a line under the title, a tag on the catalogue entry */
.series { margin: 10px 0 0; font-family: var(--font-mono); font-size: 0.86rem; }
.series .label { margin-right: 8px; }
.series-tag { margin-left: 6px; }

/* episode navigation: catalogue order, a bar under the breadcrumb and a block after Sources */
.ep-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center;
  margin: -6px 0 22px; font-family: var(--font-mono); font-size: 0.84rem; }
.ep-nav a { text-decoration: none; padding: 10px 0; }  /* 44 px tap height with the line */
.ep-nav a:hover { text-decoration: underline; text-decoration-color: var(--signal); }
.ep-nav .newer { text-align: right; }
.ep-nav .all { text-align: center; color: var(--graphite); }
.ep-nav-end { display: grid; gap: 14px; margin: 40px 0 0; padding-top: 18px; border-top: 2px solid var(--rule); }
.ep-nav-end a { text-decoration: none; display: block; }
.ep-nav-end .dir { display: block; font-family: var(--font-mono); font-size: 0.78rem; color: var(--graphite);
  letter-spacing: 0.06em; text-transform: uppercase; }
.ep-nav-end .t { font-weight: 600; }
.ep-nav-end a:hover .t { text-decoration: underline; text-decoration-color: var(--signal); }
.ep-nav-end .newer { text-align: right; }
.ep-nav-end .all { font-family: var(--font-mono); font-size: 0.86rem; }

/* catalogue search (xel-search.js) */
.ep-search { margin: 12px 0 4px; }
.episodes > [hidden], .ep-search[hidden] { display: none; }  /* .episode-card sets display: grid */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ep-search input {
  width: 100%; max-width: 520px; box-sizing: border-box; min-height: 44px;
  font-family: var(--font-mono); font-size: 1rem; /* 16px: no iOS zoom on focus */
  color: var(--ink); background: var(--card); border: 2px solid var(--ink); padding: 8px 12px;
  box-shadow: 4px 4px 0 var(--shadow);
}
:root:not([data-theme="light"]) .ep-search input { border-color: var(--rule); }
.ep-search input:focus { outline: 3px solid var(--signal); outline-offset: 2px; }
.ep-search .meta { margin: 8px 0 0; }
.ep-search .meta:empty { display: none; }  /* no count line until something is typed */
.linkish { font: inherit; color: var(--signal); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; }

/* Xel's notes (body_html): Xel's own long-form view, set apart from the sourced material */
.xel-notes .body { border-left: 3px solid var(--signal); padding-left: 18px; }
.xel-notes .body h3 { margin: 26px 0 8px; font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
  header.site-header .prompt .cursor { animation: none; }
  .btn:hover { transform: none; }
}
