/* ==========================================================================
   Handbook layout
   A sticky table of contents beside a single column of prose. The column is
   deliberately narrow — roughly 74 characters — because this page is read,
   not scanned.
   ========================================================================== */

.guide {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 52px;
  align-items: start;
  padding: 40px 0 80px;
}

/* --- Table of contents --------------------------------------------------- */

.toc {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  max-height: calc(100dvh - var(--nav-h) - 48px);
  overflow-y: auto;
  padding-right: 8px;
  font-size: .84rem;
}

.toc h4 {
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }

.toc a {
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  border-left: 2px solid transparent;
  transition: color .18s, background .18s, border-color .18s;
  line-height: 1.4;
}

.toc a::before {
  counter-increment: toc;
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--text-3);
  flex: none;
  padding-top: 1px;
}

.toc a:hover { color: var(--text); background: rgba(0,255,156,.05); }

/* Set by the scrollspy in guide.js as you move through the page. */
.toc a.active {
  color: var(--green);
  background: var(--green-dim);
  border-left-color: var(--green);
}

.toc a.active::before { color: var(--green-3); }

/* --- Prose --------------------------------------------------------------- */

.prose { max-width: 74ch; font-size: .94rem; line-height: 1.75; color: var(--text-2); }

.prose > section { padding-bottom: 46px; margin-bottom: 46px; border-bottom: 1px solid var(--line); }
.prose > section:last-child { border-bottom: 0; }

.prose h2 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  color: var(--text);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  scroll-margin-top: calc(var(--nav-h) + 20px);
}

.prose h2 i, .prose h2 svg { width: 22px; height: 22px; color: var(--green); flex: none; }

.prose .lede {
  font-size: 1rem;
  color: var(--text-3);
  margin: 0 0 26px;
  padding-left: 34px;
}

.prose h3 {
  font-size: 1.02rem;
  color: var(--text);
  margin: 34px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.prose h4 {
  font-size: .88rem;
  color: var(--green-2);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: .02em;
  margin: 24px 0 10px;
}

.prose strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--green-4); }
.prose a { text-decoration: underline; text-decoration-color: rgba(0,255,156,.35); text-underline-offset: 3px; }

/* Definition lists read better than tables for short term/meaning pairs. */
.prose dl.defs { margin: 0 0 20px; }
.prose dl.defs dt {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--green-2);
  margin-top: 14px;
}
.prose dl.defs dd { margin: 3px 0 0; padding-left: 0; }

/* --- Reference tables ---------------------------------------------------- */

.tbl-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--line); border-radius: var(--r); }

table.ref {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  min-width: 480px;
}

table.ref th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
  padding: 11px 14px;
  background: rgba(0,255,156,.04);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.ref td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(22,35,29,.7);
  vertical-align: top;
  color: var(--text-2);
}

table.ref tr:last-child td { border-bottom: 0; }
table.ref tbody tr:hover { background: rgba(0,255,156,.025); }
table.ref td:first-child { color: var(--text); font-family: var(--font-mono); font-size: .78rem; white-space: nowrap; }
table.ref .yes { color: var(--green); }
table.ref .no  { color: var(--text-3); }

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

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

ol.steps > li {
  position: relative;
  padding: 0 0 22px 44px;
  margin: 0;
  border-left: 1px solid var(--line);
}

ol.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }

ol.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -14px; top: -2px;
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-1);
  border: 1px solid var(--line-hot);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: .72rem;
}

ol.steps > li > strong {
  display: block;
  color: var(--text);
  margin-bottom: 7px;
  font-size: .96rem;
}

/* --- Request-flow diagram ------------------------------------------------ */

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  margin: 0 0 22px;
  font-family: var(--font-mono);
  font-size: .74rem;
}

.flow .node {
  flex: 1 1 128px;
  min-width: 118px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  text-align: center;
  color: var(--text-2);
}

.flow .node b {
  display: block;
  color: var(--green);
  font-weight: 500;
  margin-bottom: 4px;
  font-size: .82rem;
}

.flow .node small { color: var(--text-3); font-size: .92em; line-height: 1.4; display: block; }

.flow .arrow {
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  color: var(--green-4);
}

/* On narrow screens the row becomes a column, so the arrows must turn too. */
@media (max-width: 620px) {
  .flow { flex-direction: column; }
  .flow .arrow { height: 24px; transform: rotate(90deg); }
}

/* --- Cost / comparison cards --------------------------------------------- */

.cards-mini {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

.mini {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.mini h5 {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}

.mini .big {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--green);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.mini p { margin: 6px 0 0; font-size: .78rem; color: var(--text-3); line-height: 1.5; }

/* Recommendation badge on the database comparison. */
.pick {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #041008;
  background: var(--green);
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: 2px;
}

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

@media (max-width: 980px) {
  .guide { grid-template-columns: minmax(0, 1fr); gap: 0; }

  /* The TOC becomes a collapsed disclosure above the prose rather than a
     sidebar, so it costs one line instead of a whole screen. */
  .toc {
    position: static;
    max-height: none;
    margin-bottom: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
  }
  .toc h4 { padding: 14px 16px; margin: 0; cursor: pointer; }
  .toc ol { padding: 6px 10px 12px; columns: 2; column-gap: 10px; }
  .toc li { break-inside: avoid; }
  .prose { max-width: none; }
}

@media (max-width: 560px) {
  .toc ol { columns: 1; }
  .prose .lede { padding-left: 0; }
  .prose h2 { font-size: 1.25rem; }
}
