/* docs-shell — chrome for the /docs static sub-site (ADR-D11).
   A port of the abrq-mgmt docs shell (hostinger/src/public/docs/app.css)
   onto the @abrq/ui v3 tokens. Dimensions per the Design Contract in
   docs/plans/DOCS-PLATFORM-PLAN.md §2. Token-only colors (DS rule) —
   no hex literals in this file. Light-only at launch (matches the
   baseline); logical properties throughout so RTL activation later is
   a build flag, not a rework. */

:root {
  color-scheme: light;
  --docs-nav-height: 64px;
}
html {
  scroll-padding-top: calc(var(--docs-nav-height) + 16px);
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.docs-body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.65;
}

/* ---------------------------------------------------------------- topbar */
.docs-skip {
  position: absolute;
  inset-inline-start: -100vw;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  z-index: 60;
}
.docs-skip:focus-visible { inset-inline-start: 0.5rem; top: 0.5rem; }

.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--docs-nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.docs-topbar-inner {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.docs-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
}
.docs-brand-name {
  font-weight: 700;
  letter-spacing: 0.04em;
}
.docs-brand-suffix { color: var(--primary); }
.docs-product-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.5rem;
}
.docs-topbar-spacer { flex: 1; }
.docs-topbar-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
}
.docs-topbar-link:hover { color: var(--ink); background: var(--surface-2); }
.docs-nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------- search */
.docs-search { position: relative; }
.docs-search-input {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  width: clamp(140px, 18vw, 240px);
}
.docs-search-input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}
.docs-search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  inset-inline-end: 0;
  width: min(28rem, 90vw);
  max-height: 60vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg, 0 10px 28px rgba(27, 36, 31, 0.12));
  z-index: 60;
}
.docs-search-hit {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.9rem;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.docs-search-hit:hover { background: var(--surface-2); }
.docs-search-hit-section { color: var(--muted); }
.docs-search-hit-title { font-weight: 600; }
.docs-search-hit-excerpt { font-size: 0.8125rem; color: var(--muted); }
.docs-search-hit-excerpt mark { background: var(--accent-soft); color: inherit; }
.docs-search-none { margin: 0; padding: 0.75rem 0.9rem; color: var(--muted); }
@media (max-width: 760px) {
  .docs-search { display: none; }
}

/* ------------------------------------------------------------------ grid */
.docs-page {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 860px) minmax(170px, 230px);
  gap: clamp(1rem, 2vw, 2rem);
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem;
}
.docs-sidebar,
.docs-toc {
  position: sticky;
  top: calc(var(--docs-nav-height) + 1rem);
  max-height: calc(100vh - var(--docs-nav-height) - 2rem);
  overflow: auto;
  align-self: start;
}

/* --------------------------------------------------------------- sidebar */
.docs-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9375rem;
}
.docs-tree ul { list-style: none; margin: 0; padding: 0; }
.docs-section { margin-block-end: 1.25rem; }
.docs-section-label {
  display: block;
  color: var(--muted);
  margin-block-end: 0.35rem;
}
.docs-tree li li ul { padding-inline-start: 0.9rem; }
.docs-tree a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-inline-start: 2px solid transparent;
  border-radius: var(--radius-sm);
}
.docs-tree a:hover { color: var(--ink); background: var(--surface-2); }
.docs-tree li.active > a {
  color: var(--primary);
  border-inline-start-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 500;
}
.docs-badge {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.3rem;
  vertical-align: middle;
}
.docs-badge-new { background: var(--primary-soft); color: var(--primary); }
.docs-badge-deprecated { background: var(--warn-soft); color: var(--warn); }

/* --------------------------------------------------------------- content */
.docs-breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0;
  color: var(--muted);
}
.docs-breadcrumbs li + li::before { content: "/"; margin-inline-end: 0.35rem; color: var(--border); }
.docs-breadcrumbs a { color: var(--muted); text-decoration: none; }
.docs-breadcrumbs a:hover { color: var(--ink); }
.docs-breadcrumbs [aria-current="page"] { color: var(--ink); }

.docs-article { min-width: 0; }
.docs-applies {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin-block-end: 1rem;
}

/* callouts — bold-lead blockquotes, tinted by reserved lead word */
.abrq-prose blockquote.docs-callout {
  border-inline-start: 3px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}
.abrq-prose blockquote.docs-callout-note { border-inline-start-color: var(--primary); background: var(--primary-soft); }
.abrq-prose blockquote.docs-callout-tip { border-inline-start-color: var(--signal); background: var(--surface); }
.abrq-prose blockquote.docs-callout-warn { border-inline-start-color: var(--warn); background: var(--warn-soft); }

/* copy button (docs.js wraps pre in .docs-pre-wrap) */
.docs-pre-wrap { position: relative; }
.docs-copy-btn {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease);
}
.docs-pre-wrap:hover .docs-copy-btn,
.docs-copy-btn:focus-visible { opacity: 1; }
@media (hover: none) {
  .docs-copy-btn { opacity: 1; }
}
.docs-copy-btn.done { color: var(--signal); border-color: var(--signal); }
@media (prefers-reduced-motion: reduce) {
  .docs-copy-btn { transition: none; }
}

/* ------------------------------------------------------------------- toc */
.docs-toc ul { list-style: none; margin: 0.5rem 0 0; padding: 0; font-size: 0.875rem; }
.docs-toc h2 { margin: 0; color: var(--muted); }
.docs-toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-inline-start: 2px solid var(--border);
}
.docs-toc .toc-l3 a { padding-inline-start: 1.1rem; }
.docs-toc a:hover { color: var(--ink); }
.docs-toc li.current a { color: var(--primary); border-inline-start-color: var(--primary); }
.docs-toc-inline { display: none; }

/* ----------------------------------------------------------------- pager */
.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-block-start: 3rem;
  border-top: 1px solid var(--border);
  padding-block-start: 1rem;
}
.docs-pager a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--surface);
}
.docs-pager a:hover { border-color: var(--primary); }
.docs-pager a .abrq-label { color: var(--muted); }
.docs-pager-next { text-align: end; align-items: flex-end; }

/* --------------------------------------------------------------- landing */
.docs-landing {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 3rem clamp(1rem, 3vw, 2rem);
}
.docs-landing h1 { margin: 0 0 0.5rem; }
.docs-landing-lead { color: var(--muted); max-width: 60ch; }
.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-block-start: 2rem;
}
.docs-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--ink);
}
.docs-card:hover { border-color: var(--primary); }
.docs-card-name { font-weight: 600; font-size: 1.1rem; }
.docs-card-meta { color: var(--muted); }

/* ---------------------------------------------------------------- footer */
.docs-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 2.5rem;
}
.docs-footer a { color: var(--muted); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1050px) {
  .docs-page { grid-template-columns: minmax(190px, 250px) minmax(0, 1fr); }
  .docs-toc { display: none; }
  .docs-toc-inline {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0.5rem 0.75rem;
    margin-block-end: 1rem;
  }
  .docs-toc-inline ul { list-style: none; margin: 0.5rem 0 0; padding: 0; }
  .docs-toc-inline a { color: var(--muted); text-decoration: none; display: block; padding: 0.15rem 0; }
}
@media (max-width: 760px) {
  /* The answer outranks the nav on a phone: article first, tree after. */
  .docs-page { display: block; }
  .docs-sidebar {
    position: static;
    max-height: none;
    order: 2;
    border-top: 1px solid var(--border);
    margin-block-start: 2rem;
    padding-block-start: 1rem;
  }
  .docs-nav-toggle { display: inline-block; }
  .docs-sidebar[hidden] { display: none; }
  .docs-product-chip { display: none; }
  .docs-pager { grid-template-columns: 1fr; }
  .docs-pager-next { text-align: start; align-items: flex-start; }
}
