/* ============================================================
   Plottery docs. Two-column Docusaurus-style layout on top of
   the shared "candlelit codex" theme in styles.css. Generated
   pages (scripts/build_docs.py) all pull in this one file.
   ============================================================ */

/* Height of the fixed site header. These are first-paint fallbacks matching
   the header's size at each breakpoint; docs.js measures the real height and
   overwrites the variable, so webfont metrics can't knock the bars off. */
:root { --docs-top: 71px; }
@media (max-width: 640px) { :root { --docs-top: 55px; } }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Keep the decorative embers quiet behind a dense docs page. */
.docs-body .ember { opacity: 0.15; }

.docs-page {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding-top: var(--docs-top);
  display: grid;
  /* Third column is the "On this page" rail. Short pages ship no rail, and
     an empty auto column takes no width, so they still read as two. */
  grid-template-columns: 274px minmax(0, 1fr) auto;
}

/* ============ Left sidebar ============ */
.docs-sidebar {
  position: sticky;
  top: var(--docs-top);
  align-self: start;
  height: calc(100vh - var(--docs-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--rule);
  background: rgba(10, 10, 11, 0.28);
  /* Thin, themed scrollbar instead of the default chunky one. */
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.docs-sidebar::-webkit-scrollbar { width: 9px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
.docs-sidebar:hover::-webkit-scrollbar-thumb { background: var(--border-strong); background-clip: padding-box; }

.docs-sidebar-inner { padding: 22px 16px 40px; }

.docs-sidebar-title {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 4px 10px 14px;
}
.docs-sidebar-title:hover { color: var(--bone); }

.docs-nav { display: block; }

/* A page sitting at the top of the tree (docs/index.md) has no section
   wrapper, so it needs the list reset the sections get from .docs-cat ul. */
.docs-nav > ul { list-style: none; margin: 2px 0 10px; padding: 0; }

/* Collapsible category (native <details>) */
.docs-cat { margin-bottom: 6px; }
.docs-cat > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-subtle);
  user-select: none;
}
.docs-cat > summary::-webkit-details-marker { display: none; }
.docs-cat > summary:hover { color: var(--bone); background: rgba(229, 181, 112, 0.04); }
.docs-cat-chev svg { width: 13px; height: 13px; transition: transform 150ms ease; opacity: 0.7; }
.docs-cat[open] > summary .docs-cat-chev svg { transform: rotate(90deg); }

.docs-cat ul { list-style: none; margin: 2px 0 10px; padding: 0; }

/* A section nested inside a section. It inherits the section header treatment
   from .docs-cat (grey uppercase mono), so every folder in the sidebar reads
   the same whatever its depth; only the indent and rule mark the nesting. */
.docs-subcat { margin: 2px 0 4px; padding-left: 10px; border-left: 1px solid var(--rule); }
.docs-subcat > summary { padding-left: 4px; }
.docs-subcat ul { margin: 1px 0 4px; }
.docs-subcat .docs-link { padding-left: 12px; }
.docs-link {
  display: block;
  padding: 6px 12px 6px 14px;
  margin: 1px 0;
  border-left: 2px solid transparent;
  border-radius: 0 7px 7px 0;
  color: var(--bone);
  font-size: 0.9rem;
  line-height: 1.35;
  transition: color 130ms ease, background 130ms ease, border-color 130ms ease;
}
.docs-link:hover { color: var(--cream); background: rgba(229, 181, 112, 0.05); }
.docs-link.active {
  color: var(--cream);
  font-weight: 600;
  background: rgba(229, 181, 112, 0.09);
  border-left-color: var(--amber-400);
}

.docs-dl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 22px 8px 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f4d29a 0%, var(--amber-500) 60%, var(--amber-600) 100%);
  color: var(--ink-950);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 18px rgba(176, 122, 48, 0.22);
}
.docs-dl svg { width: 16px; height: 16px; }
.docs-dl:hover { filter: brightness(1.04); }

/* ============ Mobile top bar (hidden on desktop) ============ */
.docs-mobilebar {
  display: none;
  position: sticky;
  top: var(--docs-top);
  z-index: 30;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.docs-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg-card-2);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.docs-menu-toggle svg { width: 15px; height: 15px; }
.docs-mobile-current {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docs-backdrop { display: none; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, 0.55); }
.docs-backdrop.show { display: block; }

/* ============ Content ============ */
.docs-content { min-width: 0; padding: 38px 56px 88px; }
.docs-content > * { max-width: 800px; }

.docs-crumbs {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  font-size: 0.82rem;
  color: var(--text-subtle);
}
.docs-crumbs a { color: var(--bone); }
.docs-crumbs a:hover { color: var(--cream); text-decoration: underline; text-underline-offset: 2px; }
.docs-crumbs .sep { color: var(--text-subtle); opacity: 0.6; }
.docs-crumbs .cur { color: var(--text-muted); }

/* Prose */
.doc-body h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.7rem);
  letter-spacing: -0.02em;
  color: var(--cream);
  margin: 0 0 18px;
  text-wrap: balance;
}
/* Lead: everything between the h1 and the first section heading */
.doc-body > :is(p, ul, ol):not(:is(h2, h3) ~ *) {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 1.58;
  color: var(--bone);
  margin: 0 0 20px;
  text-wrap: pretty;
}
.doc-body > :is(ul, ol):not(:is(h2, h3) ~ *) li {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
.doc-body h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--cream);
  margin: 40px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 74px;
  text-wrap: balance;
}
.doc-body h3 {
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--cream);
  margin: 26px 0 8px;
  scroll-margin-top: 74px;
}
.doc-body h4 { font-size: 1rem; font-weight: 600; color: var(--text-dim); margin: 18px 0 6px; }
.doc-body p {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.72;
  margin: 0 0 14px;
  text-wrap: pretty;
}
.doc-body strong { color: var(--text-dim); font-weight: 600; }
.doc-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.doc-body a:hover { color: var(--cream); }

.doc-body ul, .doc-body ol { margin: 0 0 14px; padding-left: 0; }
.doc-body ul { list-style: none; }
.doc-body ul li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.55;
}
.doc-body ul li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border: 1px solid var(--amber-400);
  opacity: 0.7;
  transform: rotate(45deg);
}
.doc-body ol { padding-left: 22px; }
.doc-body ol li { color: var(--text-muted); font-size: 16px; line-height: 1.55; margin-bottom: 4px; }
.doc-body li strong { color: var(--cream); }

/* Inline code / UI path chip */
.doc-code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text-dim);
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
}
.doc-pre {
  margin: 0 0 16px;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.doc-pre code { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-dim); white-space: pre; }

/* Screenshots. The figure carries the frame so a transparent PNG or GIF sits
   on a surface instead of floating on the page background. width/height come
   from the file itself, and the pair below keeps that from distorting a scaled
   image while still reserving the right space before it loads. */
.doc-figure { margin: 0 0 20px; }
.doc-img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg-card-2);
}
.doc-figure figcaption {
  margin-top: 8px;
  color: var(--text-subtle);
  font-size: 0.85rem;
  line-height: 1.5;
}

.doc-body hr { border: 0; border-top: 1px solid var(--rule); margin: 28px 0; }

/* Callout (from > blockquote) */
.doc-body .note {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--amber-400);
  border-radius: 3px;
  background: rgba(229, 181, 112, 0.045);
  padding: 14px 18px;
  margin: 20px 0;
}
.doc-body .note p { margin: 0; color: var(--bone); font-size: 15px; }
.doc-body .note p + p { margin-top: 10px; }
.doc-body .note strong { color: var(--cream); }

/* Labeled callout (from !Tip / !Note / !Warning) */
.doc-callout {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--amber-400);
  border-radius: 3px;
  background: rgba(229, 181, 112, 0.045);
  padding: 12px 18px 14px;
  margin: 20px 0;
}
.doc-callout-warning { border-left-color: var(--rose-400); background: rgba(228, 124, 138, 0.05); }
.doc-callout-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-400);
}
.doc-callout-warning .doc-callout-label { color: var(--rose-400); }
.doc-callout p { margin: 0; color: var(--bone); font-size: 15px; }
.doc-callout strong { color: var(--cream); }

/* Branching-questions example (from ```example bad|good ...``` blocks).
   A bad block followed by a good one shares an Incorrect/Correct toggle
   (CSS-only, via the two hidden radio inputs). */
.doc-extoggle { margin: 20px 0; }
.doc-extoggle > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.doc-extoggle-bar { display: flex; }
.doc-extoggle-bar label {
  padding: 7px 16px;
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-right: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-subtle);
}
.doc-extoggle > input:nth-of-type(1):checked ~ .doc-extoggle-bar label:nth-of-type(1) {
  color: var(--rose-400);
  background: rgba(228, 124, 138, 0.06);
}
.doc-extoggle > input:nth-of-type(2):checked ~ .doc-extoggle-bar label:nth-of-type(2) {
  color: #a8c686;
  background: rgba(168, 198, 134, 0.06);
}
.doc-extoggle > input:nth-of-type(1):not(:checked) ~ .doc-example-bad { display: none; }
.doc-extoggle > input:nth-of-type(2):not(:checked) ~ .doc-example-good { display: none; }
.doc-extoggle .doc-example { border-top-left-radius: 0; }

/* A lone example block keeps a plain text label instead of the toggle. */
.doc-example-wrap { margin: 20px 0; }
.doc-example-label { margin-bottom: 6px; font-size: 0.8rem; color: var(--text-subtle); }
.doc-example-label-bad { color: var(--rose-400); }

.doc-example {
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.doc-example-bad { border-color: rgba(228, 124, 138, 0.25); }
.doc-example-good { border-color: rgba(168, 198, 134, 0.22); }
.doc-example-cap {
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  color: var(--bone);
  font-size: 0.9rem;
}
.doc-example-disclaim {
  position: absolute;
  top: 8px;
  right: 12px;
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-style: italic;
  opacity: 0.7;
}
/* The example body is drawn as a small graph: the root question centered,
   connector lines down to the branch questions, each edge labeled with the
   answer that leads there. Lines are borders on ::before/::after. */
.doc-example-flow { position: relative; padding: 18px 16px; }
.doc-q {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card-2);
  padding: 10px 14px 12px;
}
.doc-q-root {
  position: relative;
  width: fit-content;
  min-width: 280px;
  max-width: 100%;
  margin: 0 auto;
}
/* Stem from the root card down to the horizontal bar of the branch row. */
.doc-q-root::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -16px;
  height: 16px;
  border-left: 1px solid var(--rule);
}
.doc-q-branches { display: flex; gap: 14px; margin-top: 16px; }
.doc-branch { flex: 1; min-width: 0; position: relative; padding-top: 14px; }
/* Horizontal bar across the branch row, cut to start/end at the outer
   branches' centers. */
.doc-branch::after {
  content: "";
  position: absolute;
  top: 0;
  left: -7px;
  right: -7px;
  border-top: 1px solid var(--rule);
}
.doc-branch:first-child::after { left: 50%; }
.doc-branch:last-child::after { right: 50%; }
/* Stem from the bar down to each branch's edge label. */
.doc-branch::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 14px;
  border-left: 1px solid var(--rule);
}
.doc-branch-label {
  margin-bottom: 6px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.78rem;
  font-style: italic;
}
.doc-q-text {
  margin-bottom: 6px;
  color: var(--cream);
  font-size: 15px;
  font-weight: 600;
}
/* One row per option the player can pick: "label → tag". A shared grid keeps
   every arrow at the same horizontal spot; the label column sizes to the
   widest label in the question. */
.doc-q-options {
  display: grid;
  grid-template-columns: max-content max-content 1fr;
  column-gap: 10px;
  row-gap: 8px;
  align-items: baseline;
  font-size: 14px;
}
.doc-q-option { display: contents; }
.doc-q-opt-label {
  position: relative;
  padding-left: 17px;
  color: var(--bone);
}
.doc-q-dot {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--text-subtle);
  border-radius: 50%;
}
.doc-q-arrow { color: var(--text-subtle); }
.doc-q-opt-effect { color: var(--text-subtle); }
/* Stacked branches on narrow screens: drop the horizontal bar, keep a single
   stem into each card. */
@media (max-width: 560px) {
  .doc-q-branches { flex-direction: column; }
  .doc-branch::after { content: none; }
}
.doc-example-note {
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--rule);
  color: var(--text-muted);
  font-size: 14px;
}

/* Tables */
.doc-table-wrap { overflow-x: auto; margin: 0 0 18px; }
.doc-table { border-collapse: collapse; width: 100%; font-size: 15px; }
.doc-table th, .doc-table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.doc-table th { color: var(--cream); background: var(--bg-card-2); font-weight: 600; }
.doc-table td { color: var(--text-muted); }

/* Prev / next pager */
.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.docs-pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card-2);
  transition: border-color 130ms ease, background 130ms ease;
}
.docs-pager-link:hover { border-color: rgba(229, 181, 112, 0.5); }
.docs-pager-link.next { text-align: right; }
.docs-pager-dir { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-subtle); }
.docs-pager-title { font-family: var(--font-serif); font-size: 1.05rem; color: var(--cream); }

/* ============ Responsive ============ */
/* ============ Right rail: on this page ============ */
.docs-toc {
  position: sticky;
  top: var(--docs-top);
  align-self: start;
  width: 232px;
  max-height: calc(100vh - var(--docs-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.docs-toc-inner { padding: 44px 20px 40px 4px; }
.docs-toc-title {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding-bottom: 10px;
}
.docs-toc ul { list-style: none; margin: 0; padding: 0; }
.docs-toc-link {
  display: block;
  padding: 5px 0 5px 12px;
  border-left: 2px solid var(--rule);
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.4;
  transition: color 130ms ease, border-color 130ms ease;
}
.docs-toc-link:hover { color: var(--bone); border-left-color: var(--border-strong); }
.docs-toc-sub { padding-left: 24px; font-size: 0.79rem; }
.docs-toc-link.active { color: var(--cream); border-left-color: var(--amber-400); }

/* Below this the rail would squeeze the prose, so the sidebar keeps the space. */
@media (max-width: 1180px) {
  .docs-page { grid-template-columns: 274px minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  /* z-index: auto, not 1: the desktop z-index makes .docs-page a stacking
     context, which would trap the drawer's z-index 40 under the backdrop
     (z-index 39, a sibling of .docs-page) and swallow every tap on the menu. */
  .docs-page { grid-template-columns: 1fr; z-index: auto; }
  .docs-mobilebar { display: flex; }
  .docs-sidebar {
    position: fixed;
    top: var(--docs-top);
    left: 0;
    width: 288px;
    max-width: 84vw;
    height: calc(100vh - var(--docs-top));
    z-index: 40;
    transform: translateX(-102%);
    transition: transform 200ms ease;
    background: var(--ink-900);
  }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-content { padding: 26px 22px 72px; }
  .docs-pager { grid-template-columns: 1fr; }
}
