/*
 * Documentation theme for conceptlz/adobe-sign and conceptlz/adobe-sign-laravel.
 * Source of truth: tools/docs/assets/css/docs.css. `php tools/docs/build.php` copies it into each docs/.
 *
 * Motif: a notarial ledger. Paper, iron-gall ink, a rare ochre stamp, signature lines.
 */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;

  --paper: oklch(0.975 0.008 85);
  --paper-raised: oklch(0.99 0.005 85);
  --paper-sunk: oklch(0.952 0.011 85);
  --ink: oklch(0.26 0.055 265);
  --ink-soft: oklch(0.44 0.04 265);
  --ink-faint: oklch(0.58 0.03 265);
  --rule: oklch(0.875 0.014 85);
  --rule-strong: oklch(0.78 0.02 85);

  --brand: oklch(0.43 0.14 265);
  --brand-hover: oklch(0.36 0.15 265);
  --brand-wash: oklch(0.94 0.025 265);
  --brand-line: oklch(0.82 0.06 265);

  --stamp: oklch(0.7 0.135 68);
  --stamp-ink: oklch(0.47 0.11 60);
  --stamp-wash: oklch(0.95 0.035 80);

  --ok-ink: oklch(0.45 0.1 155);
  --ok-wash: oklch(0.95 0.03 155);
  --danger-ink: oklch(0.5 0.16 28);
  --danger-wash: oklch(0.95 0.03 28);

  --code-bg: oklch(0.255 0.045 265);
  --code-ink: oklch(0.93 0.012 85);
  --code-rule: oklch(0.34 0.05 265);
  --tok-comment: oklch(0.68 0.03 265);
  --tok-keyword: oklch(0.8 0.1 275);
  --tok-string: oklch(0.84 0.1 80);
  --tok-number: oklch(0.82 0.12 60);
  --tok-variable: oklch(0.86 0.07 160);
  --tok-type: oklch(0.92 0.04 85);
  --tok-function: oklch(0.84 0.08 310);
  --tok-punct: oklch(0.75 0.02 265);

  --shadow-raised: 0 1px 0 oklch(0.85 0.015 85), 0 12px 32px -18px oklch(0.3 0.05 265 / 0.35);

  --font-display: "Gloock", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.8125rem;
  --text-sm: 0.9rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-h3: clamp(1.25rem, 1.1rem + 0.5vw, 1.45rem);
  --text-h2: clamp(1.6rem, 1.3rem + 1vw, 2.05rem);
  --text-h1: clamp(2.3rem, 1.7rem + 2.4vw, 3.4rem);
  --text-hero: clamp(2.8rem, 1.8rem + 4.2vw, 5rem);

  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --topbar-h: 3.75rem;
  --sidebar-w: 17.5rem;
  --toc-w: 14rem;
  --measure: 54rem;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: oklch(0.195 0.026 265);
  --paper-raised: oklch(0.225 0.03 265);
  --paper-sunk: oklch(0.175 0.024 265);
  --ink: oklch(0.925 0.014 85);
  --ink-soft: oklch(0.78 0.02 265);
  --ink-faint: oklch(0.64 0.025 265);
  --rule: oklch(0.31 0.03 265);
  --rule-strong: oklch(0.4 0.035 265);

  --brand: oklch(0.79 0.1 268);
  --brand-hover: oklch(0.86 0.08 268);
  --brand-wash: oklch(0.26 0.05 265);
  --brand-line: oklch(0.45 0.08 265);

  --stamp: oklch(0.8 0.13 75);
  --stamp-ink: oklch(0.84 0.11 78);
  --stamp-wash: oklch(0.27 0.04 70);

  --ok-ink: oklch(0.8 0.1 155);
  --ok-wash: oklch(0.26 0.04 160);
  --danger-ink: oklch(0.78 0.12 30);
  --danger-wash: oklch(0.27 0.05 28);

  --code-bg: oklch(0.155 0.024 265);
  --code-rule: oklch(0.28 0.035 265);

  --shadow-raised: 0 0 0 1px oklch(0.3 0.03 265), 0 16px 40px -20px oklch(0.05 0.02 265 / 0.8);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + var(--space-lg));
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="dark"] body {
  line-height: 1.72;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--brand-line);
  transition: color 120ms, text-decoration-color 120ms;
}

a:hover {
  color: var(--brand-hover);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection {
  background: var(--stamp-wash);
  color: var(--ink);
}

.skip-link {
  position: absolute;
  left: var(--space-md);
  top: -4rem;
  z-index: 100;
  padding: var(--space-xs) var(--space-md);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-sm);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  background: color-mix(in oklch, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  flex: none;
  color: var(--brand);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.brand-package {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}

.icon-button:hover {
  background: var(--paper-sunk);
  color: var(--ink);
  border-color: var(--rule);
}

.icon-button svg {
  width: 1.2rem;
  height: 1.2rem;
}

.menu-button {
  display: none;
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

.topbar-link {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}

.topbar-link:hover {
  color: var(--ink);
}

/* ---------- Search ---------- */

.search {
  position: relative;
  width: min(22rem, 40vw);
}

.search-input {
  width: 100%;
  height: 2.4rem;
  padding: 0 2.6rem 0 2.3rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
}

.search-input::placeholder {
  color: var(--ink-faint);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}

.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

.search-key {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input:not(:placeholder-shown) ~ .search-key {
  display: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(34rem, calc(100vw - 2rem));
  max-height: min(70vh, 32rem);
  overflow-y: auto;
  margin: 0;
  padding: var(--space-xs);
  list-style: none;
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}

.search-results[hidden] {
  display: none;
}

.search-result a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
}

.search-result[aria-selected="true"] a,
.search-result a:hover {
  background: var(--brand-wash);
}

.search-result-title {
  display: block;
  font-weight: 600;
}

.search-result-path {
  display: block;
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.search-result-snippet {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.search-result mark {
  background: var(--stamp-wash);
  color: inherit;
  border-radius: 2px;
}

.search-empty {
  padding: var(--space-md);
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0 var(--space-2xl);
  max-width: 92rem;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--space-xl) var(--space-lg) var(--space-3xl);
  border-right: 1px solid var(--rule);
  overscroll-behavior: contain;
}

.nav-group + .nav-group {
  margin-top: var(--space-xl);
}

.nav-group-title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: block;
  position: relative;
  padding: 0.32rem 0.6rem;
  margin-left: -0.6rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.95rem;
  text-decoration: none;
}

.nav-list a:hover {
  color: var(--ink);
  background: var(--paper-sunk);
}

.nav-list a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  background: var(--brand-wash);
}

.nav-list a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0.6rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--stamp);
  transform: translateY(-50%);
}

.sidebar-other {
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px dashed var(--rule-strong);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.sidebar-other a {
  display: inline-block;
  margin-top: var(--space-2xs);
  font-weight: 600;
}

.content {
  min-width: 0;
  padding: var(--space-2xl) 0 var(--space-4xl);
}

.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  max-height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-2xl) 0;
  font-size: var(--text-sm);
}

.toc-title {
  margin: 0 0 var(--space-sm);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--rule);
}

.toc li a {
  display: block;
  padding: 0.22rem 0 0.22rem var(--space-md);
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.4;
}

.toc li.toc-sub a {
  padding-left: calc(var(--space-md) + var(--space-sm));
  font-size: var(--text-xs);
}

.toc li a:hover {
  color: var(--ink);
}

.toc li a.is-active {
  color: var(--brand);
  border-left-color: var(--brand);
}

/* ---------- Document typography ---------- */

.doc {
  max-width: var(--measure);
}

.doc-header {
  margin-bottom: var(--space-2xl);
}

.eyebrow {
  margin: 0 0 var(--space-sm);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stamp-ink);
}

.doc h1,
.doc h2,
.doc h3,
.doc h4 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.doc h1 {
  margin: 0;
  font-size: var(--text-h1);
  line-height: 1.05;
}

/* The "sign here" line under every page title. */
.doc-header h1::after {
  content: "×";
  display: block;
  width: min(18rem, 60%);
  margin-top: var(--space-lg);
  padding: 0 0 3px 2px;
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink-faint);
}

.lede {
  margin: var(--space-lg) 0 0;
  max-width: 40rem;
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--ink-soft);
}

.doc h2 {
  margin: var(--space-3xl) 0 var(--space-md);
  font-size: var(--text-h2);
  line-height: 1.15;
}

.doc h3 {
  margin: var(--space-2xl) 0 var(--space-sm);
  font-size: var(--text-h3);
  line-height: 1.25;
}

.doc h4 {
  margin: var(--space-xl) 0 var(--space-xs);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
}

.doc h2 + h3 {
  margin-top: var(--space-lg);
}

.doc p,
.doc ul,
.doc ol,
.doc dl {
  margin: 0 0 var(--space-md);
}

.doc ul,
.doc ol {
  padding-left: 1.4rem;
}

.doc li + li {
  margin-top: 0.3rem;
}

.doc li > ul,
.doc li > ol {
  margin-top: 0.3rem;
  margin-bottom: 0;
}

.doc ul li::marker {
  color: var(--stamp);
}

.doc ol li::marker {
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.doc strong {
  font-weight: 700;
}

.doc hr {
  margin: var(--space-3xl) 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.heading-anchor {
  margin-left: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.7em;
  color: var(--ink-faint);
  text-decoration: none;
  opacity: 0;
  transition: opacity 120ms;
}

.doc :is(h2, h3):hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.doc dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-xs) var(--space-lg);
}

.doc dt {
  font-weight: 700;
}

.doc dd {
  margin: 0;
  color: var(--ink-soft);
}

/* ---------- Inline code, kbd, badges ---------- */

.doc :not(pre) > code {
  padding: 0.08em 0.36em;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper-sunk);
  font-family: var(--font-mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-soft);
}

.badge {
  display: inline-block;
  padding: 0.05em 0.5em;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  vertical-align: 0.1em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge-brand {
  border-color: var(--brand-line);
  background: var(--brand-wash);
  color: var(--brand);
}

.badge-stamp {
  border-color: color-mix(in oklch, var(--stamp) 60%, transparent);
  background: var(--stamp-wash);
  color: var(--stamp-ink);
}

.badge-ok {
  border-color: color-mix(in oklch, var(--ok-ink) 40%, transparent);
  background: var(--ok-wash);
  color: var(--ok-ink);
}

.badge-danger {
  border-color: color-mix(in oklch, var(--danger-ink) 40%, transparent);
  background: var(--danger-wash);
  color: var(--danger-ink);
}

/* An HTTP endpoint, e.g. <span class="endpoint"><b>GET</b> /agreements/{id}</span> */
.endpoint {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.endpoint b {
  padding: 0.02em 0.4em;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.82em;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ---------- Code blocks ---------- */

.code {
  position: relative;
  margin: var(--space-lg) 0;
  border-radius: var(--radius-md);
  background: var(--code-bg);
  color: var(--code-ink);
  overflow: hidden;
}

.code figcaption {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.5rem var(--space-md);
  border-bottom: 1px solid var(--code-rule);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--tok-comment);
}

.code figcaption::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--stamp);
}

.doc pre,
.code pre {
  margin: 0;
  padding: var(--space-md) var(--space-lg);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.7;
  tab-size: 4;
  background: var(--code-bg);
  color: var(--code-ink);
}

.doc > pre {
  border-radius: var(--radius-md);
  margin: var(--space-lg) 0;
}

.doc pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
}

.copy-button {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--code-rule);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--tok-comment);
  font: 600 var(--text-xs) / 1.5 var(--font-body);
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms, color 120ms;
}

.code:hover .copy-button,
.copy-button:focus-visible,
.copy-button[data-copied] {
  opacity: 1;
}

.copy-button:hover {
  color: var(--code-ink);
}

.copy-button[data-copied] {
  color: var(--tok-string);
}

@media (hover: none) {
  .copy-button {
    opacity: 1;
  }
}

.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}

.tok-keyword {
  color: var(--tok-keyword);
}

.tok-string {
  color: var(--tok-string);
}

.tok-number {
  color: var(--tok-number);
}

.tok-variable {
  color: var(--tok-variable);
}

.tok-type {
  color: var(--tok-type);
  font-weight: 600;
}

.tok-function {
  color: var(--tok-function);
}

.tok-punct {
  color: var(--tok-punct);
}

/* ---------- Callouts ---------- */

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2xs) var(--space-md);
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-md);
  background: var(--brand-wash);
}

.callout::before {
  content: "i";
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-top: 0.1rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--brand);
  font: 400 1rem / 1 var(--font-display);
}

.callout-title {
  margin: 0;
  font-weight: 700;
}

.callout > :not(.callout-title) {
  grid-column: 2;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout p {
  margin-bottom: var(--space-xs);
}

.callout-tip {
  border-color: color-mix(in oklch, var(--ok-ink) 35%, transparent);
  background: var(--ok-wash);
}

.callout-tip::before {
  content: "✓";
  color: var(--ok-ink);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.callout-warning {
  border-color: color-mix(in oklch, var(--stamp) 55%, transparent);
  background: var(--stamp-wash);
}

.callout-warning::before {
  content: "!";
  color: var(--stamp-ink);
}

.callout-danger {
  border-color: color-mix(in oklch, var(--danger-ink) 35%, transparent);
  background: var(--danger-wash);
}

.callout-danger::before {
  content: "×";
  color: var(--danger-ink);
}

/* Legal / regulatory context: looks like a stamped notary note. */
.callout-legal {
  border-style: dashed;
  border-color: var(--rule-strong);
  background: var(--paper-raised);
}

.callout-legal::before {
  content: "§";
  color: var(--stamp-ink);
  border-style: double;
  border-width: 3px;
}

/* ---------- Steps ---------- */

.steps {
  counter-reset: step;
  margin: var(--space-xl) 0;
  padding: 0;
  list-style: none;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 var(--space-xl) 3.4rem;
  margin: 0;
}

.steps > li + li {
  margin-top: 0;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.1rem;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1.5px solid var(--stamp);
  border-radius: 50%;
  outline: 1px solid color-mix(in oklch, var(--stamp) 45%, transparent);
  outline-offset: 3px;
  background: var(--paper);
  color: var(--stamp-ink);
  font: 400 1.05rem / 1 var(--font-display);
}

.steps > li::after {
  content: "";
  position: absolute;
  left: 1.1rem;
  top: 2.6rem;
  bottom: 0.3rem;
  border-left: 1px dashed var(--rule-strong);
}

.steps > li:last-child {
  padding-bottom: 0;
}

.steps > li:last-child::after {
  display: none;
}

.step-title {
  display: block;
  margin-bottom: var(--space-2xs);
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.3;
}

/* ---------- Tables ---------- */

.table-wrap {
  margin: var(--space-lg) 0;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.doc th,
.doc td {
  padding: 0.6rem var(--space-md);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}

.doc thead th {
  background: var(--paper-sunk);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.doc tbody tr:last-child > * {
  border-bottom: 0;
}

.doc td code {
  white-space: nowrap;
}

/* ---------- API signatures ---------- */

.api {
  margin: var(--space-xl) 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
}

.api-signature {
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.api-signature .endpoint {
  display: flex;
  margin-top: var(--space-2xs);
}

.api-body {
  padding: var(--space-md);
}

.api-body > :last-child {
  margin-bottom: 0;
}

/* ---------- FAQ ---------- */

.faq {
  margin: var(--space-lg) 0;
  border-top: 1px solid var(--rule);
}

.faq details {
  border-bottom: 1px solid var(--rule);
}

.faq summary {
  position: relative;
  display: block;
  padding: var(--space-md) 2.6rem var(--space-md) 0;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.45;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  width: 0.6rem;
  height: 0.6rem;
  border-right: 1.5px solid var(--ink-faint);
  border-bottom: 1.5px solid var(--ink-faint);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 220ms var(--ease-out);
}

.faq details[open] > summary::after {
  transform: translateY(-30%) rotate(-135deg);
}

.faq summary:hover {
  color: var(--brand);
}

.faq-answer {
  padding: 0 0 var(--space-lg);
  color: var(--ink);
}

.faq-answer > :last-child {
  margin-bottom: 0;
}

.faq-group-title {
  margin-top: var(--space-3xl);
}

/* ---------- Figures & diagrams ---------- */

.diagram {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  overflow-x: auto;
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 34rem;
  font-family: var(--font-body);
}

.diagram figcaption {
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* Diagram SVG vocabulary: use these classes instead of hard-coded colours. */
.d-box {
  fill: var(--paper);
  stroke: var(--rule-strong);
  stroke-width: 1.2;
}

.d-box-brand {
  fill: var(--brand-wash);
  stroke: var(--brand-line);
  stroke-width: 1.2;
}

.d-box-stamp {
  fill: var(--stamp-wash);
  stroke: var(--stamp);
  stroke-width: 1.2;
}

.d-box-ok {
  fill: var(--ok-wash);
  stroke: color-mix(in oklch, var(--ok-ink) 50%, transparent);
  stroke-width: 1.2;
}

.d-box-muted {
  fill: var(--paper-sunk);
  stroke: var(--rule);
  stroke-width: 1.2;
  stroke-dasharray: 4 3;
}

.d-line {
  fill: none;
  stroke: var(--ink-faint);
  stroke-width: 1.3;
}

.d-line-brand {
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.5;
}

.d-line-dashed {
  fill: none;
  stroke: var(--ink-faint);
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
}

.d-arrowhead {
  fill: var(--ink-faint);
}

.d-arrowhead-brand {
  fill: var(--brand);
}

.d-text {
  fill: var(--ink);
  font-size: 14px;
}

.d-text-strong {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.d-text-soft {
  fill: var(--ink-soft);
  font-size: 12px;
}

.d-text-mono {
  fill: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.d-text-display {
  fill: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
}

.d-text-stamp {
  fill: var(--stamp-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.d-dot-stamp {
  fill: var(--stamp);
}

/* ---------- Link lists ("where next") ---------- */

.next-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-md);
  margin: var(--space-xl) 0;
  padding: 0;
  list-style: none;
}

.next-links li {
  margin: 0;
}

.next-links a {
  display: block;
  height: 100%;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms, background 150ms;
}

.next-links a:hover {
  border-color: var(--brand-line);
  background: var(--brand-wash);
}

.next-links strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
}

.next-links span {
  display: block;
  margin-top: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* ---------- Comparison grid (e.g. SES / AES / QES) ---------- */

.levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0;
  margin: var(--space-xl) 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.level {
  padding: var(--space-lg);
  background: var(--paper-raised);
}

.level + .level {
  border-left: 1px solid var(--rule);
}

.level .level-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.2rem;
  line-height: 1;
}

.level .level-full {
  margin: var(--space-2xs) 0 var(--space-md);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stamp-ink);
}

.level p {
  font-size: 0.95rem;
}

.level > :last-child {
  margin-bottom: 0;
}

@media (max-width: 40rem) {
  .level + .level {
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
}

/* ---------- Home hero ---------- */

.hero {
  padding: var(--space-xl) 0 var(--space-2xl);
  margin-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--rule);
}

.doc .hero-title {
  margin: 0;
  max-width: 14ch;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-hero);
  line-height: 0.98;
  letter-spacing: -0.015em;
}

.hero-sign {
  position: relative;
  max-width: 30rem;
  margin: var(--space-xl) 0 var(--space-lg);
}

.hero-sign svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.signature-stroke {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.signature-line {
  stroke: var(--rule-strong);
  stroke-width: 1;
}

.signature-x {
  fill: var(--ink-faint);
  font-family: var(--font-display);
  font-size: 26px;
}

.signature-caption {
  fill: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: no-preference) {
  .js .signature-stroke {
    stroke-dasharray: var(--len, 1600);
    stroke-dashoffset: var(--len, 1600);
    animation: sign 2.4s var(--ease-out) 0.35s forwards;
  }

  .js .hero-reveal {
    opacity: 0;
    transform: translateY(8px);
    animation: reveal 700ms var(--ease-out) var(--delay, 0ms) forwards;
  }
}

@keyframes sign {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-lede {
  max-width: 38rem;
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--ink-soft);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition: background 120ms, border-color 120ms, color 120ms;
}

.button:hover {
  border-color: var(--ink-faint);
  background: var(--paper-sunk);
  color: var(--ink);
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.button-primary:hover {
  border-color: var(--brand-hover);
  background: var(--brand-hover);
  color: var(--paper);
}

.install-line {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: fit-content;
  max-width: 100%;
  margin-top: var(--space-lg);
  padding: 0.55rem 0.6rem 0.55rem var(--space-md);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  overflow-x: auto;
}

.doc .install-line code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  white-space: nowrap;
  overflow-wrap: normal;
}

.install-line::before {
  content: "$";
  color: var(--stamp-ink);
}

.install-line .copy-inline {
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink-soft);
  font: 600 var(--text-xs) / 1.5 var(--font-body);
  cursor: pointer;
}

/* Feature ledger: a ruled list, not a card grid. */
.ledger {
  margin: var(--space-xl) 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.ledger li {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) 1fr;
  gap: var(--space-lg);
  margin: 0;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--rule);
}

.ledger li + li {
  margin-top: 0;
}

.ledger-term {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.35;
}

.ledger-desc {
  color: var(--ink-soft);
}

@media (max-width: 40rem) {
  .ledger li {
    grid-template-columns: 1fr;
    gap: var(--space-2xs);
  }
}

/* ---------- Troubleshooting: problem finder and issue cards ---------- */

.finder {
  margin: var(--space-xl) 0 var(--space-2xl);
  padding: var(--space-lg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
}

.doc .finder-title {
  margin: 0 0 var(--space-sm);
  line-height: 1.2;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.finder-search {
  position: relative;
  margin-bottom: var(--space-md);
}

.finder-search[hidden] {
  display: none;
}

.finder-input {
  width: 100%;
  height: 2.9rem;
  padding: 0 var(--space-md) 0 2.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.finder-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}

.finder-search svg {
  position: absolute;
  left: 0.85rem;
  top: 0.9rem;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--ink-faint);
  pointer-events: none;
}

.doc .finder-status {
  margin: var(--space-xs) 0 0;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  min-height: 1.4em;
}

.finder-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-lg) var(--space-xl);
  margin: var(--space-md) 0 0;
}

.doc .finder-group-title {
  margin: 0 0 var(--space-2xs);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stamp-ink);
}

.finder-group-title a {
  color: inherit;
  text-decoration: none;
}

.doc .finder-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc .finder-group li {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.45;
}

.doc .finder-group li + li {
  margin-top: 0.3rem;
}

.finder-group a {
  text-decoration: none;
}

.finder-group a:hover {
  text-decoration: underline;
}

.issue-group-intro {
  color: var(--ink-soft);
}

.issue {
  margin: var(--space-lg) 0 var(--space-xl);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
  overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h) + var(--space-md));
}

.issue[hidden] {
  display: none;
}

.issue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--rule);
}

.doc .issue-head h3 {
  flex: 1 1 18rem;
  margin: 0;
  font-size: 1.3rem;
}

.issue-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin: 0;
}

.issue-tags .badge {
  font-family: var(--font-mono);
  font-weight: 600;
}

.issue-part {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
}

.issue-part + .issue-part {
  border-top: 1px dashed var(--rule);
}

.doc .issue-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  margin: 0;
  padding-top: 0.1rem;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.issue-label::before {
  content: "";
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.3rem;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
}

.issue-cause .issue-label::before {
  border-color: var(--stamp);
  background: var(--stamp-wash);
}

.issue-fix {
  background: color-mix(in oklch, var(--ok-wash) 70%, var(--paper-raised));
}

.issue-fix .issue-label {
  color: var(--ok-ink);
}

.issue-fix .issue-label::before {
  border-color: var(--ok-ink);
  background: var(--ok-ink);
}

.issue-body > :first-child {
  margin-top: 0;
}

.issue-body > :last-child {
  margin-bottom: 0;
}

.issue-body .code,
.issue-body .table-wrap,
.issue-body > pre {
  margin: var(--space-sm) 0;
}

@media (max-width: 40rem) {
  .issue-part {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .issue-head,
  .issue-part {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

/* ---------- Legal and about pages ---------- */

.doc .legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-lg);
  margin: var(--space-lg) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.doc .legal-meta li {
  margin: 0;
}

.legal-meta strong {
  color: var(--ink);
}

.summary-box {
  margin: var(--space-xl) 0;
  padding: var(--space-lg) var(--space-xl);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
}

.doc .summary-box-title {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.doc .summary-box ul {
  margin-bottom: 0;
}

.maker {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-lg) var(--space-xl);
  align-items: center;
  margin: var(--space-xl) 0;
  padding: var(--space-xl);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
}

.maker-seal {
  width: 6.5rem;
  height: 6.5rem;
  color: var(--brand);
}

.doc .maker-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 1.4rem + 1.4vw, 2.5rem);
  line-height: 1.05;
}

.doc .maker-role {
  margin: var(--space-2xs) 0 var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stamp-ink);
}

.maker p:last-child {
  margin-bottom: 0;
}

@media (max-width: 40rem) {
  .maker {
    grid-template-columns: 1fr;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer p {
  margin: 0;
}

.site-footer-legal {
  max-width: 46rem;
}

/* ---------- Pager & footer ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  max-width: var(--measure);
  margin-top: var(--space-4xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--rule);
}

.pager a {
  display: block;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms, background 150ms;
}

.pager a:hover {
  border-color: var(--brand-line);
  background: var(--brand-wash);
}

.pager-next {
  grid-column: 2;
  text-align: right;
}

.pager-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pager-title {
  display: block;
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: var(--space-xl) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-md);
  max-width: 92rem;
  margin: 0 auto;
}

.site-footer a {
  color: var(--ink-soft);
}

/* ---------- Responsive ---------- */

@media (max-width: 75rem) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    padding-right: var(--space-xl);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 56rem) {
  :root {
    --topbar-h: 3.5rem;
  }

  .topbar {
    padding: 0 var(--space-md);
    gap: var(--space-xs);
  }

  .menu-button {
    display: inline-grid;
  }

  .topbar-link,
  .brand-package {
    display: none;
  }

  .search {
    width: auto;
    flex: 1;
    max-width: 18rem;
  }

  .search-key {
    display: none;
  }

  .layout {
    display: block;
    padding: 0 var(--space-md);
  }

  /* The drawer runs the full height behind the top bar and pads its content below it. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(20rem, 86vw);
    height: 100dvh;
    padding-top: calc(var(--topbar-h) + var(--space-lg));
    background: var(--paper);
    border-right: 1px solid var(--rule);
    transform: translateX(-105%);
    transition: transform 280ms var(--ease-out), visibility 0s linear 280ms;
    visibility: hidden;
  }

  .nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 280ms var(--ease-out);
    box-shadow: var(--shadow-raised);
  }

  .nav-backdrop {
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 20;
    background: oklch(0.2 0.03 265 / 0.35);
  }

  .nav-backdrop[hidden] {
    display: none;
  }

  .content {
    padding-top: var(--space-xl);
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    grid-column: 1;
  }

  .doc dl {
    grid-template-columns: 1fr;
  }

  .doc dd {
    margin-bottom: var(--space-sm);
  }
}

@media (max-width: 34rem) {
  .brand-text,
  .topbar-spacer {
    display: none;
  }

  .search {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toc,
  .pager,
  .copy-button,
  .nav-backdrop {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .faq details {
    break-inside: avoid;
  }
}
