/* ==========================================================
   HELP / KNOWLEDGE BASE  (/help, /help/<id>, rendered by help.js)
   Page-specific styling layered on top of v2.css and setup.css
   ========================================================== */

/* Clip sideways overflow like setup.css does, without making <main> a scroll box,
   so the sticky topic sidebar stays in view. */
.kb-page main { overflow: visible; overflow-x: clip; }

/* ---------- Home: hero and search ---------- */
.kb-hero { padding: 72px max(24px, calc((100vw - 1180px) / 2)) 80px; }
.kb-search { position: relative; max-width: 640px; margin-top: 2rem; }
.kb-search input {
  width: 100%; box-sizing: border-box; height: 58px; padding: 0 1.2rem 0 3.2rem;
  border-radius: 16px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  color: #fff; font: 500 1.02rem "DM Sans", system-ui, sans-serif; outline: none;
}
.kb-search input::placeholder { color: rgba(255,255,255,.45); }
.kb-search input:focus { border-color: var(--green); background: rgba(255,255,255,.09); }
.kb-search > svg { position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: rgba(255,255,255,.55); }
.kb-results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 20; background: #fff; color: var(--ink);
  border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; display: none; }
.kb-results a, .kb-results .kb-none { display: block; padding: .8rem 1.1rem; text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.kb-results > :first-child { border-top: 0; }
.kb-results a:hover { background: #f1f6f2; }
.kb-results a:focus-visible { outline-offset: -3px; }
.kb-results b { display: block; font: 700 .95rem "Manrope", sans-serif; }
.kb-results span { display: block; color: var(--ink-soft); font-size: .84rem; margin-top: .15rem; }
.kb-results small { color: var(--green-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .66rem; }
.kb-popular { margin-top: 1rem; color: rgba(255,255,255,.5); font-size: .85rem; }
.kb-popular a { color: var(--aqua); text-decoration: none; margin-right: .9rem; }
.kb-actions { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: 2rem; }
/* Read by screen readers only (the search result count). */
.kb-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Home: tours and topics ---------- */
.kb-wrap { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 96px; }
.kb-h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 .4rem; }
.kb-sub { color: var(--ink-soft); margin: 0 0 1.8rem; }

.kb-tours { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 64px; }
.kb-tour { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; border-radius: 18px; border: 1px solid var(--line);
  background: var(--night); color: #fff; cursor: pointer; text-align: left; font: inherit; }
.kb-tour:hover { border-color: var(--green); }
.kb-tour .play { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--night); }
.kb-tour b { display: block; font: 800 .98rem "Manrope", sans-serif; }
.kb-tour span { color: rgba(255,255,255,.6); font-size: .82rem; }

.kb-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 1.2rem; }
.kb-cat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.5rem 1.2rem; }
.kb-cat-head { display: flex; align-items: center; gap: .8rem; }
.kb-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #e6f6ee; color: var(--green-dark); flex: 0 0 auto; }
.kb-icon svg { width: 20px; height: 20px; }
.kb-cat h3 { margin: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.kb-cat h3 a { color: var(--ink); text-decoration: none; }
.kb-cat p { color: var(--ink-soft); font-size: .9rem; line-height: 1.55; margin: .8rem 0 .9rem; }
.kb-cat ul { list-style: none; margin: 0; padding: .8rem 0 0; border-top: 1px solid var(--line); }
.kb-cat li a { display: flex; justify-content: space-between; gap: .6rem; padding: .38rem 0; color: var(--ink); text-decoration: none; font-size: .92rem; }
.kb-cat li a:hover { color: var(--green-dark); }
.kb-cat li a::after { content: "→"; color: var(--green); }
.kb-cat .count { margin-left: auto; color: var(--ink-soft); font-size: .75rem; font-weight: 700; }
.kb-cat[hidden] { display: none; }

/* ---------- Tags: where a page works (Montis App / ChatGPT & Claude), filter and legend ---------- */
.kb-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 .55rem; border-radius: 999px; font: 700 .72rem "DM Sans", sans-serif; white-space: nowrap; }
.kb-tag.sm { height: 18px; padding: 0 .45rem; font-size: .64rem; }
.kb-tag-app { background: #e2f4ea; color: var(--green-dark); }
.kb-tag-ai { background: #e4edfd; color: #1f5fbf; }
.kb-applies { display: inline-flex; gap: .35rem; align-items: center; }
.kb-cat li a.tagged::after { content: none; }
/* The article name takes the room left by its tags; on narrow cards the tags wrap rather than overflow. */
.kb-cat li a.tagged > span:first-child { flex: 1 1 0%; }
.kb-cat li a .tags { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; align-self: flex-start; gap: .25rem; flex: 0 1 auto; }
.kb-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: -0.6rem 0 1.6rem; }
.kb-filter[hidden] { display: none; }
.kb-filter span.lbl { color: var(--ink-soft); font-size: .85rem; margin-right: .2rem; }
.kb-filter button { height: 32px; padding: 0 .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 .84rem "DM Sans", sans-serif; cursor: pointer; }
.kb-filter button[aria-pressed="true"] { background: var(--night); color: #fff; border-color: var(--night); }
.kb-legend { color: var(--ink-soft); font-size: .8rem; margin: -0.8rem 0 1.4rem; }

/* ---------- Article ---------- */
.kb-crumbs { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 0; color: var(--ink-soft); font-size: .86rem; }
.kb-crumbs a { color: var(--green-dark); text-decoration: none; }
.kb-grid { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 20px 0 96px; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 2.2rem; align-items: start; }
.kb-side { position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: auto; padding-right: .4rem; }
/* At rest the topic list starts 96px below the top of <main> (as in the approved design);
   once the page scrolls it sticks 96px below the top of the window. */
.kb-grid > .kb-side { margin-top: calc(96px - 48px - .86rem * 1.65); }
.kb-side .grp { margin-bottom: 1rem; }
.kb-side .grp > a { display: flex; align-items: center; gap: .55rem; font: 800 .74rem "Manrope", sans-serif; text-transform: uppercase; letter-spacing: .07em; color: var(--ink); text-decoration: none; padding: .35rem .2rem; }
.kb-side .grp > a svg { width: 15px; height: 15px; color: var(--green-dark); }
.kb-side ul { list-style: none; margin: .2rem 0 0 .45rem; padding: 0 0 0 .8rem; border-left: 2px solid var(--line); }
.kb-side li a { display: block; padding: .3rem .5rem; border-radius: 8px; color: var(--ink-soft); text-decoration: none; font-size: .88rem; }
.kb-side li a:hover { color: var(--ink); background: #eaf1ec; }
.kb-side li a[aria-current="page"], .kb-side .grp > a[aria-current="page"] { color: var(--green-dark); background: #e2f4ea; font-weight: 700; }
.kb-browse { display: none; }
.kb-browse .kb-side { display: block; position: static; max-height: none; margin-top: .8rem; }

.kb-article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.4rem clamp(1.2rem, 4vw, 3rem); }
.kb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: .6rem 0 1.6rem; color: var(--ink-soft); font-size: .84rem; }
.kb-open { margin-left: auto; display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--green); color: var(--green-dark); text-decoration: none; font-weight: 700; font-size: .82rem; }
.kb-open svg { width: 14px; height: 14px; }
/* "Applies to:" chips: a long chip (one with its report name) wraps on narrow screens instead of overflowing. */
.kb-meta .kb-applies { flex-wrap: wrap; max-width: 100%; }
.kb-meta .kb-tag { height: auto; min-height: 22px; padding-block: 2px; line-height: 1.3; white-space: normal; max-width: 100%; box-sizing: border-box; }
/* Where "Applies to" no longer fits beside the reading time, it gets its own row (no dangling "·"). */
.kb-article { container: kb-article / inline-size; }
@container kb-article (max-width: 740px) {
  .kb-meta .sep { display: none; }
  .kb-meta .kb-applies { flex-basis: 100%; }
}
.kb-body h1 { font-size: clamp(2rem, 4vw, 2.8rem); margin: 0; line-height: 1.1; }
.kb-body h2 { font-size: 1.5rem; margin: 2.2rem 0 .6rem; }
.kb-body h3 { font-size: 1.08rem; margin: 1.9rem 0 .5rem; }
.kb-body h2[id], .kb-body h3[id] { scroll-margin-top: 96px; }
.kb-body { overflow-wrap: break-word; }
.kb-body p, .kb-body li { color: #2e3d3a; line-height: 1.72; font-size: 1rem; }
.kb-body ul { padding-left: 1.2rem; }
.kb-body li { margin: .3rem 0; }
.kb-body blockquote { margin: 1.4rem 0; padding: .9rem 1.2rem; border-left: 3px solid var(--green); background: #effaf4; border-radius: 0 12px 12px 0; }
.kb-body blockquote p { margin: 0; }
.kb-body .kb-callout { margin: 1.4rem 0; padding: .9rem 1.2rem; border-left: 3px solid var(--green); background: #effaf4; border-radius: 0 12px 12px 0; }
.kb-body .kb-callout p { margin: 0; }
.kb-body table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .92rem; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kb-body th { text-align: left; background: #f1f5f1; padding: .6rem .8rem; font: 800 .72rem "Manrope", sans-serif; text-transform: uppercase; letter-spacing: .06em; }
.kb-body td { padding: .55rem .8rem; border-top: 1px solid var(--line); }
/* Wide tables and code lines scroll inside the article instead of widening it. */
.kb-body .kb-table { overflow-x: auto; margin: 1.2rem 0; }
.kb-body .kb-table > table { margin: 0; }
.kb-body pre { overflow-x: auto; }
.kb-body img { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.kb-body a { color: var(--green-dark); font-weight: 600; }
.kb-body .tour-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.1rem; border-radius: 999px; border: 0; background: var(--night); color: #fff; font: 700 .9rem "DM Sans", sans-serif; cursor: pointer; }
.kb-body .tour-btn svg { width: 18px; height: 18px; color: var(--green); }

.kb-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.4rem; }
.kb-pager a { display: block; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: var(--ink); background: var(--card); }
.kb-pager a:hover { border-color: var(--green); }
.kb-pager small { display: block; color: var(--ink-soft); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.kb-pager b { font: 700 .98rem "Manrope", sans-serif; }
.kb-pager .next { text-align: right; }
.kb-related { margin-top: 2.4rem; }
.kb-related h3 { font-size: 1rem; margin: 0 0 .8rem; }
.kb-related div { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.kb-related a { display: block; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-decoration: none; color: var(--ink); }
.kb-related a span { display: block; color: var(--ink-soft); font-size: .8rem; margin-top: .25rem; line-height: 1.45; }

/* ---------- Tour player ---------- */
.kb-modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; background: rgba(7,19,16,.78); padding: 16px; }
.kb-modal.open { display: grid; }
.kb-modal-box { width: min(960px, 100%); background: var(--night); border-radius: 18px; padding: 14px; }
.kb-modal-head { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 2px 4px 12px; font: 800 .8rem "Manrope", sans-serif; text-transform: uppercase; letter-spacing: .08em; }
.kb-modal-head button { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
.kb-modal video { width: 100%; aspect-ratio: 16/9; border-radius: 12px; background: #000; }

@media (max-width: 900px) {
  .kb-grid { grid-template-columns: minmax(0, 1fr); }
  .kb-side { display: none; }
  .kb-browse { display: block; margin-bottom: 1rem; }
  .kb-browse summary { cursor: pointer; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card); font-weight: 700; }
  .kb-pager { grid-template-columns: 1fr; }
  .kb-open { margin-left: 0; }
}
