/* docs.css — styles scoped to docs.php. Unique variable prefix (--dc-) to avoid collisions. */

:root {
  --dc-sidebar-w: 292px;
  /* Adjust these two if your real site header or this search bar render at a
     different height — every sticky offset and scroll-jump on this page is
     calculated from them, in one place. */
  --dc-header-h: 76px;
  --dc-search-h: 49px;
  --dc-code-bg: #0e1a35;
  --dc-code-ink: #dbe6ff;
  --dc-code-accent: #7db2ff;
  --dc-note-bg: #eef3ff;
  --dc-note-line: #c7d7fb;
  --dc-note-ink: #1f3e9e;
  --dc-warn-bg: #fff6e6;
  --dc-warn-line: #f0cd7e;
  --dc-warn-ink: #7a5a06;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --dc-note-bg: #101d40;
    --dc-note-line: #24407f;
    --dc-note-ink: #a9c2ff;
    --dc-warn-bg: #2a2107;
    --dc-warn-line: #6b551a;
    --dc-warn-ink: #e8c565;
    --dc-code-bg: #060c1c;
  }
}
:root[data-theme="dark"] {
  --dc-note-bg: #101d40; --dc-note-line: #24407f; --dc-note-ink: #a9c2ff;
  --dc-warn-bg: #2a2107; --dc-warn-line: #6b551a; --dc-warn-ink: #e8c565;
  --dc-code-bg: #060c1c;
}

/*
  Base icon + button styles for this page, defined here rather than assumed from
  site.css — kept fully self-contained so docs.php never depends on (or collides
  with) whatever generic ".icon"/".btn" classes may or may not exist elsewhere.
*/
.dc-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dc-icon.dc-icon-filled { fill: currentColor; stroke: none; }
.dc-icon.inline { width: 0.85em; height: 0.85em; margin-left: 2px; }

.dc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.dc-btn:hover { background: var(--surface-2); text-decoration: none; }
.dc-btn-outline { background: transparent; }
.dc-btn-outline:hover { background: var(--surface); }
.dc-btn .dc-icon { color: var(--brand-dim); }

/* Search bar — sticky, shown at the top of the page on every screen size */
.dc-search-bar {
  position: sticky; top: var(--dc-header-h); z-index: 58;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
}
.dc-search-box {
  max-width: 1320px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px;
  background: var(--surface);
}
.dc-search-box .dc-icon { color: var(--muted); }
.dc-search-input {
  flex: 1; border: none; background: transparent; outline: none;
  font-family: 'Manrope', sans-serif; font-size: 0.94rem; color: var(--ink);
}
.dc-search-input::placeholder { color: var(--muted); }
.dc-search-clear {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; padding: 2px;
}
.dc-search-clear:hover { color: var(--ink); }
.dc-search-count { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

mark.dc-search-hit { background: #fde68a; color: #1a1a1a; border-radius: 3px; padding: 0 1px; }
mark.dc-search-hit.is-current { background: var(--brand); color: #fff; }

/* "You are here" section indicator, shown only on mobile via .dc-mobile-bar */
.dc-mobile-bar {
  display: none;
  position: sticky; top: calc(var(--dc-header-h) + var(--dc-search-h)); z-index: 55;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  align-items: center; gap: 10px;
}
.dc-mobile-bar .dc-current {
  font-size: 0.82rem; font-weight: 700; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-mobile-bar select {
  margin-left: auto; max-width: 55%;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--ink); font-size: 0.85rem; font-weight: 600; padding: 7px 10px;
}
.dc-toc-btn {
  display: none;
  align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font-weight: 700; font-size: 0.82rem;
  padding: 7px 12px; cursor: pointer;
}

.dc-shell { max-width: 1320px; margin: 0 auto; display: flex; align-items: flex-start; }

.dc-sidebar {
  width: var(--dc-sidebar-w); flex: none;
  position: sticky; top: calc(var(--dc-header-h) + var(--dc-search-h));
  height: calc(100vh - var(--dc-header-h) - var(--dc-search-h));
  overflow-y: auto;
  padding: 26px 16px 60px 24px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--dc-note-line) transparent;
}
.dc-sidebar::-webkit-scrollbar { width: 6px; }
.dc-sidebar::-webkit-scrollbar-track { background: transparent; }
.dc-sidebar::-webkit-scrollbar-thumb {
  background: var(--dc-note-line);
  border-radius: 10px;
}
.dc-sidebar:hover::-webkit-scrollbar-thumb { background: var(--brand-dim); }
.dc-group { margin-bottom: 20px; }
.dc-group-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0 0 8px 10px;
}
.dc-group-label .dc-icon { width: 15px; height: 15px; color: var(--brand-dim); }

.dc-sidebar a.dc-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--body-text); font-size: 0.89rem; font-weight: 500;
}
.dc-sidebar a.dc-link .dc-icon { width: 15px; height: 15px; color: var(--muted); flex: none; }
.dc-sidebar a.dc-link:hover { background: var(--surface); text-decoration: none; color: var(--ink); }
.dc-sidebar a.dc-link.is-active { background: var(--dc-note-bg); color: var(--dc-note-ink); font-weight: 700; }
.dc-sidebar a.dc-link.is-active .dc-icon { color: var(--dc-note-ink); }

.dc-main { flex: 1; min-width: 0; padding: 40px 52px 60px; }
.dc-content { max-width: 800px; }

/* Hero */
.dc-hero { padding: 4px 0 34px; border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.dc-hero h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); margin: 0 0 12px; }
.dc-hero .lead { color: var(--muted); font-size: 1.06rem; max-width: 640px; margin: 0 0 22px; }
.dc-hero-note {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--dc-note-bg); color: var(--dc-note-ink);
  border: 1px solid var(--dc-note-line); border-radius: var(--radius);
  padding: 12px 16px; font-size: 0.88rem; max-width: 620px;
}
.dc-hero-note .dc-icon { width: 17px; height: 17px; margin-top: 2px; }
.dc-hero-note a { color: var(--dc-note-ink); font-weight: 700; text-decoration: underline; }

.dc-hero-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 26px; }
.dc-hero-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--surface); }
.dc-hero-card .dc-hcard-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--dc-note-bg); color: var(--brand-dim);
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.dc-hero-card .dc-hcard-icon .dc-icon { width: 19px; height: 19px; }
.dc-hero-card h4 { margin: 0 0 5px; font-size: 0.98rem; }
.dc-hero-card p { margin: 0 0 8px; font-size: 0.86rem; color: var(--muted); }
.dc-hero-card a { font-size: 0.85rem; font-weight: 700; }

/* Sections */
.dc-section { margin-bottom: 58px; scroll-margin-top: calc(var(--dc-header-h) + var(--dc-search-h) + 12px); }
.dc-kicker {
  display: flex; align-items: center; gap: 8px;
  color: var(--brand-dim); font-weight: 800; font-size: 0.8rem;
  letter-spacing: 0.03em; margin-bottom: 6px;
}
.dc-kicker .dc-icon { width: 16px; height: 16px; }
.dc-section h2 { font-size: 1.5rem; margin: 0 0 8px; scroll-margin-top: calc(var(--dc-header-h) + var(--dc-search-h) + 12px); }
.dc-section h3 { font-size: 1.14rem; margin: 34px 0 10px; scroll-margin-top: calc(var(--dc-header-h) + var(--dc-search-h) + 12px); }
.dc-section h4 { font-size: 1rem; margin: 22px 0 8px; }
.dc-section p { margin: 0 0 15px; }
.dc-section ul, .dc-section ol { margin: 0 0 16px; padding-left: 22px; }
.dc-section li { margin-bottom: 7px; }

.dc-def { color: var(--muted); font-size: 0.92rem; }

ol.dc-steps { padding-left: 0; list-style: none; counter-reset: step; }
ol.dc-steps li {
  counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 18px;
}
ol.dc-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -1px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--dc-note-bg); color: var(--dc-note-ink);
  font-weight: 800; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--dc-note-line);
}

table { width: 100%; border-collapse: collapse; margin: 8px 0 20px; font-size: 0.89rem; display: block; overflow-x: auto; }
table thead, table tbody { display: table; width: 100%; table-layout: fixed; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 800; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.02em; }

pre {
  background: var(--dc-code-bg); color: var(--dc-code-ink);
  border-radius: var(--radius); padding: 16px 18px 16px;
  overflow-x: auto; margin: 0 0 18px; font-size: 0.83rem; line-height: 1.55;
}
pre code { background: none; color: inherit; padding: 0; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
code { background: var(--surface-2); color: var(--ink); padding: 0.14em 0.4em; border-radius: 5px; font-size: 0.87em; font-family: 'IBM Plex Mono', ui-monospace, monospace; overflow-wrap: anywhere; word-break: break-word; }
pre code { font-size: inherit; overflow-wrap: normal; word-break: normal; white-space: pre; }

.dc-code-wrap { position: relative; }
.dc-copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,0.08); color: var(--dc-code-accent);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 6px;
  font-size: 0.72rem; font-family: 'Manrope', sans-serif; font-weight: 700;
  padding: 5px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.dc-copy-btn:hover { background: rgba(255,255,255,0.16); }
.dc-copy-btn .dc-icon { width: 13px; height: 13px; }

.dc-callout {
  display: flex; gap: 12px; align-items: flex-start;
  border-left: 3px solid var(--dc-note-line); background: var(--dc-note-bg);
  color: var(--dc-note-ink); border-radius: 0 8px 8px 0;
  padding: 14px 16px; margin: 0 0 20px; font-size: 0.89rem;
}
.dc-callout .dc-icon { width: 18px; height: 18px; margin-top: 1px; flex: none; }
.dc-callout.dc-warn { border-color: var(--dc-warn-line); background: var(--dc-warn-bg); color: var(--dc-warn-ink); }
.dc-callout strong { display: block; margin-bottom: 3px; }

.dc-kv { display: grid; grid-template-columns: 170px 1fr; gap: 5px 16px; font-size: 0.9rem; margin-bottom: 18px; }
.dc-kv dt { color: var(--muted); font-weight: 700; }
.dc-kv dd { margin: 0; overflow-wrap: anywhere; }

.dc-toc-inline {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 30px; background: var(--surface);
}
.dc-toc-inline p { margin: 0 0 8px; font-weight: 800; color: var(--ink); font-size: 0.83rem; text-transform: uppercase; letter-spacing: 0.02em; }
.dc-toc-inline ul { margin: 0; padding-left: 18px; font-size: 0.88rem; }

.dc-glossary dt { font-weight: 800; color: var(--ink); margin-top: 14px; }
.dc-glossary dd { margin: 4px 0 0; color: var(--body-text); }

.dc-divider { height: 1px; background: var(--line); margin: 46px 0; }

/* Prev / Next pagination */
.dc-pager {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 8px; padding-top: 30px; border-top: 1px solid var(--line);
}
.dc-pager-link {
  flex: 1; max-width: 48%;
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; color: var(--ink);
}
.dc-pager-link:hover { background: var(--surface); text-decoration: none; border-color: var(--brand); }
.dc-pager-link.dc-next { align-items: flex-end; text-align: right; margin-left: auto; }
.dc-pager-label { font-size: 0.72rem; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 5px; }
.dc-pager-title { font-weight: 700; font-size: 0.95rem; }

.dc-footer { max-width: 800px; padding-top: 30px; margin-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

/* ---------- Mobile ---------- */
@media (max-width: 980px) {
  .dc-hero-cards { grid-template-columns: 1fr; }
  .dc-mobile-bar { display: flex; }
  .dc-toc-btn { display: inline-flex; }

  .dc-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
    background: var(--bg);
    width: min(86vw, 330px);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.22);
    padding-top: 20px;
  }
  .dc-sidebar.is-open { transform: translateX(0); }
  .dc-sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(10,14,30,0.45); z-index: 110;
  }
  .dc-sidebar-backdrop.is-open { display: block; }

  .dc-main { padding: 22px 18px 80px; }
  .dc-content { max-width: 100%; font-size: 0.94rem; }
  .dc-search-bar { padding: 10px 16px; }
  .dc-search-count { display: none; }
  .dc-content .dc-hero h1 { font-size: 1.5rem; }
  .dc-content .dc-section h2 { font-size: 1.28rem; }
  .dc-content .dc-section h3 { font-size: 1.02rem; }
  .dc-content .dc-hero .lead { font-size: 0.96rem; }
  .dc-kv { grid-template-columns: 1fr; gap: 2px 0; }
  .dc-kv dt { margin-top: 8px; }
  .dc-kv dt:first-child { margin-top: 0; }
  table { font-size: 0.82rem; }
  .dc-pager { flex-direction: row; gap: 8px; }
  .dc-pager-link, .dc-pager-link.dc-next { max-width: 50%; padding: 10px 12px; }
  .dc-pager-title { font-size: 0.85rem; }
  .dc-pager-label { font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dc-sidebar { transition: none; }
}
