/* vflow documentation styling.
 *
 * Every page links this file, the pdoc-generated API pages and the
 * hand-written articles in pages/ alike, so the two cannot drift apart.
 * pdoc's own stylesheet still handles the two-column layout; this file sets
 * the palette, the type, the header bar and the article layout on top of it.
 * The layout follows the imodels docs (csinva.io/imodels).
 */

:root {
  /* the sidebar width and the widest comfortable line of text; together they
     decide how much horizontal room the article really has */
  --sidebar-w: 22rem;
  --measure: 92ch;

  /* greys lean toward the slate outline of the vflow logo */
  --ink: #1d2526;
  --ink-soft: #3a4546;
  --muted: #5f6b6b;
  --line: #dfe5e5;
  --line-soft: #ecf0f0;
  /* links: between the logo's blue and aqua, dark enough to read as text */
  --accent: #13789a;
  --accent-dark: #0b5a73;
  --accent-soft: #e6f4f6;
  --surface: #ffffff;
  --surface-alt: #f6f9f9;
  --code-bg: #f3f6f6;
}

body {
  color: var(--ink);
  background: var(--surface);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  line-height: 1.62;
}

a, a:visited { color: var(--accent); text-decoration: none; }
a:hover, a:focus { color: var(--accent-dark); text-decoration: underline; }

h1, h2, h3, h4, h5 { color: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.1em; line-height: 1.15; }
h2 { font-size: 1.5em; margin: 1.9em 0 0.6em; padding-bottom: 0.25em;
     border-bottom: 1px solid var(--line-soft); }
h3 { font-size: 1.15em; margin: 1.5em 0 0.5em; }

/* ---------- header bar ---------- */
#site-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.35rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
#site-header .nav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--muted); background: transparent;
  border: 1px solid transparent; flex: 0 0 auto;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#site-header .nav-icon:hover {
  background: var(--surface-alt); color: var(--accent);
  border-color: var(--line); text-decoration: none;
}
#site-header .nav-icon svg { width: 18px; height: 18px; display: block; }
#site-logo { flex: 0 0 auto; line-height: 0; margin-left: auto; opacity: 0.92;
             transition: opacity 0.15s ease; }
#site-logo:hover { opacity: 1; }
#site-logo img, #site-logo svg { height: 24px; width: auto; display: block; }
/* On the home page the o of the logo, a ring of drops, makes one eased turn
   with a gentle swell, rests, and repeats (as on the talk's title slide).
   Turn and swell are separate properties so neither jerks at the other's
   keyframes. */
#site-logo .vo { transform-box: fill-box; transform-origin: center; }
#site-logo.animate .vo {
  animation: vo-turn 3.2s 0.4s infinite, vo-swell 3.2s 0.4s infinite;
}
@keyframes vo-turn {
  0% { rotate: 0deg; animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
  75%, 100% { rotate: 360deg; }
}
@keyframes vo-swell {
  0% { scale: 1; animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  37.5% { scale: 1.1; animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  75%, 100% { scale: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #site-logo.animate .vo { animation: none; }
}
#site-tagline { margin: 0; min-width: 0; font-size: 0.8rem; line-height: 1.35;
                color: var(--muted); }
#site-tagline b { color: var(--ink); font-weight: 600; }
@media (max-width: 760px) {
  #site-tagline { display: none; }
  #site-header { gap: 0.6rem; }
}

/* ---------- layout ---------- */
#content { padding: 1.6em 2em 4em; }
#sidebar { padding: 1.6em 1.4em; background: var(--surface-alt);
           border-right: 1px solid var(--line); }
/* pdoc packs a 30% sidebar and a 70% article to the left. Let the article
   fill the row and spend the surplus on its own side padding, so the text sits
   centred and never runs wider than a comfortable line. Kept inside pdoc's own
   breakpoint so the stacked mobile layout is left alone. */
@media screen and (min-width: 700px) {
  #sidebar { width: min(var(--sidebar-w), 32vw); flex: 0 0 auto; }
  #content {
    width: auto; max-width: none; flex: 1 1 auto;
    min-width: 0;  /* a wide code line must not push the layout past the window */
    padding-left:  max(2.5rem, (100vw - var(--sidebar-w) - var(--measure)) / 2);
    padding-right: max(2.5rem, (100vw - var(--sidebar-w) - var(--measure)) / 2);
  }
}
#sidebar h1, #sidebar h3 { font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); padding-bottom: 0.35em; margin-top: 1.4em; }
#sidebar > ul > li:first-child h3, #sidebar > h3:first-child { margin-top: 0; }
#sidebar .toc ul, #sidebar #index { font-size: 0.88rem; }
#sidebar li { margin: 0.18em 0; }
#sidebar a { overflow-wrap: break-word; }
#sidebar code { background: transparent; padding: 0; }

/* anything that cannot narrow scrolls in its own box, never the page */
#content pre, #content table, .article pre, .article table {
  max-width: 100%; overflow-x: auto;
}
#content img, .article img, #content svg { max-width: 100%; height: auto; }

/* ---------- guides list in the sidebar ---------- */
/* each row: the guide, an optional tag, then its date pushed to the right */
#sidebar .post-list li { display: flex; align-items: baseline; gap: 0.45em; margin: 0.22em 0; }
#sidebar .post-list .post-date {
  margin-left: auto; padding-left: 0.5em; font-size: 0.74rem; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
#sidebar .post-list .post-tag {
  flex: 0 0 auto; font-size: 0.62rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent-dark); background: var(--accent-soft);
  border: 1px solid #c4e3e8; border-radius: 999px; padding: 0.05em 0.5em;
  white-space: nowrap; position: relative; top: -0.05em;
}
a.post-list-head { color: inherit; text-decoration: none; }
a.post-list-head:hover { color: var(--accent); }

/* ---------- article pages (pages/*.html) ---------- */
.article { max-width: var(--measure); margin: 0 auto; }
.article h1, .post-authors, .post-links { text-align: center; }
.article h1 { display: block; margin-bottom: 0.25em; }
.post-authors { margin: 0; color: var(--muted); font-weight: 400; font-size: 1rem; }
.post-links { color: var(--muted); font-size: 0.9rem; margin: 0.5em 0 0; }
.post-links a { white-space: nowrap; }

/* the numbered contents bar under the abstract */
nav.toc-main {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 1em 0 1.8em; padding: 9px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
nav.toc-main a { font-size: 14px; padding: 3px 10px; border-radius: 3px; white-space: nowrap; }
nav.toc-main a:hover { background: var(--surface-alt); text-decoration: none; }
nav.toc-main span { display: inline-block; min-width: 16px; color: var(--muted);
                    font-variant-numeric: tabular-nums; }

/* the lead paragraph, set like a paper's abstract */
.abstract {
  margin: 1.4em auto 2.2em; padding: 0 2.4em; max-width: 44rem;
  font-size: 0.95em; line-height: 1.65; color: var(--ink-soft);
}
.abstract code { font-size: 0.9em; }

/* a pull-out note: a key point the reader should not miss */
.callout {
  margin: 1.4em 0; padding: 0.9em 1.2em;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0; color: var(--ink-soft);
}
.callout p { margin: 0.3em 0; }

/* ---------- figures, captions and step lists ---------- */
.fig-anchor { display: block; scroll-margin-top: 4.5rem; }
h2[id], h3[id] { scroll-margin-top: 4.5rem; }
.caption {
  font-size: 0.86rem; color: var(--muted); text-align: center; line-height: 1.5;
  max-width: 46rem; margin: 0.7em auto 1.8em;
}
.caption-above { margin: 1.8em auto 0.7em; }
.caption b { color: var(--ink); font-weight: 600; }

/* numbered steps with a rule down the left */
ol.steps { list-style: none; counter-reset: step; padding-left: 0; margin: 1.2em 0; }
ol.steps > li { counter-increment: step; position: relative; padding: 0 0 1em 2.6em; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0.05em;
  width: 1.7em; height: 1.7em; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.85em; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
ol.steps > li::after {
  content: ""; position: absolute; left: 0.84em; top: 1.9em; bottom: 0.2em;
  width: 1px; background: var(--line);
}
ol.steps > li:last-child::after { display: none; }
ol.steps > li > strong:first-child { display: block; }

/* ---------- tables ---------- */
#content table, .article table {
  border-collapse: collapse; margin: 1.2em auto; font-size: 0.92em;
}
#content table th, #content table td, .article table th, .article table td {
  border: 1px solid var(--line); padding: 6px 11px; text-align: left; vertical-align: top;
}
#content table th, .article table th { background: var(--surface-alt); font-weight: 600; }
#content table tr:nth-child(even) td, .article table tr:nth-child(even) td { background: #fbfcfc; }
td.num, th.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.verdict-good { box-shadow: inset 3px 0 0 #2f8f5b; }
.verdict-warn { box-shadow: inset 3px 0 0 #c98a14; }

/* ---------- code ---------- */
code { background: var(--code-bg); border-radius: 3px; padding: 1px 5px; font-size: 0.9em; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px;
      margin: 1.1em 0; padding: 0.8em 1em; }
pre code { background: transparent; padding: 0; font-size: 0.82em; }
pre.terminal { background: #1d2526; border-color: #1d2526; }
/* a terminal block is output, not code: keep it light-on-dark even if a
   highlighter has wrapped it */
pre.terminal code, pre.terminal code * {
  color: #e6eded !important; background: transparent !important;
}

summary > h1, summary > h2, summary > h3, summary > h4, summary > h5 { display: inline; margin: 0; }
summary { cursor: pointer; }

/* ---------- footer ---------- */
#footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }

/* ---------- API pages: tighter spacing than pdoc's defaults ---------- */
#content section dl { margin-bottom: 0.8em; }
#content section dd { margin: 0 0 0.6em 1.6em; }
#content section dd p { margin: 0.35em 0; }
#content section dd dd { margin-left: 1.4em; }
#content section h2.section-title { margin: 1.3em 0 0.5em; }
#content .desc h2 { margin: 0.9em 0 0.25em; padding-bottom: 0; border-bottom: 0; font-size: 1em; }
#content section .name { padding: 4px 8px; }
#content section details.source { margin: 0.25em 0; }
