/* =====================================================
   COIxist — Documentation, legal and company pages
   ("Paper & Ink"). Loaded after tokens.css, fonts.css and
   base.css. The docs page uses the sidebar layout; the
   reading pages (about, security, privacy, terms) add
   .docs-layout--reading and drop the sidebar.
   ===================================================== */

/* ─── LAYOUT ─── */
.docs-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: clamp(32px, 4vw, 72px);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

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

/* ─── SIDEBAR ─── */
.docs-sidebar {
  position: sticky;
  top: var(--nav-height);
  align-self: start;
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: 32px 16px 48px 0;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.docs-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}

.docs-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
}

.docs-search input {
  width: 100%;
  height: 40px;
  padding: 0 64px 0 36px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 200ms;
}

.docs-search input::placeholder { color: var(--text-3); }
.docs-search input:focus { border-color: var(--text); }

.docs-search kbd {
  position: absolute;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  background: var(--paper);
}

.docs-search-clear {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--text-3);
  background: var(--paper-2);
}

.docs-search-clear:hover { color: var(--text); }
.docs-search:has(.docs-search-clear:not([hidden])) kbd { display: none; }

.docs-sidebar-section { margin-bottom: 26px; }

.docs-sidebar-heading {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 8px;
  padding-left: 12px;
}

.docs-sidebar-link {
  display: block;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-2);
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: color 160ms, background-color 160ms;
}

.docs-sidebar-link:hover { color: var(--text); background: var(--paper-2); }

.docs-sidebar-link.active {
  color: var(--text);
  background: var(--paper-2);
  border-left-color: var(--text);
  border-radius: 0 6px 6px 0;
}

/* ─── CONTENT ─── */
.docs-content { min-width: 0; }

.docs-content-inner {
  max-width: var(--measure);
  padding: clamp(40px, 5vw, 72px) 0 clamp(64px, 8vw, 120px);
}

.docs-layout--reading .docs-content-inner {
  margin: 0 auto;
  max-width: 760px;
}

.docs-article {
  padding-bottom: clamp(40px, 5vw, 64px);
  margin-bottom: clamp(40px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
}

.docs-article:last-of-type { border-bottom: 0; margin-bottom: 0; }

.docs-breadcrumb {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 16px;
}

.docs-article h1 {
  font-size: clamp(36px, 4.4vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin-bottom: 28px;
}

.docs-body .docs-article h2 {
  font-size: clamp(28px, 3vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.docs-article h2 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 44px 0 14px;
}

.docs-article h2:first-of-type { margin-top: 0; }

.docs-body .docs-article h3,
.docs-article h3 {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 32px 0 10px;
}

.docs-body .docs-article h3 { font-weight: 400; font-size: 21px; }

.docs-article h4 {
  font-size: 16px;
  font-weight: 500;
  margin: 24px 0 8px;
}

.docs-article p {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-2);
  margin-bottom: 14px;
}

.docs-article > p:first-of-type,
.docs-article h1 + p {
  color: var(--text);
}

.docs-article a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: text-decoration-color 160ms;
}

.docs-article a:hover { text-decoration-color: var(--text); }

.docs-article ul, .docs-article ol {
  margin: 0 0 16px 22px;
}

.docs-article li {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-2);
  margin-bottom: 8px;
  padding-left: 4px;
}

.docs-article li::marker { color: var(--text-3); }

.docs-article strong { color: var(--text); font-weight: 500; }

.docs-article code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
}

.docs-article pre {
  margin: 16px 0 20px;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--text-on-ink);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

.docs-article pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ─── TABLES ─── */
.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 14.5px;
}

.docs-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12.5px;
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--line-strong);
}

.docs-table td {
  padding: 11px 12px 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  vertical-align: top;
  line-height: 1.5;
}

.docs-table td:first-child { color: var(--text); }
.docs-table tr:last-child td { border-bottom: 0; }

@media (max-width: 768px) {
  .docs-table { display: block; overflow-x: auto; }
}

/* ─── CALLOUTS + BADGES ─── */
.docs-callout {
  margin: 20px 0 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--text);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--paper-2);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-2);
}

.docs-callout strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.docs-callout--info { border-left-color: var(--accent); }
.docs-callout--warning { border-left-color: var(--risk-medium); }

.docs-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid currentColor;
  vertical-align: middle;
  margin-left: 6px;
}

.docs-badge--red { color: var(--risk-high); }
.docs-badge--blue { color: var(--risk-low); }
.docs-badge--yellow { color: var(--risk-medium); }
.docs-badge--gray { color: var(--text-3); }

/* ─── TABS ─── */
.docs-tabs { margin: 20px 0 24px; }

.docs-tab-buttons {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.docs-tab-btn {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 160ms, border-color 160ms;
}

.docs-tab-btn:hover { color: var(--text); }
.docs-tab-btn.active { color: var(--text); border-bottom-color: var(--text); }
.docs-tab-content { display: none; padding: 18px 0 4px; }
.docs-tab-content.active { display: block; }

/* ─── LEGAL META ─── */
.legal-meta {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.legal-meta p { font-size: 14.5px; color: var(--text-2); margin-bottom: 6px; }
.legal-meta strong { color: var(--text); }

/* ─── SEARCH STATE ─── */
.docs-article.is-hidden,
.docs-sidebar-link.is-hidden,
.docs-sidebar-section.is-hidden { display: none; }

.docs-search-status {
  font-size: 14px;
  color: var(--text-2);
  padding: 12px 16px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
}

.docs-search-status:empty { display: none; }
.docs-search-status.is-empty-state { color: var(--text); }

/* ─── MOBILE DRAWER ─── */
.docs-subbar {
  display: none;
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 10px var(--gutter);
}

.docs-nav-hamburger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 6px 0;
}

.docs-nav-hamburger::before {
  content: '';
  width: 14px;
  height: 10px;
  border-top: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.docs-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 17, 22, 0.35);
  z-index: 101;
}

.docs-backdrop.is-visible { display: block; }

@media (max-width: 960px) {
  .docs-layout { grid-template-columns: 1fr; gap: 0; }
  .docs-subbar { display: block; }
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(320px, 86vw);
    background: var(--paper);
    padding: 24px 20px 40px;
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 260ms var(--ease);
    z-index: 102;
  }
  .docs-sidebar.is-open { transform: none; }
  body.docs-drawer-open { overflow: hidden; }
  .docs-content-inner { padding-top: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .docs-sidebar { transition: none; }
}

@media print {
  .nav, .bar, .docs-sidebar, .docs-subbar, .footer, .docs-search { display: none !important; }
  .docs-layout { display: block; padding: 0; }
  .docs-article { page-break-inside: avoid; }
}
