/* Kalendar documentation — dark-first, hairline borders. The chrome is monochrome;
   hierarchy there comes from brightness, weight and space. Code blocks are the one
   exception: a snippet is scanned for structure, so its tokens carry real hue. */

:root {
  --bg: #000;
  --surface: #0a0a0a;
  --surface-2: #111;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ededed;
  --muted: #a1a1a1;
  --dim: #707070;

  --accent: #ededed;
  --accent-2: #8f8f8f;
  --accent-ink: #fff;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --accent-line: rgba(255, 255, 255, 0.42);
  --on-accent: #000;

  --veil: rgba(0, 0, 0, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --code-bg: #0e0e0e;
  --code-chrome: #161616;

  --tok-kw: #ff7b72;
  --tok-str: #a5d6ff;
  --tok-num: #79c0ff;
  --tok-comment: #7d8590;
  --tok-anno: #7ee787;
  --tok-type: #ffa657;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 10px;
  --bar: 56px;
  --sidebar: 260px;
  --toc: 232px;

  /* The content column, sized for the widest thing in it: a table, a screenshot, a snippet.
     Prose is not that thing — see --measure. */
  --content: 800px;

  /* The line length of running text. In `ch` so it stays a count of characters rather than a
     distance — it tracks both the font size and whichever face the reader's platform actually
     picked. About seventy of them, which is the length a reader can carry from the end of one line
     to the start of the next without losing the thread. The column is usually narrower than this
     anyway; the cap is what stops a wide screen turning a paragraph into a single long line. */
  --measure: 66ch;

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

:root[data-theme="light"] {
  --bg: #fff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.2);
  --text: #171717;
  --muted: #525252;
  --dim: #8f8f8f;

  --accent: #171717;
  --accent-2: #6b6b6b;
  --accent-ink: #000;
  --accent-soft: rgba(0, 0, 0, 0.06);
  --accent-line: rgba(0, 0, 0, 0.38);
  --on-accent: #fff;

  --veil: rgba(255, 255, 255, 0.75);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --code-bg: #f6f8fa;
  --code-chrome: #eceff2;

  --tok-kw: #cf222e;
  --tok-str: #0a3069;
  --tok-num: #0550ae;
  --tok-comment: #6e7781;
  --tok-anno: #116329;
  --tok-type: #953800;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 60;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  transition: top 150ms var(--ease);
}

.skip:focus {
  top: 12px;
  text-decoration: none;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--bar);
  background: var(--veil);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-name {
  font-size: 15px;
}

.logo-mark {
  display: block;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-links a {
  position: relative;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  transition: color 150ms var(--ease);
}

.topbar-links a::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 150ms var(--ease);
}

.topbar-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.topbar-links a:hover::after {
  transform: scaleX(1);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.theme-toggle .icon {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  transition: opacity 150ms var(--ease), transform 200ms var(--ease);
}

:root[data-theme="dark"] .icon--sun,
:root[data-theme="light"] .icon--moon {
  opacity: 0;
  transform: scale(0.6) rotate(-40deg);
}

/* ── Search ──────────────────────────────────────────────────────────────── */

/* The one thing in the bar that grows: it takes the slack between the brand and the links, so the
   box is where a reader's eye already is rather than tucked against an edge. */
.search-open {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(280px, 32vw);
  margin-left: auto;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--dim);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}

.search-open:hover {
  border-color: var(--border-strong);
  color: var(--muted);
}

/* Search needs a script. Without one the button is a control that does nothing, which is worse than
   no control at all — the `js` class is set before the first paint, so this never flickers. */
html:not(.js) .search-open {
  display: none;
}

.search-open-label {
  flex: 1;
}

.icon--search {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-key,
.search-close kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
}

.search[hidden] {
  display: none;
}

.search {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  /* Not centred: a dialog that opens under the cursor's usual resting place is one the eye finds
     without hunting, and results grow downwards from there rather than pushing the field about. */
  align-content: start;
  justify-items: center;
  padding: 10vh 16px 16px;
}

.search-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.search-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: 78vh;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--dim);
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  appearance: none;
}

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

/* `type="search"` for the semantics and the mobile keyboard, without the platform's own clear
   button — the panel already has one control for getting out, and two is one too many. */
.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-close {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.search-status {
  margin: 0;
  padding: 10px 16px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}

.search-results {
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
}

.search-results:empty {
  display: none;
}

.search-result a {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.search-result a:hover {
  text-decoration: none;
}

.search-result.is-active a,
.search-result a:hover {
  background: var(--surface-2);
}

.search-crumb {
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search-heading {
  font-size: 15px;
  font-weight: 550;
  line-height: 1.4;
}

.search-snippet {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search mark {
  padding: 0 1px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--text);
}

/* The page behind the dialog must not scroll under it: a wheel over the scrim moving the article is
   how a reader loses their place while searching for it. */
html.is-searching,
html.is-searching body {
  overflow: hidden;
}

.menu-toggle {
  display: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block;
  width: 14px;
  height: 1.5px;
  margin: 0 auto;
  background: currentColor;
  border-radius: 2px;
  transition: transform 200ms var(--ease), opacity 150ms var(--ease);
}

.menu-toggle span::before,
.menu-toggle span::after {
  content: "";
  position: relative;
}

.menu-toggle span::before {
  top: -5px;
}

.menu-toggle span::after {
  top: 3.5px;
}

.menu-toggle[aria-expanded="true"] span {
  background: transparent;
}

.menu-toggle[aria-expanded="true"] span::before {
  transform: translateY(5px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span::after {
  transform: translateY(-3.5px) rotate(-45deg);
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  gap: 40px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  align-items: start;
}

.sidebar,
.toc {
  position: sticky;
  top: var(--bar);
  max-height: calc(100vh - var(--bar));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 0 48px;
}

.content {
  min-width: 0;
  max-width: var(--content);
  padding: 32px 0 96px;
}

/*
 * The drawer's backdrop. Out of the document entirely at desktop widths — it is a child of the
 * layout grid, and a fourth child in a three-column grid takes a column and shunts the sidebar,
 * the content and the contents each one place along.
 */
.scrim {
  display: none;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

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

.nav-quick {
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.nav-heading {
  margin: 22px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.nav-link {
  position: relative;
  display: block;
  padding: 5px 10px 5px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 150ms var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.nav-link:hover::before {
  transform: scaleY(1);
}

.nav-link.is-active {
  color: var(--text);
  font-weight: 500;
  background: var(--accent-soft);
}

.nav-link.is-active::before {
  transform: scaleY(1);
}

/* ── On this page ────────────────────────────────────────────────────────── */

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

.toc-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

/* `--muted`, not `--dim`. These are 13px links a reader is meant to read and choose between, and
   --dim on the page background is about 4.2:1 — under the 4.5:1 that text this size needs. --dim
   stays where it belongs: on labels that name a thing rather than being read. */
.toc a {
  display: block;
  padding: 4px 0 4px 14px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}

.toc-l3 a {
  padding-left: 26px;
  font-size: 12.5px;
}

.toc a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc a.is-current {
  color: var(--accent-ink);
  border-left-color: var(--accent);
}

/* ── Prose ───────────────────────────────────────────────────────────────── */

/* Headings. Four steps that stay apart at every size — 36 / 24 / 19 / 16 against 16px body — because
   a heading a reader has to compare against its neighbour to rank is not doing its job. `h4` is the
   one that has to work at body size: it earns its rank on weight and colour instead, since going
   any smaller would put a heading below the text it introduces.
   `text-wrap: balance` evens out the lines of a heading that wraps, so a two-line title does not
   arrive as eight words and a widow. Ignored where it is not supported, which costs nothing. */
.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
  scroll-margin-top: calc(var(--bar) + 16px);
}

.prose h1 {
  margin: 0 0 24px;
  font-size: 36px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.prose h2 {
  margin: 56px 0 16px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 24px;
  font-weight: 600;
}

.prose h3 {
  margin: 36px 0 12px;
  font-size: 19px;
  font-weight: 600;
}

.prose h4 {
  margin: 28px 0 10px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.prose p,
.prose li {
  color: var(--muted);
}

/* The measure applies to running text, not to the column that holds it: a table, a snippet and a
   screenshot all want the full width, and narrowing them to a comfortable *reading* width would
   only add a horizontal scrollbar to each. Direct children only, so text nested inside something
   that sets its own width keeps that width. */
.prose > p,
.prose > ul,
.prose > ol,
.prose > blockquote {
  max-width: var(--measure);
}

.prose p {
  margin: 0 0 18px;
  text-wrap: pretty;
}

.prose ul,
.prose ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.prose li {
  margin: 6px 0;
  text-wrap: pretty;
}

/* A nested list belongs to the item above it. Without this it inherits the gap that separates one
   top-level list from the paragraph after it, and reads as a new list rather than a continuation. */
.prose li > ul,
.prose li > ol {
  margin: 6px 0 0;
}

.prose li::marker {
  color: var(--dim);
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose hr {
  height: 0;
  margin: 40px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Theme-aware screenshots.
   Every calendar picture ships as a pair — one drawn in the library's light palette, one in its dark
   one — and both are in the document. Which one shows is decided here rather than in script, so the
   right one is painted on the first frame, including for a reader whose stored preference the inline
   bootstrap in <head> has just applied.
   `prefers-color-scheme` would not do: the site has its own toggle that writes `data-theme` on the
   root and remembers it, so a reader on a light OS reading the dark site would get a white
   screenshot burned into a black page. `data-theme` is the thing the toggle moves, so it is the
   thing these keys off. It is always one of the two values — the markup ships with it set and the
   bootstrap only ever rewrites it — so there is no third state to style for. */
.shot {
  display: none;
}

:root[data-theme="dark"] .shot--dark,
:root[data-theme="light"] .shot--light {
  display: block;
}

/* The lead screenshot on a view's page: centred, and never taller than a screen, so the prose that
   explains the view is not pushed below the fold by the picture of it.
   No `width` here on purpose. The generator writes `width`/`height` attributes at half the bitmap's
   size, which the browser treats as a presentational hint — the lowest-priority style there is — so
   the picture lays out at its dp size with twice the pixels behind it. Any author-level `width`
   would beat that hint and stretch it back to its full bitmap width, undoing the reason it is
   drawn at 2x in the first place. */
.prose .shot {
  margin: 24px auto;
  max-height: 70vh;
}

/* The gallery on the views index: as many columns as fit, each one a picture above the view's name.
   `align-items: start` so a short calendar sits at the top of its cell instead of floating in the
   middle of the tallest one's row. */
.shot-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-items: start;
  margin: 28px 0 8px;
}

.shot-gallery figure {
  margin: 0;
}

.shot-gallery .shot {
  margin: 0;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  object-position: top center;
}

.shot-gallery figcaption {
  margin-top: 10px;
  font-size: 14px;
}

.shot-gallery figcaption a {
  font-family: var(--mono);
}

.shot-gallery p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.prose blockquote {
  margin: 24px 0;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent-line);
  color: var(--muted);
}

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

.anchor {
  margin-left: 8px;
  color: var(--dim);
  font-weight: 400;
  opacity: 0;
  transition: opacity 150ms var(--ease);
}

h1:hover > .anchor,
h2:hover > .anchor,
h3:hover > .anchor,
h4:hover > .anchor,
.anchor:focus-visible {
  opacity: 1;
  text-decoration: none;
}

/* Inline code */

.prose :not(pre) > code,
.tile code {
  padding: 0.15em 0.4em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.87em;
}

.prose a > code {
  color: var(--accent-ink);
  border-color: var(--accent-line);
}

/* A symbol the generator linked to its reference entry. Marked with a dotted underline rather than a
   solid one: these are dense — a paragraph can carry six — and six solid underlines in a paragraph
   is a paragraph nobody reads. The line firms up on hover, which is when a reader is asking. */
.api-link {
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-color: var(--dim);
  text-underline-offset: 3px;
}

.api-link:hover {
  color: var(--accent-ink);
  text-decoration: underline solid;
  text-decoration-color: var(--accent-line);
}

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  margin: 24px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* A table's own type: one step under the prose, and tighter leading than a paragraph gets. A cell is
   read across, not down a column of lines, so 1.7 only pushes the rows apart. */
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.55;
}

.table-wrap th,
.table-wrap td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.table-wrap th {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
}

.table-wrap tr:last-child td {
  border-bottom: 0;
}

/* ── Code blocks ─────────────────────────────────────────────────────────── */

.code-block {
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
}

.code-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--code-chrome);
}

.code-lang {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.copy {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}

.copy:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.copy.is-copied {
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
}

/* Monospace reads smaller than the sans beside it at the same size, so a snippet is set a little
   under the prose rather than well under it. Leading is tighter than a paragraph's: code is read a
   line at a time, and 1.7 pulls the lines of one expression apart. */
.code-block code {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
}

.tok-kw { color: var(--tok-kw); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-anno { color: var(--tok-anno); }
.tok-type { color: var(--tok-type); }

/* ── Previous / next ─────────────────────────────────────────────────────── */

.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.page-nav-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 150ms var(--ease), transform 200ms var(--ease);
}

.page-nav-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  text-decoration: none;
}

.page-nav-card--next {
  text-align: right;
}

.page-nav-label {
  color: var(--dim);
  font-size: 12px;
}

.page-nav-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

/* ── Landing page ────────────────────────────────────────────────────────── */

.landing {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.hero {
  position: relative;
  isolation: isolate;
  padding: 88px 0 72px;
  text-align: center;
}

.aurora {
  position: absolute;
  inset: -20% 0 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(60% 60% at 50% 35%, #000 30%, transparent 100%);
  mask-image: radial-gradient(60% 60% at 50% 35%, #000 30%, transparent 100%);
}

.aurora span {
  position: absolute;
  width: 46vw;
  height: 46vw;
  max-width: 620px;
  max-height: 620px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.16;
  animation: drift 24s var(--ease) infinite alternate;
}

.aurora span:nth-child(1) {
  left: 8%;
  top: -8%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 68%);
}

.aurora span:nth-child(2) {
  right: 6%;
  top: 2%;
  background: radial-gradient(circle, var(--accent-2) 0%, transparent 68%);
  animation-delay: -8s;
  animation-duration: 30s;
}

.aurora span:nth-child(3) {
  left: 36%;
  top: 18%;
  background: radial-gradient(circle, #ffffff 0%, transparent 70%);
  animation-delay: -16s;
  animation-duration: 36s;
}

:root[data-theme="light"] .aurora span {
  opacity: 0.28;
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(4%, 6%, 0) scale(1.12); }
  100% { transform: translate3d(-5%, -4%, 0) scale(0.94); }
}

.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero-eyebrow {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-title {
  margin: 0 0 18px;
  font-size: clamp(44px, 9vw, 76px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.02;
  background: linear-gradient(180deg, #fff 22%, var(--dim) 132%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:root[data-theme="light"] .hero-title {
  background: linear-gradient(180deg, #000 22%, var(--dim) 132%);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-tagline {
  margin: 0 auto 32px;
  max-width: 640px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
  text-wrap: pretty;
}

.hero-tagline strong {
  color: var(--text);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 40px;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), transform 200ms var(--ease);
}

.btn:hover {
  border-color: var(--text);
  transform: translateY(-1px);
  text-decoration: none;
}

/* Support links sit a step below the two calls to action: same outline, less weight, less space.
   Their own row so the primary action stays the only filled button on the page — four equal
   buttons would make a first-time reader choose between four things instead of two.
   The label is `<span>` rather than a heading: it names the row without adding an entry to the
   document outline for two links. */
.hero .hero-actions {
  margin-bottom: 16px;
}

.hero-support {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
}

.hero-support-label {
  margin-right: 2px;
  color: var(--dim);
  font-size: 13px;
}

.btn--sm {
  gap: 7px;
  padding: 6px 14px;
  border-color: var(--border);
  color: var(--muted);
  font-size: 13px;
}

.btn--sm:hover {
  color: var(--text);
}

/* The mark keeps the text's colour and never shrinks below it when the row wraps. */
.btn-icon {
  flex: none;
}

/* On a phone the row is already two lines; the label above them reads better than beside them. */
@media (max-width: 420px) {
  .hero-support-label {
    width: 100%;
    margin-right: 0;
  }
}

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn--primary:hover {
  opacity: 0.86;
  border-color: transparent;
}

.hero-install {
  max-width: 480px;
  margin: 0 auto 28px;
  text-align: left;
}

.hero-platforms {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0;
  color: var(--dim);
  font-size: 13px;
}

.hero-platforms span {
  color: var(--border-strong);
}

.home-section {
  margin-top: 72px;
}

.home-heading {
  margin: 0 0 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  padding: 18px 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 200ms var(--ease), transform 200ms var(--ease), background-color 200ms var(--ease);
}

.tile:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-2px);
  text-decoration: none;
}

.tile-title {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tile-summary {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tile-arrow {
  position: absolute;
  right: 18px;
  top: 18px;
  color: var(--dim);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}

.tile:hover .tile-arrow {
  opacity: 1;
  transform: translateX(0);
}

.home-prose {
  max-width: var(--content);
}

/* ── 404 ─────────────────────────────────────────────────────────────────── */

.notfound {
  padding: 120px 0;
  text-align: center;
}

.notfound-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--accent-ink);
}

.notfound h1 {
  margin: 12px 0 8px;
  font-size: 36px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.notfound p {
  color: var(--muted);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.footer-note {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-left: auto;
}

.footer-links a {
  color: var(--muted);
  font-size: 13px;
  transition: color 150ms var(--ease);
}

.footer-links a:hover {
  color: var(--text);
}

/* ── Scroll reveal ───────────────────────────────────────────────────────── */

/*
 * Scoped to `.js`, which the inline bootstrap adds. Content that starts invisible and waits for a
 * script is content that is missing whenever the script does not arrive.
 */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 500ms var(--ease), transform 500ms var(--ease);
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .sidebar {
    position: fixed;
    top: var(--bar);
    left: 0;
    z-index: 30;
    width: min(84vw, var(--sidebar));
    max-height: none;
    height: calc(100dvh - var(--bar));
    padding: 20px 18px 40px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform 220ms var(--ease);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .scrim {
    display: block;
    position: fixed;
    inset: var(--bar) 0 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms var(--ease);
  }

  .scrim.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar-links a:not(:last-child) {
    display: none;
  }
}

/* Below this the bar has no room for a labelled box, so the button shrinks to its icon. Search stays
   — it is the one control on a phone that replaces a sidebar nobody wants to scroll. */
@media (max-width: 720px) {
  .search-open {
    width: 32px;
    height: 32px;
    justify-content: center;
    padding: 0;
  }

  .search-open-label,
  .search-key {
    display: none;
  }

  .search {
    padding: 6vh 10px 10px;
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .layout,
  .landing,
  .footer-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .content {
    padding-top: 24px;
  }

  /* The heading scale, stepped down for a phone. The body stays at 16px — text a reader holds at
     arm's length is the last thing to shrink — so the headings come down to meet it rather than
     towering over a narrow column. */
  .prose h1 {
    font-size: 29px;
  }

  .prose h2 {
    font-size: 21px;
  }

  .prose h3 {
    font-size: 18px;
  }

  .hero {
    padding: 56px 0 48px;
  }

  .page-nav {
    grid-template-columns: 1fr;
  }

  .footer-links {
    margin-left: 0;
  }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .aurora span {
    animation: none;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }

  .btn:hover,
  .tile:hover,
  .page-nav-card:hover {
    transform: none;
  }
}
