/*
 * Documentation site styling.
 *
 * Shares the playground's identity: a technical workbench. Mono type carries codes, labels and
 * navigation; a system sans carries prose. Neutrals are biased cool-blue toward the figure's own
 * slate, and the accent is a desaturated steel so the muscle-map colours stay the only saturated
 * thing on any page.
 */

:root {
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --ground: #eef1f6;
  --surface: #ffffff;
  --surface-sunken: #e4e9f1;
  --line: #d2dae6;
  --line-strong: #b7c2d3;
  --text: #171d27;
  --text-muted: #5c6a7f;
  --text-faint: #8592a5;
  --accent: #3d6b95;
  --accent-soft: #dbe6f1;

  --good: #2f7d55;
  --warn: #9a6a16;
  --bad: #98413f;
  --info: #56609b;

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 250px;
  --contents-width: 200px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0e1219;
    --surface: #161c26;
    --surface-sunken: #10151d;
    --line: #262f3d;
    --line-strong: #364254;
    --text: #e4e9f2;
    --text-muted: #94a1b5;
    --text-faint: #6d7b90;
    --accent: #79a8d0;
    --accent-soft: #1d2938;
    --good: #66c191;
    --warn: #d8a94e;
    --bad: #dd8583;
    --info: #9aa3dd;
  }
}

:root[data-theme="dark"] {
  --ground: #0e1219;
  --surface: #161c26;
  --surface-sunken: #10151d;
  --line: #262f3d;
  --line-strong: #364254;
  --text: #e4e9f2;
  --text-muted: #94a1b5;
  --text-faint: #6d7b90;
  --accent: #79a8d0;
  --accent-soft: #1d2938;
  --good: #66c191;
  --warn: #d8a94e;
  --bad: #dd8583;
  --info: #9aa3dd;
}

:root[data-theme="light"] {
  --ground: #eef1f6;
  --surface: #ffffff;
  --surface-sunken: #e4e9f1;
  --line: #d2dae6;
  --line-strong: #b7c2d3;
  --text: #171d27;
  --text-muted: #5c6a7f;
  --text-faint: #8592a5;
  --accent: #3d6b95;
  --accent-soft: #dbe6f1;
  --good: #2f7d55;
  --warn: #9a6a16;
  --bad: #98413f;
  --info: #56609b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- layout ---------- */

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

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

@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; padding: 0 1rem; }
  .sidebar { position: static !important; height: auto !important; border-right: 0 !important; border-bottom: 1px solid var(--line); }
}

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.75rem 1.25rem 2rem 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand { display: flex; align-items: center; gap: 0.65rem; text-decoration: none; color: var(--text); }

.brand-mark { font-size: 1.3rem; color: var(--accent); line-height: 1; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--mono); font-size: 0.9rem; letter-spacing: -0.01em; }
.brand-text em { font-family: var(--mono); font-style: normal; font-size: 0.7rem; color: var(--text-faint); }

.rail-label {
  margin: 0 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; }

.nav-list a {
  display: block;
  padding: 0.32rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.nav-list a:hover { background: var(--surface); color: var(--text); }

.nav-list a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- search ---------- */

.search { position: relative; }

.search input {
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

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

.search-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.35);
  max-height: 300px;
  overflow-y: auto;
}

.search-results a {
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
}

.search-results a:hover { background: var(--accent-soft); }

.hit-page {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------- content ---------- */

.content { padding: 2.75rem 0 6rem; min-width: 0; }

.prose { max-width: 74ch; }

.prose > *:first-child { margin-top: 0; }

.prose h1 {
  font-family: var(--mono);
  font-size: clamp(1.7rem, 3.5vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}

.prose h2 {
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.012em;
  margin: 3rem 0 0.85rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  text-wrap: balance;
}

.prose h3 {
  font-size: 1.02rem;
  font-weight: 650;
  margin: 2rem 0 0.6rem;
  text-wrap: balance;
}

.prose h2 .anchor, .prose h3 .anchor {
  float: left;
  margin-left: -1.1em;
  width: 1.1em;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
}

.prose h2:hover .anchor, .prose h3:hover .anchor, .anchor:focus { opacity: 1; }

.prose p { margin: 0 0 1.1rem; }

.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.35rem; }
.prose li { margin-bottom: 0.4rem; }
.prose li > ul, .prose li > ol { margin-top: 0.4rem; }

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

.prose blockquote {
  margin: 0 0 1.1rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid var(--line-strong);
  color: var(--text-muted);
}

.prose img { max-width: 100%; height: auto; border-radius: var(--radius); display: block; margin: 1.5rem 0; }

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* inline code */
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface-sunken);
  color: var(--text);
}

/* ---------- code blocks ---------- */

.code-block {
  margin: 0 0 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.code-block pre {
  margin: 0;
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-size: 0.83rem;
  line-height: 1.6;
}

.code-block code { background: none; padding: 0; font-size: inherit; }

/* shiki dual-theme switching */
html:not([data-theme="dark"]) .shiki span { color: var(--shiki-light); }
html:not([data-theme="dark"]) .shiki { background-color: var(--shiki-light-bg) !important; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .shiki span { color: var(--shiki-dark); }
  html:not([data-theme="light"]) .shiki { background-color: var(--shiki-dark-bg) !important; }
}

html[data-theme="dark"] .shiki span { color: var(--shiki-dark); }
html[data-theme="dark"] .shiki { background-color: var(--shiki-dark-bg) !important; }
html[data-theme="light"] .shiki span { color: var(--shiki-light); }
html[data-theme="light"] .shiki { background-color: var(--shiki-light-bg) !important; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; margin: 0 0 1.5rem; }

.prose table, .data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.87rem;
}

.prose table { margin: 0 0 1.5rem; display: block; overflow-x: auto; }

.prose th, .prose td, .data-table th, .data-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.prose th, .data-table th {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  white-space: nowrap;
}

.data-table tbody tr:hover { background: var(--surface); }

.data-table .num, .prose td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.data-table tfoot td {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 0;
  border-top: 1px solid var(--line-strong);
}

.data-table.matrix td.yes { color: var(--good); text-align: center; font-size: 0.9rem; }
.data-table.matrix td.no { color: var(--text-faint); text-align: center; }
.data-table.matrix th:nth-child(n+3) { text-align: center; }

.data-table.catalogue .note { color: var(--text-muted); font-size: 0.82rem; min-width: 26ch; }
.data-table .self { color: var(--text-faint); font-style: italic; }

/* status / resolution tags */
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.tag-supported, .tag-drawn { color: var(--good); }
.tag-extended { color: var(--text-faint); }
.tag-splittable { color: var(--warn); }
.tag-deep { color: var(--bad); }
.tag-side-view { color: var(--info); }

/* ---------- ramp figure ---------- */

.ramp-figure { margin: 0 0 1.75rem; }

.ramp-strip {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.4rem;
}

.ramp-strip li { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.ramp-strip .swatch { width: 22px; height: 22px; border-radius: 4px; flex: none; }
.ramp-strip .lvl { font-family: var(--mono); font-size: 0.74rem; color: var(--text-muted); width: 1.3em; font-variant-numeric: tabular-nums; }
.ramp-strip code { font-size: 0.66rem; background: none; padding: 0; color: var(--text-faint); }

figcaption { font-size: 0.8rem; color: var(--text-faint); }

/* ---------- call to action ---------- */

.cta-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1.75rem; }

.cta {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--ground);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 1px solid var(--accent);
}

.cta:hover { filter: brightness(1.08); }

.cta-quiet { background: transparent; color: var(--accent); border-color: var(--line-strong); }
.cta-quiet:hover { border-color: var(--accent); filter: none; }

/* ---------- on-this-page rail ---------- */

.contents {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 2.9rem 0 2rem;
}

.contents ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }

.contents a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.15rem 0;
}

.contents a:hover { color: var(--accent); }
.contents .depth-3 { padding-left: 0.85rem; font-size: 0.76rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
