/* UnTXT documentation site — shell for the pages generated by
   scripts/generate-docs.js. Palette and type come from /tokens.css. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--ff-body);
  font-size: 16px;
  line-height: 1.6;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── header ───────────────────────────────────────────────────────────────── */

.docs-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
}

.docs-brand {
  font-family: var(--ff-display);
  font-size: 18px;
  color: var(--text-primary);
  text-decoration: none;
}
.docs-brand span { color: var(--text-tertiary); }

.back-to-app {
  margin-left: auto;
  font-size: 14px;
  color: var(--interactive);
  text-decoration: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
}
.back-to-app:hover { background: var(--hover-bg); color: var(--hover-fg); border-color: var(--hover-bg); }

.nav-toggle {
  display: none;
  align-items: center; gap: 8px;
  min-height: 36px; padding: 6px 12px;
  font: inherit; font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
}

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

.docs-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.docs-sidebar {
  position: sticky;
  top: 61px;
  height: calc(100vh - 61px);
  overflow-y: auto;
  padding: 20px 12px 40px 20px;
  border-right: 1px solid var(--border-light);
}

.nav-filter { display: block; margin-bottom: 14px; }
.nav-filter input {
  width: 100%;
  padding: 8px 10px;
  font: inherit; font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}
.nav-filter input:focus-visible {
  outline: 2px solid var(--interactive);
  outline-offset: 1px;
}

.docs-nav a {
  display: block;
  padding: 5px 10px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-lg);
}
.docs-nav a:hover { background: var(--tint-faint); color: var(--text-primary); }
.docs-nav a.active,
.docs-nav a.nav-home.active {
  background: var(--tint-strong);
  color: var(--text-primary);
}

.nav-home { margin-bottom: 10px; }

.nav-group { margin-bottom: 6px; }
.nav-group > summary {
  padding: 6px 10px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  cursor: pointer;
  list-style: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::before {
  content: '\25B8';
  display: inline-block;
  width: 14px;
  color: var(--text-muted);
}
.nav-group[open] > summary::before { content: '\25BE'; }
.nav-group ul { margin: 0 0 8px; padding: 0 0 0 14px; list-style: none; }

.nav-group.filtered-out { display: none; }
.docs-nav li.filtered-out { display: none; }

/* ── article ──────────────────────────────────────────────────────────────── */

.docs-main {
  padding: 28px 24px 80px;
  min-width: 0;
}

.docs-article {
  max-width: 72ch;
  color: var(--text-secondary);
}

.docs-article h1 {
  font-family: var(--ff-display);
  font-weight: var(--fw-heading);
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 20px;
  color: var(--text-primary);
}
.docs-article h2 {
  font-family: var(--ff-display);
  font-weight: var(--fw-heading);
  font-size: 22px;
  margin: 34px 0 10px;
  color: var(--text-primary);
  scroll-margin-top: 76px;
}
.docs-article h3 {
  font-size: 17px;
  font-weight: var(--fw-strong);
  margin: 22px 0 8px;
  color: var(--text-primary);
}
.docs-article p  { margin: 0 0 14px; }
.docs-article ul,
.docs-article ol { margin: 0 0 16px; padding-left: 22px; }
.docs-article li { margin-bottom: 5px; }
.docs-article a  { color: var(--interactive); }
.docs-article a:hover { color: var(--interactive-hover); }
.docs-article strong { color: var(--text-primary); }

.docs-article blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--interactive);
  background: var(--tint-faint);
  color: var(--text-secondary);
}

.docs-article hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 28px 0;
}

.docs-article code {
  font-family: var(--ff-mono);
  font-size: 0.9em;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: var(--radius);
}

.code-block {
  margin: 0 0 16px;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}
.code-block code {
  font-family: var(--ff-mono);
  font-size: 13px;
  line-height: 1.5;
  background: none;
  padding: 0;
  color: var(--text-primary);
  white-space: pre;
}

.table-wrap { overflow-x: auto; margin: 0 0 18px; }
.docs-article table { border-collapse: collapse; width: 100%; font-size: 14px; }
.docs-article th,
.docs-article td {
  border: 1px solid var(--border-light);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.docs-article th { background: var(--bg-secondary); color: var(--text-primary); }

.index-list { columns: 2; column-gap: 32px; }
@media (max-width: 640px) { .index-list { columns: 1; } }

/* ── on this page ─────────────────────────────────────────────────────────── */

.on-this-page {
  margin: 0 0 28px;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  font-size: 14px;
  max-width: 72ch;
}
.otp-title {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.on-this-page ul { margin: 0; padding-left: 18px; }
.on-this-page a { color: var(--interactive); text-decoration: none; }
.on-this-page a:hover { text-decoration: underline; }

/* ── embedded benchmark pages ─────────────────────────────────────────────── */

.embed-note { font-size: 14px; color: var(--text-tertiary); }
.embed-frame {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
}
.embed-frame iframe {
  display: block;
  width: 100%;
  height: min(1400px, 82vh);
  border: 0;
}
/* The benchmark pages are their own full-width documents — let them use the
   whole column rather than the 72ch prose measure. */
.docs-article:has(.embed-frame) { max-width: none; }

/* ── mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .back-to-app { padding: 6px 10px; }

  .docs-layout { grid-template-columns: minmax(0, 1fr); }

  .docs-sidebar {
    display: none;
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px 20px;
  }
  .docs-sidebar.open { display: block; }

  .docs-main { padding: 20px 20px 64px; }
}

@media (max-width: 520px) {
  .docs-brand span { display: none; }   /* keep the header on one line */
  .docs-header { gap: 10px; padding: 10px 14px; }
  .docs-article h1 { font-size: 25px; }
  .docs-article h2 { font-size: 20px; }
}

/* ── Gated pages ─────────────────────────────────────────────────────────── */
.doc-lock { font-size: 11px; opacity: .55; margin-left: 4px; }
.gated-note { font-size: 13px; color: var(--text-tertiary, #64748b); margin: 2px 0 8px; }
.gate-state {
  border: 1px solid var(--border-base, #e2e8f0); border-radius: 12px;
  padding: 22px 24px; background: var(--bg-secondary, #f8fafc); margin-top: 8px;
}
.gate-state p { margin: 0 0 14px; line-height: 1.6; }
.gate-state p:last-child { margin-bottom: 0; }
.gate-btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; text-decoration: none;
  background: var(--brand-ink, #1E1B4B); color: var(--on-brand, #FFFDF9);
  font-weight: var(--fw-strong, 700); font-size: 14px;
}
.gate-link { font-size: 14px; color: var(--interactive, #4338CA); margin-left: 10px; }

/* ── Footer ──────────────────────────────────────────────────────────────
   Every generated docs page carries this. It is the only route from a
   public page to any of our social accounts — before it existed the site
   linked to none of them, so a reader who wanted to follow had nowhere
   to go. Kept to one line of text and a row of names: this sits under
   pages people are reading because they are worried about an assessment,
   and a large footer would be reaching for attention at the wrong moment. */
.docs-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-base, #e2e8f0);
  font-size: 0.875rem;
  color: var(--text-tertiary, #64748b);
}
.docs-footer-line { margin: 0 0 0.75rem; }
.docs-footer-line a { color: inherit; text-decoration: underline; }
.docs-footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.docs-footer-social a {
  color: var(--interactive, #4338CA);
  text-decoration: none;
}
.docs-footer-social a:hover { text-decoration: underline; }
