/* UltraCodey docs + legal shell — extends /assets/style.css + /assets/account.css.
   Side-tab sidebar (sticky), clean content column, optional right "on this page".
   Reuses the same tokens: --ink --muted --line --violet --radius --paper … */

:root {
  --ink-soft: #3a414f;   /* body copy: softer than --ink, still ~10:1 on white */
  --violet-soft: #f1efff; /* tinted violet surface (active tab, chips) */
}

/* ───────────────────────── skip link (a11y) ───────────────────────── */

.skip-link {
  position: absolute;
  left: 12px;
  top: -56px;
  z-index: 100;
  padding: 9px 15px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  font-weight: 850;
  font-size: 0.88rem;
  transition: top 160ms ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

/* ───────────────────────── layout shell ───────────────────────── */

.docs-layout {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 200px;
  gap: 40px;
  align-items: start;
  padding: clamp(24px, 4vw, 44px) 0 clamp(56px, 7vw, 88px);
}

/* When a page opts out of the right rail (legal pages), drop the third column. */
.docs-layout.no-toc {
  grid-template-columns: 248px minmax(0, 1fr);
  width: min(1040px, calc(100% - 40px));
}

/* ───────────────────────── left sidebar (side tabs) ───────────────────────── */

.docs-side {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  padding-right: 8px;
  /* thin, unobtrusive scrollbar */
  scrollbar-width: thin;
}

.docs-side::-webkit-scrollbar { width: 8px; }
.docs-side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

.docs-nav-group + .docs-nav-group {
  margin-top: 22px;
}

.docs-group-label {
  margin: 0 0 8px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.docs-nav-group ul {
  display: grid;
  gap: 2px;
}

.docs-nav-group a {
  display: block;
  padding: 7px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.docs-nav-group a:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.docs-nav-group a.active {
  color: var(--violet);
  border-left-color: var(--violet);
  background: var(--violet-soft);
  font-weight: 800;
}

.docs-nav-group a:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

/* Cross-link to the other section (Legal ⇄ Docs) gets a subtle divider. */
.docs-nav-group.linkout a {
  color: var(--ink);
  font-weight: 700;
}
.docs-nav-group.linkout a:hover { color: var(--violet); }

/* ───────────────────────── content column ───────────────────────── */

.docs-content {
  min-width: 0;
  max-width: 760px;
}

.doc-eyebrow {
  margin-bottom: 10px;
  color: var(--violet);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.docs-content h1 {
  max-width: none;
  margin: 0;
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.12;
  text-align: left;
}

.doc-updated {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.doc-lead {
  margin-top: 16px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.docs-content section {
  scroll-margin-top: 96px;
  padding-top: 14px;
}

.docs-content h2 {
  margin: 38px 0 0;
  padding-top: 8px;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.25;
}

.docs-content h3 {
  margin: 26px 0 0;
  font-size: 1.12rem;
  font-weight: 850;
  line-height: 1.3;
}

.docs-content p,
.docs-content li {
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.68;
}

.docs-content p { margin-top: 14px; }

.docs-content ul,
.docs-content ol {
  margin-top: 14px;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}

.docs-content ul { list-style: disc; }
.docs-content ol { list-style: decimal; }

.docs-content li::marker { color: var(--muted); }

.docs-content strong { color: var(--ink); font-weight: 800; }

.docs-content a:not(.button) {
  color: var(--violet);
  font-weight: 700;
}
.docs-content a:not(.button):hover { text-decoration: underline; }

.docs-content code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.86em;
}

.docs-content hr {
  margin: 40px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* callout / note box */
.doc-callout {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  border-radius: var(--radius);
  background: var(--paper-soft);
}

.doc-callout p { margin-top: 0; }
.doc-callout p + p { margin-top: 10px; }

.doc-callout.warn { border-left-color: var(--amber); background: var(--uc-amber-soft); }
.doc-callout strong { color: var(--ink); }

/* definition-ish rows (e.g. plan tiers, data types) */
.doc-deflist {
  margin-top: 16px;
  display: grid;
  gap: 0;
}
.doc-deflist > div {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.doc-deflist > div:last-child { border-bottom: 0; }
.doc-deflist dt {
  font-size: 0.96rem;
  font-weight: 850;
  color: var(--ink);
}
.doc-deflist dd {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.6;
}

/* legal section table of contents */
.legal-toc {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
}
.legal-toc-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.legal-toc ol {
  margin-top: 10px;
  columns: 2;
  column-gap: 28px;
}
.legal-toc a { font-size: 0.9rem; }

/* ───────────────────────── right "on this page" ───────────────────────── */

.docs-toc {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  font-size: 0.84rem;
}

.docs-toc-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.docs-toc a {
  display: block;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  line-height: 1.4;
  transition: color 160ms ease, border-color 160ms ease;
}

.docs-toc a:hover { color: var(--ink); }

.docs-toc a.active {
  color: var(--violet);
  border-left-color: var(--violet);
  font-weight: 700;
}

.docs-toc a:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

/* ───────────────────────── mobile sidebar toggle ───────────────────────── */

.docs-side-toggle {
  display: none;
}

.docs-side-toggle:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

@media (max-width: 1080px) {
  .docs-layout,
  .docs-layout.no-toc {
    grid-template-columns: 220px minmax(0, 1fr);
    width: min(100% - 32px, 1040px);
    gap: 30px;
  }
  .docs-toc { display: none; }
}

@media (max-width: 820px) {
  .docs-layout,
  .docs-layout.no-toc {
    display: block;
    width: min(100% - 28px, 1040px);
  }

  .docs-side-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    margin-bottom: 14px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--paper-solid);
    color: var(--ink);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
  }

  .docs-side-toggle::after {
    content: "▾";
    color: var(--muted);
    transition: transform 180ms ease;
  }
  .docs-side-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

  .docs-side {
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 22px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-soft);
  }

  .docs-side[hidden] { display: none; }

  .docs-content { max-width: none; }

  .docs-content h1 { font-size: 2.05rem; }

  .legal-toc ol { columns: 1; }
}
