/* ==========================================================================
   Long-form documents: customer guide, guide index, legal pages, 404.
   Same tokens as site.css. Motion only on progress/feedback, never > 200 ms.
   ========================================================================== */

.doc-main { padding-top: calc(var(--nav-h) + clamp(28px, 5vw, 56px)); }
.doc-head { max-width: 820px; }
.doc-head .h1 { font-size: clamp(1.9rem, 4.6vw, 3.4rem); line-height: 1.05; }
.doc-head .lead { margin-left: 0; }
.doc-meta {
  display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; color: var(--fg-50);
}
.doc-meta time { color: var(--fg-80); }
.doc-note {
  margin: 18px 0 0; max-width: 820px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--glass); color: var(--fg-65); font-size: 13px;
}

/* ---------- reading progress ---------- */
.read-progress {
  position: fixed; inset: var(--nav-h) 0 auto 0; z-index: 49; height: 2px;
  background: transparent; pointer-events: none;
}
.read-progress span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.5), #fff);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
}

/* ---------- layout: sidebar + article ---------- */
.doc-layout {
  display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: clamp(28px, 4vw, 56px);
  margin-top: clamp(32px, 5vw, 56px); padding-bottom: clamp(64px, 9vw, 112px);
}
.doc-side { position: relative; }
.doc-side-inner {
  position: sticky; top: calc(var(--nav-h) + 20px);
  max-height: calc(100vh - var(--nav-h) - 40px); overflow: auto;
  display: flex; flex-direction: column; gap: 18px; padding-right: 4px;
}
.doc-search { display: flex; flex-direction: column; gap: 8px; }
.doc-search label { font-size: 11px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--fg-50); }
.doc-search-row { position: relative; display: flex; align-items: center; }
.doc-search-row svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--fg-50); pointer-events: none; }
.doc-search input {
  width: 100%; min-height: 42px; padding: 8px 38px 8px 36px;
  border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04);
  color: #fff; font: 500 14px/1.3 var(--font);
}
.doc-search input::placeholder { color: var(--fg-35); }
.doc-search input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.doc-search input::-webkit-search-cancel-button { display: none; }
.doc-search-clear {
  position: absolute; right: 6px; width: 30px; height: 30px; border-radius: 8px;
  border: 0; background: transparent; color: var(--fg-65); cursor: pointer; font: 700 16px/1 var(--font);
}
.doc-search-clear:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.doc-search-status { min-height: 1.2em; margin: 0; font-size: 12px; color: var(--fg-50); }

.toc h2 { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--fg-50); }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.toc a {
  display: flex; gap: 10px; padding: 7px 10px; border-radius: 9px;
  color: var(--fg-65); text-decoration: none; font-size: 14px; line-height: 1.35;
  border-left: 1px solid transparent;
}
.toc a::before { content: attr(data-n); font-family: var(--mono); font-size: 11px; color: var(--fg-35); padding-top: 2px; }
.toc a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.toc a[aria-current="true"] { color: #fff; background: rgba(255, 255, 255, 0.07); border-left-color: #fff; }
.toc li[hidden] { display: none; }
.doc-side-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- article ---------- */
.doc-article { min-width: 0; max-width: 780px; }
.doc-sec { padding: 8px 0 34px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.doc-sec:last-child { border-bottom: 0; }
.doc-sec[hidden] { display: none; }
.doc-sec h2 {
  position: relative; display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 16px; font-size: clamp(1.25rem, 2.4vw, 1.6rem); font-weight: 700; letter-spacing: 0.04em; line-height: 1.25;
}
.doc-sec h2 .num { font-family: var(--mono); font-size: 13px; color: var(--fg-65); letter-spacing: 0.1em; }
.anchor {
  margin-left: 4px; padding: 0 6px; border-radius: 6px;
  color: var(--fg-35); text-decoration: none; font-weight: 400;
  opacity: 0; transition: opacity .12s;
}
.doc-sec h2:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: #fff; }
@media (hover: none) { .anchor { opacity: 1; } }

.prose { color: var(--fg-80); font-size: 16px; line-height: 1.75; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 1.3em; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--fg-35); }
.prose strong { color: #fff; }
.prose a { color: #fff; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose code, .prose kbd {
  font-family: var(--mono); font-size: 0.86em; padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: #fff;
}
.prose kbd { border-bottom-width: 2px; }

.callout {
  position: relative; margin: 18px 0; padding: 14px 16px 14px 18px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04);
  font-size: 15px; line-height: 1.65; color: var(--fg-80);
}
.callout::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.6); }
.callout.warn { border-color: rgba(255, 176, 32, 0.4); background: rgba(255, 176, 32, 0.07); }
.callout.warn::before { background: #ffb020; box-shadow: 0 0 8px rgba(255, 176, 32, 0.7); }
.callout strong:first-child { color: #fff; }

.cmd {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  margin: 10px 0 14px; padding: 12px 12px 12px 16px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: #0b0b0b; overflow: hidden;
}
.cmd code { flex: 1; min-width: 0; padding: 4px 0; border: 0; background: none; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; color: #e9e9e9; }
.cmd code::before { content: "> "; color: var(--fg-35); }
.copy-btn {
  flex-shrink: 0; min-width: 76px; min-height: 32px; padding: 4px 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.06); color: #fff;
  font: 700 12px/1 var(--font); letter-spacing: 0.08em; cursor: pointer; transition: background .12s, border-color .12s;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.12); }
.copy-btn[data-state="ok"] { border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.14); color: #a7f3d0; }
.copy-btn[data-state="fail"] { border-color: rgba(255, 107, 107, 0.5); color: #ffb4b4; }

/* Figures: inline SVG diagrams. Fine strokes on the dark page; all colour comes from classes
   (the CSP forbids style attributes), so the drawings follow the page theme. */
.prose figure { margin: 22px 0; padding: 18px 14px 12px; width: 100%; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.prose figure svg { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.prose figcaption { margin: 12px auto 0; max-width: 62ch; font-size: 13px; line-height: 1.5; text-align: center; color: var(--fg-50); }
.fig-s, .fig-sd, .fig-sa, .fig-ar { fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.fig-sd { stroke: rgba(255, 255, 255, 0.35); stroke-dasharray: 4 4; }
.fig-sa { stroke: #ffb020; }
.fig-ar { stroke: rgba(255, 255, 255, 0.7); }
.fig-dot { fill: rgba(255, 255, 255, 0.7); stroke: none; }
.prose figure text { font-family: var(--font); font-size: 17px; fill: var(--fg-80); }
.prose figure .fig-b { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; fill: #fff; }
.prose figure .fig-d { font-size: 14.5px; fill: var(--fg-50); }
.prose figure .fig-a { fill: #ffb020; }
@media (max-width: 480px) { .prose figure { padding: 14px 8px 10px; } }

.issues { margin: 0; display: grid; gap: 10px; }
.issues dt { font-weight: 700; color: #fff; padding-top: 10px; border-top: 1px solid var(--line); }
.issues dt:first-child { border-top: 0; padding-top: 0; }
.issues dd { margin: 0; color: var(--fg-65); }

.table-wrap { overflow-x: auto; margin: 10px 0 16px; border: 1px solid var(--line); border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.prose th, .prose td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-50); background: rgba(255, 255, 255, 0.03); }
/* Row labels: a <th scope="row"> is a header for machines but a cell for the eye. */
.prose tbody th { font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--fg-80); background: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.prose tr:last-child td { border-bottom: 0; }
.prose td a { white-space: nowrap; }
.req-table:empty::before { content: attr(data-loading); color: var(--fg-50); font-size: 14px; }

::highlight(doc-search) { background: rgba(255, 214, 10, 0.35); color: #fff; }

.doc-foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ---------- guide index ---------- */
.guide-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; padding: clamp(22px, 4vw, 36px); }
.guide-card .card-title { font-size: clamp(1.3rem, 2.6vw, 1.8rem); }
.guide-card ol { margin: 0; padding-left: 1.4em; color: var(--fg-65); font-size: 14px; line-height: 1.6; columns: 2; column-gap: 24px; }
.guide-card ol a { color: var(--fg-80); text-decoration: none; }
.guide-card ol a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.guide-links { margin-top: 16px; }
.guide-links ul { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) { .guide-card { grid-template-columns: 1fr; } .guide-card ol { columns: 1; } }

/* ---------- legal ---------- */
.legal-layout { grid-template-columns: 220px minmax(0, 1fr); }
.legal-related { margin-top: 12px; }
.legal-related ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.legal-related a { color: var(--fg-65); text-decoration: none; font-size: 14px; }
.legal-related a:hover, .legal-related a[aria-current="page"] { color: #fff; }

/* ---------- 404 ---------- */
.e404 { min-height: calc(100vh - 200px); display: grid; place-items: center; text-align: center; padding: calc(var(--nav-h) + 40px) 0 80px; }
.e404 .h1 { font-size: clamp(2rem, 6vw, 4rem); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .doc-layout, .legal-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-side-inner { position: static; max-height: none; overflow: visible; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--glass); }
  .toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; }
}
@media (max-width: 520px) {
  .toc ol { grid-template-columns: minmax(0, 1fr); }
  .cmd { flex-direction: column; }
  .copy-btn { align-self: flex-end; }
  .prose { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .anchor, .copy-btn { transition: none; }
}

/* ---------- print ---------- */
@media print {
  @page { margin: 16mm 14mm; }
  html, body { background: #fff !important; color: #000 !important; }
  body { font-size: 11pt; line-height: 1.5; }
  .site-nav, .site-footer, .skip-link, .read-progress, .doc-side, .anchor, .copy-btn, .doc-foot, .no-print { display: none !important; }
  .doc-main { padding-top: 0; }
  .doc-layout, .legal-layout { display: block; margin: 0; padding: 0; }
  .doc-article { max-width: none; }
  .h1, .h2, .doc-sec h2 { color: #000 !important; text-shadow: none !important; }
  .eyebrow { border: 0; padding: 0; color: #555; }
  .eyebrow::before { display: none; }
  .doc-main, .doc-main *, .doc-main *::marker { color: #000 !important; text-shadow: none !important; }
  .doc-meta, .doc-meta *, .mono, .doc-sec h2 .num, .issues dd { color: #444 !important; }
  .table-wrap { overflow: visible !important; border-color: #bbb !important; }
  .prose td a { white-space: normal !important; }
  .prose td a::after, .prose th a::after { content: none !important; }
  .prose strong, .prose a, .issues dt, .callout strong:first-child { color: #000 !important; }
  .prose a[href^="http"]::after, .prose a[href^="/"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #555; }
  .prose a[href^="/"]::after { content: " (papocheats.shop" attr(href) ")"; }
  .doc-sec { break-inside: auto; border-color: #ccc; }
  .doc-sec h2 { break-after: avoid; }
  .doc-sec[hidden] { display: block !important; }
  .callout, .cmd, .table-wrap { break-inside: avoid; background: #f5f5f5 !important; border-color: #bbb !important; color: #000 !important; }
  .callout.warn { background: #fff6e0 !important; }
  .cmd code { color: #000 !important; }
  .prose code, .prose kbd { background: #eee !important; color: #000 !important; border-color: #ccc !important; }
  .prose th { background: #eee !important; color: #000 !important; }
  .prose figure { break-inside: avoid; background: #fff !important; border-color: #bbb !important; }
  .fig-s, .fig-sd, .fig-ar { stroke: #444 !important; }
  .fig-sa { stroke: #b36b00 !important; }
  .fig-dot { fill: #444 !important; }
  .prose figure text, .prose figure .fig-b { fill: #000 !important; }
  .prose figure .fig-d { fill: #555 !important; }
  .prose figure .fig-a { fill: #8a5200 !important; }
  .prose figcaption { color: #444 !important; }
  ::highlight(doc-search) { background: none; }
}

.toc a:not([data-n])::before { content: none; }
