/* ── /recommend/how-it-works — RECOMMENDATIONS.md rendered in the site ──── */

.hiw-wrap {
  /* Contents + gap + a readable measure, centred under the nav */
  max-width: calc(250px + 48px + 780px + 2 * var(--gutter));
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* ── Contents ───────────────────────────────────────────────────────────── */
.hiw-toc {
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  font-size: 0.82rem;
  scrollbar-width: thin;
}
.hiw-toc summary { display: none; }
#hiw-toc ul { list-style: none; }
#hiw-toc a {
  display: block;
  padding: 3px 0 3px 12px;
  border-left: 2px solid var(--color-border-light);
  color: var(--color-text-muted);
  line-height: 1.35;
}
#hiw-toc li li a {
  padding-left: 24px;
  font-size: 0.78rem;
}
#hiw-toc a:hover {
  color: var(--color-text);
  text-decoration: none;
}
#hiw-toc a.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: 600;
}

/* ── The document ───────────────────────────────────────────────────────── */
.hiw-doc {
  max-width: 780px;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.65;
}
.hiw-doc h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 14px;
}
.hiw-doc h2 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 44px 0 12px;
}
.hiw-doc h3 {
  font-size: 1.08rem;
  line-height: 1.35;
  margin: 30px 0 8px;
}
.hiw-doc h4 {
  font-size: 0.95rem;
  margin: 22px 0 6px;
}
.hiw-doc :is(h1, h2, h3, h4) { scroll-margin-top: 64px; }
.hiw-anchor {
  margin-left: 8px;
  font-weight: 400;
  color: var(--color-text-light);
  opacity: 0;
  transition: opacity 0.15s;
}
.hiw-doc :is(h2, h3, h4):hover .hiw-anchor,
.hiw-anchor:focus { opacity: 1; text-decoration: none; }

.hiw-doc p,
.hiw-doc ul,
.hiw-doc ol,
.hiw-doc blockquote { margin: 0 0 14px; }
.hiw-doc ul,
.hiw-doc ol { padding-left: 22px; }
.hiw-doc li { margin: 4px 0; }
.hiw-doc li > ul,
.hiw-doc li > ol { margin: 4px 0 0; }
.hiw-doc hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 36px 0;
}
.hiw-doc blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 14px;
  color: var(--color-text-muted);
}

.hiw-doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 1px 5px;
}
.hiw-doc pre {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 16px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
}
.hiw-doc pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.hiw-table {
  overflow-x: auto;
  margin: 0 0 16px;
}
.hiw-doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  line-height: 1.5;
}
.hiw-doc th,
.hiw-doc td {
  border: 1px solid var(--color-border);
  padding: 6px 10px;
  vertical-align: top;
}
.hiw-doc th:not([align]),
.hiw-doc td:not([align]) { text-align: left; }
.hiw-doc th {
  background: var(--color-surface-alt);
  font-weight: 600;
}

/* ── Phones and narrow windows: contents collapse above the text ───────── */
@media (max-width: 900px) {
  .hiw-wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .hiw-toc {
    position: static;
    max-height: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 14px;
  }
  .hiw-toc summary {
    display: list-item;
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text);
  }
  .hiw-toc details[open] summary { margin-bottom: 8px; }
  .hiw-doc h1 { font-size: 1.55rem; }
}
