/* Unroll docs: a Markdown file open in the site window (window.css).
   The Explorer sidebar lists the site's files and the file's outline, the toolbar
   holds breadcrumbs and a Source / Preview switch, and the editor shows the
   rendered preview or the Markdown it reads as. */

html { scroll-padding-top: 72px; }

/* ---------- window with a sidebar ---------- */
.window.has-side {
  grid-template-columns: 52px 248px minmax(0, 1fr);
  grid-template-areas: "title title title" "act side editor" "status status status";
}
.window.has-side.side-hidden { grid-template-columns: 52px 0 minmax(0, 1fr); }
.side-hidden .side { visibility: hidden; }
.activity button[aria-pressed="true"] { color: var(--strong); border-left-color: var(--strong); }

.side {
  grid-area: side;
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 0 48px;
  background: var(--chrome);
  border-right: 1px solid var(--border);
  font-size: 13px;
  scrollbar-width: thin;
}
.side h2 {
  display: flex; align-items: center; gap: 6px;
  margin: 10px 0 4px; padding: 0 14px;
  font: 600 11px/2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.side h2::before { content: "⌄"; font-size: 12px; line-height: 1; transform: translateY(-2px); }
.side ul, .side ol { list-style: none; margin: 0; padding: 0; }
.side a {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 14px 3px 22px; color: var(--fg); text-decoration: none;
  border-left: 2px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side a:hover { background: var(--hover); color: var(--strong); }
.side a[aria-current="page"] { background: var(--sel); color: var(--strong); }
.side-outline a { padding-left: 22px; color: var(--muted); }
.side-outline a::before { content: "#"; font: 11px var(--mono); color: var(--faint); }
.side-outline a[aria-current="true"] { color: var(--strong); border-left-color: var(--accent); background: var(--hover); }

/* ---------- toolbar: breadcrumbs and the view switch ---------- */
.doc-toolbar { padding-bottom: 10px; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; color: var(--muted); }
.crumbs > * { flex: none; }
.crumbs .sep { color: var(--faint); }
.crumbs .file-name { font-size: 14px; }
/* The last crumb is the section being read; like VS Code's, it opens the file's symbols. */
.crumb-menu { position: relative; flex: 0 1 auto; min-width: 0; }
.crumb-menu summary {
  display: flex; align-items: center; gap: 5px; max-width: 100%;
  list-style: none; cursor: pointer; padding: 2px 6px; border-radius: 4px; color: var(--fg);
}
.crumb-menu summary::-webkit-details-marker { display: none; }
.crumb-menu summary::after { content: "⌄"; font-size: 12px; color: var(--muted); transform: translateY(-2px); }
.crumb-menu summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-menu summary:hover, .crumb-menu[open] summary { background: var(--hover); color: var(--strong); }
.crumb-menu ol {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 240px; max-height: min(60vh, 420px); overflow-y: auto;
  margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--lift);
}
.crumb-menu a { display: block; padding: 5px 10px; border-radius: 4px; color: var(--fg); text-decoration: none; white-space: nowrap; }
.crumb-menu a:hover, .crumb-menu a:focus-visible { background: var(--hover); color: var(--strong); }
.crumb-menu a[aria-current="true"] { background: var(--sel); color: var(--strong); }

/* ---------- preview ---------- */
.doc-body { padding: clamp(28px, 4vw, 56px) clamp(20px, 4vw, 56px) 12px; min-width: 0; }
.prose { max-width: 46em; margin: 0 auto; }
.prose h1 { font-size: clamp(32px, 1.2rem + 2vw, 46px); line-height: 1.1; letter-spacing: -.025em; margin-bottom: 18px; }
.prose .lede { font-size: clamp(16.5px, .9rem + .35vw, 19px); color: var(--muted); margin-bottom: 8px; }
.prose .lede strong { color: var(--fg); }
.prose h2 { font-size: clamp(23px, 1rem + .9vw, 29px); margin: 52px 0 12px; padding-top: 22px; border-top: 1px solid var(--border); }
.prose h3 { margin: 26px 0 8px; }
.prose p, .prose li { color: var(--fg); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--muted); }
.prose .muted { color: var(--muted); }
.prose kbd + kbd { margin-left: 3px; }
.table-scroll { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-soft); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { font: 500 12px var(--mono); color: var(--muted); background: var(--card-2); }
.prose td:first-child { white-space: nowrap; color: var(--strong); font-weight: 500; }
.prose td .logo { width: 15px; height: 15px; margin-right: 8px; vertical-align: -2px; }

/* ---------- source: the same file as Markdown ---------- */
.md-source {
  max-width: 64em; margin: 0 auto; padding: 0;
  font: 13px/1.75 var(--mono); color: var(--fg);
  white-space: pre-wrap; overflow-wrap: anywhere;
  counter-reset: line;
}
.md-source > span { display: block; padding-left: 5ch; text-indent: -5ch; counter-increment: line; }
.md-source > span::before {
  content: counter(line); display: inline-block; width: 4ch; margin-right: 1ch; text-indent: 0;
  text-align: right; color: var(--faint); user-select: none;
}
.md-source > span:target { background: var(--hover); }
.md-h { color: var(--tok-lit); font-weight: 600; }
.md-b { color: var(--strong); font-weight: 600; }
.md-i { font-style: italic; }
.md-c { color: var(--tok-str); }
.md-u { color: var(--faint); }
.md-l { color: var(--link); }
.md-p { color: var(--faint); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .window.has-side { grid-template-columns: 52px 212px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .window.has-side, .window.has-side.side-hidden { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "editor" "status"; }
  .side { display: none; }
  /* One short row, so it can stay in reach while reading. */
  .doc-page .toolbar { position: sticky; }
  .crumbs .crumb-root, .crumbs .crumb-root + .sep { display: none; }
  .crumb-menu ol { position: fixed; left: 12px; right: 12px; top: auto; min-width: 0; margin-top: 6px; }
  .doc-body { padding: 22px 16px 8px; }
  .prose h2 { margin-top: 40px; }
  html { scroll-padding-top: 64px; }
}
