/* Sidebar — a documentation-site layout: navigation and filters on the left, content on the right. */

:root {
  --bg: #ffffff;
  --side: #f7f7f8;
  --text: #18181b;
  --muted: #5b5f66;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --field: #ffffff;
  --hover: #eeeef0;
  --accent: #2459d6;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --mark: color-mix(in srgb, var(--accent) 20%, transparent);
  --radius: 6px;
  --side-w: 272px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315;
    --side: #18191c;
    --text: #e8e8eb;
    --muted: #a3a6ad;
    --line: #2a2b30;
    --line-strong: #3a3b41;
    --field: #1d1e22;
    --hover: #222327;
    --accent: #7ea6ff;
    --mark: color-mix(in srgb, var(--accent) 30%, transparent);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
[hidden] { display: none !important; }
html:not(.js) .js-only { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: 8px; top: -48px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); z-index: 10; }
.skip:focus { top: 8px; }

/* ── Top bar ─────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 20px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand .sep { color: var(--line-strong); font-weight: 400; }
.brand .sub { color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ch { color: var(--muted); white-space: nowrap; }
.menu {
  display: none; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--field); color: var(--text); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.menu:hover { text-decoration: none; background: var(--hover); }
.menu svg { width: 16px; height: 16px; flex: none; }

/* ── Layout ──────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - 56px);
  background: linear-gradient(to right, var(--side) calc(var(--side-w) - 1px), var(--line) 0 var(--side-w), transparent 0);
}
.side {
  position: sticky; top: 0; align-self: start;
  max-height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 16px 32px;
}
.content { padding: 40px 48px 64px; min-width: 0; }
.content > * { max-width: 760px; }

.group + .group { margin-top: 28px; }
.group-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 0 8px 8px; font-size: 13px; font-weight: 600; color: var(--text);
}
.group-h .muted { font-weight: 400; }

/* ── Fields ──────────────────────────────────────── */
.field { position: relative; }
.field svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field input {
  width: 100%; height: 40px; padding: 0 40px 0 36px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--field); color: var(--text); font: inherit; font-size: 15px;
  -webkit-appearance: none; appearance: none;
}
.field input::placeholder { color: var(--muted); opacity: 1; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.field kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  min-width: 22px; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 4px;
  font: 12px/18px var(--font); color: var(--muted); text-align: center; background: var(--side);
}
.field input:focus ~ kbd, .field input:not(:placeholder-shown) ~ kbd { display: none; }
.side .field input { height: 36px; font-size: 14px; }
.side .field { margin-bottom: 8px; }

/* ── Facets (filters as a list on desktop, chips on phones) ── */
.facet { display: flex; flex-direction: column; gap: 1px; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 6px 8px; border: 0; border-radius: var(--radius);
  background: none; font-size: 14px; text-align: left; cursor: pointer; color: var(--text);
}
.opt:hover { background: var(--hover); }
.opt .l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .n { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.opt[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.opt[aria-pressed="true"] .n { color: var(--accent); }
.opt:disabled { opacity: .45; cursor: default; }
.opt.more { color: var(--accent); }

/* ── Video navigation in the sidebar ─────────────── */
.vnav-list { display: flex; flex-direction: column; gap: 1px; }
.vnav-list a {
  display: block; padding: 7px 8px; border-radius: var(--radius);
  color: var(--text); font-size: 14px; line-height: 1.4;
}
.vnav-list a:hover { background: var(--hover); text-decoration: none; }
.vnav-list a .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vnav-list a .d { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.vnav-list a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.vnav-list a[aria-current="page"] .d { color: var(--accent); font-weight: 400; }
.vnav-empty { padding: 6px 8px; font-size: 14px; color: var(--muted); }
.back { display: inline-block; padding: 6px 8px; font-size: 14px; }

/* ── Page header ─────────────────────────────────── */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
h1 { font-size: 30px; line-height: 1.2; font-weight: 650; letter-spacing: -0.015em; text-wrap: pretty; overflow-wrap: anywhere; }
.lede { margin-top: 10px; color: var(--muted); font-size: 16px; max-width: 65ch; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.vhead { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 28px; align-items: start; }
.vhead .thumb { grid-column: 2; grid-row: 1; }
.thumb {
  display: block; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: var(--side); border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.none { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.vhead.nothumb { grid-template-columns: minmax(0, 1fr); }

/* ── Search bar in the content column ────────────── */
.find { margin-top: 32px; }
.pagehead + .listwrap > .status { margin-top: 24px; }
.status { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.status b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.textbtn { padding: 2px 0; border: 0; background: none; color: var(--accent); font-size: 14px; cursor: pointer; }
.textbtn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Sources ─────────────────────────────────────── */
.sec { margin-top: 28px; }
.sec h2 { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 18px; font-weight: 600; }
.sec h2 .c { color: var(--muted); font-size: 14px; font-weight: 400; font-variant-numeric: tabular-nums; }
#list > .sec:first-child:not(:has(h2)) { margin-top: 16px; border-top: 1px solid var(--line); }
.s { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.s:target { background: var(--accent-soft); box-shadow: -12px 0 0 var(--accent-soft), 12px 0 0 var(--accent-soft); }
.s .n { padding-top: 1px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.s .n:hover { color: var(--accent); }
.s .t { font-size: 16px; font-weight: 550; line-height: 1.4; overflow-wrap: anywhere; }
.s .by { margin-top: 2px; font-size: 14px; color: var(--muted); }
.s .by span + span::before { content: "·"; margin: 0 6px; }
.s .note { margin-top: 6px; font-size: 15px; color: var(--text); max-width: 68ch; }
.s .tail { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.kind { padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); font-size: 12px; line-height: 18px; }
.dm { overflow-wrap: anywhere; }
.at { font-variant-numeric: tabular-nums; }
.copy { padding: 0; border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.copy:hover { color: var(--accent); }
.copy.done { color: var(--accent); }
.empty { margin-top: 24px; padding: 28px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.empty p + p { margin-top: 6px; }
.empty strong { color: var(--text); font-weight: 600; }

/* ── Prev / next ─────────────────────────────────── */
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; }
.pn a {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.pn a:hover { border-color: var(--accent); text-decoration: none; }
.pn .k { font-size: 13px; color: var(--muted); }
.pn .t { font-weight: 550; color: var(--accent); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.pn .nx { grid-column: 2; text-align: right; }

/* ── Index list ──────────────────────────────────── */
.vlist { margin-top: 20px; border-top: 1px solid var(--line); }
.v { padding: 16px 0; border-bottom: 1px solid var(--line); }
.vrow { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 16px; align-items: start; }
.vrow .thumb { width: 128px; }
.vrow .thumb.none { background: var(--side); }
.v h2 { font-size: 17px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.v h2 a { color: var(--text); }
.v h2 a:hover { color: var(--accent); }
.v .meta { margin-top: 4px; gap: 4px 12px; }
.v .desc { margin-top: 6px; font-size: 15px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hits { margin: 10px 0 0 144px; font-size: 14px; }
.hits:empty { display: none; }
.hits li { display: grid; grid-template-columns: 28px minmax(0, 1fr); padding: 4px 0; }
.hits .hn { color: var(--muted); font-variant-numeric: tabular-nums; }
.hits .hd { color: var(--muted); }
.hits a { overflow-wrap: anywhere; }
.hits .hmore { display: block; padding-left: 28px; }

/* ── Footer ──────────────────────────────────────── */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.foot ul { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot .made a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }

/* ── Phones and narrow windows ───────────────────── */
@media (max-width: 879px) {
  .top { padding: 0 16px; height: 52px; }
  .top .ch { display: none; }
  .menu { display: inline-flex; }
  .layout { display: flex; flex-direction: column; min-height: 0; background: none; }
  .side, .content { display: contents; }
  .layout > * > * { padding-left: 16px; padding-right: 16px; }
  .vnav { order: 0; display: none; padding-top: 12px; padding-bottom: 12px; background: var(--side); border-bottom: 1px solid var(--line); }
  .vnav.open { display: block; }
  .vnav .group-h { margin-left: 0; }
  .vnav-list { max-height: 60vh; overflow-y: auto; }
  .pagehead { order: 1; padding-top: 24px; }
  .find { order: 2; margin-top: 20px; }
  .filters { order: 3; margin-top: 4px; }
  .listwrap { order: 4; }
  .pn { order: 5; }
  .foot { order: 6; margin: 48px 16px 24px; padding-left: 0; padding-right: 0; }
  .side-index { order: 2; margin-top: 20px; }

  h1 { font-size: 24px; }
  .vhead { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .vhead .thumb { grid-column: 1; grid-row: auto; order: -1; max-width: 100%; }
  .vhead .thumb.none { display: none; }

  .filters .group + .group { margin-top: 10px; }
  .filters .group-h, .side-index .group-h { margin: 0 0 6px; }
  .side-index .group + .group { margin-top: 14px; }
  .facet { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .opt {
    width: auto; padding: 5px 10px; gap: 6px;
    border: 1px solid var(--line-strong); border-radius: 999px; font-size: 14px;
  }
  .opt[aria-pressed="true"] { border-color: var(--accent); }
  .opt .l { max-width: 200px; }

  .vrow { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  .vrow .thumb { width: 96px; }
  .v h2 { font-size: 16px; }
  .v .desc { display: none; }
  .hits { margin-left: 0; }
  .pn { grid-template-columns: 1fr; gap: 10px; margin-top: 36px; }
  .pn .nx { grid-column: 1; }
  .s:target { box-shadow: -16px 0 0 var(--accent-soft), 16px 0 0 var(--accent-soft); }
}

@media (min-width: 880px) {
  .side-index .group-h, .filters .group-h { margin-top: 0; }
  .filters { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
  .side-index .field { margin: 0 0 20px; }
}

@media (prefers-reduced-motion: no-preference) {
  .opt, .vnav-list a, .pn a, .field input { transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
}
