/* PowerVFD docs portal — built on base.css (PowerTally token set). */

/* Docs-only tokens + dark theme ----------------------------------------- */
:root {
  --code-bg: #230609;          /* crimson-950, same as PowerTally dark sections */
  --code-border: #230609;
  --code-text: #f6eeee;
  --header-h: 64px;
  --mark: #fdf0de;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #140b0d; --tray: #1c1013; --line: #34242a; --line-strong: #4a353b;
    --ink: #f1ecec; --ink-2: #d9d1d2; --muted: #ab9fa1; --faint: #85797c; --heading: #ffffff;
    --red: #e6535f; --red-ink: #e6535f; --red-ink-hover: #ff8a93; --red-wash: #3a1419;
    --amber-50: #2e1d0b; --mark: #4a2e10;
    --code-bg: #0c0506; --code-border: #34242a;
    --shadow-card: 0 1px 2px #0006; --shadow-lift: 0 20px 40px -12px #000a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #140b0d; --tray: #1c1013; --line: #34242a; --line-strong: #4a353b;
  --ink: #f1ecec; --ink-2: #d9d1d2; --muted: #ab9fa1; --faint: #85797c; --heading: #ffffff;
  --red: #e6535f; --red-ink: #e6535f; --red-ink-hover: #ff8a93; --red-wash: #3a1419;
  --amber-50: #2e1d0b; --mark: #4a2e10;
  --code-bg: #0c0506; --code-border: #34242a;
  --shadow-card: 0 1px 2px #0006; --shadow-lift: 0 20px 40px -12px #000a;
  color-scheme: dark;
}

body.docs { background: var(--paper); color: var(--ink); }

/* Header ------------------------------------------------------------------ */
.docs-header-wrap {
  position: sticky; top: -32px; z-index: 40;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.docs .parent-strip { background: var(--paper); border-bottom-color: var(--line); }
.docs-strip-inner { padding: 0 20px; width: 100%; }
.pc-logo-white { display: none; }
:root[data-theme="dark"] .pc-logo-color { display: none; }
:root[data-theme="dark"] .pc-logo-white { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pc-logo-color { display: none; }
  :root:not([data-theme="light"]) .pc-logo-white { display: block; }
}
:root[data-theme="dark"] .brand .wm-vfd { color: #fff; }

.docs-header { height: var(--header-h); display: flex; align-items: center; gap: 16px; padding: 0 20px; }
.docs-header .brand-mark { width: 30px; height: 30px; }
.docs-header .wordmark { font-size: 23px; }

.search-trigger {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  width: min(380px, 40vw); height: 40px; padding: 0 8px 0 14px;
  background: var(--tray); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font: 400 14px var(--font-sans); cursor: pointer;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--ink-2); }
.search-trigger-text { flex: 1; text-align: left; }
.search-kbd, .search-dialog kbd {
  font: 500 11px var(--font-mono); color: var(--muted); background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px;
}
.header-links { display: flex; align-items: center; gap: 8px; }
.header-links a { font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; padding: 8px 10px; }
.header-links a:hover { color: var(--red); }
.theme-toggle, .sidebar-toggle {
  width: 40px; height: 40px; display: inline-grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-2);
}
.theme-toggle:hover, .sidebar-toggle:hover { color: var(--red); border-color: var(--line-strong); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
.sidebar-toggle { display: none; }

/* Layout ------------------------------------------------------------------ */
.docs-layout {
  display: grid; grid-template-columns: 272px minmax(0, 1fr) 232px;
  max-width: 1480px; margin: 0 auto;
}
.docs-sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100vh - var(--header-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 16px 32px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 24px;
}
.nav-heading {
  display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 8px 12px;
}
.nav-group a {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font-size: 14.5px;
}
.nav-group a:hover { background: var(--tray); color: var(--heading); }
.nav-group a[aria-current="page"] { background: var(--red-wash); color: var(--red); font-weight: 600; }
.nav-method {
  font: 600 10px var(--font-mono); letter-spacing: .06em; color: var(--red);
  border: 1px solid currentColor; border-radius: 999px; padding: 1px 6px;
}
.server-setting { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--line); }
.server-setting .nav-heading { margin-left: 0; }
.server-setting p { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.base-url-input, .inline-setting input, #error-query {
  width: 100%; height: 38px; padding: 0 12px; font: 13px var(--font-mono); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.base-url-input:focus, #error-query:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: transparent; }
.search-box input:focus, .search-box input:focus-visible { outline: none; }
.search-box:focus-within { box-shadow: inset 0 -2px 0 var(--red); }

.docs-main { min-width: 0; padding: 40px 56px 48px; outline: none; }
.docs-toc {
  position: sticky; top: var(--header-h); align-self: start;
  max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 40px 16px 32px 8px;
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc-list a {
  display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent;
  font-size: 13.5px; line-height: 1.4; color: var(--muted); text-decoration: none;
}
.toc-list a:hover { color: var(--heading); }
.toc-list a.is-active { color: var(--red); border-left-color: var(--red); font-weight: 500; }
.toc-list .toc-h3 a { padding-left: 26px; font-size: 13px; }

.sidebar-scrim { position: fixed; inset: 0; background: rgba(35, 6, 9, .45); z-index: 55; }

@media (max-width: 1200px) {
  .docs-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 900px) {
  .sidebar-toggle { display: inline-grid; }
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 60;
    background: var(--paper); transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-lift);
  }
  .docs-sidebar.is-open { transform: none; }
  .docs-main { padding: 28px 20px 40px; }
  .header-links a { display: none; }
  .search-trigger { width: auto; flex: 1; max-width: 320px; }
}
@media (max-width: 520px) {
  .docs-header { gap: 10px; padding: 0 12px; }
  .docs-header .brand small { display: none; }
  .search-trigger-text, .search-kbd { display: none; }
  .search-trigger { flex: none; width: 40px; padding: 0; justify-content: center; }
}

/* Articles ----------------------------------------------------------------- */
html.js .doc { display: none; }
html.js .doc.is-active { display: block; }
html:not(.js) .doc + .doc { margin-top: 64px; padding-top: 48px; border-top: 1px solid var(--line); }

.doc { max-width: 780px; }
.doc-crumb { margin-bottom: 12px; }
.doc h1 { font-size: clamp(2rem, 4vw, 2.5rem); line-height: 1.1; margin-bottom: 14px; }
.doc h2 { font-size: 24px; margin: 52px 0 14px; scroll-margin-top: calc(var(--header-h) + 20px); }
.doc h3 { font-size: 18px; margin: 32px 0 10px; scroll-margin-top: calc(var(--header-h) + 20px); }
.doc h2, .doc h3 { position: relative; }
.heading-anchor {
  margin-left: 8px; color: var(--faint); text-decoration: none; font-weight: 400;
  opacity: 0; transition: opacity .15s ease;
}
.doc h2:hover .heading-anchor, .doc h3:hover .heading-anchor, .heading-anchor:focus { opacity: 1; }
.heading-anchor:hover { color: var(--red); }

.doc-lede { font-size: 18px; line-height: 1.65; color: var(--muted); margin-bottom: 20px; }
.doc p, .doc li { color: var(--ink-2); line-height: 1.72; }
.doc p + p { margin-top: 14px; }
.doc ul, .doc ol { margin: 14px 0; padding-left: 22px; }
.doc li + li { margin-top: 6px; }
.doc strong { color: var(--heading); font-weight: 600; }
.doc .muted { color: var(--muted); font-size: 14.5px; }
.doc :not(pre) > code {
  font-size: .86em; color: var(--heading); background: var(--tray);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; overflow-wrap: anywhere;
}
.doc a code { color: inherit; }

/* Steps */
.doc ol.steps { list-style: none; padding: 0; counter-reset: step; }
.doc ol.steps > li {
  counter-increment: step; position: relative; padding: 2px 0 2px 44px; margin-top: 16px;
}
.doc ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font: 600 13px var(--font-mono); color: var(--red); background: var(--red-wash);
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 28px 0 8px; }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 20px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); text-decoration: none; transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: var(--red); transform: translateY(-1px); }
.card strong { color: var(--heading); font-size: 16px; }
.card span { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
@media (max-width: 600px) { .cards { grid-template-columns: 1fr; } }

/* Endpoint */
.endpoints { display: grid; gap: 8px; margin: 4px 0 20px; }
.endpoint {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--tray); border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 14px;
}
.endpoint code { color: var(--heading); font-weight: 500; overflow-wrap: anywhere; }
.method { font: 600 12px var(--font-mono); color: #fff; background: var(--red); border-radius: 999px; padding: 3px 10px; letter-spacing: .04em; }
.endpoint-note { font-family: var(--font-sans); font-size: 13px; color: var(--muted); }

/* Callouts */
.callout {
  margin: 20px 0; padding: 14px 18px; border-radius: var(--radius);
  background: var(--tray); border: 1px solid var(--line); border-left: 3px solid var(--red);
}
.callout p { margin: 0; }
.callout-warn { background: var(--amber-50); border-left-color: var(--amber); }

.inline-setting { display: flex; align-items: center; gap: 12px; margin: 16px 0 10px; max-width: 520px; }
.inline-setting label { font-weight: 600; font-size: 14px; color: var(--heading); white-space: nowrap; }

/* Tables */
.table-wrap {
  margin: 18px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
}
.doc table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.doc th {
  text-align: left; padding: 10px 14px; background: var(--tray); border-bottom: 1px solid var(--line);
  font: 500 11px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.doc td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; color: var(--ink-2); line-height: 1.6; }
.doc tbody tr:first-child td { border-top: 0; }
.doc td.num { font-family: var(--font-mono); text-align: right; }
.ref-table td:first-child { white-space: nowrap; }
.fields td:nth-child(2) { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.fields td:nth-child(3) { font-size: 13.5px; }
.errors td:nth-child(2) { min-width: 240px; }
.errors td:nth-child(2) code { white-space: normal; }
.glossary td:first-child { font-weight: 600; color: var(--heading); }
tr.flash td, .flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 30% { background: var(--mark); } 100% { background: transparent; } }

/* Status pills */
.status {
  display: inline-block; font: 600 12px var(--font-mono); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
  border: 1px solid transparent;
}
.s200 { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.s400 { color: #9a5a14; background: #fdf5ea; border-color: #fbebd6; }
.s402 { color: #7a1220; background: #fbeaec; border-color: #f4c7cc; }
.s403, .s404 { color: #b42332; background: #fff1f2; border-color: #fecdd3; }
.s500 { color: #33374a; background: #eef0f6; border-color: #e1e4ee; }
:root[data-theme="dark"] .status { background: transparent; border-color: currentColor; }
:root[data-theme="dark"] .s200 { color: #34d399; } :root[data-theme="dark"] .s400 { color: #f2b56b; }
:root[data-theme="dark"] .s402, :root[data-theme="dark"] .s403, :root[data-theme="dark"] .s404 { color: #ff8a93; }
:root[data-theme="dark"] .s500 { color: #c9c1c3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status { background: transparent; border-color: currentColor; }
  :root:not([data-theme="light"]) .s200 { color: #34d399; } :root:not([data-theme="light"]) .s400 { color: #f2b56b; }
  :root:not([data-theme="light"]) .s402, :root:not([data-theme="light"]) .s403, :root:not([data-theme="light"]) .s404 { color: #ff8a93; }
  :root:not([data-theme="light"]) .s500 { color: #c9c1c3; }
}

/* Error filter */
.error-filter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: 500 13px var(--font-mono); padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--paper); color: var(--ink-2); border: 1px solid var(--line);
}
.chip:hover { border-color: var(--red); color: var(--red); }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
#error-query { flex: 1; min-width: 200px; border-radius: 999px; font-family: var(--font-sans); font-size: 14px; padding: 0 16px; }
.empty-note { color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--red); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Code blocks -------------------------------------------------------------- */
.code-block {
  margin: 18px 0; border-radius: 12px; overflow: hidden;
  background: var(--code-bg); border: 1px solid var(--code-border);
}
.code-head {
  display: flex; align-items: center; gap: 4px; min-height: 42px; padding: 0 6px 0 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.code-title { font: 500 11.5px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.55); margin-right: auto; }
.code-tabs { display: flex; gap: 2px; margin-right: auto; overflow-x: auto; scrollbar-width: none; }
.code-tabs::-webkit-scrollbar { display: none; }
.code-tabs button {
  background: none; border: 0; cursor: pointer; padding: 11px 10px 10px; border-bottom: 2px solid transparent;
  font: 500 13px var(--font-sans); color: rgba(255,255,255,.6); white-space: nowrap;
}
.code-tabs button:hover { color: #fff; }
.code-tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--amber); }
.copy-btn {
  flex: none; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 999px;
  color: rgba(255,255,255,.8); font: 500 12px var(--font-sans); padding: 5px 12px; cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.copy-btn.is-done { color: #34d399; border-color: #34d39966; }
.code-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.65; color: var(--code-text); tab-size: 2; }
.code-block pre[hidden] { display: none; }
.code-block code { font-family: var(--font-mono); }
.t-key { color: #ff9aa2; }
.t-str { color: #f6c28b; }
.t-num { color: #7ee0c3; }
.t-kw { color: #ff9aa2; font-weight: 500; }
.t-com { color: rgba(255,255,255,.45); font-style: italic; }
.t-var { color: #ffd6a8; }
.base-url-token { color: #fff; background: rgba(221,138,46,.22); border-radius: 3px; box-shadow: 0 0 0 1px rgba(221,138,46,.45); }

/* Pager + footer ------------------------------------------------------------ */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 780px; margin-top: 64px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 1px solid var(--line);
  border-radius: var(--radius-card); text-decoration: none; background: var(--paper); box-shadow: var(--shadow-card);
}
.pager a:hover { border-color: var(--red); }
.pager .pager-next { grid-column: 2; text-align: right; }
.pager small { font: 500 11px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.pager span { color: var(--heading); font-weight: 600; }
.docs-footer { max-width: 780px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.docs-footer a { color: var(--muted); }
.docs-footer a:hover { color: var(--red); }

/* Search dialog --------------------------------------------------------------- */
.search-dialog {
  width: min(660px, calc(100vw - 24px)); max-height: min(640px, calc(100vh - 80px));
  margin: 72px auto auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-card);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lift);
  display: none; flex-direction: column; overflow: hidden;
}
.search-dialog[open] { display: flex; }
.search-dialog::backdrop { background: rgba(35, 6, 9, .45); backdrop-filter: blur(2px); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-box input {
  flex: 1; height: 56px; border: 0; background: transparent; color: var(--ink);
  font: 400 17px var(--font-sans);
}
.search-box input::-webkit-search-cancel-button { display: none; }
.search-close { background: none; border: 0; cursor: pointer; padding: 4px; }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.search-results:empty { display: none; }
.search-group { font: 500 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 10px 10px 4px; }
.search-result a {
  display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink);
}
.search-result[aria-selected="true"] a { background: var(--red-wash); }
.sr-title { display: flex; align-items: baseline; gap: 8px; font-weight: 600; font-size: 14.5px; color: var(--heading); }
.sr-name { min-width: 0; overflow-wrap: anywhere; }
.sr-type { position: relative; top: -1px; }
.sr-title code { font-size: 13px; }
.sr-type {
  font: 500 10px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; flex: none;
}
.sr-path { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sr-snippet { display: block; font-size: 13.5px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; overflow-wrap: anywhere; }
.search-results mark { background: var(--mark); color: var(--heading); border-radius: 3px; padding: 0 1px; }
.search-hint { padding: 16px 18px; font-size: 14px; color: var(--muted); }
.search-hint button {
  font: 500 13px var(--font-mono); color: var(--red); background: var(--red-wash); border: 0; border-radius: 999px;
  padding: 2px 9px; cursor: pointer;
}
.search-empty { padding: 20px 12px; color: var(--muted); font-size: 14px; }
.search-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.search-foot kbd { margin-right: 4px; }
@media (max-width: 520px) { .search-dialog { margin-top: 12px; } .search-foot { display: none; } }
