/* ============================================================
   Docs (/docs, /docs/<section>) and API reference (/api-docs)
   Plain CSS on tokens. Prose typography lives in public.css (.prose-doc).
   ============================================================ */

/* Tailwind display utilities beat the UA [hidden] rule; keep hidden hidden. */
.doc-shell [hidden], .api-layout [hidden], #api-token-card [hidden] { display: none !important; }

/* --- Docs shell: sidebar + content -------------------------------------- */
.doc-shell {
  max-width: 72rem; margin: 0 auto; padding: 0 1rem;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0;
}
@media (min-width: 640px) { .doc-shell { padding: 0 1.5rem; } }
@media (min-width: 1024px) {
  .doc-shell { grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; }
}

.doc-sidebar { display: none; }
@media (min-width: 1024px) {
  .doc-sidebar {
    display: block; position: sticky; top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h)); overflow-y: auto;
    padding: 2rem 0.25rem 2rem 0; border-right: 1px solid rgb(var(--line-default));
  }
}

.doc-content { min-width: 0; padding: 1.5rem 0 4rem; }
@media (min-width: 1024px) { .doc-content { padding: 2.5rem 0 5rem; } }
.doc-article { max-width: 46rem; }
.doc-article:focus { outline: none; }

/* Section list (sidebar and mobile sheet share the markup) */
.doc-group {
  padding: 1rem 0.75rem 0.25rem; font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: rgb(var(--fg-faint));
}
.doc-group:first-child { padding-top: 0.25rem; }
.doc-link {
  position: relative; display: block; padding: 0.375rem 0.75rem; border-radius: var(--radius-sm);
  font-size: 0.875rem; color: rgb(var(--fg-muted));
  transition: color var(--duration-fast) var(--ease-out-expo), background-color var(--duration-fast) var(--ease-out-expo);
}
.doc-link:hover { color: rgb(var(--fg-default)); background: rgb(var(--bg-raised)); }
.doc-link[aria-current] { color: rgb(var(--fg-default)); background: rgb(var(--bg-raised)); font-weight: 500; }
.doc-link[aria-current]::before {
  content: ""; position: absolute; left: 0; top: 0.5rem; bottom: 0.5rem; width: 2px;
  border-radius: 2px; background: rgb(var(--accent-500));
}
.doc-search { margin-bottom: 0.75rem; position: relative; }
.doc-search .input { padding-left: 2rem; }
.doc-search i { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: rgb(var(--fg-subtle)); pointer-events: none; }
.doc-search-empty { padding: 0.5rem 0.75rem; font-size: 0.8125rem; color: rgb(var(--fg-subtle)); }

/* Mobile: in-flow sticky bar under the top bar (never at the bottom: the tab bar lives there) */
.doc-mobile-bar {
  position: sticky; top: var(--topbar-h); z-index: 5;
  display: flex; align-items: center; gap: 0.75rem;
  margin: 0 -1rem; padding: 0.5rem 1rem;
  background: rgb(var(--bg-base) / 0.9);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgb(var(--line-default));
}
@media (min-width: 640px) { .doc-mobile-bar { margin: 0 -1.5rem; padding: 0.5rem 1.5rem; } }
@media (min-width: 1024px) { .doc-mobile-bar { display: none; } }
.doc-mobile-current { font-size: 0.8125rem; color: rgb(var(--fg-muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-sheet-body { max-height: 70vh; overflow-y: auto; padding: 0.5rem 0.75rem 1rem; }

/* Content loading state during an HTMX swap */
#docs-content { transition: opacity var(--duration-fast) var(--ease-out-expo); }
#docs-content.htmx-request { opacity: 0.5; }

/* Body cells in doc tables may wrap (public.css keeps prose table cells on one line). */
.doc-article.prose-doc .table-wrap table td { white-space: normal; }
.doc-article.prose-doc .table-wrap table td:first-child { white-space: nowrap; }

/* --- API reference ------------------------------------------------------ */
.api-layout { display: flex; gap: 2.5rem; align-items: flex-start; }
.api-sidebar { display: none; }
@media (min-width: 1024px) {
  .api-sidebar {
    display: block; width: 12rem; flex-shrink: 0; position: sticky;
    top: calc(var(--topbar-h) + 1.5rem); max-height: calc(100vh - var(--topbar-h) - 3rem); overflow-y: auto;
  }
}
.api-section { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.api-section-title {
  font-size: 1.125rem; font-weight: 600; color: rgb(var(--fg-default));
  padding-bottom: 0.75rem; margin-bottom: 1rem; border-bottom: 1px solid rgb(var(--line-default));
}
.api-list {
  display: flex; flex-direction: column; border: 1px solid rgb(var(--line-default));
  border-radius: var(--radius-lg); background: rgb(var(--bg-raised)); overflow: hidden;
}
.api-group {
  padding: 0.75rem 1rem 0.375rem; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgb(var(--fg-subtle));
  border-top: 1px solid rgb(var(--line-default)); background: rgb(var(--bg-base) / 0.4);
}
.api-list > .api-group:first-child { border-top: 0; }
.api-endpoint {
  display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); column-gap: 0.75rem; row-gap: 0.25rem;
  align-items: center; width: 100%; text-align: left; padding: 0.75rem 1rem;
  border-top: 1px solid rgb(var(--line-subtle));
  transition: background-color var(--duration-fast) var(--ease-out-expo);
}
.api-list > .api-endpoint:first-child { border-top: 0; }
.api-endpoint:hover { background: rgb(var(--bg-overlay) / 0.7); }
.api-endpoint:focus-visible { outline-offset: -2px; }
@media (min-width: 768px) {
  .api-endpoint { grid-template-columns: 4.25rem minmax(0, 1fr) auto; }
}
.api-method { justify-content: center; font-family: var(--font-mono); font-size: 0.625rem; letter-spacing: 0.04em; }
.api-path { font-family: var(--font-mono); font-size: 0.8125rem; color: rgb(var(--fg-default)); overflow-wrap: anywhere; }
.api-param { color: rgb(var(--accent-400)); }
.api-desc { grid-column: 2; font-size: 0.75rem; color: rgb(var(--fg-subtle)); }
@media (min-width: 768px) { .api-desc { grid-column: 3; text-align: right; } }

.api-code {
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.65; white-space: pre; overflow-x: auto;
  padding: 0.875rem 1rem; border-radius: var(--radius-md);
  background: rgb(var(--bg-inset)); border: 1px solid rgb(var(--line-default)); color: rgb(var(--fg-default));
}
.api-response { min-height: 5rem; max-height: 26rem; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(var(--fg-muted)); }
.api-response[data-tone="ok"] { color: rgb(var(--fg-default)); }
.api-response[data-tone="error"] { color: rgb(var(--danger)); border-color: rgb(var(--danger) / 0.3); }
#api-status[data-tone="ok"] { color: rgb(var(--success)); }
#api-status[data-tone="error"] { color: rgb(var(--danger)); }
.api-inline {
  font-family: var(--font-mono); font-size: 0.75rem; padding: 0.05rem 0.3rem; border-radius: var(--radius-sm);
  background: rgb(var(--bg-inset)); border: 1px solid rgb(var(--line-default)); color: rgb(var(--fg-default));
}
