/* Docs center: tree / reading column / outline. Tokens come from ../shell.css. */

.docs-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 clamp(16px, 3vw, 32px);
  background: var(--studio-paper);
  border-bottom: 1px solid var(--studio-rule);
}

.docs-crumbs {
  display: flex;
  gap: 8px;
  min-width: 0;
  color: var(--studio-ink-faint);
  font-size: 13px;
  white-space: nowrap;
}

.docs-crumbs a { text-decoration: none; }
.docs-crumbs a:hover { color: var(--studio-accent); }
.docs-crumbs span:last-child { color: var(--studio-ink); }

.docs-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(300px, 40vw);
  height: 34px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--studio-rule-strong);
  border-radius: var(--studio-radius);
  color: var(--studio-ink-faint);
  background: var(--studio-sheet);
  transition: border-color var(--studio-duration) var(--studio-ease), box-shadow var(--studio-duration) var(--studio-ease);
}

.docs-search:focus-within {
  border-color: var(--studio-ink);
  box-shadow: none;
}

.docs-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--studio-ink);
  background: transparent;
  font: inherit;
}

.docs-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 760px) 200px;
  justify-content: start;
  gap: clamp(24px, 3vw, 48px);
  padding: 0 clamp(16px, 3vw, 32px);
}

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

.docs-tree,
.docs-toc {
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  padding: 24px 0 32px;
  overflow-y: auto;
}

.docs-tree-title,
.docs-toc-title {
  margin: 0 0 10px;
  color: var(--studio-ink-strong);
  font-size: 13px;
  font-weight: 600;
}

.docs-tree-group + .docs-tree-group { margin-top: 14px; }

.docs-tree-section {
  margin: 0 0 4px;
  padding: 0 10px;
  color: var(--studio-ink-faint);
  font-size: 12px;
}

.docs-tree ul {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-tree-link {
  position: relative;
  display: block;
  padding: 6px 10px;
  border-radius: var(--studio-radius-s);
  color: var(--studio-ink-muted);
  line-height: 1.45;
  text-decoration: none;
  transition: background var(--studio-duration) var(--studio-ease), color var(--studio-duration) var(--studio-ease);
}

.docs-tree-link:hover {
  color: var(--studio-ink);
  background: var(--studio-hover);
}

.docs-tree-link[aria-current="page"] {
  color: var(--studio-ink-strong);
  font-weight: 600;
  background: var(--studio-sheet);
}

.docs-tree-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--studio-accent);
}

.docs-tree-empty {
  padding: 0 10px;
  color: var(--studio-ink-faint);
}

/* ---------- article ---------- */

.docs-article {
  min-width: 0;
  padding: 36px 0 80px;
  color: var(--studio-ink);
  font-size: 15px;
  line-height: 1.8;
}

.docs-loading { color: var(--studio-ink-faint); }

.docs-article h1 {
  margin: 0 0 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--studio-rule-strong);
  color: var(--studio-ink-strong);
  font-size: clamp(26px, 1.4vw + 16px, 32px);
  font-weight: 600;
  line-height: 1.3;
}

.docs-article h2 {
  margin: 44px 0 12px;
  color: var(--studio-ink-strong);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.4;
  scroll-margin-top: 76px;
}

.docs-article h3 {
  margin: 28px 0 8px;
  color: var(--studio-ink-strong);
  font-size: 17px;
  font-weight: 600;
  scroll-margin-top: 76px;
}

.docs-article h4 {
  margin: 20px 0 6px;
  font-size: 15px;
}

.docs-article p { margin: 12px 0; }

.docs-article a {
  color: var(--studio-accent);
  text-decoration: underline;
  text-decoration-color: rgba(200, 67, 44, 0.35);
  text-underline-offset: 3px;
}

.docs-article a:hover { text-decoration-color: currentColor; }

.docs-article ul,
.docs-article ol {
  margin: 10px 0;
  padding-left: 1.5em;
}

.docs-article li { margin: 4px 0; }
.docs-article li > ul, .docs-article li > ol { margin: 4px 0; }
.docs-article li::marker { color: var(--studio-ink-faint); }

.docs-article strong { color: var(--studio-ink-strong); }

.docs-article code {
  padding: 1px 6px;
  border-radius: var(--studio-radius-s);
  color: var(--studio-accent-strong);
  background: var(--studio-desk);
  font-family: var(--studio-mono);
  font-size: 0.86em;
}

.docs-article pre {
  margin: 16px 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: var(--studio-radius);
  color: #efe7d6;
  background: var(--studio-ink-strong);
  line-height: 1.65;
}

.docs-article pre code {
  padding: 0;
  color: inherit;
  background: none;
  font-size: 13px;
}

.docs-article hr {
  margin: 36px 0;
  border: 0;
  border-top: 1px solid var(--studio-rule);
}

.docs-article blockquote {
  margin: 16px 0;
  padding: 2px 16px;
  border-left: 3px solid var(--studio-rule-strong);
  color: var(--studio-ink-muted);
}

/* Tables scroll on their own so a wide table never pushes the page sideways. */
.doc-table {
  margin: 16px 0;
  overflow-x: auto;
  border-top: 2px solid var(--studio-ink-strong);
  border-bottom: 1px solid var(--studio-ink-strong);
}

.doc-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}

.doc-table th,
.doc-table td {
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--studio-rule);
}

.doc-table th {
  color: var(--studio-ink-strong);
  background: transparent;
  border-bottom-color: var(--studio-ink-strong);
  font-weight: 600;
  white-space: nowrap;
}

.doc-table tr:last-child td { border-bottom: 0; }

/* Callouts are margin notes: only the rule and the label carry colour, the page stays paper.
   tip = green, note = slate, warning = vermilion, example = a sheet of script in ochre. */
.doc-callout {
  --callout: var(--studio-slate);
  margin: 20px 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--callout);
}

.doc-callout.is-tip { --callout: var(--studio-green); }
.doc-callout.is-warning { --callout: var(--studio-accent); }

.doc-callout.is-example {
  --callout: var(--studio-ochre);
  padding: 14px 20px;
  border: 1px solid var(--studio-rule);
  border-left: 3px solid var(--callout);
  background: var(--studio-sheet);
}

.doc-callout > :first-child { margin-top: 0; }
.doc-callout > :last-child { margin-bottom: 0; }

.doc-callout-title {
  margin: 0 0 4px !important;
  color: var(--callout);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- pager ---------- */

.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--studio-rule-strong);
}

.docs-article .docs-pager-link {
  display: grid;
  gap: 2px;
  color: var(--studio-ink-strong);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--studio-duration) var(--studio-ease);
}

.docs-article .docs-pager-link:hover { color: var(--studio-accent); }
.docs-pager-link small { color: var(--studio-ink-faint); font: 400 12px/1.5 var(--studio-font); }
.docs-pager-link.is-next { text-align: right; }

/* ---------- outline ---------- */

.docs-toc ol {
  margin: 0;
  padding: 0 0 0 12px;
  list-style: none;
  border-left: 1px solid var(--studio-rule);
}

.docs-toc li.is-sub { padding-left: 12px; }

.docs-toc a {
  display: block;
  margin-left: -13px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  color: var(--studio-ink-muted);
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;
}

.docs-toc a:hover { color: var(--studio-ink); }

.docs-toc a.is-active {
  color: var(--studio-accent);
  border-left-color: var(--studio-accent);
}

@media (max-width: 1240px) {
  .docs-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 820px) {
  .docs-bar { position: static; }
  .docs-crumbs { display: none; }
  .docs-search { width: 100%; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-tree { position: static; order: 2; max-height: none; padding-top: 20px; border-top: 1px solid var(--studio-rule); }
  .docs-article { padding-top: 16px; }
}
