/* Hallmark · page: notes · theme: Console · system in hub/base.css; the older token names map onto it in hub/tokens.css */

/* Notes: the article page, its prose, and the diagram conventions note bodies use. */
.note { max-width: 720px; padding: var(--space-2xl) 0; }
.note-head { display: grid; gap: var(--space-md); }
.note-head h1 { text-wrap: balance; max-width: 24ch; font-size: clamp(1.875rem, 1.4vw + 1.25rem, 2.5rem); line-height: 1.08; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-md); margin: var(--space-xs) 0 0; font-size: var(--text-sm); color: var(--muted); }
.note-meta .badge:hover { color: var(--text); border-color: var(--border-strong); }
.note-preview { margin: 0 0 24px; padding: 12px 16px; border: 1px dashed var(--accent); border-radius: var(--r-inner); font-size: 13px; color: var(--muted); }
.note-foot { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); }
.note-foot h2 { font-size: var(--text-lg); }
.note-foot .note-list { margin-top: 12px; }
.note-foot > p { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg); margin: var(--space-xl) 0 0; }

/* Contents: numbered, built from the note's sections. A box under the title on narrow screens;
   a sticky sidebar that tracks the current section on wide ones. */
.toc { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: flex; gap: 12px; padding: 4px 0; font-size: 14px; line-height: 1.4; color: var(--muted); transition: color 0.15s; }
.toc a::before { content: counter(toc, decimal-leading-zero); flex: none; padding-top: 1px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toc a:hover, .toc a[aria-current] { color: var(--text); }
.toc a[aria-current]::before { color: var(--color-accent); }
.toc-top { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--r-inner); background: var(--surface); }
.toc-top summary { padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 500; list-style-position: inside; }
.toc-top summary span { font-weight: 400; color: var(--faint); }
.toc-top .toc { padding: 0 16px 12px; }
.toc-side { display: none; }
.toc-label { margin: 0 0 12px; font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); }
.toc-side .toc { border-left: 1px solid var(--border); }
.toc-side .toc a { margin-left: -1px; padding: 8px 0 8px 16px; border-left: 1px solid transparent; font-size: 13.5px; }
.toc-side .toc a[aria-current] { border-left-color: var(--color-accent); }
.toc-top-link { display: inline-block; margin-top: 16px; font-size: 13px; color: var(--faint); }
.toc-top-link:hover { color: var(--text); }

/* Numbered sections, matching the contents */
.has-toc .prose { counter-reset: section; }
.has-toc .prose h2 { counter-increment: section; }
.has-toc .prose h2::before {
  content: counter(section, decimal-leading-zero);
  display: block; margin-bottom: 8px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--muted);
}
.has-toc .prose h2:not(:first-of-type) { padding-top: 2.2em; border-top: 1px solid var(--border); }

@media (min-width: 1080px) {
  .note.has-toc {
    max-width: none; display: grid; column-gap: 64px; justify-content: start;
    grid-template-columns: minmax(0, 720px) 230px;
  }
  .note.has-toc > * { grid-column: 1; }
  .note.has-toc > .toc-side {
    display: block; grid-column: 2; grid-row: 1 / span 6; align-self: start;
    position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow-y: auto;
  }
  .note.has-toc > .toc-top { display: none; }
}

/* Prose */
.prose { margin-top: var(--space-xl); font-size: 16px; line-height: 1.7; color: var(--color-ink-2); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose figure, .prose pre { margin: 0 0 1.25em; }
.prose h2 { max-width: none; margin: 2.2em 0 0.6em; font-size: 1.375rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.02em; scroll-margin-top: 88px; }
.prose h3 { max-width: none; margin: 1.8em 0 0.5em; font-size: 1.125rem; line-height: 1.35; font-weight: 600; letter-spacing: -0.015em; scroll-margin-top: 88px; }
.prose a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--color-rule-2); }
.prose a:hover { color: var(--color-accent); text-decoration-color: currentColor; }
.prose strong { font-weight: 500; color: var(--text); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--faint); }
.prose blockquote { padding: 4px 0 4px 16px; border-left: 2px solid var(--color-accent); color: var(--color-ink-2); }
.prose hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--border); }
.prose code { padding: 0.12em 0.36em; font-size: 0.86em; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; }
.prose pre { padding: 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-inner); }
.prose pre code { padding: 0; font-size: inherit; background: none; border: 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { font-weight: 500; color: var(--text); border-bottom-color: var(--border-strong); }
.prose td { color: var(--muted); }
.prose .callout { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-inner); font-size: 15px; }
.prose .callout > :last-child { margin-bottom: 0; }

/* Diagrams: inline SVG inside <figure class="diagram">, drawn with these classes so they follow
   the light/dark theme. Shapes: .box, .box.accent, .box.ok, .box.ghost. Lines: .edge (add
   marker-end="url(#arrow)"), .edge.dash. Text: .label, .label.small, .label.muted, .label.mono. */
.prose .diagram { margin: 2em 0; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-tile); }
.prose .diagram svg { display: block; width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.prose .diagram figcaption { margin-top: 16px; font-size: 13px; line-height: 1.5; color: var(--faint); text-align: center; }
.diagram .box { fill: var(--bg-2); stroke: var(--border-strong); stroke-width: 1.2; }
.diagram .box.accent { fill: color-mix(in srgb, var(--accent) 12%, var(--surface)); stroke: var(--accent); }
.diagram .box.ok { fill: var(--ok-bg); stroke: var(--ok); }
.diagram .box.ghost { fill: none; stroke: var(--border-strong); stroke-dasharray: 5 4; }
.diagram .edge { fill: none; stroke: var(--muted); stroke-width: 1.4; }
.diagram .edge.dash { stroke-dasharray: 5 4; }
.diagram .edge.accent { stroke: var(--accent); }
.diagram .arrowhead { fill: var(--muted); }
.diagram .label { fill: var(--text); font-family: var(--font-sans); font-size: 14px; font-weight: 500; }
.diagram .label.small { font-size: 12px; font-weight: 400; }
.diagram .label.muted { fill: var(--muted); font-weight: 400; }
.diagram .label.mono { font-family: var(--font-mono); font-size: 11.5px; font-weight: 400; fill: var(--muted); }

/* Opt-in flow: <figure class="diagram animate">. Its arrows become dashed lines that move
   steadily from node to node. notes.js adds .playing only while the diagram is on screen; nothing
   moves without JavaScript or when the reader asks for reduced motion. */
.diagram.animate .edge { stroke-dasharray: 5 5; }
.diagram.animate.playing .edge { animation: diagram-march 1.4s linear infinite; }
@keyframes diagram-march {
  from { stroke-dashoffset: 10; }
  to { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .diagram.animate.playing .edge { animation: none; }
}

@media (max-width: 560px) {
  .note { padding-top: 32px; }
  .prose { font-size: 16px; }
  .prose .diagram { padding: 16px; margin-left: -4px; margin-right: -4px; }
}
