/* saaio.dev in the jasu.dev look: Nord surfaces, one purple accent, no shadows.
   Layout: sections nav | reading column | "On this page", under a sticky, translucent header. */

:root {
  color-scheme: light;
  --surface: #f8f9fb;
  --card: #eceff4;
  --ink: #2e3440;
  --muted: #4c566a;
  --subtle: #d8dee9;
  --border: #d8dee9;
  --code-block: #2e3440;
  --code-head: #3b4252;
  --code-ink: #eceff4;
  --code-dim: #9aa8bd;
  --code-bg: #e5e9f0;
  --code-inline: #4b6c8a;
  --accent: #7b5eaf;
  --on-accent: #f8f9fb;
  --link: #4b6c8a;
  --constructive: #a3be8c;
  --warning: #d08770;
  --critical: #bf616a;
  --header: rgba(248, 249, 251, 0.82);
  --hover: rgba(76, 86, 106, 0.07);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --top: 64px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #2e3440;
    --card: #3b4252;
    --ink: #eceff4;
    --muted: #a3b8cc;
    --subtle: #434c5e;
    --border: #434c5e;
    --code-block: #272c36;
    --code-head: #2e3440;
    --code-bg: #3b4252;
    --code-inline: #88c0d0;
    --accent: #bd93f9;
    --on-accent: #2e3440;
    --link: #88c0d0;
    --warning: #ebcb8b;
    --header: rgba(46, 52, 64, 0.8);
    --hover: rgba(236, 239, 244, 0.06);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #2e3440;
  --card: #3b4252;
  --ink: #eceff4;
  --muted: #a3b8cc;
  --subtle: #434c5e;
  --border: #434c5e;
  --code-block: #272c36;
  --code-head: #2e3440;
  --code-bg: #3b4252;
  --code-inline: #88c0d0;
  --accent: #bd93f9;
  --on-accent: #2e3440;
  --link: #88c0d0;
  --warning: #ebcb8b;
  --header: rgba(46, 52, 64, 0.8);
  --hover: rgba(236, 239, 244, 0.06);
}

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

html { scroll-padding-top: calc(var(--top) + 24px); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 17px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease); }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 50; background: var(--card); padding: 8px 14px; border-radius: var(--radius); }

/* Header */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.top-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--top);
  max-width: 1440px;
  margin: 0 auto;
  padding-left: max(32px, env(safe-area-inset-left, 0px));
  padding-right: max(32px, env(safe-area-inset-right, 0px));
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); width: 240px; flex: none; }
.brand:hover { color: var(--ink); }
.wordmark { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.version { font: 600 12px/1 var(--mono); padding: 4px 7px; border-radius: 99px; background: var(--card); color: var(--muted); border: 1px solid var(--border); }

.search-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.search-button:hover { border-color: color-mix(in srgb, var(--muted) 45%, transparent); }
.search-button span { flex: 1; text-align: left; }
kbd { font: 600 12px/1 var(--sans); padding: 4px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }

.top-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.top-links a.text { padding: 6px 10px; border-radius: var(--radius); font-size: 15px; font-weight: 500; color: var(--muted); text-decoration: none; transition: color 150ms var(--ease), background-color 150ms var(--ease); }
.top-links a.text:hover, .top-links a.text[aria-current] { color: var(--ink); }
.icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}
.icon:hover { background: var(--hover); color: var(--ink); }
.theme .moon { display: none; }
:root[data-theme="dark"] .theme .sun { display: none; }
:root[data-theme="dark"] .theme .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { display: none; }
  :root:not([data-theme="light"]) .theme .moon { display: block; }
}
.menu, .search-icon, .scrim { display: none; }

/* Layout */

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 760px) 220px;
  gap: 64px;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: max(32px, env(safe-area-inset-left, 0px));
  padding-right: max(32px, env(safe-area-inset-right, 0px));
  justify-content: space-between;
}

.nav, .outline {
  position: sticky;
  top: calc(var(--top) + env(safe-area-inset-top, 0px));
  align-self: start;
  max-height: calc(100vh - var(--top) - env(safe-area-inset-top, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: 36px 48px;
  scrollbar-width: thin;
}

.nav-section + .nav-section { margin-top: 28px; }
.nav-title { margin: 0 0 8px; padding-left: 12px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  text-decoration: none;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}
.nav a:hover { color: var(--ink); background: var(--hover); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--card); font-weight: 600; }

.outline-title { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.outline ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.outline a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 14px;
  border-left: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-decoration: none;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.outline a:hover { color: var(--ink); }
.outline a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.outline-edit { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }
.outline-edit a { color: var(--muted); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.outline-edit a:hover { color: var(--ink); }
.outline-edit svg.i { width: 14px; height: 14px; }

.content { min-width: 0; padding-block: 44px 72px; }

/* The page */

.eyebrow { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--accent); }

article > :first-child { margin-top: 0; }
article h1 { font-size: clamp(2rem, 4.4vw, 2.6rem); line-height: 1.1; font-weight: 800; letter-spacing: -0.035em; margin: 0 0 16px; text-wrap: balance; }
article h1 + p { font-size: 19px; line-height: 1.65; color: var(--muted); margin-bottom: 28px; }
article h2 { position: relative; font-size: 26px; line-height: 1.25; font-weight: 750; letter-spacing: -0.02em; margin: 64px 0 16px; padding-top: 28px; border-top: 1px solid var(--border); text-wrap: balance; }
article h3 { position: relative; font-size: 20px; line-height: 1.35; font-weight: 700; letter-spacing: -0.01em; margin: 40px 0 12px; }
article h4 { position: relative; font-size: 17px; font-weight: 700; margin: 28px 0 8px; }

article h1 + h2 { margin-top: 28px; padding-top: 0; border-top: 0; }
article h1 + h2 .anchor { top: 0; }
.anchor { position: absolute; left: -1.1em; width: 1em; color: var(--subtle); text-decoration: none; font-weight: 500; opacity: 0; transition: opacity 150ms var(--ease), color 150ms var(--ease); }
article h2 .anchor { top: 28px; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); }

article p, article ul, article ol, article .code, article .table, article blockquote, article img { margin: 0 0 20px; }
article ul, article ol { padding-left: 1.3em; }
article li { margin: 6px 0; padding-left: 2px; }
article li::marker { color: var(--muted); }
article li > p { margin: 0; }
article li > ul, article li > ol { margin: 6px 0 0; }
article strong { font-weight: 650; }
article hr { border: 0; border-top: 1px solid var(--border); margin: 48px 0; }
article img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }

/* The page's own list of sections: a card where the outline is not beside it */
article ul.toc { list-style: none; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); columns: 2; column-gap: 28px; font-size: 15px; }
article ul.toc::before { content: "On this page"; display: block; column-span: all; margin-bottom: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
article ul.toc li { margin: 0; padding: 3px 0; break-inside: avoid; }
article ul.toc a { color: var(--muted); text-decoration: none; }
article ul.toc a:hover { color: var(--accent); }

article :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--code-bg);
  color: var(--code-inline);
  border-radius: 4px;
  padding: 0.14em 0.36em;
  overflow-wrap: break-word;
}
article a code { color: inherit; }

.code { position: relative; border-radius: var(--radius-lg); background: var(--code-block); overflow: hidden; border: 1px solid color-mix(in srgb, var(--code-block) 80%, var(--border)); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 8px 0 16px; background: var(--code-head); border-bottom: 1px solid rgba(236, 239, 244, 0.06); }
.code-lang { font: 600 12px/1 var(--mono); letter-spacing: 0.04em; color: var(--code-dim); text-transform: lowercase; }
.copy { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--code-dim); font-size: 13px; cursor: pointer; transition: color 150ms var(--ease), background-color 150ms var(--ease); }
.copy:hover { color: var(--code-ink); background: rgba(236, 239, 244, 0.08); }
.copy svg.i { width: 15px; height: 15px; }
.copy .done { display: none; }
.copy.copied { color: var(--constructive); }
.copy.copied .idle { display: none; }
.copy.copied .done { display: inline-flex; }
.code pre { margin: 0; padding: 16px 20px 18px; overflow-x: auto; color: var(--code-ink); font: 14px/1.7 var(--mono); tab-size: 4; }
.code pre code { font: inherit; color: inherit; background: none; padding: 0; }
.code .c { color: var(--code-dim); }

article .table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
article table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.55; }
article th, article td { padding: 10px 16px; text-align: left; vertical-align: top; }
article th { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink); background: var(--card); border-bottom: 1px solid var(--border); white-space: nowrap; }
article td { border-bottom: 1px solid var(--border); }
article tr:last-child td { border-bottom: 0; }
article tbody tr { transition: background-color 150ms var(--ease); }
article tbody tr:hover { background: var(--hover); }
article td code { white-space: nowrap; }

article blockquote { padding: 4px 0 4px 18px; border-left: 3px solid var(--border); color: var(--muted); }
article blockquote > :last-child { margin-bottom: 0; }

/* Callouts: GitHub alerts */
article blockquote[class^="markdown-alert-"] {
  --tone: var(--link);
  margin-left: 0;
  margin-right: 0;
  position: relative;
  padding: 16px 20px 16px 60px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
}
article blockquote[class^="markdown-alert-"]::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 16px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--tone) 22%, transparent);
}
article blockquote[class^="markdown-alert-"]::after {
  content: "";
  position: absolute;
  left: 23px;
  top: 21px;
  width: 18px;
  height: 18px;
  background: var(--tone);
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
article blockquote.markdown-alert-note { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 7.5v.5'/%3E%3C/svg%3E"); }
article blockquote.markdown-alert-tip { --tone: var(--constructive); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4M12 3a6 6 0 0 0-4 10.5c.6.6 1 1.4 1 2.5h6c0-1.1.4-1.9 1-2.5A6 6 0 0 0 12 3z'/%3E%3C/svg%3E"); }
article blockquote.markdown-alert-important { --tone: var(--accent); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16.5v.5'/%3E%3C/svg%3E"); }
article blockquote.markdown-alert-warning, article blockquote.markdown-alert-caution { --tone: var(--warning); --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20L12 3z'/%3E%3Cpath d='M12 10v4M12 17v.5'/%3E%3C/svg%3E"); }
article blockquote.markdown-alert-caution { --tone: var(--critical); }
article .markdown-alert-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--ink); line-height: 28px; }
article blockquote[class^="markdown-alert-"] > :last-child { margin-bottom: 0; }

/* Previous and next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; }
.pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), transform 150ms var(--ease);
}
.pager a:hover { border-color: var(--accent); background: var(--hover); transform: translateY(-1px); }
.pager .next { grid-column: 2; text-align: right; }
.pager small { font-size: 13px; color: var(--muted); }
.pager strong { font-size: 17px; font-weight: 650; color: var(--ink); }
.pager a:hover strong { color: var(--accent); }

.foot { border-top: 1px solid var(--border); margin-top: 24px; }
.foot-inner { max-width: 1440px; margin: 0 auto; padding: 28px max(32px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(32px, env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; font-size: 13px; color: var(--muted); }
.foot a { color: var(--muted); }

/* Home: the README as the front page */
.home article h1 { font-size: clamp(2.6rem, 7vw, 4rem); letter-spacing: -0.045em; margin-bottom: 18px; }
.home article h1 + p { font-size: clamp(19px, 2.4vw, 22px); line-height: 1.55; color: var(--ink); max-width: 34em; }
.home article h1 + p + ul { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 28px; }
.home article h1 + p + ul li { margin: 0; padding: 12px 16px 12px 42px; position: relative; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); font-size: 15px; line-height: 1.5; }
.home article h1 + p + ul li:last-child:nth-child(odd) { grid-column: 1 / -1; }
.home article h1 + p + ul li::before { content: ""; position: absolute; left: 19px; top: 19px; width: 8px; height: 8px; border-radius: 99px; background: var(--accent); outline: 4px solid color-mix(in srgb, var(--accent) 22%, transparent); }

/* Narrower: the outline goes into the page, then the nav into a drawer */

@media (min-width: 1240px) { article ul.toc { display: none; } }

@media (max-width: 1239px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 48px; }
  .outline { display: none; }
}

@media (max-width: 900px) {
  :root { --top: 58px; }
  body { font-size: 16.5px; }
  .top-inner, .layout { padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
  .top-inner { gap: 4px; }
  .brand { width: auto; margin-right: auto; margin-left: 4px; }
  .search-button, .top-links a.text { display: none; }
  .menu, .search-icon { display: inline-grid; }
  .menu { margin-left: -8px; }
  .top-links { margin-left: 0; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .content { padding-block: 28px 56px; }
  article h2 { margin-top: 48px; padding-top: 24px; font-size: 23px; }
  article h2 .anchor { top: 24px; }
  .anchor { display: none; }
  article ul.toc { columns: 1; }
  .home article h1 + p + ul { grid-template-columns: 1fr; }
  .code pre { font-size: 13px; padding: 14px 16px 16px; }
  article table:has(th:nth-child(3)) { min-width: 640px; }

  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(320px, 86vw);
    max-height: none;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 220ms var(--ease), visibility 0s linear 220ms;
  }
  .nav.open { transform: none; visibility: visible; transition: transform 220ms var(--ease); }
  .nav a { padding: 9px 12px; font-size: 16px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(46, 52, 64, 0.45); opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease); }
  .nav.open + .scrim { opacity: 1; pointer-events: auto; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}

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

/* Pagefind's search modal, in the same colors */
:root {
  --pf-text: var(--ink);
  --pf-text-secondary: var(--muted);
  --pf-text-muted: var(--muted);
  --pf-background: var(--surface);
  --pf-border: var(--border);
  --pf-border-focus: var(--accent);
  --pf-skeleton: var(--card);
  --pf-skeleton-shine: var(--subtle);
  --pf-hover: var(--card);
  --pf-mark: var(--ink);
  --pf-scroll-shadow: transparent;
  --pf-shadow-sm: none;
  --pf-shadow-md: none;
  --pf-shadow-lg: none;
  --pf-outline-focus: var(--accent);
  --pf-font: var(--sans);
  --pf-input-height: 44px;
  --pf-input-font-size: 16px;
  --pf-result-title-font-size: 15px;
  --pf-result-excerpt-font-size: 14px;
  --pf-border-radius: var(--radius-lg);
  --pf-modal-backdrop: rgba(46, 52, 64, 0.5);
  --pf-modal-max-width: 640px;
  --pf-modal-top: 12dvh;
}
