/* Documentation pages: sidebar on the left, content on the right.
   --product is set on <body> per product; everything coloured derives from it. */

:root {
  --bg: #f6f7f9; --card: #fff; --line: #e3e5e9; --ink: #1a1d24; --muted: #6b7280;
  --accent: #3d2b6b; --accent-soft: #efecf6; --code-bg: #f0eef7;
}
body { --accent: var(--product, #3d2b6b); }
@supports (color: color-mix(in srgb, red 10%, white)) {
  body {
    --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--card));
    --code-bg: color-mix(in srgb, var(--accent) 8%, var(--card));
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d; --card: #1e2128; --line: #2e323b; --ink: #e6e8ec; --muted: #9aa1ad;
    --accent: #a996e0; --accent-soft: #262232; --code-bg: #262a33;
  }
  /* The product colours are picked for light backgrounds and come out too dark
     on a dark one, so they get lightened here. */
  @supports (color: color-mix(in srgb, red 10%, white)) {
    body {
      --accent: color-mix(in srgb, var(--product, #3d2b6b) 45%, #ffffff);
      --accent-soft: color-mix(in srgb, var(--product, #3d2b6b) 26%, var(--card));
      --code-bg: color-mix(in srgb, var(--product, #3d2b6b) 14%, var(--card));
    }
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.wrap { display: flex; align-items: flex-start; gap: 32px; max-width: 1500px; margin: 0 auto; padding: 0 24px; }

/* --- Sidebar ------------------------------------------------------------ */

nav.sidebar {
  position: sticky; top: 0; flex: 0 0 290px; max-height: 100vh; overflow-y: auto;
  padding: 24px 0; font-size: 14px;
}
nav.sidebar .back {
  display: block; padding: 0 12px 10px; font-size: 12.5px; color: var(--muted);
  text-decoration: none;
}
nav.sidebar .back::before { content: "‹ "; }
nav.sidebar .back:hover { color: var(--accent); }
nav.sidebar .brand {
  display: block; font-weight: 700; font-size: 15px; color: var(--ink);
  text-decoration: none; padding: 0 12px 12px;
}

/* --- Snapshot picker ---------------------------------------------------- */

/* Deliberately <details> instead of <select>: the pages should also open by
   double-click from the file system, without the picker depending on
   JavaScript. */
.snapshots {
  margin: 0 12px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card);
}
.snapshots > summary {
  display: flex; align-items: baseline; gap: 6px; cursor: pointer;
  padding: 8px 11px; border-radius: 7px; list-style: none; user-select: none;
  font-size: 13.5px;
}
.snapshots > summary::-webkit-details-marker { display: none; }
.snapshots > summary::after {
  content: "▾"; margin-left: auto; font-size: 11px; color: var(--muted);
  transition: transform .15s ease;
}
.snapshots[open] > summary::after { transform: rotate(180deg); }
.snapshots > summary:hover { background: var(--accent-soft); }
.snapshots .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; color: var(--muted);
}
.snapshots .date { font-weight: 650; }
.snapshots .list { border-top: 1px solid var(--line); padding: 5px; }
.snapshots .list a {
  display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none;
  color: var(--ink); font-size: 13.5px;
}
.snapshots .list a:hover { background: var(--accent-soft); }
.snapshots .list a.current { color: var(--accent); font-weight: 650; }
.snapshots .list a .note {
  display: block; font-size: 11.5px; color: var(--muted); font-weight: 400;
}
.snapshots .single { padding: 8px 11px; font-size: 12.5px; color: var(--muted); }

/* --- Navigation tree ---------------------------------------------------- */

nav.sidebar details.section > summary {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--muted); padding: 9px 12px; border-radius: 6px;
  list-style: none; user-select: none;
}
nav.sidebar details.section > summary::-webkit-details-marker { display: none; }
nav.sidebar details.section > summary::before {
  content: "›"; font-size: 15px; line-height: 1; transition: transform .15s ease;
  display: inline-block; transform: rotate(0deg);
}
nav.sidebar details.section[open] > summary::before { transform: rotate(90deg); }
nav.sidebar details.section > summary:hover { background: var(--accent-soft); color: var(--ink); }
nav.sidebar details.section > summary a { color: inherit; text-decoration: none; }
nav.sidebar details.has-current > summary { color: var(--accent); }
nav.sidebar .group { padding: 0 0 8px; }
nav.sidebar .group a {
  display: block; padding: 5px 12px 5px 30px; border-radius: 6px;
  color: var(--ink); text-decoration: none;
}
nav.sidebar .group a:hover { background: var(--accent-soft); }
nav.sidebar .group a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.sidebar a.aside-link {
  display: block; margin: 0 12px 10px; padding: 6px 11px; font-size: 13.5px;
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: 6px;
}
nav.sidebar a.aside-link:hover { background: var(--accent-soft); }
nav.sidebar a.aside-link.current { color: var(--accent); border-color: var(--accent); }

/* --- Content ------------------------------------------------------------ */

main { flex: 1; min-width: 0; padding: 24px 0 80px; }
article {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 32px 40px;
}
article > *:first-child { margin-top: 0; }
h1 { font-size: 27px; line-height: 1.25; margin: 0 0 20px; }
h2 {
  font-size: 20px; margin: 38px 0 12px; padding-bottom: 7px;
  border-bottom: 2px solid var(--accent-soft);
}
h3 { font-size: 17px; margin: 28px 0 8px; }
p, li { max-width: 76ch; }
a { color: var(--accent); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875em;
  background: var(--code-bg); padding: 2px 6px; border-radius: 4px;
}
pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }
img {
  max-width: 100%; height: auto; display: block; margin: 20px 0 6px;
  border: 1px solid var(--line); border-radius: 6px;
}
img + em, p > em:only-child { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 24px; }
.table-scroll { overflow-x: auto; margin: 18px 0; }
table { border-collapse: collapse; font-size: 14.5px; min-width: 100%; }
th, td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--accent-soft); font-weight: 600; }
blockquote {
  margin: 18px 0; padding: 10px 18px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 6px 6px 0; color: var(--muted);
}
.footnote { margin-top: 28px; font-size: 13px; color: var(--muted); }

@media (max-width: 900px) {
  .wrap { display: block; padding: 0 16px; }
  nav.sidebar { position: static; max-height: none; width: auto; padding: 16px 0; }
  article { padding: 22px 20px; }
}
@media print {
  nav.sidebar { display: none; }
  article { border: none; padding: 0; }
}
