/* Documentation pages. Shares the landing page's palette and type so /javascript-engine/,
   /test262/ and friends read as the same site as the React home page. System fonts only:
   the CSP allows no external stylesheets or font files. */
:root {
  color-scheme: dark;
  --bg: #101016;
  --bg-raised: #191921;
  --bg-card: #1b1924;
  --bg-code: #0b0e12;
  --ink: #f5f6ef;
  --muted: #b7b1c2;
  --muted-dark: #858c8a;
  --line: rgba(245, 246, 239, 0.14);
  --line-strong: rgba(245, 246, 239, 0.26);
  --dark-ink: #0a0c0d;
  --lilac: #cec0ff;
  --purple: #7c3aed;
  --cyan: #22d3ee;
  --yellow: #edff80;
  --coral: #ff8065;
  --paper: #f1f0fa;
  --paper-strong: #faf9ff;
  --page: min(1180px, calc(100% - 48px));
  --measure: 76ch;
  --radius: 16px;
  --sans: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.68;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { color: var(--dark-ink); background: var(--lilac); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 4px; }
a { color: var(--lilac); text-decoration: underline; text-decoration-color: rgba(206, 192, 255, 0.35); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); text-decoration-color: currentColor; }
img { max-width: 100%; height: auto; }
code, kbd, pre { font-family: var(--mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
code { font-size: 0.88em; padding: 0.1em 0.38em; border-radius: 6px; background: rgba(255, 255, 255, 0.07); color: #e8e4f5; }
pre code { padding: 0; background: none; color: inherit; font-size: inherit; }
h1, h2, h3 { margin: 0; font-weight: 820; letter-spacing: -0.04em; line-height: 1.12; text-wrap: balance; }
h1 { font-size: clamp(2.35rem, 5.2vw, 3.9rem); letter-spacing: -0.055em; }
h2 { font-size: clamp(1.65rem, 3vw, 2.35rem); margin-top: 3.2rem; }
h3 { font-size: 1.25rem; margin-top: 2rem; letter-spacing: -0.02em; }
h2 + h3 { margin-top: 1.4rem; }
p, ul, ol { margin: 0 0 1.15em; }
li { margin-bottom: 0.35em; }
strong { font-weight: 760; color: #fff; }
.lead { font-size: 1.15rem; color: #dcd7e6; }

.skip {
  position: absolute; top: -100px; left: 16px; z-index: 100;
  padding: 10px 14px; border-radius: 10px; background: var(--yellow); color: var(--dark-ink); font-weight: 800;
}
.skip:focus { top: 12px; }

/* Header ------------------------------------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 40; isolation: isolate;
  width: var(--page); margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  min-height: 72px;
}
.site-header::before {
  content: ""; position: absolute; z-index: -1; inset: 0 calc((100vw - 100%) / -2);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 16, 22, 0.9);
  backdrop-filter: blur(18px) saturate(135%);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0;
  color: var(--ink); text-decoration: none;
  font-size: 1.35rem; font-weight: 850; letter-spacing: -0.06em;
}
.brand img { width: 28px; height: 28px; filter: drop-shadow(0 0 9px rgba(124, 58, 237, 0.55)); }
.site-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 18px; }
.site-nav a {
  position: relative; display: inline-flex; align-items: center; min-height: 40px;
  color: #c7ccc9; font-size: 0.875rem; font-weight: 650; text-decoration: none; white-space: nowrap;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 5px; height: 2px;
  background: var(--lilac); transform: scaleX(0); transform-origin: right; transition: transform 180ms ease;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

/* Page frame -------------------------------------------------------------- */
.page { width: var(--page); margin-inline: auto; padding-block: 28px 96px; }
.breadcrumbs { font-size: 0.8125rem; color: var(--muted); font-family: var(--mono); letter-spacing: 0.02em; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 30px; padding: 0; }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--muted-dark); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); }
.breadcrumbs [aria-current] { color: var(--lilac); }

.page-header { max-width: 60rem; margin-bottom: 2.4rem; }
.page-header .lede { font-size: clamp(1.15rem, 1.6vw, 1.35rem); line-height: 1.5; color: #dcd7e6; margin: 1.1rem 0 1.2rem; text-wrap: pretty; }
.page-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; color: var(--muted); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.page-meta time { color: var(--lilac); }

article.doc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 48px; }
article.doc > section, article.doc > .page-header, article.doc > .related { max-width: var(--measure); }
article.doc > section { grid-column: 1; }

.toc { padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-raised); margin-bottom: 2rem; }
.toc strong { display: block; color: var(--lilac); font-family: var(--mono); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 8px; }
.toc ol { margin: 0; padding-left: 1.1em; font-size: 0.9375rem; line-height: 1.5; }
.toc li { margin-bottom: 4px; }
.toc a { color: #dcd7e6; text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; }

@media (min-width: 1080px) {
  article.doc { grid-template-columns: minmax(0, 1fr) 240px; }
  article.doc > .page-header, article.doc > section, article.doc > .related { grid-column: 1; }
  .toc { grid-column: 2; grid-row: 2 / span 60; align-self: start; position: sticky; top: 92px; margin: 0; }
}

/* Content blocks ---------------------------------------------------------- */
section > h2::before {
  content: ""; display: block; width: 44px; height: 3px; margin-bottom: 14px;
  background: linear-gradient(90deg, #c4b5fd, #7c3aed, #22d3ee); border-radius: 2px;
}
figure { margin: 1.6rem 0; }
figure.code { border: 1px solid #2a3030; border-radius: var(--radius); background: var(--bg-code); overflow: hidden; box-shadow: 8px 8px 0 #08080c; }
figure.code figcaption { display: flex; align-items: center; min-height: 40px; padding-inline: 16px; border-bottom: 1px solid var(--line); color: var(--muted-dark); font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
figure.code pre { margin: 0; padding: 20px 22px; overflow-x: auto; color: #d9dfdc; font-size: 0.8125rem; line-height: 1.75; tab-size: 2; }
figure.media { text-align: center; }
figure.media img { border-radius: 12px; border: 1px solid var(--line); }
figcaption { color: var(--muted); font-size: 0.875rem; }
figure.media figcaption { margin-top: 8px; }

.callout { margin: 1.6rem 0; padding: 18px 22px; border: 1px solid rgba(206, 192, 255, 0.35); border-left: 4px solid var(--lilac); border-radius: 12px; background: rgba(206, 192, 255, 0.06); }
.callout p { margin: 0; }
.callout-title { display: block; margin-bottom: 6px; color: var(--lilac); }
.callout-warning { border-color: rgba(255, 128, 101, 0.4); border-left-color: var(--coral); background: rgba(255, 128, 101, 0.07); }
.callout-warning .callout-title { color: var(--coral); }
.callout-note { border-color: rgba(34, 211, 238, 0.35); border-left-color: var(--cyan); background: rgba(34, 211, 238, 0.06); }
.callout-note .callout-title { color: var(--cyan); }

.table-scroll { margin: 1.6rem 0; overflow-x: auto; border: 1px solid #ced0c9; border-radius: 13px; background: var(--paper-strong); color: var(--dark-ink); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.875rem; }
caption { caption-side: top; padding: 12px 16px 6px; text-align: left; color: #59615b; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
th, td { padding: 11px 16px; border-bottom: 1px solid #dcddd7; text-align: left; vertical-align: top; }
thead th { color: #59615b; background: #ebede6; font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
tbody th { font-weight: 700; color: var(--dark-ink); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
td { color: #3d443f; }
.table-scroll code { background: rgba(124, 58, 237, 0.1); color: #3b2570; }
.table-scroll a { color: #5b21b6; }
.table-scroll strong { color: var(--dark-ink); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 1.6rem 0; }
.stat { padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-card); }
.stat dt { order: 2; color: var(--muted); font-size: 0.8125rem; }
.stat dd { margin: 0 0 4px; font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 850; letter-spacing: -0.04em; color: var(--lilac); font-variant-numeric: tabular-nums; }
.stat-note { margin: 6px 0 0; color: var(--muted-dark); font-size: 0.78rem; line-height: 1.45; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 1.6rem 0; }
.card { display: block; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-card); color: inherit; text-decoration: none; transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease; }
.card strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 1.05rem; letter-spacing: -0.02em; }
.card p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 18px 40px -28px rgba(124, 58, 237, 0.55); }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.6rem 0; }
.steps li { position: relative; padding-left: 58px; margin-bottom: 1.2rem; }
.steps li::before { counter-increment: step; content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 2px; color: var(--yellow); font-family: var(--mono); font-size: 0.9rem; font-weight: 800; }
.steps li strong { display: block; margin-bottom: 4px; }
.steps li p { margin: 0; color: #dcd7e6; }

.timeline { list-style: none; padding: 0; margin: 1.6rem 0; border-left: 2px solid rgba(206, 192, 255, 0.3); }
.timeline-item { position: relative; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 0 0 1.4rem 26px; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, #c4b5fd, #7c3aed, #22d3ee); box-shadow: 0 0 0 4px var(--bg); }
.timeline-item time { color: var(--lilac); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em; padding-top: 4px; }
.timeline-item strong { display: block; }
.timeline-item p { margin: 4px 0 0; color: #dcd7e6; font-size: 0.9375rem; }
@media (max-width: 620px) { .timeline-item { grid-template-columns: 1fr; gap: 2px; } }

.faq details { border-top: 1px solid var(--line); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--lilac); font-size: 1.4rem; font-weight: 300; flex-shrink: 0; }
.faq details[open] summary::after { content: "−"; }
.faq summary h3 { margin: 0; font-size: 1.05rem; }
.faq details p { margin: 10px 0 0; color: #dcd7e6; }

.related { margin-top: 3.5rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.related h2 { margin-top: 0; font-size: 1.3rem; }
.related h2::before { display: none; }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li { margin-bottom: 8px; }
.related li span { color: var(--muted); }

/* Journal ----------------------------------------------------------------- */
.journal .page-header, .journal-entry .entry { max-width: var(--measure); }
.journal-search { margin: 2rem 0 2.6rem; padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); max-width: var(--measure); }
.journal-search label { display: block; margin-bottom: 8px; color: var(--lilac); font-family: var(--mono); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; }
.search-row input:focus { border-color: var(--lilac); outline: none; box-shadow: 0 0 0 3px rgba(206, 192, 255, 0.25); }
.search-row button { padding: 0 18px; border: 1px solid transparent; border-radius: 10px; background: var(--yellow); color: var(--dark-ink); font: inherit; font-weight: 800; cursor: pointer; }
.search-row button:hover { background: #f5ffb2; }
.search-status { margin: 10px 0 0; color: var(--muted); font-size: 0.875rem; }
.tag-filters, .year-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: #dcd7e6; font: inherit; font-size: 0.78rem; font-weight: 650; text-decoration: none; cursor: pointer; }
.tag:hover { border-color: var(--lilac); color: var(--ink); }
.tag[aria-pressed="true"] { background: var(--lilac); border-color: var(--lilac); color: var(--dark-ink); }
.year-filters a { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; text-decoration: none; }
.year-filters a:hover { color: var(--ink); }
.entries { max-width: var(--measure); }
.year { font-size: 1rem; color: var(--lilac); font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; margin: 2.2rem 0 1rem; }
.year::before { display: none; }
.entry { padding: 22px 24px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-card); }
.entry header time { display: block; color: var(--lilac); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.06em; margin-bottom: 6px; }
.entry h2, .entry h1 { margin: 0 0 8px; font-size: 1.35rem; }
.journal-entry .entry h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
.entry h2::before { display: none; }
.entry h2 a, .entry h1 a { color: var(--ink); text-decoration: none; }
.entry h2 a:hover { color: var(--lilac); }
.entry-summary { color: #dcd7e6; }
.entry footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.8125rem; color: var(--muted); }
.entry footer .commits { margin-left: auto; }
.entry footer .commits a { color: var(--muted); }
.entry figure.code { box-shadow: none; }
.search-empty { color: var(--muted); }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; max-width: var(--measure); margin-top: 2rem; font-size: 0.9375rem; }
.pager .newer { text-align: right; }
@media (max-width: 620px) { .pager { grid-template-columns: 1fr; } .pager .newer { text-align: left; } }

/* Footer ------------------------------------------------------------------ */
.site-footer { width: var(--page); margin-inline: auto; padding: 30px 0 40px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; color: var(--muted); font-size: 0.875rem; }
.site-footer p { margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: #dcd7e6; text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }

.not-found .page-header { margin-top: 10vh; }

@media (max-width: 720px) {
  :root { --page: calc(100% - 32px); }
  body { font-size: 1rem; }
  .site-header { flex-wrap: wrap; padding-block: 10px; }
  .site-nav { justify-content: flex-start; gap: 0 14px; }
  .site-nav a { min-height: 34px; font-size: 0.8125rem; }
  th, td { padding: 9px 12px; }
  figure.code pre { padding: 16px; }
  .journal-search { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .site-nav a::after { transition: none; }
  .card:hover { transform: none; }
}
