/*
 * Shared styles for a "notes collection" viewer — the in-browser Markdown
 * reader used by /notes/storage/ and /notes/unstaged/. Pairs with
 * /notes/collection.js and sits on top of /theme.css (design tokens + base
 * layout). A collection page needs only:
 *   <link rel="stylesheet" href="/theme.css">
 *   <link rel="stylesheet" href="/notes/collection.css">
 * plus the two <script> tags for marked + collection.js.
 */

header.h .meta {
  font: 500 13px/1 var(--mono); color: var(--ink-faint); margin: 16px 0 0;
}

/* index list (ul.notes) styles live in /theme.css */

/* Clicking a rail entry is an in-page jump; animate it unless the reader has
   asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---- note index rail (scrollspy contents) ----
 * The rail (aside.note-toc) is filled by buildToc() in collection.js from the
 * note's own h2/h3 headings, and left empty (:empty hides it) when a note has
 * too few sections to be worth one. The note body stays at the normal .wide
 * width so it lines up with the note header above it.
 *
 * Mobile-first: the index is a bordered, self-scrolling box above the note.
 * On wide screens it floats into the left gutter beside the centered body and
 * sticks as you scroll, highlighting the section you're in — same pattern as
 * /notes/networking/. Below that width there's no gutter, so it stays a block. */
.note-layout { max-width: 820px; }
.note-toc:empty { display: none; }
.note-toc {
  margin: 32px 0 8px;
  padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel);
  max-height: 45vh; overflow-y: auto;
  font: 500 13.5px/1.4 var(--sans);
}
.note-toc a {
  display: block; padding: 5px 0 5px 12px; margin-left: -14px;
  color: var(--ink-soft); text-decoration: none;
  border-left: 2px solid transparent;
  overflow-wrap: break-word;
}
.note-toc a.sub { padding-left: 26px; font-size: 13px; color: var(--ink-faint); }
.note-toc a:hover { color: var(--accent-ink); }
.note-toc a.active {
  color: var(--accent-ink); font-weight: 700;
  border-left-color: var(--accent);
}

/* Enabled where the left gutter can hold a ~190px rail + gap beside the 820px
   body: (100vw - 820)/2 >= ~224px  ->  100vw >= ~1268px. */
@media (min-width: 1280px) {
  .note-toc {
    position: fixed; top: 50%; transform: translateY(-50%);
    left: calc((100vw - 820px) / 2 - 224px);
    width: 190px; margin: 0;
    padding: 0 0 0 16px;
    border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none;
    max-height: calc(100vh - 48px); overflow-y: auto;
  }
  .note-toc a { padding: 5px 0 5px 15px; margin-left: -17px; }
}

/* ---- rendered markdown ---- */
.md { padding: 40px 0 0; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 {
  font-family: var(--serif); line-height: 1.25; margin: 2em 0 0.6em; letter-spacing: -0.01em;
}
.md h1 { font-size: 30px; font-weight: 700; }
.md h2 {
  font-size: 24px; font-weight: 700;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.md h3 { font-size: 19px; font-weight: 700; }
.md h4 { font-size: 16px; font-weight: 700; font-family: var(--sans); }
.md p { margin: 0 0 1.1em; }
.md ul, .md ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.md li { margin: 0.35em 0; }
.md li > ul, .md li > ol { margin: 0.35em 0; }
.md a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.md blockquote {
  margin: 0 0 1.1em; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--line-firm); color: var(--ink-soft);
}
.md img { max-width: 100%; height: auto; }

.md code {
  font: 0.86em/1.5 var(--mono); background: var(--code-bg);
  padding: 2px 5px; border-radius: 4px;
  overflow-wrap: break-word;
}
.md pre {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; margin: 0 0 1.4em;
  font: 13.5px/1.6 var(--mono);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.md pre code {
  background: none; padding: 0; border-radius: 0;
  font-size: 13.5px; line-height: 1.6; white-space: pre;
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.4em; }
.md table { border-collapse: collapse; width: 100%; font: 400 14px/1.5 var(--sans); }
.md th, .md td {
  border: 1px solid var(--line); padding: 8px 11px; text-align: left; vertical-align: top;
}
.md th {
  background: var(--accent-soft); color: var(--accent-ink);
  font: 600 12px/1.4 var(--mono); letter-spacing: 0.04em; white-space: nowrap;
}
.md td code { font-size: 0.92em; }

/* not-found state (.path / ul.where) styles live in /theme.css, mirroring the
   site-wide /404.html; a collection page only overrides the .path margin — it
   sits under the header here rather than standing alone. */
.path { margin: 4px 0 0; }

.status { padding: 40px 0; font: 400 15px/1.6 var(--sans); color: var(--ink-soft); }
.status code {
  font: 13px/1.5 var(--mono); background: var(--code-bg);
  padding: 2px 5px; border-radius: 4px;
}

.pagenav { padding: 36px 0 0; border-top: 1px solid var(--line); margin-top: 48px; }
.pagenav a {
  font: 600 14px/1 var(--sans); color: var(--accent-ink); text-decoration: none;
}
.pagenav a:hover { text-decoration: underline; }
