/* ============================================================ */
/* INSTABOOKS — Documentation (/docs/db)                         */
/* Sidebar + long-form technical body. Builds on main.css.       */
/* ============================================================ */

/* ---------- Hero ---------- */

/* One hero for the whole section, so it reads as a masthead: centered, with
   the title and lede on the same axis rather than ranged left against an
   empty right half. */
.docs-hero {
  padding: 64px 0 56px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.docs-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin: 0 auto 16px;
  color: var(--ink);
  max-width: 800px;
}

.docs-hero .page-lede {
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--muted);
  margin: 0 auto;
  max-width: 600px;
}

/* ---------- Page actions ---------- */

.docs-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 24px 0 0;
}

/* In the content column it sits under the page title, not the lede. */
.docs-body .docs-actions {
  margin: 0 0 28px;
}

/* The body styles every link; these are controls, not prose. */
.docs-body a.docs-action {
  color: var(--muted);
  text-decoration: none;
}

.docs-body a.docs-action:hover { color: var(--ink); }

.docs-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms ease;
}

.docs-action:first-child { padding-left: 0; }

.docs-action + .docs-action { border-left: 1px solid var(--line); }

.docs-action:hover { color: var(--ink); }

.docs-action[disabled] { color: var(--brand); cursor: default; }

.docs-action svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* The markdown badge's viewBox is wider than tall; size by height so its
   glyph reads at the same visual size as the square copy icon. */
.docs-action-md svg {
  width: auto;
  height: 15px;
}

/* ---------- Two-column layout ---------- */

.docs-main {
  background: var(--section);
  padding: 40px 0 96px;
}

.docs-layout {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

/* ---------- Sidebar ---------- */

.docs-nav {
  position: sticky;
  top: 24px;
  font-size: 0.94rem;
}

.docs-nav h2 {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.docs-nav h2 + ul { margin-bottom: 28px; }

.docs-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-nav li { margin: 0 0 2px; }

.docs-nav a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  line-height: 1.4;
  transition: background 120ms ease, color 120ms ease;
}

.docs-nav a:hover {
  background: var(--section-2);
  color: var(--ink);
}

.docs-nav a[aria-current="page"] {
  background: var(--brand-tint);
  color: var(--brand-deep);
  font-weight: 600;
}

/* ---------- Body typography ---------- */

/* One column edge for everything. Capping the text narrower than the
   figures and tables beside it just makes the right margin jog. */
.docs-body { max-width: 780px; }

/* The page's own title, in the content column — the hero above it is fixed
   for the whole section. */
.docs-body .docs-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  color: var(--ink);
}

.docs-body .docs-lede {
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 8px;
}

.docs-body h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 52px 0 14px;
  padding-top: 4px;
  color: var(--ink);
}

.docs-body > h2:first-child { margin-top: 0; }

.docs-body h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.3;
  margin: 34px 0 10px;
  color: var(--ink);
}

.docs-body h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  margin: 26px 0 8px;
  color: var(--ink-soft);
}

.docs-body p {
  font-size: 1.03rem;
  line-height: 1.72;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

.docs-body ul,
.docs-body ol {
  margin: 0 0 18px;
  padding-left: 22px;
}

.docs-body li {
  font-size: 1.03rem;
  line-height: 1.7;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.docs-body li > p { margin: 0 0 8px; }

.docs-body strong { color: var(--ink); font-weight: 600; }

.docs-body a {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.docs-body a:hover { color: var(--brand-deep); }

/* Inline UI-reference icon, e.g. the gear next to "Settings". Sized to sit
   on the text baseline; overflow: visible because the glyph draws slightly
   outside its own viewBox (a Font Awesome quirk, not a bug here). */
.ui-gear-icon {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  overflow: visible;
  vertical-align: -0.12em;
  margin: 0 0.06em;
}

.docs-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--section-2);
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink);
  word-break: break-word;
}

/* ---------- Code blocks ---------- */

.docs-body pre {
  font-family: var(--font-mono);
  font-size: 0.87rem;
  line-height: 1.6;
  background: #0f1c21;
  color: #e6efe9;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.docs-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  word-break: normal;
}

/* Hand-applied syntax tokens — no highlighter, no JS. Each code block's
   keywords/strings/comments/numbers are wrapped in these spans by hand
   when the block is written. Colors sit on the pre's dark background. */
.tok-kw  { color: #7dd3fc; }
.tok-str { color: #86efac; }
.tok-com { color: #6b8494; font-style: italic; }
.tok-num { color: #fbbf87; }

/* A block labelled with what it is — "SQL", "Terminal", "Python". */
.docs-code {
  margin: 0 0 22px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.docs-code .docs-code-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--section-2);
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

.docs-code pre {
  margin: 0;
  border-radius: 0;
}

/* ---------- Connection field table ---------- */

.docs-body .conn-fields {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 0.97rem;
}

.docs-body .conn-fields th,
.docs-body .conn-fields td {
  text-align: left;
  vertical-align: top;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}

.docs-body .conn-fields thead th {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
}

.docs-body .conn-fields tbody th {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  width: 140px;
}

.docs-body .conn-fields td code { white-space: nowrap; }

/* ---------- General tables ---------- */

.docs-body .table-wrap {
  overflow-x: auto;
  margin: 0 0 24px;
}

.docs-body table.docs-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.94rem;
  line-height: 1.55;
}

.docs-body table.docs-table th:first-child {
  width: 200px;
}

.docs-body #query-errors-table .docs-table th.means-col {
  width: 200px;
}

.docs-body table.docs-table th,
.docs-body table.docs-table td {
  text-align: left;
  vertical-align: top;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}

.docs-body table.docs-table th {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
}

.docs-body table.docs-table tbody tr:nth-child(even) { background: var(--section-2); }

.docs-body table.docs-table code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
}

/* ---------- Callouts ---------- */

.docs-body .note,
.docs-body .warn {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 0 0 22px;
  font-size: 0.97rem;
  line-height: 1.65;
}

.docs-body .note {
  background: var(--brand-tint);
  border-left: 3px solid var(--brand);
}

.docs-body .warn {
  background: #fdf3e7;
  border-left: 3px solid #c98a2e;
}

.docs-body .note p:last-child,
.docs-body .warn p:last-child { margin-bottom: 0; }

.docs-body .note strong { color: var(--brand-deep); }

/* ---------- Numbered walkthrough steps ---------- */

.docs-steps {
  list-style: none;
  counter-reset: docs-step;
  margin: 0 0 28px;
  padding: 0;
}

.docs-steps > li {
  counter-increment: docs-step;
  position: relative;
  padding: 0 0 30px 52px;
  margin: 0;
  border-left: 1px solid var(--line);
}

.docs-steps > li:last-child {
  border-left-color: transparent;
  padding-bottom: 4px;
}

.docs-steps > li::before {
  content: counter(docs-step);
  position: absolute;
  left: -16px;
  top: -2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-deep);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.docs-steps > li > h3 {
  margin: 4px 0 10px;
  font-size: 1.08rem;
}

.docs-steps > li > *:last-child { margin-bottom: 0; }

/* ---------- Screenshots ---------- */

.docs-body figure.shot {
  margin: 0 0 28px;
  max-width: 780px;
}

.docs-body figure.shot img {
  width: 100%;
  height: auto;
  border: 1px solid color-mix(in oklab, var(--line), #000 22%);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  background: var(--section-2);
}

.docs-body figure.shot figcaption {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 10px;
}

/* Narrow shots — dialogs, prompts — sit at half width on wide screens. */
.docs-body figure.shot.narrow img { max-width: 460px; }

/* A shot whose file is not in the tree yet renders as a labelled slot
   instead of a broken image. docs-shots.js sets .missing on error. */
.docs-body figure.shot.missing img { display: none; }

.docs-body figure.shot.missing .shot-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--section-2);
}

.docs-body figure.shot .shot-slot { display: none; }

.shot-slot-label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.shot-slot-path {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brand-deep);
  background: var(--section);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  word-break: break-all;
}

/* A row of shots, used on the landing page. */
.shot-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin: 0 0 32px;
  max-width: none;
}

.shot-gallery figure.shot { margin: 0; max-width: none; }

.shot-gallery figure.shot.missing .shot-slot { min-height: 160px; }

/* ---------- Landing-page cards ---------- */

.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 0 0 32px;
  max-width: none;
}

.docs-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  background: var(--section);
  box-shadow: var(--shadow-card);
  transition: transform 150ms ease, box-shadow 200ms ease, border-color 150ms ease;
}

.docs-body a.docs-card { text-decoration: none; color: inherit; }

.docs-card:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(13, 27, 36, 0.08);
}

.docs-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 6px;
  color: var(--ink);
}

.docs-card p {
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

/* ---------- Next / previous ---------- */

.docs-next {
  margin: 56px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 0.98rem;
  color: var(--muted);
}

.docs-next a { font-weight: 600; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .docs-nav {
    position: static;
    border-bottom: 1px solid var(--line);
    padding-bottom: 20px;
  }

  .docs-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .docs-nav h2 + ul { margin-bottom: 18px; }

  .docs-nav a {
    border: 1px solid var(--line);
    padding: 5px 12px;
  }

  .shot-gallery { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .docs-hero { padding: 44px 0 22px; }
  .docs-main { padding: 32px 0 64px; }
  .docs-body .conn-fields tbody th { width: auto; }
  .docs-steps > li { padding-left: 40px; }
  .docs-steps > li::before { left: -14px; width: 28px; height: 28px; }
}
