/*
 * SpiderIQ Default Theme — custom overrides + prose styling.
 * Tailwind CDN loads via <script> tag in head.liquid.
 */

/* Custom color mappings via CSS variables (set by head.liquid) */
.bg-surface { background-color: var(--surface); }
.bg-surface-elevated { background-color: var(--surface-elevated); }
.bg-subtle { background-color: var(--subtle); }
.border-subtle { border-color: var(--subtle); }
.bg-primary { background-color: var(--primary); }
.text-primary { color: var(--primary); }
.border-primary { border-color: var(--primary); }

/* Prose styling for rendered content */
.prose { line-height: 1.75; }
.prose h1 { font-size: 2rem; font-weight: 600; margin-top: 2rem; margin-bottom: 1rem; }
.prose h2 { font-size: 1.5rem; font-weight: 600; margin-top: 1.75rem; margin-bottom: 0.75rem; }
.prose h3 { font-size: 1.25rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.prose p { margin-bottom: 1rem; }
.prose ul, .prose ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.25rem; }
.prose blockquote { border-left: 3px solid var(--primary); padding-left: 1rem; font-style: italic; color: #a1a1aa; }
.prose pre { background: #0A0A0B; border: 1px solid var(--subtle); border-radius: 0.5rem; padding: 1rem; overflow-x: auto; margin-bottom: 1rem; }
.prose code { font-size: 0.875rem; }
.prose img { border-radius: 0.5rem; margin: 1.5rem 0; }
.prose a { color: var(--primary); text-decoration: underline; }
.prose a:hover { opacity: 0.8; }
.prose hr { border-color: var(--subtle); margin: 2rem 0; }

.prose-invert { color: #d4d4d8; }
.prose-invert h1, .prose-invert h2, .prose-invert h3, .prose-invert h4 { color: #fff; }
.prose-invert strong { color: #fff; }
.prose-invert code { color: #e4e4e7; }

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Font */
body { font-family: system-ui, -apple-system, sans-serif; }
.font-serif { font-family: 'Georgia', serif; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

   DOCS THEME
   ========================================================================= */
:root {
  --docs-sidebar-w: 17rem;
  --docs-code-bg: #0b0b0d;
  --docs-header-h: 3.5rem;
  --docs-max: 92rem;
}

/* ---- Docs header --------------------------------------------------------- */
.docs-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--subtle);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
}
.docs-header-inner {
  max-width: var(--docs-max); margin: 0 auto; height: var(--docs-header-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
}
.docs-brand { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.docs-brand-name { font-family: var(--font-heading, serif); font-size: 1.05rem; color: #fff; }
.docs-topnav { display: none; align-items: center; gap: 0.35rem; }
.docs-topnav-link { font-size: 0.85rem; color: #a1a1aa; padding: 0.35rem 0.6rem; border-radius: 0.4rem; transition: all .15s; }
.docs-topnav-link:hover { color: #fff; background: var(--subtle); }
.docs-badge { margin-left: 0.4rem; font-size: 0.62rem; padding: 0.05rem 0.35rem; border-radius: 0.35rem; background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.docs-header-spacer { flex: 1; }
.docs-search-trigger {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.7rem; border: 1px solid var(--subtle); border-radius: 0.5rem;
  background: var(--surface-elevated); color: #8b8b90; font-size: 0.82rem; transition: all .15s;
}
.docs-search-trigger:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--subtle)); color: #d4d4d8; }
.docs-search-label { display: none; }
.docs-kbd, .docs-kbd { font-size: 0.7rem; padding: 0.05rem 0.35rem; border: 1px solid var(--subtle); border-radius: 0.3rem; color: #8b8b90; }
.docs-ask-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0.75rem; border-radius: 0.5rem; font-size: 0.82rem; font-weight: 600;
  color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  background: color-mix(in srgb, var(--primary) 10%, transparent); transition: all .15s;
}
.docs-ask-btn:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.docs-signin { font-size: 0.82rem; color: #d4d4d8; padding: 0.4rem 0.7rem; }
.docs-signin:hover { color: #fff; }
.docs-menu-toggle { display: inline-flex; color: #d4d4d8; padding: 0.3rem; margin-left: -0.3rem; }

/* ---- Three-column layout ------------------------------------------------- */
.docs-layout {
  max-width: var(--docs-max); margin: 0 auto;
  display: grid; grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr);
  align-items: start;
}

/* ---- Sidebar ------------------------------------------------------------- */
.docs-sidebar {
  position: sticky; top: var(--docs-header-h); align-self: start;
  height: calc(100vh - var(--docs-header-h));
  border-right: 1px solid var(--subtle);
}
.docs-sidebar-inner { height: 100%; overflow-y: auto; padding: 1.25rem 0.75rem 3rem; }
.docs-sidebar-scrim { display: none; }
.docs-filter { padding: 0 0.4rem 0.75rem; }
.docs-filter-input {
  width: 100%; font-size: 0.8rem; padding: 0.4rem 0.6rem;
  background: var(--surface-elevated); border: 1px solid var(--subtle); border-radius: 0.45rem; color: #e5e5e5;
}
.docs-filter-input:focus { outline: none; border-color: color-mix(in srgb, var(--primary) 50%, var(--subtle)); }
.docs-nav { font-size: 0.855rem; }
.docs-node--section > .docs-node-row { margin-top: 1rem; }
.docs-node-row { display: flex; align-items: center; }
.docs-node-link {
  flex: 1; display: block; padding: 0.3rem 0.6rem; border-radius: 0.4rem;
  color: #a1a1aa; text-decoration: none; transition: all .12s;
  border-left: 2px solid transparent; margin-left: -2px;
}
.docs-node-link:hover { color: #fff; background: var(--subtle); }
.docs-node-link.is-active { color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); border-left-color: var(--primary); font-weight: 500; }
.docs-node-link--section { color: #71717a; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.06em; font-weight: 600; padding-top: 0.4rem; padding-bottom: 0.2rem; }
.docs-node-link--section:hover { background: transparent; color: #a1a1aa; }
.docs-node-toggle { color: #71717a; padding: 0.25rem; transition: transform .15s; }
.docs-node-toggle[aria-expanded="false"] { transform: rotate(-90deg); }
.docs-node-children { padding-left: 0.7rem; margin-left: 0.3rem; border-left: 1px solid var(--subtle); }
.docs-node--collapsed > .docs-node-children { display: none; }
.docs-node--hidden { display: none; }

/* ---- Main column --------------------------------------------------------- */
.docs-main { min-width: 0; padding: 2.25rem 2rem 5rem; }
.docs-title { font-family: var(--font-heading, serif); font-size: 2rem; color: #fff; margin-bottom: 0.75rem; }

/* ---- API reference header ------------------------------------------------ */
.docs-api-head { border-bottom: 1px solid var(--subtle); padding-bottom: 1.25rem; margin-bottom: 1.5rem; }
.docs-base-url { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #8b8b90; }
.docs-base-url code { color: #e5e5e5; background: var(--surface-elevated); border: 1px solid var(--subtle); padding: 0.15rem 0.5rem; border-radius: 0.35rem; }
.docs-base-copy { color: #8b8b90; padding: 0.2rem; }
.docs-base-copy:hover { color: #fff; }

/* ---- Endpoint card (2-col: desc | sticky code) --------------------------- */
.ep-card {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 27rem);
  gap: 2.5rem; padding: 2.25rem 0; border-bottom: 1px solid var(--subtle);
  align-items: start; scroll-margin-top: 5rem;
}
.ep-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.ep-method {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem; border-radius: 0.3rem; text-transform: uppercase;
}
.ep-method--get { color: #5eead4; background: rgba(45,212,191,.14); border: 1px solid rgba(45,212,191,.3); }
.ep-method--post { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.ep-method--put { color: #93c5fd; background: rgba(96,165,250,.14); border: 1px solid rgba(96,165,250,.3); }
.ep-method--patch { color: #fbbf24; background: rgba(251,191,36,.14); border: 1px solid rgba(251,191,36,.3); }
.ep-method--delete { color: #fca5a5; background: rgba(248,113,113,.14); border: 1px solid rgba(248,113,113,.3); }
.ep-path { font-size: 0.92rem; color: #fff; word-break: break-all; }
.ep-summary { color: #fff; font-weight: 500; margin-bottom: 0.4rem; }
.ep-description { color: #a1a1aa; font-size: 0.9rem; line-height: 1.6; margin-bottom: 0.5rem; }
.ep-label { text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.08em; color: #71717a; font-weight: 600; margin: 1.4rem 0 0.6rem; }
.ep-params { display: flex; flex-direction: column; gap: 0.15rem; }
.ep-param { padding: 0.55rem 0; border-top: 1px solid var(--subtle); }
.ep-param:first-child { border-top: none; }
.ep-param-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ep-param-name { color: #fff; font-size: 0.82rem; }
.ep-param-type { color: var(--primary); font-size: 0.75rem; font-family: var(--font-mono); }
.ep-param-loc { color: #71717a; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ep-param-req { color: #fca5a5; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ep-param-desc { color: #a1a1aa; font-size: 0.82rem; margin-top: 0.25rem; }
.ep-responses { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.ep-responses li { display: flex; align-items: center; gap: 0.55rem; font-size: 0.82rem; color: #a1a1aa; }
.ep-status { font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 0.3rem; }
.ep-status--2 { color: #5eead4; background: rgba(45,212,191,.14); }
.ep-status--3 { color: #93c5fd; background: rgba(96,165,250,.14); }
.ep-status--4 { color: #fbbf24; background: rgba(251,191,36,.14); }
.ep-status--5 { color: #fca5a5; background: rgba(248,113,113,.14); }

/* ---- Sticky code panel --------------------------------------------------- */
.ep-code { position: sticky; top: calc(var(--docs-header-h) + 1.5rem); }
.ep-code-panel { background: var(--docs-code-bg); border: 1px solid var(--subtle); border-radius: 0.6rem; overflow: hidden; }
.ep-code-bar { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--subtle); background: color-mix(in srgb, var(--surface-elevated) 60%, transparent); }
.ep-req-line { display: flex; align-items: center; gap: 0.5rem; }
.ep-code-path { color: #d4d4d8; font-size: 0.78rem; word-break: break-all; }
.ep-code-tabs { display: flex; align-items: center; gap: 0.15rem; padding: 0.4rem 0.5rem 0; border-bottom: 1px solid var(--subtle); }
.ep-tab { font-size: 0.75rem; color: #8b8b90; padding: 0.35rem 0.6rem; border-radius: 0.35rem 0.35rem 0 0; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .12s; }
.ep-tab:hover { color: #d4d4d8; }
.ep-tab.is-active { color: #fff; border-bottom-color: var(--primary); }
.ep-copy { margin-left: auto; color: #8b8b90; padding: 0.3rem; margin-bottom: 0.2rem; }
.ep-copy:hover { color: #fff; }
.ep-copy.is-copied { color: #5eead4; }
.ep-code-bodies { max-height: 24rem; overflow: auto; }
.ep-code-body { display: none; margin: 0; padding: 0.85rem 1rem; font-size: 0.78rem; line-height: 1.6; color: #d4d4d8; background: transparent; white-space: pre; }
.ep-code-body.is-active { display: block; }
.ep-disclosure { border-top: 1px solid var(--subtle); }
.ep-disclosure summary { padding: 0.55rem 0.85rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: #8b8b90; cursor: pointer; list-style: none; }
.ep-disclosure summary::-webkit-details-marker { display: none; }
.ep-disclosure summary::before { content: "›"; display: inline-block; margin-right: 0.4rem; transition: transform .15s; }
.ep-disclosure[open] summary::before { transform: rotate(90deg); }
.ep-json { margin: 0; padding: 0 1rem 0.85rem; font-size: 0.75rem; color: #d4d4d8; overflow-x: auto; }
.ep-tryit-wrap { padding: 0.7rem 0.85rem; border-top: 1px solid var(--subtle); }
.ep-tryit {
  width: 100%; padding: 0.5rem; border-radius: 0.45rem; font-size: 0.8rem; font-weight: 600;
  color: #0a0a0b; background: var(--primary); transition: opacity .15s;
}
.ep-tryit:hover { opacity: 0.9; }
.ep-tryit[disabled] { opacity: 0.5; cursor: progress; }

/* ---- Try-it result ------------------------------------------------------- */
.ep-tryit-result { margin-top: 0.6rem; border-top: 1px solid var(--subtle); padding-top: 0.6rem; }
.ep-tryit-status { font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 0.3rem; }
.ep-tryit-out { margin: 0.4rem 0 0; padding: 0.6rem 0.75rem; background: #000; border-radius: 0.4rem; font-size: 0.72rem; color: #d4d4d8; max-height: 16rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.ep-tryit-form { padding: 0.7rem 0.85rem; border-top: 1px solid var(--subtle); display: flex; flex-direction: column; gap: 0.35rem; }
.ep-tryit-lbl { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: #71717a; margin-top: 0.3rem; }
.ep-tryit-in, .ep-tryit-ta { width: 100%; background: #000; border: 1px solid var(--subtle); border-radius: 0.4rem; padding: 0.4rem 0.55rem; color: #e5e5e5; font-size: 0.76rem; font-family: var(--font-mono); }
.ep-tryit-in:focus, .ep-tryit-ta:focus { outline: none; border-color: color-mix(in srgb, var(--primary) 50%, var(--subtle)); }
.ep-tryit-ta { resize: vertical; }
.ep-tryit-send { margin-top: 0.6rem; padding: 0.45rem; border-radius: 0.45rem; font-size: 0.78rem; font-weight: 600; color: #0a0a0b; background: var(--primary); }
.ep-tryit-send[disabled] { opacity: 0.6; cursor: progress; }

/* ---- Prose doc + TOC ----------------------------------------------------- */
.docs-article-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 14rem; gap: 3rem; align-items: start; }
.docs-article { max-width: 48rem; }
.docs-toc { position: sticky; top: calc(var(--docs-header-h) + 1.5rem); font-size: 0.8rem; }
.docs-toc-title { text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.08em; color: #71717a; font-weight: 600; margin-bottom: 0.6rem; }
.docs-toc-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; border-left: 1px solid var(--subtle); }
.docs-toc-list a { display: block; padding: 0.2rem 0 0.2rem 0.8rem; color: #8b8b90; border-left: 2px solid transparent; margin-left: -1px; transition: all .12s; }
.docs-toc-list a:hover { color: #d4d4d8; }
.docs-toc-list a.is-active { color: var(--primary); border-left-color: var(--primary); }
.docs-toc-list a[data-level="3"] { padding-left: 1.6rem; font-size: 0.76rem; }

/* ---- Inline codegroup (prose :::codegroup → tabs, upgraded by docs.js) ---- */
.codegroup { border: 1px solid var(--subtle); border-radius: 0.6rem; overflow: hidden; margin-bottom: 1.25rem; background: var(--docs-code-bg); }
.codegroup-tabs { display: flex; gap: 0.15rem; padding: 0.4rem 0.5rem 0; border-bottom: 1px solid var(--subtle); }
.codegroup-tab { font-size: 0.75rem; color: #8b8b90; padding: 0.35rem 0.6rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.codegroup-tab.is-active { color: #fff; border-bottom-color: var(--primary); }
.codegroup pre { margin: 0; border: none; border-radius: 0; background: transparent; }
.codegroup pre[data-language] { display: none; }
.codegroup pre.is-active { display: block; }

/* ---- Ask-AI panel -------------------------------------------------------- */
.docs-ask-panel { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; }
.docs-ask-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.docs-ask-dialog { position: relative; margin-top: 8vh; width: min(40rem, 92vw); background: var(--surface-elevated); border: 1px solid var(--subtle); border-radius: 0.75rem; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.docs-ask-header { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--subtle); color: #fff; font-weight: 600; }
.docs-ask-x { color: #8b8b90; }
.docs-ask-x:hover { color: #fff; }
.docs-ask-form { display: flex; gap: 0.5rem; padding: 0.85rem 1rem; }
.docs-ask-input { flex: 1; background: var(--surface); border: 1px solid var(--subtle); border-radius: 0.5rem; padding: 0.55rem 0.75rem; color: #fff; font-size: 0.9rem; }
.docs-ask-input:focus { outline: none; border-color: color-mix(in srgb, var(--primary) 50%, var(--subtle)); }
.docs-ask-send { padding: 0.55rem 1rem; border-radius: 0.5rem; background: var(--primary); color: #0a0a0b; font-weight: 600; font-size: 0.85rem; }
.docs-ask-body { max-height: 50vh; overflow-y: auto; padding: 0 1rem 1.25rem; color: #d4d4d8; font-size: 0.9rem; line-height: 1.65; }
.docs-ask-body:empty { display: none; }
.docs-ask-answer { white-space: pre-wrap; }
.docs-ask-sources { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--subtle); }
.docs-ask-sources a { display: block; color: var(--primary); font-size: 0.82rem; padding: 0.15rem 0; }
.docs-ask-loading { color: #8b8b90; }

/* ---- Responsive ---------------------------------------------------------- */
@media (min-width: 768px) { .docs-topnav { display: flex; } .docs-search-label { display: inline; } }
@media (min-width: 1024px) { .docs-menu-toggle { display: none; } }

@media (max-width: 1023px) {
  .docs-layout { display: block; }
  .docs-sidebar {
    position: fixed; top: 0; left: 0; z-index: 50; height: 100vh; width: min(20rem, 82vw);
    background: var(--surface); border-right: 1px solid var(--subtle);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .docs-sidebar.is-open { transform: translateX(0); }
  .docs-sidebar.is-open .docs-sidebar-scrim { display: block; position: fixed; inset: 0; left: min(20rem,82vw); background: rgba(0,0,0,.5); }
  .docs-main { padding: 1.5rem 1.1rem 4rem; }
}

@media (max-width: 1100px) {
  .ep-card { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .ep-code { position: static; }
  .docs-article-wrap { grid-template-columns: minmax(0, 1fr); }
  .docs-toc { display: none; }
}

/* FR-001 overlay — floating Ask-AI trigger (used when the docs top-bar isn't applied) */
.docs-ask-fab {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 55;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.6rem 0.95rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  color: #0a0a0b; background: var(--primary); border: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); cursor: pointer;
}
.docs-ask-fab:hover { opacity: 0.92; }

/* FR-001 overlay — docs landing index cards (readable on any brand palette) */
.docs-index-section { margin-bottom: 2.25rem; }
.docs-index-section-title { text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.08em; color: #71717a; font-weight: 600; margin-bottom: 0.8rem; }
.docs-index-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.docs-index-card { display: block; padding: 1rem 1.1rem; border: 1px solid var(--subtle); border-radius: 0.6rem; background: var(--docs-code-bg); transition: border-color .15s, transform .15s; text-decoration: none; }
.docs-index-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--subtle)); transform: translateY(-1px); }
.docs-index-card-title { color: #fff; font-weight: 500; font-size: 0.92rem; }
