/* RetaFunnel — docs layout (retafunnel.com/docs). Builds on the tokens in styles.css. */

.docs { padding: clamp(32px, 5vw, 64px) 0 clamp(56px, 8vw, 110px); min-height: 70vh; }
.docs-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: clamp(28px, 4vw, 64px); align-items: start; }

/* ---------- Sidebar ---------- */
.docs-side { position: sticky; top: calc(var(--nav-h) + 24px); max-height: calc(100vh - var(--nav-h) - 48px); overflow-y: auto; padding-right: 8px; }
.docs-side h4 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 22px 0 8px; font-weight: 500; }
.docs-side ul { display: grid; gap: 2px; }
.docs-side a {
  display: block; padding: 7px 12px; border-left: 2px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: var(--ink-2); line-height: 1.35; transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}
.docs-side a:hover { color: var(--ink); background: var(--surface-2); }
.docs-side a[aria-current="page"] { color: var(--ink); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.docs-side .docs-home { font-weight: 500; color: var(--ink); padding-left: 12px; }
.docs-side-toggle { display: none; }

/* ---------- Content ---------- */
.docs-content { min-width: 0; max-width: 72ch; }
.docs-content .label { margin-bottom: 18px; }
.docs-content h1 { font-size: clamp(34px, 4.4vw, 56px); max-width: 18ch; }
.docs-content .lede { margin-top: 16px; color: var(--ink-2); font-size: 18px; max-width: 60ch; }
.docs-body { margin-top: 36px; color: var(--ink-2); font-size: 16.5px; line-height: 1.65; }
.docs-body > :first-child { margin-top: 0; }

.docs-body h2, .docs-body h3, .docs-body h4 { position: relative; color: var(--ink); scroll-margin-top: 90px; }
.docs-body h2 { font-family: var(--font-body); font-size: 28px; font-weight: 500; letter-spacing: -0.015em; line-height: 1.2; margin: 44px 0 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.docs-body h3 { font-size: 20px; font-weight: 500; letter-spacing: -0.01em; margin: 32px 0 10px; }
.docs-body h4 { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; margin: 26px 0 8px; }
.docs-body .anchor { margin-left: 8px; color: var(--ink-4); font-weight: 400; opacity: 0; transition: opacity 0.2s; text-decoration: none; }
.docs-body h2:hover .anchor, .docs-body h3:hover .anchor, .docs-body h4:hover .anchor, .docs-body .anchor:focus-visible { opacity: 1; }
.docs-body .anchor:hover { color: var(--accent); }
.docs-body :is(h2, h3, h4):target { scroll-margin-top: 90px; }

.docs-body p { margin: 0 0 16px; }
.docs-body a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; transition: text-decoration-color 0.2s; }
.docs-body a:hover { text-decoration-color: var(--accent); }
.docs-body strong { color: var(--ink); font-weight: 600; }
.docs-body ul, .docs-body ol { margin: 0 0 18px; padding-left: 26px; display: grid; gap: 8px; }
.docs-body ul { list-style: disc; }
.docs-body ol { list-style: decimal; }
.docs-body li > ul, .docs-body li > ol { margin: 8px 0 0; }
.docs-body li::marker { color: var(--ink-3); font-family: var(--font-mono); font-size: 0.9em; }
.docs-body hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.docs-body img { border-radius: var(--radius-sm); border: 1px solid var(--line); }

.docs-body blockquote { margin: 0 0 18px; padding: 10px 18px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); }
.docs-body blockquote p:last-child { margin-bottom: 0; }

.docs-body code { font-family: var(--font-mono); font-size: 0.9em; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; overflow-wrap: anywhere; }
.docs-body h2 code, .docs-body h3 code { font-size: 0.85em; }
.docs-body .code { position: relative; margin: 0 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.docs-body .code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; -webkit-overflow-scrolling: touch; }
.docs-body .code code { font-size: inherit; color: var(--ink-2); background: none; border: 0; padding: 0; border-radius: 0; overflow-wrap: normal; white-space: pre; }
.docs-body .code .copy {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--ink-3);
  padding: 4px 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  opacity: 0.75; transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}
.docs-body .code:hover .copy, .docs-body .code .copy:focus-visible { opacity: 1; }
.docs-body .code .copy:hover { color: var(--ink); border-color: var(--ink-3); }
.docs-body .code .copy.done { color: var(--green); border-color: var(--green); opacity: 1; }

.docs-body .table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
.docs-body table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.docs-body th, .docs-body td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.docs-body th { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; color: var(--ink-3); background: var(--surface); white-space: nowrap; }
.docs-body tbody tr:last-child td { border-bottom: 0; }
.docs-body td code { white-space: nowrap; }

/* On this page */
.docs-toc { margin-top: 28px; padding: 14px 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.docs-toc-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.docs-toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; columns: auto; }
.docs-toc a { font-size: 14px; color: var(--ink-2); display: inline-block; padding: 2px 0; transition: color 0.2s; }
.docs-toc a:hover, .docs-toc a.is-active { color: var(--ink); }
.docs-toc a.is-active { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
@media (min-width: 600px) { .docs-toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Meta */
.docs-updated { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); letter-spacing: 0.02em; }
.docs-pn { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.docs-pn-item { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color 0.2s, transform 0.25s var(--ease); }
.docs-pn-item.next { text-align: right; }
.docs-pn-item.empty { border-color: transparent; }
.docs-pn-item:not(.empty):hover { border-color: var(--line-strong); transform: translateY(-2px); }
.docs-pn-label { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em; }
.docs-pn-title { font-size: 15px; color: var(--ink); font-weight: 500; }

/* ---------- Index ---------- */
.docs-index { max-width: none; }
.docs-cards { margin-top: 40px; }
.docs-cards h2 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; margin-bottom: 14px; }
.doc-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.doc-card { display: flex; flex-direction: column; gap: 8px; padding: 20px; min-height: 160px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color 0.25s, transform 0.25s var(--ease), background-color 0.25s; }
.doc-card:hover { border-color: var(--line-strong); transform: translateY(-2px); background: var(--surface-2); }
.doc-card h3 { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); }
.doc-card p { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.doc-card .more { margin-top: auto; padding-top: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--teal); }
.docs-help { margin-top: 40px; font-size: 14.5px; color: var(--ink-3); }
.docs-help a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 1100px) { .doc-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .doc-cards { grid-template-columns: minmax(0, 1fr); } .doc-card { min-height: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .docs { padding-top: 20px; }
  .docs-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .docs-side { position: static; max-height: none; overflow: visible; display: none; padding: 6px 0 14px; border-bottom: 1px solid var(--line); }
  .docs-side.open { display: block; }
  .docs-side h4 { margin-top: 14px; }
  .docs-side-toggle {
    display: inline-flex; align-items: center; gap: 8px; justify-self: start;
    font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--ink-2);
    padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  }
  .docs-side-toggle::before { content: ""; width: 12px; height: 1.5px; background: currentColor; box-shadow: 0 -4px 0 currentColor, 0 4px 0 currentColor; }
  .docs-side-toggle[aria-expanded="true"] { color: var(--ink); border-color: var(--ink-3); }
  .docs-content .lede { font-size: 17px; }
  .docs-body h2 { font-size: 24px; margin-top: 36px; }
  .docs-pn { grid-template-columns: minmax(0, 1fr); }
  .docs-pn-item.next { text-align: left; }
  .docs-pn-item.empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .doc-card, .docs-pn-item, .docs-body .code .copy, .docs-side a, .docs-body .anchor { transition: none; }
  .doc-card:hover, .docs-pn-item:not(.empty):hover { transform: none; }
}
