/* ============================================================
   THE TERMINAL TIMES — Writings section, arielruff.com
   Shared styles: index (front page) + article (sheet)
   ============================================================ */
:root {
  --bg: oklch(0.94 0 0);
  --ink: oklch(0.26 0.012 255);
  --ink-soft: oklch(0.55 0.012 255);
  --amber: oklch(0.55 0.11 65);
  --line: oklch(0.26 0.012 255 / 0.14);
  --line-strong: oklch(0.26 0.012 255 / 0.3);
  --paper: oklch(0.94 0 0);
  --paper-edge: #e8e2d4;
  --newsink: #23272f;
  --news-soft: #555b66;
  --news-softer: #888;
  --news-rule: #c9c2b0;
  --deck-ink: #3a3f49;
  --code-bg: #23272f;
  --code-ink: #e8e6df;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Space Grotesk", system-ui, sans-serif;
  --serif-head: "Playfair Display", Georgia, serif;
  --serif-body: "Source Serif 4", Georgia, serif;
}
[data-theme="dark"] {
  --bg: oklch(0.2 0.01 255);
  --ink: oklch(0.9 0.005 250);
  --ink-soft: oklch(0.65 0.01 255);
  --line: oklch(0.9 0.005 250 / 0.14);
  --line-strong: oklch(0.9 0.005 250 / 0.3);
  --paper: #24262b;
  --paper-edge: #17181c;
  --newsink: #e6e2d8;
  --news-soft: #b8b3a6;
  --news-softer: #8d8a80;
  --news-rule: #46484f;
  --deck-ink: #c9c4b8;
  --code-bg: #17181c;
  --code-ink: #e8e6df;
}
[data-theme="dark"] img { filter: brightness(.88) contrast(1.02); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--ink); font-family: var(--mono); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; transition: background .25s; }
::selection { background: var(--amber); color: white; }
a { color: inherit; }

/* ---------- site nav (matches main site) ---------- */
nav.site {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(20px, 4vw, 56px);
  background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-strong);
  font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase;
}
nav.site .navleft { display: flex; align-items: center; gap: 16px; }
nav.site .brand { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; text-transform: none; text-decoration: none; }
nav.site .sys { color: var(--ink-soft); }
nav.site .links { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 30px); }
nav.site .links a { color: var(--ink-soft); text-decoration: none; transition: color .2s; }
nav.site .links a:hover, nav.site .links a.here { color: var(--ink); }
@media (max-width: 640px) { nav.site .sys { display: none; } }

#theme-toggle {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong);
  border-radius: 6px; cursor: pointer; transition: color .2s, border-color .2s;
}
#theme-toggle:hover { color: var(--amber); border-color: var(--amber); }
#theme-toggle svg { width: 15px; height: 15px; }
[data-theme="dark"] #theme-toggle .ico-moon { display: none; }
:root:not([data-theme="dark"]) #theme-toggle .ico-sun { display: none; }

/* reading progress */
.progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--amber); width: 0%; z-index: 40; transition: width .1s linear; }

/* ============ FRONT PAGE ============ */
.broadsheet {
  max-width: 1080px; margin: 110px auto 80px; background: var(--paper);
  border: 1px solid var(--paper-edge); border-radius: 2px;
  box-shadow: 0 30px 60px -40px oklch(0.26 0.012 255 / 0.5), 0 2px 0 var(--paper-edge);
  padding: clamp(22px, 4vw, 56px); color: var(--newsink);
}
.masthead { text-align: center; border-bottom: 3px double var(--newsink); padding-bottom: 14px; }
.masthead .eyebrow { font-size: 10.5px; letter-spacing: .3em; text-transform: uppercase; color: var(--amber); }
.masthead h1 { font-family: var(--serif-head); font-weight: 900; font-size: clamp(34px, 7vw, 74px); letter-spacing: .01em; line-height: 1; margin: 8px 0 6px; }
.masthead .dateline {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--newsink); margin-top: 12px; padding-top: 8px;
  font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
}
.front { display: grid; grid-template-columns: 1.7fr 1fr; gap: 0; margin-top: 26px; }
@media (max-width: 760px) {
  .front { grid-template-columns: 1fr; }
  .lead { border-right: none !important; padding-right: 0 !important; }
  .rail { padding-left: 0 !important; border-top: 1px solid var(--newsink); margin-top: 26px; padding-top: 20px; }
}
.lead { border-right: 1px solid var(--newsink); padding-right: 32px; }
.kicker { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--amber); font-weight: 600; }
.lead a { color: inherit; text-decoration: none; }
.lead h2 { font-family: var(--serif-head); font-weight: 700; font-size: clamp(26px, 4vw, 44px); line-height: 1.08; margin: 8px 0 12px; }
.lead h2:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--amber); }
.lead .photo { border: 1px solid var(--newsink); margin: 6px 0 10px; }
.lead .photo img { width: 100%; display: block; aspect-ratio: 1.9; object-fit: cover; filter: grayscale(.25) contrast(1.05); }
.lead .photo figcaption { font-size: 10.5px; letter-spacing: .06em; padding: 6px 8px; border-top: 1px solid var(--newsink); text-transform: uppercase; color: var(--news-soft); }
.lead .deck { font-family: var(--serif-body); font-size: 17px; line-height: 1.55; font-style: italic; color: var(--deck-ink); }
.byline { margin-top: 12px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--news-soft); }
.byline b { color: var(--newsink); }
.rail { padding-left: 32px; display: flex; flex-direction: column; }
.rail-item { padding: 16px 0; border-bottom: 1px solid var(--news-rule); }
.rail-item:first-child { padding-top: 0; }
.rail-item a { color: inherit; text-decoration: none; }
.rail-item h3 { font-family: var(--serif-head); font-weight: 700; font-size: 20px; line-height: 1.2; margin: 5px 0 6px; }
.rail-item a:hover h3 { color: var(--amber); }
.rail-item p { font-family: var(--serif-body); font-size: 13.5px; color: var(--news-soft); }
.rail-item .meta { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--news-softer); margin-top: 8px; }
.below-fold { border-top: 3px double var(--newsink); margin-top: 30px; padding-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
@media (max-width: 760px) { .below-fold { grid-template-columns: 1fr; } }
.bf-item a { color: inherit; text-decoration: none; }
.bf-item h4 { font-family: var(--serif-head); font-size: 17px; line-height: 1.25; margin: 4px 0 6px; }
.bf-item a:hover h4 { color: var(--amber); }
.bf-item p { font-family: var(--serif-body); font-size: 12.5px; color: var(--news-soft); }
.bf-item .meta { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--news-softer); margin-top: 6px; }
.index-foot { text-align: center; margin-top: 30px; padding-top: 12px; border-top: 1px solid var(--newsink); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--news-softer); }
.index-foot a { color: var(--amber); text-decoration: none; }
.empty-press { text-align: center; padding: 60px 10px; font-family: var(--serif-body); font-style: italic; font-size: 17px; color: var(--news-soft); }

/* ============ ARTICLE ============ */
.article-stage { padding: 96px 16px 90px; position: relative; }
.article-layout { max-width: 880px; margin: 0 auto; position: relative; }
.sheet {
  background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 2px; color: var(--newsink);
  box-shadow: 0 30px 60px -40px oklch(0.26 0.012 255 / 0.5), 0 2px 0 var(--paper-edge);
}
.sheet .feature { position: relative; }
.sheet .feature img { width: 100%; display: block; aspect-ratio: 2.2; object-fit: cover; filter: grayscale(.2) contrast(1.05); cursor: zoom-in; }
.sheet .feature .section-flag {
  position: absolute; top: 18px; left: 18px; background: var(--paper); border: 1px solid var(--newsink);
  padding: 6px 12px; font-size: 10px; letter-spacing: .24em; text-transform: uppercase; font-weight: 600;
}
.sheet .feature figcaption { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--news-softer); padding: 8px 18px 0; }
.sheet-inner { padding: clamp(24px, 5vw, 60px); }
.art-head { border-bottom: 3px double var(--newsink); padding-bottom: 18px; margin-bottom: 26px; }
.art-head .kicker { display: block; margin-bottom: 8px; }
.art-head h1 { font-family: var(--serif-head); font-weight: 900; font-size: clamp(30px, 5.4vw, 54px); line-height: 1.06; }
.art-head .deck { font-family: var(--serif-body); font-style: italic; font-size: 18px; color: var(--deck-ink); margin-top: 12px; max-width: 56ch; }
.art-head .byline-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--news-softer); }

.prose { font-family: var(--serif-body); font-size: 17px; line-height: 1.75; max-width: 62ch; }
.prose > * + * { margin-top: 1.25em; }
.prose a { color: inherit; text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.prose a:hover { color: var(--amber); }
.prose strong { font-weight: 600; }
.prose mark { background: linear-gradient(100deg, oklch(0.85 0.14 85 / 0) 1%, oklch(0.85 0.14 85 / 0.7) 3%, oklch(0.85 0.14 85 / 0.4) 98%); color: inherit; padding: 0 3px; }
.prose code { font-family: var(--mono); font-size: .82em; background: color-mix(in oklab, var(--newsink) 8%, transparent); border-radius: 3px; padding: 1px 5px; }
.prose .dropcap::first-letter {
  font-family: var(--serif-head); font-weight: 900; float: left;
  font-size: 4.6em; line-height: .82; padding: 0.04em 0.1em 0 0; color: var(--amber);
}
.prose h2 { font-family: var(--display); font-size: 13px; letter-spacing: .22em; text-transform: uppercase; color: var(--amber); border-top: 1px solid var(--newsink); padding-top: 14px; margin-top: 2em; scroll-margin-top: 80px; }
.prose blockquote { border-left: 3px solid var(--amber); padding-left: 20px; font-style: italic; font-size: 19px; color: var(--deck-ink); }
.prose blockquote .attr { display: block; margin-top: 6px; font-family: var(--mono); font-style: normal; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--news-softer); }
.prose hr { border: none; border-top: 3px double var(--newsink); width: 120px; margin: 2.2em auto; }

/* code blocks */
.codeblock { position: relative; }
.codeblock pre {
  background: var(--code-bg); color: var(--code-ink); border-radius: 4px; padding: 20px 18px 18px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
}
.codeblock .lang { position: absolute; top: 8px; right: 84px; font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: oklch(0.8 0.11 65); }
.codeblock .copy-btn {
  position: absolute; top: 6px; right: 8px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  background: transparent; color: var(--code-ink); border: 1px solid oklch(1 0 0 / 0.25); border-radius: 3px; padding: 3px 8px; cursor: pointer;
}
.codeblock .copy-btn:hover { border-color: oklch(0.8 0.11 65); color: oklch(0.8 0.11 65); }

/* images & galleries */
.figblock { margin: 1.6em 0; }
.figblock img { width: 100%; display: block; border: 1px solid var(--newsink); cursor: zoom-in; }
.figblock figcaption { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--news-softer); padding-top: 7px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 1.6em 0; }
.gallery img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1.2; border: 1px solid var(--newsink); display: block; cursor: zoom-in; }

/* pull quote */
.pullquote {
  border-top: 3px double var(--newsink); border-bottom: 3px double var(--newsink);
  padding: 20px 4px; text-align: center; font-family: var(--serif-head); font-size: clamp(20px, 3vw, 27px); font-weight: 700; line-height: 1.3;
}
.pullquote .attr { display: block; margin-top: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--amber); font-weight: 400; }

/* Tufte sidenotes */
.sn-ref { color: var(--amber); font-weight: 600; cursor: pointer; font-size: .8em; vertical-align: super; }
@media (min-width: 1260px) {
  .sidenote {
    position: absolute; right: -250px; width: 210px;
    font-family: var(--mono); font-size: 11px; line-height: 1.55; color: var(--ink-soft);
    border-left: 2px solid var(--amber); padding-left: 12px;
  }
  .sidenote .sn-num { color: var(--amber); font-weight: 600; }
}
@media (max-width: 1259px) {
  .sidenote { display: none; }
  .sidenote.open { display: block; margin: 1em 0; background: color-mix(in oklab, var(--amber) 9%, var(--paper)); border-left: 2px solid var(--amber); padding: 10px 14px; font-family: var(--mono); font-size: 11.5px; color: var(--news-soft); }
  .sidenote.open .sn-num { color: var(--amber); font-weight: 600; }
}
.prose p { position: relative; }

/* sticky TOC rail */
.toc-rail { display: none; }
@media (min-width: 1420px) {
  .toc-rail {
    display: block; position: fixed; top: 120px; left: max(20px, calc(50vw - 440px - 260px)); width: 220px;
    font-size: 11px;
  }
  .toc-rail .toc-title { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 10px; }
  .toc-rail a { display: block; color: var(--ink-soft); text-decoration: none; padding: 5px 0 5px 12px; border-left: 2px solid var(--line); line-height: 1.4; transition: color .15s, border-color .15s; }
  .toc-rail a:hover { color: var(--ink); }
  .toc-rail a.here { color: var(--amber); border-left-color: var(--amber); }
}

.art-foot { border-top: 3px double var(--newsink); margin-top: 40px; padding-top: 14px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--news-softer); font-family: var(--mono); }
.art-foot a { color: var(--news-soft); text-decoration: none; }
.art-foot a:hover { color: var(--amber); }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: oklch(0.15 0.01 255 / 0.94);
  display: none; align-items: center; justify-content: center; padding: 4vh 4vw; cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox .lb-cap { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #ddd; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

.loading, .notfound { text-align: center; padding: 160px 20px; font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
.notfound a { color: var(--amber); }

/* ---------- code line numbers (added by article.js) ---------- */
.codeblock pre code.numbered { counter-reset: ln; display: block; }
.codeblock pre code.numbered .cl { counter-increment: ln; display: inline; }
.codeblock pre code.numbered .cl::before {
  content: counter(ln); display: inline-block; width: 2.2em; margin-right: 1em;
  text-align: right; color: oklch(1 0 0 / 0.28); user-select: none;
}
.codeblock pre code.hljs { background: transparent; padding: 0; }

/* ---------- reactions ---------- */
.react-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.react-chip {
  font-family: var(--mono); font-size: 11px; color: var(--news-soft);
  border: 1px solid var(--news-rule); border-radius: 999px; padding: 2px 9px;
  background: color-mix(in oklab, var(--paper) 92%, var(--newsink));
}

/* ---------- highlight-to-share toolbar ---------- */
.sel-bar {
  position: absolute; z-index: 55; display: none; gap: 2px; align-items: center;
  background: var(--newsink); border-radius: 7px; padding: 4px;
  box-shadow: 0 10px 26px oklch(0.15 0.01 255 / 0.4);
}
[data-theme="dark"] .sel-bar { background: oklch(0.13 0.01 255); border: 1px solid var(--line-strong); }
.sel-bar.open { display: flex; }
.sel-bar button {
  background: transparent; border: none; color: var(--paper); cursor: pointer;
  font-family: var(--mono); font-size: 12px; padding: 5px 10px; border-radius: 5px; line-height: 1;
}
[data-theme="dark"] .sel-bar button { color: var(--ink); }
.sel-bar button:hover { background: oklch(1 0 0 / 0.14); }
.sel-bar .sep { width: 1px; height: 16px; background: oklch(1 0 0 / 0.25); margin: 0 3px; }

/* ---------- draft preview banner (signed-in admin only) ---------- */
.draft-banner {
  position: sticky; top: 0; z-index: 45; text-align: center;
  background: repeating-linear-gradient(-45deg, oklch(0.55 0.11 65), oklch(0.55 0.11 65) 14px, oklch(0.48 0.1 65) 14px, oklch(0.48 0.1 65) 28px);
  color: white; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; padding: 8px 14px;
}
.draft-banner a { color: white; text-decoration: underline; }

/* ---------- subway wayfinding map (shared design with the landing page) ---------- */
.subway {
  position: fixed; top: 45px; left: 0; right: 0; z-index: 29;
  background: color-mix(in oklab, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-strong);
}
.sub-track {
  position: relative; max-width: 760px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 28px 10px;
}
.sub-line {
  position: absolute; left: 42px; right: 42px; top: 19px; height: 3px;
  background: var(--amber); border-radius: 2px; transform-origin: left center;
  animation: sub-draw .55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes sub-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.sub-train {
  position: absolute; top: 16.5px; left: 42px; width: 16px; height: 8px;
  transform: translateX(-50%); background: var(--ink); border-radius: 4px;
  transition: left .6s cubic-bezier(0.16, 1.1, 0.3, 1);
}
.sub-stop {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center;
  gap: 7px; text-decoration: none; min-width: 40px;
}
.sub-stop .stn {
  width: 13px; height: 13px; border-radius: 50%; box-sizing: border-box;
  background: var(--bg); border: 3px solid var(--amber);
  transition: transform .2s, background .2s;
}
.sub-stop:hover .stn { transform: scale(1.25); }
.sub-stop.here .stn { background: var(--amber); animation: stn-pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes stn-pulse {
  0% { box-shadow: 0 0 0 0 oklch(0.55 0.11 65 / 0.45); }
  70% { box-shadow: 0 0 0 10px oklch(0.55 0.11 65 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.55 0.11 65 / 0); }
}
.sub-stop .stn.term { border-radius: 3.5px; }
.sub-stop .stn.xfer { border-color: oklch(0.4 0.06 255); }
[data-theme="dark"] .sub-stop .stn.xfer { border-color: oklch(0.72 0.08 255); }
.sub-stop.here .stn.xfer { background: oklch(0.4 0.06 255); animation-name: stn-pulse-x; }
[data-theme="dark"] .sub-stop.here .stn.xfer { background: oklch(0.72 0.08 255); }
@keyframes stn-pulse-x {
  0% { box-shadow: 0 0 0 0 oklch(0.4 0.06 255 / 0.45); }
  70% { box-shadow: 0 0 0 10px oklch(0.4 0.06 255 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.4 0.06 255 / 0); }
}
.sub-stop .lbl { font-size: 9px; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.sub-stop.here .lbl, .sub-stop:hover .lbl { color: var(--ink); }
.sub-stop.here .lbl { font-weight: 600; }
body.has-subway .broadsheet { margin-top: 175px; }
body.has-subway .article-stage { padding-top: 165px; }
@media (max-width: 620px) {
  .sub-stop .lbl { display: none; }
  .sub-stop.here .lbl { display: block; }
  .sub-track { padding: 14px 18px 8px; }
  .sub-line { left: 30px; right: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .sub-stop.here .stn { animation: none; }
  .sub-train { transition: none; }
  .sub-line { animation: none; }
}
