/* Lusian — shared styles for the homepage, documentation and legal pages. */

@font-face {
  font-family: "Poppins";
  src: url("/assets/fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/assets/fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/assets/fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #111214;
  --text: #2b2e33;
  --muted: #5d6169;
  --faint: #6b6f76;
  --line: #e6e6e9;
  --line-strong: #d2d3d7;
  --wash: #f6f6f7;
  --bg: #ffffff;
  --surface: #ffffff;
  --on-ink: #ffffff;
  --ink-hover: #2a2c31;
  --hover-line: #b9bbc1;
  --shadow: rgba(17, 18, 20, .28);
  --wrap: 1180px;
  --gutter: clamp(20px, 4vw, 40px);
  --radius: 12px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --sans: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --code: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, Menlo, monospace;
  --header-h: 72px;
}

/* black theme: chosen with the header toggle, or by the system when no choice is saved */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f4f5;
  --text: #d6d6da;
  --muted: #a3a3ab;
  --faint: #8e8e97;
  --line: #1e1e21;
  --line-strong: #2f2f34;
  --wash: #131315;
  --bg: #000000;
  --surface: #0a0a0b;
  --on-ink: #000000;
  --ink-hover: #d9d9dd;
  --hover-line: #46464d;
  --shadow: rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 14px;
  font-weight: 500;
}
.skip-link:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.icon-arrow { flex: none; transition: transform .25s var(--ease); }
.icon-arrow-left { transform: scaleX(-1); }

/* ---------- Header ---------- */

.site-header { position: relative; z-index: 5; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

 .wordmark { display: inline-flex; align-items: center; gap: 6px; line-height: 1; border-radius: 4px; white-space: nowrap; }
.wordmark img { display: block; width: 38px; height: 38px; object-fit: contain; flex: none; }
.wordmark span { color: var(--ink); font-family: "Poppins", sans-serif; font-weight: 600; font-size: 28px; letter-spacing: -.085em; padding-right: .1em; }
.wordmark-sm img { width: 32px; height: 32px; }
.wordmark-sm span { font-size: 23px; }

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 500;
}

.nav-link {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  transition: color .2s, background-color .2s;
}
.nav-link:hover { color: var(--ink); background: var(--wash); }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav .btn { margin-left: 8px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, color .2s, transform .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-sm { height: 44px; padding: 0 15px; border-radius: 10px; font-size: 14px; }

.btn-dark { background: var(--ink); color: var(--on-ink); }
.btn-dark:hover { background: var(--ink-hover); }

.btn-outline { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); }
.btn:hover .icon-arrow { transform: translateX(3px); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Hero ---------- */

.hero {
  /* visible keyboard strip: the top half of the keyboard photo */
  --kb-w: clamp(340px, 40vw, 600px);
  --kb-h: calc(var(--kb-w) * .5);
  position: relative;
  border-bottom: 1px solid var(--line-strong);
  overflow: hidden;
}

.hero-inner {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  padding-top: clamp(40px, 7vh, 80px);
  /* on wide screens the subline sits beside the keyboard instead of above it */
  padding-bottom: max(calc(var(--kb-h) * .55), 120px);
}

.hero-title {
  grid-column: 4 / span 9;
  margin: 0;
  font-weight: 560;
  font-size: clamp(34px, 4.6vw, 62px);
  line-height: 1.12;
  letter-spacing: -0.035em;
  max-width: 17em;
  animation: rise .9s var(--ease) both;
}

.mark {
  display: inline-block;
  padding: .03em .24em;
  margin: 0 -.02em;
  border: 1.5px solid transparent;
  border-radius: .3em;
  line-height: 1.08;
  animation: outline .7s var(--ease) .55s forwards;
}
.mark-2 { white-space: nowrap; animation-delay: .8s; }

@keyframes outline {
  from { border-color: transparent; transform: scale(1.04); }
  to { border-color: var(--ink); transform: scale(1); }
}

.hero-sub {
  grid-column: 4 / span 4;
  margin-top: clamp(22px, 3vh, 32px);
  animation: rise .9s var(--ease) .15s both;
}
.hero-sub p {
  margin: 0 0 22px;
  max-width: 26em;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

/* the keyboard rests on the divider: its cut bottom edge meets the line
   and its cut right edge runs off the page */
.keyboard {
  position: absolute;
  right: 0;
  bottom: 0;
  width: var(--kb-w);
  height: var(--kb-h);
  overflow: hidden;
  pointer-events: none;
}
.keyboard img { width: 100%; animation: keyboard 1.1s var(--ease) .25s both; }

@keyframes keyboard {
  from { transform: translateY(18%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes rise {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- Split sections ---------- */

.split { padding: clamp(64px, 9vw, 120px) 0; }
.split + .split { border-top: 1px solid var(--line-strong); }

.split-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: clamp(40px, 6vw, 88px);
  align-items: center;
}

.split-copy { max-width: 480px; }

.split-copy h2 {
  margin: 0 0 18px;
  font-weight: 620;
  font-size: clamp(26px, 2.7vw, 36px);
  line-height: 1.15;
  letter-spacing: -0.028em;
}

.split-copy p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.split-copy .btn { margin-top: 12px; }

.principles {
  margin: 24px 0 20px;
  border-top: 1px solid var(--line);
}
.principles > div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.principles dt { font-weight: 600; }
.principles dd { margin: 0; color: var(--muted); }

/* code illustration, styled after the editor window in the original artwork */
.code-window {
  margin: 0;
  border-radius: 18px;
  background: #1c1c1e;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 24px 48px -28px rgba(17, 18, 20, .45);
  overflow: hidden;
}
.code-chrome { display: flex; gap: 8px; padding: 20px 22px 4px; }
.code-chrome span { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.code-chrome span:nth-child(2) { background: #febc2e; }
.code-chrome span:nth-child(3) { background: #28c840; }

.code {
  margin: 0;
  padding: 14px 24px 26px 18px;
  overflow-x: auto;
  color: #e6e6e6;
  font-family: var(--code);
  font-size: clamp(12.5px, 1.05vw, 14.5px);
  line-height: 1.85;
  tab-size: 2;
}
.code { scrollbar-width: none; -ms-overflow-style: none; }
.code::-webkit-scrollbar { display: none; }
.code:focus-visible { outline-offset: -4px; }
.code .ln { display: inline-block; width: 2.2em; color: #8a8c92; user-select: none; }
.code .c { color: #6a9955; }
.code .k { color: #569cd6; }
.code .v { color: #9cdcfe; }
.code .f { color: #dcdcaa; }
.code .p { color: #4ec9b0; }

/* phone photo framed so the photo's cut right and bottom edges meet the frame */
.phone-frame {
  position: relative;
  margin: 0;
  aspect-ratio: 1202 / 1086;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--wash);
  overflow: hidden;
}
.phone-frame img {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 94%;
  max-width: none;
}

/* ---------- Footer ---------- */

.site-footer { padding: 0 var(--gutter) 40px; }
main > .split:last-child { padding-bottom: clamp(56px, 7vw, 96px); }
.docs-shell + .site-footer, .not-found + .site-footer { padding-top: 8px; }

.footer-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px clamp(20px, 4vw, 40px) 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer-tagline { margin: 12px 0 20px; color: var(--muted); font-size: 14.5px; }

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 6px;
  font-size: 14.5px;
  font-weight: 500;
}
.footer-nav a {
  padding: 6px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  color: var(--text);
  transition: color .2s, background-color .2s;
}
.footer-nav a:hover { color: var(--ink); background: var(--wash); }
.footer-nav-legal { margin-top: 2px; font-size: 13.5px; font-weight: 450; }
.footer-nav-legal a { color: var(--muted); }

.copyright {
  margin: 20px 0 0;
  padding-top: 18px;
  width: 100%;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Scroll reveal (only when JS is running) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
.js .reveal.in { opacity: 1; transform: none; }
.js .split-copy.reveal { transition-delay: .1s; }

/* ---------- Docs and legal layout ---------- */

.docs-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 56px;
  align-items: start;
  padding-top: 24px;
  padding-bottom: clamp(48px, 8vw, 96px);
  border-top: 1px solid var(--line);
}

.docs-sidebar {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 8px 4px 32px 0;
}

.side-group { margin-top: 24px; }
.side-group ul { list-style: none; margin: 0; padding: 0; }
.side-label {
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.side-nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.4;
  transition: background-color .15s, color .15s;
}
.side-nav a:hover { background: var(--wash); color: var(--ink); }
.side-group li a { display: flex; align-items: flex-start; gap: 10px; }
.side-icon { flex: none; margin-top: 2px; color: var(--faint); transition: color .15s; }
.side-nav a:hover .side-icon, .side-nav a[aria-current="page"] .side-icon { color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--wash); color: var(--ink); font-weight: 600; }
.side-switch { padding-top: 16px; border-top: 1px solid var(--line); }
.side-switch a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.side-switch a:hover .icon-arrow { transform: translateX(3px); }

.side-toggle { display: none; }

/* search */
.search { position: relative; }
.search-icon { position: absolute; left: 12px; top: 12px; color: var(--faint); pointer-events: none; }
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 36px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  transition: border-color .2s;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--faint); }
.search-input:hover { border-color: var(--hover-line); }
.search-input:focus { outline: none; border-color: var(--ink); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-key {
  position: absolute;
  right: 10px; top: 10px;
  min-width: 20px; height: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--faint);
  font: 500 12px/18px var(--sans);
  text-align: center;
}
.search-input:focus ~ .search-key { display: none; }

.search-results {
  position: absolute;
  left: 0; top: 46px;
  z-index: 20;
  width: min(420px, calc(100vw - 2 * var(--gutter)));
  max-height: min(70vh, 480px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 40px -18px var(--shadow);
}
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.search-result[aria-selected="true"], .search-result:hover { background: var(--wash); }
.search-result-title { display: block; color: var(--ink); font-weight: 600; }
.search-result-area { color: var(--faint); font-weight: 450; }
.search-result-text { display: block; margin-top: 2px; color: var(--muted); }
.search-result mark { background: none; color: var(--ink); font-weight: 600; }
.search-empty { margin: 0; padding: 12px; color: var(--muted); font-size: 14px; }

/* table of contents */
.docs-toc {
  position: sticky;
  top: 24px;
  padding-top: 40px;
  font-size: 13.5px;
}
.docs-toc ul { position: relative; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.docs-toc ul::before {
  content: "";
  position: absolute;
  left: -1px; top: 0;
  width: 1px;
  height: var(--toc-h, 0px);
  background: var(--ink);
  transform: translateY(var(--toc-y, 0px));
  transition: transform .35s var(--ease), height .35s var(--ease);
}
.docs-toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 12px;
  border-left: 1px solid transparent;
  color: var(--muted);
  line-height: 1.4;
  transition: color .15s, border-color .15s;
}
.docs-toc a:hover { color: var(--ink); }
.docs-toc a.is-active { color: var(--ink); }
.docs-toc .side-label { padding: 0; }

/* article typography */
.docs-main { min-width: 0; }
.prose { max-width: 720px; padding-top: 32px; color: var(--text); font-size: 16.5px; line-height: 1.72; }
.prose .eyebrow { margin: 0 0 10px; color: var(--faint); font-size: 13.5px; font-weight: 500; }
.prose .eyebrow span { margin: 0 4px; }
.prose h1 {
  margin: 0 0 14px;
  color: var(--ink);
  font-weight: 620;
  font-size: clamp(32px, 3.6vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.032em;
}
.prose .doc-meta { margin: -4px 0 20px; color: var(--faint); font-size: 14px; }
.prose .lede { margin: 0 0 32px; color: var(--muted); font-size: 18.5px; line-height: 1.6; }
.prose h2 {
  position: relative;
  margin: 48px 0 14px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 620;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.prose .lede + h2, .prose h1 + h2 { margin-top: 32px; }
.prose h3 {
  position: relative;
  margin: 32px 0 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.heading-anchor {
  margin-left: 8px;
  color: var(--line-strong);
  font-weight: 400;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
h2:hover .heading-anchor, h3:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
.heading-anchor:hover { color: var(--muted); }

.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin: 6px 0; padding-left: 4px; }
.prose li::marker { color: var(--faint); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose a:not(.btn):not(.pager-link):not(.heading-anchor) {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .15s;
}
.prose a:not(.btn):not(.pager-link):not(.heading-anchor):hover { text-decoration-color: var(--ink); }
.prose code {
  padding: .1em .35em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--wash);
  color: var(--ink);
  font-family: var(--code);
  font-size: .86em;
}
.prose kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .4em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--ink);
  font: 500 .85em/1.6 var(--sans);
  text-align: center;
}

.prose .note {
  margin: 24px 0;
  padding: 16px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  font-size: 15.5px;
}
.prose .note p:last-child, .prose .note ul:last-child { margin-bottom: 0; }
.prose .note-title { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 600; }

.prose .steps { counter-reset: step; list-style: none; padding: 0; }
.prose .steps > li {
  position: relative;
  margin: 0;
  padding: 0 0 20px 44px;
}
.prose .steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 1px;
  width: 28px; height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 26px;
  text-align: center;
}
.prose .steps > li > strong:first-child { display: block; }

.table-wrap { margin: 20px 0 24px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.55; }
.prose th, .prose td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { color: var(--ink); font-weight: 600; background: var(--wash); }
.prose td:first-child { color: var(--ink); font-weight: 500; }
/* let every column wrap; keep columns from collapsing to a word per line */
.prose th, .prose td { min-width: 9.5em; overflow-wrap: break-word; }

.prose details {
  border-bottom: 1px solid var(--line);
}
.prose details:first-of-type { border-top: 1px solid var(--line); }
.prose summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: "";
  flex: none;
  width: 9px; height: 9px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg) translateY(-3px);
  transition: transform .2s var(--ease);
}
.prose details[open] summary::after { transform: rotate(225deg) translateY(-1px); }
.prose details > div { padding: 0 0 12px; }

.card-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 8px;
}
.prose .card-link {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  text-decoration: none;
  transition: border-color .2s;
}
.prose .card-link:hover { border-color: var(--ink); }
.card-link strong { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-link:hover .icon-arrow { transform: translateX(3px); }
.card-link span { display: block; margin-top: 4px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 56px;
}
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  transition: border-color .2s;
}
.pager-link:hover { border-color: var(--ink); }
.pager-next { text-align: right; align-items: flex-end; }
.pager-dir { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 13.5px; }
.pager-title { color: var(--ink); font-weight: 600; }
.pager-prev:hover .icon-arrow { transform: scaleX(-1) translateX(3px); }
.pager-next:hover .icon-arrow { transform: translateX(3px); }

/* 404 */
.not-found { padding: clamp(72px, 14vw, 160px) 0; text-align: center; border-top: 1px solid var(--line); }
.not-found h1 { margin: 0 0 12px; font-weight: 620; font-size: clamp(32px, 4vw, 48px); letter-spacing: -0.03em; }
.not-found p { margin: 0 auto 28px; max-width: 30em; color: var(--muted); font-size: 17px; }
.not-found .actions { justify-content: center; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 230px minmax(0, 1fr); gap: 48px; }
  .docs-toc { display: none; }
}

@media (max-width: 1080px) {
  .hero { --kb-w: clamp(320px, 56vw, 560px); }
  .hero-title { grid-column: 1 / -1; }
  .hero-sub { grid-column: 1 / span 8; }
  .hero-inner { padding-bottom: calc(var(--kb-h) + 40px); }
}

@media (max-width: 860px) {
  .docs-shell { display: block; padding-top: 12px; }
  .side-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
  }
  .side-toggle-current { margin-left: auto; color: var(--muted); font-weight: 450; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .docs-sidebar {
    position: static;
    display: none;
    max-height: none;
    margin-top: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
  }
  .docs-shell.nav-open .docs-sidebar { display: block; }
  .search-results { width: 100%; }
  .prose { padding-top: 24px; }
}

@media (max-width: 760px) {
  .nav-link-wide { display: none; }
  .hero-title { font-size: clamp(32px, 8.6vw, 46px); }
  .hero-sub { grid-column: 1 / -1; }
  .hero-sub p { font-size: 16.5px; }
  .hero { --kb-w: 84vw; }
  .split-inner { grid-template-columns: 1fr; }
  .split-copy { max-width: none; }
  .principles > div { grid-template-columns: 1fr; gap: 2px; }
  .card-links { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  /* tables become stacked cards: one block per row, each value labelled */
  .prose thead { display: none; }
  .prose table, .prose tbody, .prose tr, .prose td { display: block; }
  .prose tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .prose tr:last-child { border-bottom: 0; }
  .prose th, .prose td { min-width: 0; }
  .prose td { padding: 0; border: 0; }
  .prose td + td { margin-top: 6px; }
  .prose td:first-child { margin-bottom: 2px; }
  .prose td + td::before {
    content: attr(data-label);
    display: block;
    color: var(--faint);
    font-size: 12.5px;
    font-weight: 600;
  }
}

@media (max-width: 480px) {
  .nav-link { padding: 8px; }
  .nav .btn { margin-left: 2px; }
  .wordmark img { width: 32px; height: 32px; }
  .wordmark span { font-size: 24px; }
  .actions .btn { flex: 1 1 auto; }
  .pager { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .nav-link { display: none; }
  .nav .btn { margin-left: 0; padding-inline: 11px; }
  .wordmark span { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Theme toggle and black-theme details ---------- */

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, background-color .2s;
}
.theme-toggle:hover { color: var(--ink); background: var(--wash); }
.theme-toggle svg { grid-area: 1 / 1; transition: opacity .25s var(--ease), transform .35s var(--ease); }
.theme-toggle .icon-sun { opacity: 0; transform: rotate(-45deg) scale(.7); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(45deg) scale(.7); }
[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: none; }



[data-theme="dark"] .code-window {
  background: #111113;
  box-shadow: 0 0 0 1px var(--line-strong);
}

/* keep theme changes from animating every colour on the page */
.theme-switching, .theme-switching * { transition: none !important; }

/* ==========================================================================
   Motion
   Durations stay short (150-700ms) and ease out; prefers-reduced-motion
   switches all of it off.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* header settles in on every page */
body:not(:has(.docs-shell)) .header-inner { animation: fade-in .6s var(--ease) both; }

/* buttons: a little lift on hover, a press on click */
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.985); transition-duration: .08s; }
.btn-dark:hover { box-shadow: 0 8px 18px -10px var(--shadow); }

/* nav links: underline grows from the left */
.nav-link { position: relative; }
.nav-link::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 4px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.nav-link:hover::after, .nav-link[aria-current="page"]::after { transform: scaleX(1); }
.nav-link:hover { background: none; }

/* staggered children: list rows arrive one after another */
.js .stagger > * {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.js .in .stagger > *, .js .stagger.in > * { opacity: 1; transform: none; }
.js .stagger > *:nth-child(1) { transition-delay: .25s; }
.js .stagger > *:nth-child(2) { transition-delay: .35s; }
.js .stagger > *:nth-child(3) { transition-delay: .45s; }
.js .stagger > *:nth-child(4) { transition-delay: .55s; }

.principles dt { transition: transform .3s var(--ease); }
.principles > div:hover dt { transform: translateX(3px); }

/* code window: lines appear one by one, then a caret blinks a few times */
.code .line { display: block; }
.js .code .line {
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
  transition-delay: calc(.3s + var(--i) * 90ms);
}
.js .code-window.in .code .line { opacity: 1; transform: none; }
.code .caret {
  display: inline-block;
  width: .55em;
  height: 1.1em;
  margin-left: 4px;
  vertical-align: -.2em;
  background: #e6e6e6;
  opacity: 0;
}
.js .code-window.in .caret { animation: caret 1s steps(1) 1.1s 6 both; }
@keyframes caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.code-window { transition: opacity .8s var(--ease), transform .8s var(--ease), box-shadow .4s var(--ease); }
.code-chrome span { transition: transform .3s var(--ease); }
.code-window:hover .code-chrome span { transform: scale(1.15); }

/* phone: the photo rises into its frame */
.phone-frame img { transition: transform 1.2s var(--ease) .1s; }
.js .phone-frame.reveal img { transform: translateY(8%); }
.js .phone-frame.reveal.in img { transform: none; }
.js .phone-frame.reveal.in:hover img { transform: translateY(-1.5%); transition-duration: .6s; transition-delay: 0s; }

/* keyboard sinks behind the divider as you scroll (offset set by site.js) */
.keyboard { transform: translate3d(0, var(--drift, 0px), 0); will-change: transform; }

/* footer links */
.footer-nav a { transition: color .2s, background-color .2s, transform .2s var(--ease); }
.footer-nav a:hover { transform: translateY(-1px); }

/* ---------- Docs and legal pages ---------- */

.docs-main .prose { animation: fade-up .55s var(--ease) .05s both; }
.docs-toc { animation: fade-in .6s var(--ease) .3s both; }

.js .docs-sidebar .side-group { animation: fade-up .5s var(--ease) both; }
.js .docs-sidebar .side-group:nth-child(1) { animation-delay: .05s; }
.js .docs-sidebar .side-group:nth-child(2) { animation-delay: .1s; }
.js .docs-sidebar .side-group:nth-child(3) { animation-delay: .15s; }
.js .docs-sidebar .side-group:nth-child(4) { animation-delay: .2s; }
.js .docs-sidebar .side-group:nth-child(5) { animation-delay: .25s; }
.js .docs-sidebar .side-group:nth-child(6) { animation-delay: .3s; }

.side-nav a { transition: background-color .15s, color .15s, transform .25s var(--ease); }
.side-group li a:hover { transform: translateX(2px); }
.side-icon { transition: color .15s, transform .25s var(--ease); }
.side-group li a:hover .side-icon { transform: scale(1.1); }

/* mobile menu opens with a short drop */
@media (max-width: 860px) {
  .docs-shell.nav-open .docs-sidebar { animation: drop-in .25s var(--ease) both; }
  .side-toggle svg { transition: transform .3s var(--ease); }
  .side-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
}

/* search dropdown */
.search-results:not([hidden]) { animation: drop-in .18s var(--ease) both; transform-origin: top left; }
.search-result { transition: background-color .12s; }
.search-icon { transition: color .2s, transform .3s var(--ease); }
.search:focus-within .search-icon { color: var(--ink); transform: scale(1.1); }

/* a heading you jump to flashes gently */
.prose :target { animation: target-flash 1.4s var(--ease); }
@keyframes target-flash {
  0% { color: var(--muted); }
  30% { color: var(--ink); }
}

/* card links and pager lift */
.prose .card-link, .pager-link { transition: border-color .2s, transform .25s var(--ease), box-shadow .25s var(--ease); }
.prose .card-link:hover, .pager-link:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -18px var(--shadow); }

/* FAQ answers slide open (in browsers that support it) */
:root { interpolate-size: allow-keywords; }
.prose details::details-content {
  block-size: 0;
  overflow: hidden;
  transition: block-size .32s var(--ease), content-visibility .32s allow-discrete;
}
.prose details[open]::details-content { block-size: auto; }
.prose details > div { opacity: 0; transform: translateY(-4px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
.prose details[open] > div { opacity: 1; transform: none; }
.prose summary { transition: color .15s; }
.prose summary:hover { color: var(--muted); }

/* step numbers fill in on hover */
.prose .steps > li::before { transition: background-color .2s, color .2s, border-color .2s; }
.prose .steps > li:hover::before { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* table rows */
.prose tbody tr { transition: background-color .15s; }
.prose tbody tr:hover { background: var(--wash); }

/* 404 */
.not-found .wrap > * { animation: fade-up .6s var(--ease) both; }
.not-found .wrap > :nth-child(2) { animation-delay: .08s; }
.not-found .wrap > :nth-child(3) { animation-delay: .16s; }

/* ---------- Theme switch: a circle grows from the toggle ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal .6s var(--ease); }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); }
  to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 100%) var(--vt-y, 0)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:hover, .footer-nav a:hover, .side-group li a:hover, .prose .card-link:hover, .pager-link:hover { transform: none; }
  .keyboard { transform: none; }
  .js .phone-frame.reveal img { transform: none; }
  .js .reveal, .js .stagger > *, .js .code .line { opacity: 1 !important; transform: none !important; }
  .code .caret { display: none; }
  .prose details > div { opacity: 1; transform: none; }
  ::view-transition-new(root) { animation: none; }
}
