/* ==========================================================================
   INFERISE DOCS
   Layout for docs.inferise.com. Colours, type and the header's brand pieces
   come from inferise.css (copied from code.inferise.com by the build), so the
   docs look like the rest of the site and switch theme the same way.
   ========================================================================== */

:root {
  --docs-sidebar: 16.5rem;
  --docs-toc: 13rem;
  --docs-measure: 46rem;
  --docs-gutter: clamp(1rem, 3vw, 2.5rem);
  --docs-header: 64px;
}

body.docs {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}
.skip-link:focus { left: 0.5rem; }

/* ---- Header ------------------------------------------------------------- */
.docs-header { height: var(--docs-header); }

.docs-header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.75rem);
  padding: 0 var(--docs-gutter);
}

.docs-header .brand-logo { height: 24px; width: auto; }
.brand-logo-link { display: flex; align-items: center; }

.docs-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.docs-products { display: flex; gap: 1.25rem; }
.docs-products .nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
}
.docs-products .nav-link:hover,
.docs-products .nav-link.is-current { color: var(--text-primary); }
.docs-products .nav-link.is-current { box-shadow: inset 0 -2px 0 var(--accent-primary); }

.docs-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 26rem;
  margin-left: auto;
}

.docs-search input {
  width: 100%;
  height: 38px;
  padding: 0 0.85rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.95rem;
}
.docs-search input:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.docs-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  z-index: 60;
}
.docs-search-results a {
  display: block;
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
}
.docs-search-results a:last-child { border-bottom: none; }
.docs-search-results a:hover,
.docs-search-results a.is-active { background: var(--bg-surface-hover); }
.docs-search-results strong { display: block; }
.sr-where { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sr-snippet { display: block; font-size: 0.875rem; color: var(--text-secondary); }
.search-empty { padding: 0.75rem 0.9rem; color: var(--text-secondary); margin: 0; }

.docs-header .header-actions { display: flex; align-items: center; gap: 0.5rem; }

.platform-picker select {
  height: 38px;
  padding: 0 0.6rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
}

/* ---- Three columns ------------------------------------------------------ */
.docs-layout {
  display: grid;
  grid-template-columns: var(--docs-sidebar) minmax(0, 1fr) var(--docs-toc);
  gap: clamp(1.5rem, 3vw, 3rem);
  max-width: 90rem;
  margin: 0 auto;
  padding: 0 var(--docs-gutter);
}

.docs-sidebar {
  position: sticky;
  top: var(--docs-header);
  align-self: start;
  max-height: calc(100vh - var(--docs-header));
  overflow-y: auto;
  padding: 2rem 0 3rem;
}

.docs-sidebar-nav ul { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.docs-sidebar-nav li a,
.side-home {
  display: block;
  padding: 0.3rem 0.75rem;
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
}
.side-home { font-weight: 600; color: var(--text-primary); margin-bottom: 1rem; }
.docs-sidebar-nav a:hover { color: var(--text-primary); }
.docs-sidebar-nav a.is-current {
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
  background: var(--accent-soft);
}
.side-heading {
  margin: 0 0 0.4rem;
  padding-left: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.docs-main { min-width: 0; padding: 2rem 0 4rem; }
.doc { max-width: var(--docs-measure); }

.docs-toc {
  position: sticky;
  top: var(--docs-header);
  align-self: start;
  padding: 2rem 0;
}
.toc-title { margin: 0 0 0.5rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.75rem;
  border-left: 2px solid var(--border-subtle);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.4;
}
.toc a:hover { color: var(--text-primary); }
.toc a.is-current { color: var(--text-primary); border-left-color: var(--accent-primary); }

/* ---- Page text ---------------------------------------------------------- */
.breadcrumbs { margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--text-muted); }
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text-primary); }

.doc h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
}
.page-summary { font-size: 1.2rem; color: var(--text-secondary); margin: 0 0 1rem; line-height: 1.5; }
.page-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 0 0 2rem; font-size: 0.875rem; color: var(--text-muted); }
.page-meta span { padding: 0.15rem 0.55rem; border: 1px solid var(--border-subtle); border-radius: 999px; }

.doc-body h2 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1.25;
  margin: 3rem 0 1rem;
  scroll-margin-top: calc(var(--docs-header) + 1rem);
}
.doc-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  scroll-margin-top: calc(var(--docs-header) + 1rem);
}
.doc-body h4 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
.doc-body .anchor {
  float: left;
  margin-left: -1.1em;
  width: 1.1em;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0;
}
.doc-body h2:hover .anchor,
.doc-body h3:hover .anchor { opacity: 1; }

.doc-body p,
.doc-body ul,
.doc-body ol { margin: 0 0 1.1rem; }
.doc-body ul { padding-left: 1.25rem; }
.doc-body li { margin-bottom: 0.4rem; }
.doc-body a { color: var(--accent-primary); text-underline-offset: 2px; }
.doc-body a:hover { color: var(--accent-hover); }
.doc-body strong { font-weight: 600; }
.doc-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
}
.doc-body pre { overflow-x: auto; padding: 1rem; border-radius: var(--radius-md); background: var(--bg-surface-elevated); }
.doc-body pre code { padding: 0; background: none; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--border-medium);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-sans);
  font-size: 0.85em;
  text-align: center;
  white-space: nowrap;
}
.menu-path { font-weight: 600; white-space: nowrap; }

/* Numbered steps: big counters, so a reader can keep their place. */
.doc-body ol.steps { list-style: none; counter-reset: step; padding-left: 0; }
.doc-body ol.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.75rem;
  margin-bottom: 1.25rem;
}
.doc-body ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.75rem;
  text-align: center;
}
.doc-body ol.steps > li > p:last-child { margin-bottom: 0; }

/* Callouts */
.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.callout > :last-child { margin-bottom: 0; }
.callout-title { margin: 0 0 0.35rem !important; font-weight: 600; }
.callout-important { border-left-color: var(--status-warning); }
.callout-privacy { border-left-color: var(--status-success); }

.summary-box {
  margin: 0 0 2rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
}
.summary-box > :last-child { margin-bottom: 0; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; }
.doc-body table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.doc-body th, .doc-body td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-subtle); text-align: left; vertical-align: top; }
.doc-body th { font-weight: 600; color: var(--text-secondary); }

/* ---- Figures: zoomed crops of the app, matching the page's theme -------- */
.shot { margin: 1.5rem 0 2rem; }
.doc-body ol.steps .shot { margin: 1rem 0 0.5rem; }
.shot-img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: var(--shadow-subtle);
}
.shot figcaption { margin-top: 0.6rem; font-size: 0.875rem; color: var(--text-secondary); }
.shot video { display: block; max-width: 100%; border-radius: 10px; border: 1px solid var(--border-subtle); }

.shot-light { display: none; }
.shot-dark { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .shot-light { display: block; }
  :root:not([data-theme="dark"]) .shot-dark { display: none; }
}
html[data-theme="light"] .shot-light { display: block; }
html[data-theme="light"] .shot-dark { display: none; }
html[data-theme="dark"] .shot-light { display: none; }
html[data-theme="dark"] .shot-dark { display: block; }

.shot-placeholder {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
  padding: 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.shot-placeholder span { font-weight: 600; color: var(--text-primary); }
.shot-placeholder code { font-size: 0.75rem; word-break: break-all; }

/* ---- Cards (product and section home pages) ---------------------------- */
.doc-cards, .product-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.doc-card, .product-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
}
.doc-body .doc-card { color: var(--text-primary); text-decoration: none; }
.doc-card:hover { border-color: var(--accent-border); background: var(--bg-surface-hover); }
.doc-card span { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.45; }
.card-time { margin-top: auto; padding-top: 0.4rem; color: var(--text-muted); font-size: 0.8rem; }
.product-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.product-card h2 { font-family: var(--font-serif); font-weight: 500; font-size: 1.6rem; margin: 0; }
.product-card h2 a { color: var(--text-primary); text-decoration: none; }
.product-card ul { margin: 0.25rem 0 1rem; padding-left: 1.1rem; }
.product-card .btn { align-self: flex-start; margin-top: auto; }
/* .doc-body a colours every link in the content; a button keeps its own white text. */
.doc-body a.btn-primary, .doc-body a.btn-primary:hover { color: #FFFFFF; text-decoration: none; }

/* ---- End of page --------------------------------------------------------- */
.related { margin-top: 3rem; }
.related ul { list-style: none; padding: 0; }
.related li { margin-bottom: 0.75rem; }
.related li a { font-weight: 600; }
.related li span { display: block; color: var(--text-secondary); font-size: 0.95rem; }

.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}
.pn {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
}
.pn:hover { border-color: var(--accent-border); }
.pn small { color: var(--text-muted); font-size: 0.8rem; }
.pn-next { text-align: right; grid-column: 2; }

.doc-help { margin-top: 2.5rem; font-size: 0.9rem; color: var(--text-muted); }
.doc-help a { color: var(--text-secondary); }

.docs-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.5rem var(--docs-gutter);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.docs-footer a { color: var(--text-secondary); margin-left: 1rem; text-decoration: none; }

/* ---- Narrower screens ---------------------------------------------------- */
@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: var(--docs-sidebar) minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  :root { --docs-gutter: 16px; }
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-menu-btn { display: inline-flex; }
  .docs-products { display: none; }
  .docs-sidebar {
    position: fixed;
    top: var(--docs-header);
    left: 0;
    bottom: 0;
    width: min(85vw, 20rem);
    max-height: none;
    padding: 1.5rem var(--docs-gutter);
    background: var(--bg-base);
    border-right: 1px solid var(--border-subtle);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
  }
  body.sidebar-open .docs-sidebar { transform: none; box-shadow: var(--shadow-elevated); }
  .docs-main { padding-top: 1.25rem; }
  .docs-header .brand-logo { height: 20px; }
  .brand-divider, .brand-subname { font-size: 1.1rem; }
}

@media (max-width: 560px) {
  .docs-header .brand-logo-link, .docs-header .brand-divider { display: none; }
  .docs-search { max-width: none; }
  .prev-next { grid-template-columns: 1fr; }
  .pn-next { grid-column: 1; }
  .doc-body ol.steps > li { padding-left: 2.4rem; }
}

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