/* ════════════════════════════════════════════
   SupraBench API documentation styles.

   Layout: fixed left nav (docs sidebar), centered content
   column, optional right TOC. Standalone — does NOT load
   the SPA. Pages are individual HTML files so search engines
   index every endpoint.
   ════════════════════════════════════════════ */

@import url("/css/style.css");

html.docs-html, body.docs-body {
  height: auto;
  overflow: auto;
}

.docs-body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--bd);
  line-height: 1.65;
  /* Top padding leaves room for the sticky topbar (3.5rem) plus the
     iOS notch / Dynamic Island via env(). */
  padding-top: calc(env(safe-area-inset-top, 0px) + 3.5rem);
}

/* ── Top bar (shared with legal pages, but with active state for Docs) ── */
.docs-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  /* Bar grows to host the iOS notch / Dynamic Island. */
  height: calc(env(safe-area-inset-top, 0px) + 3.5rem);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: calc(env(safe-area-inset-left, 0px) + 1.5rem);
  padding-right: calc(env(safe-area-inset-right, 0px) + 1.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(3, 3, 3, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.docs-topbar__logo {
  font-family: var(--hd);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.docs-topbar__logo span { color: var(--accent); }
.docs-topbar__logo small {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text3);
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.5rem;
  vertical-align: middle;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.docs-topbar__nav {
  display: flex; gap: 1.4rem; align-items: center;
}
.docs-topbar__nav a {
  color: var(--text2);
  font-family: var(--hd);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: color var(--transition);
}
.docs-topbar__nav a:hover { color: var(--text); }
.docs-topbar__nav a.active { color: var(--accent); }
.docs-topbar__hamburger {
  display: none;
  background: none; border: 1px solid var(--border);
  color: var(--text);
  width: 2.2rem; height: 2.2rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

/* ── 3-column layout ──
   left: nav (sticky), center: content, right: page TOC (optional)
*/
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 2.5rem;
  max-width: 1280px;
  margin: 0 auto;
  /* Bottom padding lifts content above the iOS home indicator.
     Left/right pick up landscape notch insets. */
  padding: 2rem
           calc(env(safe-area-inset-right, 0px) + 1.5rem)
           calc(env(safe-area-inset-bottom, 0px) + 6rem)
           calc(env(safe-area-inset-left, 0px) + 1.5rem);
}
.docs-nav {
  position: sticky;
  /* Track the dynamic topbar height (3.5rem + iOS notch). */
  top: calc(env(safe-area-inset-top, 0px) + 4.5rem);
  align-self: start;
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - 5.5rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}
.docs-nav h4 {
  font-family: var(--hd);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  margin: 1.5rem 0 0.5rem;
  padding-left: 0.5rem;
}
.docs-nav h4:first-child { margin-top: 0; }
.docs-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border);
}
.docs-nav li { margin: 0; }
.docs-nav a {
  display: block;
  padding: 0.35rem 0.85rem;
  margin-left: -1px;
  color: var(--text2);
  font-size: 0.85rem;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.docs-nav a:hover { color: var(--text); }
.docs-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.docs-nav .badge-soon,
.docs-nav .badge-beta {
  font-size: 0.58rem;
  font-family: var(--hd);
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
  background: var(--surface);
  color: var(--text3);
  letter-spacing: 0.3px;
}
.docs-nav .badge-beta { background: rgba(255, 107, 53, 0.2); color: var(--accent); }

.docs-content {
  min-width: 0; /* prevent grid blowout from long code lines */
  max-width: 760px;
}
.docs-content h1 {
  font-family: var(--hd);
  font-weight: 700;
  font-size: 2.4rem;
  margin: 0 0 0.5rem;
  letter-spacing: -1px;
}
.docs-content h2 {
  font-family: var(--hd);
  font-weight: 600;
  font-size: 1.4rem;
  margin: 3rem 0 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: 5rem; /* anchor scrolling clears the topbar */
}
.docs-content h3 {
  font-family: var(--hd);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 2rem 0 0.5rem;
  scroll-margin-top: 5rem;
}
.docs-content p { margin: 0 0 1rem; color: var(--text); }
.docs-content p.lead {
  font-size: 1.05rem;
  color: var(--text2);
  margin-bottom: 2rem;
}
.docs-content ul, .docs-content ol { padding-left: 1.4rem; margin: 0 0 1rem; }
.docs-content li { margin: 0.3rem 0; color: var(--text); }
.docs-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.docs-content a:hover { text-decoration-thickness: 2px; }
.docs-content code {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 0.12rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
}
.docs-content blockquote {
  border-left: 3px solid var(--accent);
  background: rgba(255, 107, 53, 0.04);
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
  border-radius: 0 6px 6px 0;
  color: var(--text);
}

/* Status pills (next to page titles, endpoints, params) */
.pill {
  display: inline-block;
  font-family: var(--hd);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.5rem;
}
.pill-ga       { background: #2ea04330; color: #4ed26b; border: 1px solid #2ea04360; }
.pill-beta     { background: #e3b34130; color: #e3b341; border: 1px solid #e3b34160; }
.pill-soon     { background: #ff6b3530; color: #ffb38a; border: 1px solid #ff6b3560; }
.pill-required { background: #f8514930; color: #ff8b85; border: 1px solid #f8514960; }
.pill-optional { background: var(--surface); color: var(--text3); border: 1px solid var(--border); }

/* Demand-gated banner across all docs pages */
.preview-banner {
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.08), rgba(255, 107, 53, 0.02));
  border: 1px solid rgba(255, 107, 53, 0.4);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 0 0 2rem;
  font-size: 0.9rem;
}
.preview-banner strong { color: var(--accent); }

/* Endpoint header block: METHOD + path */
.endpoint {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0 1.5rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  word-break: break-all;
}
.method {
  display: inline-block;
  font-family: var(--hd);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.method-GET    { background: #2ea04330; color: #4ed26b; border: 1px solid #2ea04360; }
.method-POST   { background: #1f6feb30; color: #79b8ff; border: 1px solid #1f6feb60; }
.method-DELETE { background: #f8514930; color: #ff8b85; border: 1px solid #f8514960; }

/* Parameter table */
.params {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 2rem;
  font-size: 0.88rem;
}
.params th, .params td {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.params th {
  font-family: var(--hd);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.params .name {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.88rem;
}
.params .type {
  font-family: var(--mono);
  color: var(--text3);
  font-size: 0.78rem;
}
.params .desc { color: var(--text); }
.params .desc small { display: block; color: var(--text3); font-size: 0.78rem; margin-top: 0.25rem; }

/* Code block with optional language tabs + copy button */
.code-block {
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #050505;
}
.code-tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--hd);
  font-size: 0.72rem;
}
.code-tab {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  padding: 0.55rem 0.95rem;
  color: var(--text3);
  cursor: pointer;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-family: inherit;
  transition: color var(--transition), background var(--transition);
}
.code-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.code-tab.active {
  color: var(--accent);
  background: #050505;
  position: relative;
}
.code-tab.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.code-tab .lang-icon {
  display: inline-block;
  width: 0.6rem; height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  background: var(--text3);
}
.code-tab.active .lang-icon { background: var(--accent); }

.code-pane {
  position: relative;
  display: none;
}
.code-pane.active { display: block; }
.code-pane pre {
  margin: 0;
  padding: 1rem 1.1rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: #e6e6e6;
  background: transparent;
}
.code-pane pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}
.code-copy {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: var(--hd);
  font-size: 0.65rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition);
}
.code-pane:hover .code-copy { opacity: 1; }
.code-copy.copied { color: var(--accent); border-color: var(--accent); }

/* Inline syntax-ish color hints (very lightweight, no JS highlighter to keep fast) */
.code-pane pre .k  { color: #ff8b85; }   /* keyword */
.code-pane pre .s  { color: #c5e478; }   /* string  */
.code-pane pre .c  { color: #6a737d; font-style: italic; } /* comment */
.code-pane pre .n  { color: #b392f0; }   /* number  */
.code-pane pre .fn { color: #79b8ff; }   /* function/method */
.code-pane pre .v  { color: #ffb38a; }   /* variable */

/* Right-side TOC */
.docs-toc {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  font-size: 0.8rem;
}
.docs-toc h5 {
  font-family: var(--hd);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  margin: 0 0 0.6rem;
}
.docs-toc ul { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--border); }
.docs-toc a {
  display: block;
  color: var(--text3);
  text-decoration: none;
  padding: 0.25rem 0.75rem;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}
.docs-toc .toc-h3 { padding-left: 1.4rem; font-size: 0.78rem; }

/* "Last updated" + reading time meta line */
.docs-meta {
  font-size: 0.75rem;
  color: var(--text3);
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.docs-meta span::before { content: "·"; margin-right: 0.5rem; color: var(--border); }
.docs-meta span:first-child::before { content: ""; margin: 0; }

/* "Next / Previous" footer nav between pages */
.docs-pagenav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.docs-pagenav a {
  display: block;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition);
}
.docs-pagenav a:hover { border-color: var(--accent); }
.docs-pagenav a.next { text-align: right; }
.docs-pagenav small {
  display: block;
  font-family: var(--hd);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  margin-bottom: 0.25rem;
}
.docs-pagenav strong {
  font-family: var(--hd);
  font-size: 0.95rem;
  font-weight: 600;
}

/* Tier table on landing/rate-limits pages */
.tier-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 2rem;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.tier-table th, .tier-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tier-table th {
  font-family: var(--hd);
  font-weight: 600;
  background: var(--surface);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text2);
}
.tier-table tr:last-child td { border-bottom: none; }
.tier-table .check { color: #4ed26b; font-weight: 700; }
.tier-table .cross { color: var(--text3); }

/* Card grid for landing-page section links */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
.docs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none !important;
  color: var(--text) !important;
  transition: border-color var(--transition), transform var(--transition);
}
.docs-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.docs-card h3 {
  font-family: var(--hd);
  font-size: 1rem;
  margin: 0 0 0.4rem;
  color: var(--text);
}
.docs-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.5;
}

/* ── Mobile ────────────────────────────────────────── */
@media (max-width: 1100px) {
  .docs-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 2rem;
  }
  .docs-toc { display: none; }
}
@media (max-width: 800px) {
  .docs-layout {
    grid-template-columns: 1fr;
    padding: 1rem
             calc(env(safe-area-inset-right, 0px) + 1rem)
             calc(env(safe-area-inset-bottom, 0px) + 4rem)
             calc(env(safe-area-inset-left, 0px) + 1rem);
  }
  .docs-topbar__hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .docs-topbar__nav { display: none; }
  .docs-topbar__nav.is-open {
    display: flex;
    position: absolute;
    /* Drops down from the dynamic-height bar (3.5rem + iOS notch). */
    top: calc(env(safe-area-inset-top, 0px) + 3.5rem);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0;
    min-width: 180px;
  }
  .docs-topbar__nav.is-open a {
    padding: 0.7rem 1rem;
    width: 100%;
  }

  .docs-nav {
    position: static;
    max-height: none;
    margin-bottom: 2rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
  }
  .docs-nav-toggle {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.7rem 1rem;
    color: var(--text);
    font-family: var(--hd);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
  }
  .docs-nav-collapsible { display: none; }
  .docs-nav-collapsible.is-open { display: block; }

  .docs-content h1 { font-size: 1.9rem; }
  .docs-content h2 { font-size: 1.2rem; }

  .endpoint { font-size: 0.78rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .params { font-size: 0.82rem; }
  .params th, .params td { padding: 0.55rem 0.6rem; }

  .docs-pagenav { grid-template-columns: 1fr; }

  /* Tables can easily exceed viewport width on phones (tier table has
     6 columns, params table has long type cells). Without this rule,
     the whole page scrolls horizontally. Switching the table itself
     to a scrolling block contains the overflow and leaves the rest
     of the article in place. Trade-off: the border-radius-clip on
     .tier-table is lost on mobile, which is acceptable. */
  .docs-content .tier-table,
  .docs-content .params {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    /* Subtle shadow hint on the right edge tells the user there's
       more to scroll; hidden once scrolled. */
    background-image:
      linear-gradient(to right, var(--bg) 30%, transparent),
      linear-gradient(to left,  var(--bg) 30%, transparent);
    background-position: left center, right center;
    background-repeat: no-repeat;
    background-size: 20px 100%, 20px 100%;
    background-attachment: local, local;
  }
  /* Prevent cell text from wrapping into ultra-narrow columns inside
     the scrolling table — keep natural column widths. */
  .docs-content .tier-table th,
  .docs-content .tier-table td {
    white-space: nowrap;
  }
  .docs-content .params th,
  .docs-content .params td:first-child {
    white-space: nowrap;
  }
}
@media (min-width: 801px) {
  .docs-nav-toggle { display: none; }
  .docs-nav-collapsible { display: block !important; }
}
