/* ==========================================================================
   assets/blog.css — the blog reading furniture (DESIGN-V2 §5, §6)
   Linked from templates/partials/head.html, so it loads on the generated blog
   pages only; the hand-authored index.html never sees it.

   WHAT LIVES HERE vs. assets/site.css
   site.css is the design system and already styles every component the blog
   SHARES with the rest of the site — masthead, cards, chips, archive, reading
   lists, CONTENTS, prose, article foot. This file adds only what exists on a
   blog page and nowhere else:
       · the 2px ochre reading-progress bar
       · the [content 1fr][sidebar 260px] article grid + its sticky rail
       · ON THIS PAGE (ToC + scrollspy) and its <details> copy for narrow screens
       · IN THIS SERIES and the sidebar search box
       · the masthead search field (.hunt)
       · the archive's mono cells (date + series) and their column widths
       · the author-box CTA line
   Plus three deliberate overrides of site.css, each flagged OVERRIDE below.

   Tokens are consumed from site.css and never redeclared. Only --bl-* are new.
   Banned here as everywhere: linear-gradient, radial-gradient, blur, glow,
   backdrop-filter, pill radii on anything but a chip, "$" prompt glyphs.
   ========================================================================== */

:root{
  /* re-measured from the real top bar by assets/site.js, so the progress bar
     and the sticky rail stay glued to it whatever height it lands on */
  --bl-nav-h:84px;
  --bl-stick:24px;
  --bl-side:260px;
  --bl-gap:48px;
}

/* ==========================================================================
   1. READING PROGRESS — 2px ochre, pinned under the top bar
   ========================================================================== */
.read-progress{
  position:sticky;top:var(--bl-nav-h);z-index:55;
  height:2px;background:transparent;pointer-events:none;
}
.read-progress span{display:block;height:2px;width:0;background:var(--amber)}

/* ==========================================================================
   2. ARTICLE GRID — content first in the DOM, 260px rail on the right
   ========================================================================== */
.article-main{min-width:0}
.article-side{min-width:0}
.article-grid{padding-bottom:4px}

@media (min-width:1024px){
  .article-grid{
    display:grid;
    grid-template-columns:minmax(0,1fr) var(--bl-side);
    gap:var(--bl-gap);
    /* NOT align-items:start — the rail column has to stretch to the full row
       height or position:sticky has nothing to travel inside. */
  }
  .article-side__inner{
    position:sticky;top:calc(var(--bl-nav-h) + var(--bl-stick));
    display:flex;flex-direction:column;gap:26px;
    /* the rail never grows past one screen; the ToC inside it scrolls instead */
    max-height:calc(100vh - var(--bl-nav-h) - 3rem);
  }
}
@media (max-width:1023px){
  /* the rail becomes a plain block under the article */
  .article-side__inner{
    display:flex;flex-direction:column;gap:26px;
    margin-top:44px;padding-top:26px;border-top:1px solid var(--line);
  }
}

/* ==========================================================================
   3. OVERRIDE (site.css §12): where the measure is applied.
   site.css caps .prose itself, which also caps figures, code and tables.
   DESIGN-V2 §5 wants those to bleed a little wider than the text — so the
   measure moves onto the text blocks and the wide blocks get their own cap.
   Nothing may exceed 100% of the column, so the page can never scroll sideways.

   68ch of "Source Serif 4" is 772px = ~91 characters, well past the 66-70
   DESIGN-V2 §3 asks for. 37rem = 592px lands it at ~70 characters and, being
   root-relative, holds the SAME optical edge for the 25px h2 and the 17.5px
   blockquote — `em`/`ch` would resolve against each element's own size and let
   the headings run 200px wider than the paragraphs under them.
   ========================================================================== */
.prose{max-width:none}
.prose>p,.prose>ul,.prose>ol,.prose>blockquote,
.prose>h2,.prose>h3,.prose>h4,.prose>hr,.prose>.footnotes{
  max-width:min(var(--measure),37rem);
}
.prose>figure,.prose>pre,.prose>.table-scroll{max-width:min(100%,780px)}
.prose>.table-scroll{border:1px solid var(--line);border-radius:var(--r)}
.prose>.table-scroll>table{border:0}
.prose>pre{max-width:min(100%,780px)}

/* the lead image is a 3:2 crop so every article opens at the same rhythm */
.hero-figure{margin-top:0;max-width:min(100%,780px)}
.hero-figure img{aspect-ratio:3/2;object-fit:cover}

/* ==========================================================================
   4. SIDEBAR — shared chrome
   ========================================================================== */
.side-h{
  display:block;font-family:var(--mono);font-size:11px;font-weight:500;
  letter-spacing:.14em;text-transform:uppercase;color:var(--faint);
}
.side-h a{color:var(--amber-deep);border-bottom:1px solid var(--amber-line)}
.side-h a:hover{border-bottom-color:var(--amber)}
.side-block{min-width:0}

/* ---- ON THIS PAGE + scrollspy ------------------------------------------ */
.toc-nav{display:flex;flex-direction:column;min-height:0}
.toc-list{
  list-style:none;margin:12px 0 0;padding:0;
  border-left:1px solid var(--line);
  overflow-y:auto;max-height:calc(100vh - 220px);
  overscroll-behavior:contain;scrollbar-width:thin;
}
.toc-list::-webkit-scrollbar{width:6px}
.toc-list::-webkit-scrollbar-thumb{background:var(--line-2);border-radius:var(--r-xs)}
.toc-list a{
  display:block;margin-left:-1px;padding:6px 8px 6px 14px;
  border-left:2px solid transparent;
  font-size:13.5px;line-height:1.4;color:var(--muted);
  transition:color .12s,border-color .12s;
}
.toc-list a:hover{color:var(--ink)}
.toc-list .toc-l3 a{padding-left:26px;font-size:13px}
/* the section in view: ochre text + a 2px ochre left rule */
.toc-list a[aria-current=true]{
  color:var(--amber-deep);border-left-color:var(--amber);font-weight:600;
}

/* ---- IN THIS SERIES ---------------------------------------------------- */
.side-series{
  list-style:none;margin:12px 0 0;padding:0;
  max-height:34vh;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;
}
.side-series::-webkit-scrollbar{width:6px}
.side-series::-webkit-scrollbar-thumb{background:var(--line-2);border-radius:var(--r-xs)}
.side-series li{
  display:grid;grid-template-columns:24px minmax(0,1fr);gap:10px;
  align-items:baseline;padding:7px 0;border-top:1px solid var(--line);
  font-size:13.5px;line-height:1.4;
}
.side-series li:first-child{border-top:0}
.side-series .n{
  font-family:var(--mono);font-size:11px;color:var(--amber-deep);
  font-variant-numeric:tabular-nums;
}
.side-series a{color:var(--muted)}
.side-series a:hover{color:var(--amber-deep)}
.side-series li[aria-current=true]{color:var(--ink);font-weight:600}
.side-series li[aria-current=true] .n{color:var(--amber)}

/* ---- the rail's own search box ---------------------------------------- */
.side-search__line{display:flex;gap:8px;margin-top:10px}
.side-search input[type=search]{
  flex:1;min-width:0;height:38px;padding:0 12px;
  border:1px solid var(--line-2);border-radius:var(--r);
  background:var(--bg);color:var(--ink);font-size:14px;
  -webkit-appearance:none;appearance:none;
}
.side-search input[type=search]::placeholder{color:var(--faint)}
.side-search input[type=search]:focus-visible{border-color:var(--amber)}
.side-search .btn{flex:none}

/* ==========================================================================
   5. THE COLLAPSED ToC (< 1024px) — a real <details>, works with JS off
   ========================================================================== */
.toc-drop{
  border:1px solid var(--line);border-radius:var(--r-lg);
  background:var(--bg);margin-bottom:30px;
}
.toc-drop>summary{
  display:flex;align-items:center;gap:12px;
  padding:14px 18px;cursor:pointer;list-style:none;
}
.toc-drop>summary::-webkit-details-marker{display:none}
.toc-drop>summary::after{
  content:"";flex:none;margin-left:auto;width:8px;height:8px;
  border-right:2px solid var(--faint);border-bottom:2px solid var(--faint);
  transform:rotate(45deg);transition:transform .15s;
}
.toc-drop[open]>summary::after{transform:rotate(-135deg)}
.toc-drop>summary:hover .side-h{color:var(--ink)}
.toc-drop__n{
  font-family:var(--mono);font-size:11px;letter-spacing:.08em;
  text-transform:uppercase;color:var(--faint);
}
.toc-drop nav{padding:0 18px 16px}
.toc-drop .toc-list{max-height:none;overflow:visible}
@media (min-width:1024px){.toc-drop{display:none}}
@media (max-width:1023px){.article-side .toc-nav{display:none}}

/* ==========================================================================
   6. MASTHEAD SEARCH (DESIGN-V2 §6) — a real GET form to /blog/#browse, so it
   works with JS off; on /blog/ itself site.js filters in place instead.
   The masthead is light now, so the field reads as an inset surface card.
   ========================================================================== */
.hunt{margin-top:26px;display:flex;gap:10px;align-items:stretch;max-width:560px}
.hunt input[type=search]{
  flex:1;min-width:0;height:48px;padding:0 16px;
  border:1px solid var(--line-2);border-radius:var(--r);
  background:var(--bg);color:var(--ink);font-size:16px;
  -webkit-appearance:none;appearance:none;
}
.hunt input[type=search]::placeholder{color:var(--faint)}
.hunt input[type=search]:focus-visible{border-color:var(--amber);outline-offset:1px}
.hunt .btn{flex:none;min-height:48px}
.hunt .btn:hover{background:var(--amber-darker);border-color:var(--amber-darker)}

/* ==========================================================================
   7. OVERRIDE (site.css §11): the archive's two mono cells.
   DESIGN-V2 §6 reading order, now three columns:
       date (mono, tabular) · title (Inter 600) · SERIES
   There used to be a fourth cell holding the category. Series is the site's only
   taxonomy, so the two right-hand cells said the same thing and were merged —
   site.css's 3-column grid is correct as it stands and only the widths and the
   typographic treatment are tuned here.
   ========================================================================== */
.archive-row{grid-template-columns:112px minmax(0,1fr) 190px}
.archive-row .a-date{font-family:var(--mono);font-variant-numeric:tabular-nums;white-space:nowrap}
.archive-row .a-series{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.archive-row:hover .a-series{color:var(--amber-darker)}

/* ==========================================================================
   8. AUTHOR BOX — one quiet CTA line, never a banner (DESIGN-V2 §8)
   ========================================================================== */
.author-box__name{font-size:18px;font-weight:700;letter-spacing:-.015em}
.author-cta{
  margin-top:14px;padding-top:14px;border-top:1px solid var(--line-2);
  color:var(--ink-2);
}
.author-cta a{
  color:var(--amber-deep);font-weight:600;
  border-bottom:1px solid var(--amber-line);
}
.author-cta a:hover{border-bottom-color:var(--amber)}

/* ==========================================================================
   9. RESPONSIVE
   ========================================================================== */
@media (max-width:1180px){
  .archive-row{grid-template-columns:104px minmax(0,1fr) 168px}
}
@media (max-width:940px){
  /* the series cell wraps rather than squeezing the title */
  .archive-row{grid-template-columns:104px minmax(0,1fr) 132px;gap:4px 16px}
  .archive-row .a-series{white-space:normal}
}
@media (max-width:760px){
  /* site.css collapses .archive-row to one column here; place all three cells:
     date and series share the top line, the title spans both underneath */
  .archive-row{grid-template-columns:auto minmax(0,1fr);gap:5px 12px;padding:14px 16px}
  .archive-row .a-date{grid-column:1;grid-row:1}
  .archive-row .a-series{grid-column:2;grid-row:1;text-align:right;white-space:normal}
  .archive-row .a-title{grid-column:1/-1;grid-row:2}
  .hunt{flex-wrap:wrap;max-width:none}
  .hunt input[type=search]{flex:1 1 100%}
  .hunt .btn{width:100%}
  /* one screen of phone is narrower than any sane measure — let the text fill it */
  .prose>p,.prose>ul,.prose>ol,.prose>blockquote,.prose>h2,.prose>h3,.prose>h4{
    max-width:none;
  }
}
@media (max-width:420px){
  /* one screen of iPhone SE is 5px short of "WORKPLACE SERIES · 02" at the
     default tracking, which broke the "· 02" onto a second line. Tighten the
     cell rather than let the longest series label wrap. */
  .archive-row{gap:5px 10px}
  .archive-row .a-series{font-size:10px;letter-spacing:.08em}
  .prose>pre{font-size:12.5px;padding:14px}
  .toc-drop>summary{padding:13px 15px;gap:8px}
  .toc-drop nav{padding:0 15px 14px}
}

@media (prefers-reduced-motion:reduce){
  .toc-list a,.toc-drop>summary::after,.read-progress span{transition:none!important}
}

/* ==========================================================================
   10. PRINT — leave the reader with the article and nothing else
   ========================================================================== */
@media print{
  .read-progress,.article-side,.toc-drop,.hunt{display:none!important}
  .article-grid{display:block}
  .prose>p,.prose>ul,.prose>ol{max-width:none}
}
