/* pymdl documentation site.
   Tokens first; every component reads from them, so the dark theme is a token
   swap rather than a second stylesheet.  The reading surfaces are a book --
   light paper, a serif display face, a bounded measure, a chapter rail -- and
   the chrome around them is not. */

:root {
  --paper:      #fdfdff;   /* page ground */
  --paper-2:    #f3f5fd;   /* rails, code, table heads */
  --paper-3:    #e9ecfa;   /* hover fills */
  --ink:        #151831;   /* body text */
  --ink-2:      #4a5172;   /* secondary text */
  --ink-3:      #79819f;   /* captions, meta */
  --rule:       #e3e6f4;
  --rule-2:     #c9cfe6;
  --brand:      #5145e5;   /* the mark, the hero wash, active accents */
  --brand-2:    #8b5cf6;   /* the second stop of every brand gradient */
  --accent:     #4338ca;   /* links: the brand darkened to pass AA on paper */
  --accent-ink: #312e81;   /* link hover */
  --accent-soft:#eceafe;   /* tint behind the active rail item and notes */
  --amber:      #b45309;   /* the warm second voice: eyebrows, the source line */
  --amber-soft: #fff6e8;
  --good:       #11704a;
  --danger:     #b3261e;
  --code-bg:    #f4f6fd;
  --code-ink:   #1e2340;
  --shadow-sm:  0 1px 2px rgba(21, 24, 49, .05), 0 1px 3px rgba(21, 24, 49, .06);
  --shadow:     0 2px 4px rgba(21, 24, 49, .04), 0 12px 32px rgba(21, 24, 49, .08);
  --shadow-lift:0 6px 12px rgba(21, 24, 49, .07), 0 24px 48px rgba(81, 69, 229, .13);
  --font-ui:      "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-display: "Newsreader", "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-code:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 72ch;
  --rail: 17.5rem;
  --content: 78rem;
  --header-h: 3.75rem;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1220; --paper-2: #171b2d; --paper-3: #212741;
    --ink: #e8eaf7; --ink-2: #aab1cf; --ink-3: #7d86a8;
    --rule: #272d45; --rule-2: #3a4260;
    --brand: #8b85ff; --brand-2: #b98bff;
    --accent: #a9a4ff; --accent-ink: #cbc7ff; --accent-soft: #1e2049;
    --amber: #f0b45c; --amber-soft: #35280f;
    --good: #6ed39b; --danger: #f0958c;
    --code-bg: #161a2c; --code-ink: #dde1f4;
    --shadow-sm: none;
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-lift: 0 24px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0f1220; --paper-2: #171b2d; --paper-3: #212741;
  --ink: #e8eaf7; --ink-2: #aab1cf; --ink-3: #7d86a8;
  --rule: #272d45; --rule-2: #3a4260;
  --brand: #8b85ff; --brand-2: #b98bff;
  --accent: #a9a4ff; --accent-ink: #cbc7ff; --accent-soft: #1e2049;
  --amber: #f0b45c; --amber-soft: #35280f;
  --good: #6ed39b; --danger: #f0958c;
  --code-bg: #161a2c; --code-ink: #dde1f4;
  --shadow-sm: none;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-lift: 0 24px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: .16em; }
a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

code, kbd, pre, samp { font-family: var(--font-code); }

img { max-width: 100%; height: auto; }

.nowrap { white-space: nowrap; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: .6rem 1rem; background: var(--brand); color: #fff; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.page-shell { width: min(100% - 2rem, var(--content)); margin-inline: auto; }

/* ---------------------------------------------------------------- header -- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--rule);
  margin-inline: calc(-1 * max((100vw - var(--content)) / 2, 1rem));
  padding-inline: max((100vw - var(--content)) / 2, 1rem);
}

.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); }
.brand__icon { width: 26px; height: 26px; display: block; }
.brand__name { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand:hover { color: var(--ink); }

.brand__badge {
  margin-left: .1rem; padding: .1rem .45rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--amber); background: var(--amber-soft);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  border-radius: 999px;
}

.top-nav { display: flex; gap: .35rem; }
.top-nav a {
  padding: .35rem .7rem; border-radius: 999px;
  font-size: .92rem; font-weight: 500; color: var(--ink-2); text-decoration: none;
}
.top-nav a:hover { color: var(--accent-ink); background: var(--paper-3); }

/* ------------------------------------------------------------------ home -- */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 3rem; align-items: center;
  padding: 4.5rem 0 3.5rem;
}

.hero--solo { grid-template-columns: minmax(0, 1fr); max-width: 64rem; }
.hero--solo .hero__lede { max-width: 62ch; }

.hero h1 {
  margin: 0 0 .75rem;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5.5vw, 3.9rem);
  line-height: 1.05; letter-spacing: -.02em; font-weight: 600;
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.hero__sub {
  display: block; margin-top: .7rem;
  font-family: var(--font-ui);
  font-size: 1.0rem; font-weight: 500; line-height: 1.5; letter-spacing: 0;
  color: var(--ink-2); background: none; -webkit-text-fill-color: var(--ink-2);
}
.hero__sub em { font-style: italic; color: var(--ink); }

.hero__lede { margin: 1rem 0 1.6rem; font-size: 1.06rem; color: var(--ink-2); max-width: 54ch; }

.hero__attr p { margin: 0; font-size: .82rem; color: var(--ink-3); }

.hero__actions { display: flex; flex-wrap: wrap; gap: .7rem; }

.button {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .62rem 1.15rem; border-radius: 999px;
  font-size: .95rem; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--paper); border: 1px solid var(--rule-2);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.button:hover { color: var(--ink); background: var(--paper-2); transform: translateY(-1px); }

.button--primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(100deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
}
.button--primary:hover { color: #fff; box-shadow: 0 10px 26px color-mix(in srgb, var(--brand) 45%, transparent); }

/* the pipeline diagram */
.hero__visual { display: flex; justify-content: center; }
.flow { display: grid; gap: .3rem; width: 100%; max-width: 26rem; }
.flow__node {
  padding: .8rem 1rem; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--rule);
  box-shadow: var(--shadow-sm);
}
.flow__node span { display: block; font-weight: 700; font-size: .95rem; }
.flow__node strong { display: block; font-weight: 500; font-size: .87rem; color: var(--accent); }
.flow__tech { display: block; margin-top: .15rem; font-size: .76rem; color: var(--ink-3); }
.flow__arrow { justify-self: center; color: var(--brand); font-size: 1rem; line-height: 1; }

.feature-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem;
  padding: 2.5rem 0 3rem; border-top: 1px solid var(--rule);
}
.feature-strip h2 {
  margin: 0 0 .5rem; font-family: var(--font-display);
  font-size: 1.22rem; font-weight: 600; letter-spacing: -.01em;
}
.feature-strip p { margin: 0; font-size: .95rem; color: var(--ink-2); }
.feature-strip code { font-size: .86em; padding: .08em .3em; background: var(--code-bg); border-radius: 4px; }

.docs-panel { padding: 1rem 0 4rem; }

.eyebrow {
  margin: 0 0 .35rem;
  font-size: .74rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase;
  color: var(--amber);
}

.section-heading h2 {
  margin: 0 0 1.6rem; font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 600; letter-spacing: -.015em;
  max-width: 40ch;
}

/* A book is drawn as a book: a coloured spine, then the face.  One colour per
   volume below; a book with no rule of its own falls back to the brand. */

.shelf {
  --cover-w: 14rem;
  display: grid; grid-template-columns: repeat(auto-fit, var(--cover-w));
  justify-content: start; gap: 1.5rem clamp(1.2rem, 2.5vw, 2.2rem);
  padding: .5rem 0 1rem;
}

.cover {
  --cover-ink: var(--brand);
  --cover-wash: color-mix(in srgb, var(--brand) 8%, transparent);
  position: relative; display: flex; height: 100%;
  width: var(--cover-w); min-height: calc(var(--cover-w) * 1.4);
  border-radius: 3px 10px 10px 3px; overflow: hidden;
  background: var(--paper);
  box-shadow: 0 1px 1px rgba(21, 24, 49, .10), 0 10px 22px -13px rgba(21, 24, 49, .45);
  transition: transform .16s ease, box-shadow .16s ease;
}
.cover:hover, .cover:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 2px 4px rgba(21, 24, 49, .12), 0 20px 36px -16px rgba(21, 24, 49, .5);
}
.cover:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the spine, with the fold shading a real one has */
.cover__spine {
  flex: 0 0 .9rem;
  background-color: var(--cover-ink);
  background-image: linear-gradient(to right,
    color-mix(in srgb, var(--cover-ink) 86%, black) 0 22%,
    var(--cover-ink) 22% 62%,
    color-mix(in srgb, var(--cover-ink) 80%, black) 62% 78%,
    color-mix(in srgb, var(--cover-ink) 92%, white) 78% 100%);
}

.cover__face {
  display: flex; flex-direction: column; flex: 1 1 auto;
  padding: 1.2rem 1.2rem 1.05rem;
  background: linear-gradient(180deg, var(--cover-wash), transparent 55%), var(--paper);
  border-left: 1px solid var(--rule);
}
.cover__mark { width: 1.7rem; height: auto; color: var(--cover-ink); }
.cover__series {
  margin-top: .6rem; font-size: .66rem; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
}
.cover__series:empty { display: none; }
.cover__title {
  margin: .45rem 0 0; font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 600; line-height: 1.15; text-wrap: balance;
}
.cover__title a { color: var(--ink); text-decoration: none; }
.cover__title a::after { content: ""; position: absolute; inset: 0; }  /* whole cover clickable */
.cover__title a:focus-visible { outline: none; }
.cover:hover .cover__title a { color: var(--accent-ink); }
.cover__rule { width: 2.3rem; height: 2px; margin: .65rem 0 .6rem; background: var(--cover-ink); }
.cover__blurb {
  font-size: .84rem; line-height: 1.45; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden;
}
.cover__meta {
  margin-top: auto; padding-top: .9rem;
  font-size: .74rem; color: var(--ink-3); font-variant-numeric: tabular-nums;
}

/* one colour per volume */
.cover--book            { --cover-ink: #5145e5; --cover-wash: rgba(81, 69, 229, .08); }
.cover--mdl             { --cover-ink: #0e7490; --cover-wash: rgba(14, 116, 144, .08); }
.cover--mdl-environment { --cover-ink: #9d3f7c; --cover-wash: rgba(157, 63, 124, .08); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cover {
    background: var(--paper-2);
    box-shadow: 0 1px 1px rgba(0, 0, 0, .45), 0 12px 24px -15px rgba(0, 0, 0, .85);
  }
  :root:not([data-theme="light"]) .cover__face {
    background: linear-gradient(180deg, var(--cover-wash), transparent 55%), var(--paper-2);
  }
  :root:not([data-theme="light"]) .cover--book            { --cover-ink: #8b85ff; --cover-wash: rgba(139, 133, 255, .11); }
  :root:not([data-theme="light"]) .cover--mdl             { --cover-ink: #4fb6d4; --cover-wash: rgba(79, 182, 212, .11); }
  :root:not([data-theme="light"]) .cover--mdl-environment { --cover-ink: #d68cbe; --cover-wash: rgba(214, 140, 190, .11); }
}
:root[data-theme="dark"] .cover {
  background: var(--paper-2);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .45), 0 12px 24px -15px rgba(0, 0, 0, .85);
}
:root[data-theme="dark"] .cover__face {
  background: linear-gradient(180deg, var(--cover-wash), transparent 55%), var(--paper-2);
}
:root[data-theme="dark"] .cover--book            { --cover-ink: #8b85ff; --cover-wash: rgba(139, 133, 255, .11); }
:root[data-theme="dark"] .cover--mdl             { --cover-ink: #4fb6d4; --cover-wash: rgba(79, 182, 212, .11); }
:root[data-theme="dark"] .cover--mdl-environment { --cover-ink: #d68cbe; --cover-wash: rgba(214, 140, 190, .11); }

/* ------------------------------------------------------- document pages -- */

.breadcrumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  padding: 1rem 0 .4rem; font-size: .84rem; color: var(--ink-3);
}
.breadcrumbs a { text-decoration: none; color: var(--ink-2); }
.breadcrumbs a:hover { color: var(--accent-ink); }
.breadcrumbs__sep { color: var(--rule-2); }

.docs-layout {
  display: grid; grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 3rem; align-items: start;
  padding-bottom: 4rem;
}

.page-main { padding-bottom: 4rem; }

.docs-sidebar {
  position: sticky; top: calc(var(--header-h) + 1rem);
  max-height: calc(100vh - var(--header-h) - 2rem);
  overflow-y: auto; overscroll-behavior: contain;
  padding: .75rem .25rem 2rem 0;
}
.docs-sidebar__eyebrow {
  margin: 0 0 .6rem; font-size: .74rem; font-weight: 700;
  letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3);
}
.docs-sidebar__eyebrow a { color: var(--ink-2); text-decoration: none; }
.docs-sidebar__eyebrow a:hover, .chapter-nav__home.is-active { color: var(--accent-ink); }

.chapter-nav, .section-nav__list { list-style: none; margin: 0; padding: 0; }

.chapter-nav__link {
  display: block; padding: .3rem .6rem; margin-bottom: .08rem;
  border-radius: 8px;
  font-size: .87rem; line-height: 1.35; color: var(--ink-2); text-decoration: none;
}
.chapter-nav__link:hover { background: var(--paper-2); color: var(--accent-ink); }
.chapter-nav__link.is-active {
  font-weight: 600; color: var(--accent-ink); background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.chapter-nav__part {
  margin: 1.35rem 0 .4rem; padding: 0 .6rem .3rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--rule);
}
.chapter-nav__part:first-child { margin-top: .2rem; }

.section-nav__list { margin: .2rem 0 .5rem; }
.section-nav__link {
  display: block; padding: .16rem .6rem .16rem 1.1rem;
  font-size: .82rem; line-height: 1.35; color: var(--ink-3); text-decoration: none;
  border-left: 1px solid var(--rule);
}
.section-nav__link:hover { color: var(--accent-ink); border-left-color: var(--brand); }
.section-nav__link--l3 { padding-left: 1.9rem; font-size: .79rem; }

.docs-article { min-width: 0; max-width: var(--measure); padding-top: .5rem; }

.docs-article__header { margin-bottom: 2rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--rule); }
.docs-article__header h1 {
  margin: 0; font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.4vw, 2.6rem); line-height: 1.12;
  letter-spacing: -.02em; font-weight: 600;
}
.docs-article__summary { margin: .7rem 0 0; font-size: 1rem; color: var(--ink-2); }
.docs-article__source { margin: .4rem 0 0; font-size: .8rem; color: var(--ink-3); }
.docs-article__source:empty, .docs-article__summary:empty { display: none; }

/* ----------------------------------------------------------------- prose -- */

.prose { font-size: 1rem; }
.prose > :first-child { margin-top: 0; }

.prose h2 {
  margin: 2.4rem 0 .8rem; padding-top: .4rem;
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 600;
  line-height: 1.22; letter-spacing: -.015em; scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h3 {
  margin: 1.9rem 0 .5rem; font-family: var(--font-display);
  font-size: 1.26rem; font-weight: 600; line-height: 1.3;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h4 { margin: 1.5rem 0 .4rem; font-size: 1.02rem; font-weight: 700; scroll-margin-top: calc(var(--header-h) + 1rem); }
.prose h5, .prose h6 { margin: 1.2rem 0 .3rem; font-size: .92rem; font-weight: 700; color: var(--ink-2); }

.prose p { margin: 0 0 1.05rem; }
.prose ul, .prose ol { margin: 0 0 1.05rem; padding-left: 1.4rem; }
.prose li { margin: .22rem 0; }
.prose li > ul, .prose li > ol { margin: .22rem 0; }
.prose hr { margin: 2.2rem 0; border: 0; border-top: 1px solid var(--rule); }
.prose del { color: var(--ink-3); text-decoration-color: var(--danger); }

.prose blockquote {
  margin: 1.2rem 0; padding: .2rem 0 .2rem 1.1rem;
  border-left: 3px solid color-mix(in srgb, var(--brand) 55%, var(--rule));
  color: var(--ink-2);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose :not(pre) > code {
  padding: .12em .35em; font-size: .88em;
  background: var(--code-bg); color: var(--code-ink);
  border: 1px solid var(--rule); border-radius: 5px;
}

.prose pre {
  margin: 1.1rem 0; padding: .95rem 1.1rem;
  overflow-x: auto;
  font-size: .87rem; line-height: 1.55;
  background: var(--code-bg); color: var(--code-ink);
  border: 1px solid var(--rule); border-left: 3px solid color-mix(in srgb, var(--brand) 50%, var(--rule));
  border-radius: 10px;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; }

.prose table {
  display: block; width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 1.2rem 0; font-size: .92rem;
}
.prose th, .prose td { padding: .5rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.prose thead th { background: var(--paper-2); font-weight: 600; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.prose tbody tr:hover { background: var(--paper-2); }

.prose kbd {
  padding: .08em .4em; font-size: .85em;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  border-bottom-width: 2px; border-radius: 5px;
}

/* The page turn, at the foot of every chapter. */

.pager {
  display: flex; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.pager__link {
  flex: 1 1 0; display: flex; flex-direction: column; gap: .15rem;
  padding: .8rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
  transition: border-color .14s ease, background .14s ease;
}
.pager__link:hover { color: var(--ink); background: var(--paper-2); border-color: var(--rule-2); }
.pager__link--next { text-align: right; margin-left: auto; }
.pager__dir { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.pager__link--prev .pager__dir::before { content: "\2190\00a0"; }
.pager__link--next .pager__dir::after { content: "\00a0\2192"; }
.pager__title { font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; line-height: 1.25; }
.pager__link:hover .pager__title { color: var(--accent-ink); }

@media (max-width: 40rem) { .pager { flex-direction: column; } .pager__link--next { text-align: left; } }

/* ---------------------------------------------------------------- footer -- */

.site-footer {
  padding: 1.6rem 0 2.5rem; border-top: 1px solid var(--rule);
  font-size: .85rem; color: var(--ink-3);
}
.site-footer p { margin: 0 0 .2rem; }
.site-footer a { color: var(--ink-2); }
.site-footer__attr { font-size: .8rem; }

/* -------------------------------------------------------------- narrower -- */

@media (max-width: 60rem) {
  .hero { grid-template-columns: 1fr; gap: 2rem; padding-top: 2.5rem; }
  .docs-layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .docs-sidebar {
    position: static; max-height: none; overflow: visible;
    padding: .75rem 0; border-bottom: 1px solid var(--rule);
  }
  .docs-article { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
