/* Meranti Help Center — knowledge base chrome
   Theme-driven: consumes the `--site-*` custom properties emitted by
   `Console.StaticSite.StyleGenerator` (linked as style.css, before this
   file) the same way customer sites do. The chrome is not `.site`-scoped;
   only the article body is (see ARTICLE PAGE), and base.css (linked before
   style.css) styles that body.

   Pruned from the docs/design-system/ui_kits/help_center/ mockup: dropped
   the header category strip (.kb-catbar) and the header/both nav-mode
   variants (sidebar-on-desktop + drawer-on-mobile is the only shipped
   layout), the article meta line (read-time/date), the "was this helpful"
   widget, the duplicate hero search box, and the mockup's .kb-prose (no
   section type emits it). */

/* =========================================================
   DESIGN TOKENS (theme-driven, dark-safe)
   ========================================================= */

:root,
.meranti-console {
  --font-sans: var(--site-font-body);
  --font-display: var(--site-font-heading);

  /* --site-color-accent is emitted by StyleGenerator but deliberately
     unconsumed: KB chrome draws its accents from the link colour. */
  --meranti-link:     var(--site-color-link);

  --fg1: var(--site-color-text);
  --fg2: color-mix(in srgb, var(--site-color-text) 62%, var(--site-color-background));
  --fg3: color-mix(in srgb, var(--site-color-text) 38%, var(--site-color-background));
  --fg4: color-mix(in srgb, var(--site-color-text) 22%, var(--site-color-background));
  --border: color-mix(in srgb, var(--site-color-text) 14%, var(--site-color-background));

  /* page background — a faint tint toward text, so --surface (cards/header)
     sits visibly above the page on both light and dark themes */
  --bg2: color-mix(in srgb, var(--site-color-background) 95%, var(--site-color-text) 5%);
  /* card/header/panel surface — the clean theme background */
  --surface: var(--site-color-background);

  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.10), 0 4px 6px -4px rgb(0 0 0 / 0.10);

  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --dur-150: 150ms;
  --dur-200: 200ms;

  /* very light tan — a low tint of the theme's primary color, warms the
     otherwise flat surfaces (category cards + sidebar panel) */
  --kb-tan: color-mix(in srgb, color-mix(in srgb, var(--site-color-primary) 90%, var(--site-color-text)) 7%, var(--site-color-background));
}

@font-face {
  font-family: "Meranti Wordmark";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/_brand/wordmark.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  color: var(--fg1);
  background: var(--bg2);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }

/* content wrapper grows to fill the viewport so the footer sits at the bottom
   on short pages; block children inside keep normal max-width + margin:auto centering */
.kb-content { flex: 1 0 auto; }

svg.ic { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ============================================================
   HEADER
   ============================================================ */
.kb-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.kb-header-in {
  max-width: 1160px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
}
.kb-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* Tobacco, the console's light-theme --color-brand: the mark keeps the brand
   colour whatever the Help Center theme's primary is. */
.kb-brand svg { display: block; color: #5a3818; }
/* Must match the console header lockup (layouts.ex wordmark/1). The face is
   the brand's own, not the theme's heading font. */
.kb-word { font-family: "Meranti Wordmark", Georgia, serif; font-weight: 500; font-size: 25px; line-height: 1; letter-spacing: -0.018em; color: var(--fg1); }
.kb-word .sub { color: var(--fg3); }

/* header search — PagefindUI (Classic Default UI, from the binary-emitted
   pagefind-ui.js/.css) mounts into #kb-search below. PagefindUI renders its
   own search magnifier and owns everything inside the mount div — we render no
   icon of our own (that used to double up). */
.kb-search { position: relative; flex: 1; max-width: 520px; }
.kb-search #kb-search { width: 100%; }
.kb-header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* PagefindUI theming — remaps the Classic Default UI's CSS custom properties
   onto the tobacco/slate design tokens above so the search box matches the
   rest of the Help Center chrome instead of Pagefind's default blue. See
   https://pagefind.app/docs/ui/#styling-with-css-custom-properties. */
.kb-search {
  --pagefind-ui-primary: var(--meranti-link);
  --pagefind-ui-text: var(--fg1);
  --pagefind-ui-background: var(--surface);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--bg2);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 8px;
  --pagefind-ui-image-border-radius: 8px;
  --pagefind-ui-image-box-ratio: 3 / 2;
  --pagefind-ui-font: var(--font-sans);
  --pagefind-ui-scale: 0.9;
}
.kb-search .pagefind-ui__search-input { padding-left: 38px; height: 38px; background: var(--bg2); }
.kb-search .pagefind-ui__search-input:focus { background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--meranti-link) 12%, transparent); }
/* Float the results over the page instead of letting PagefindUI's in-flow
   drawer grow the sticky header (which pushed the wordmark down). Anchored to
   .kb-search (position: relative); the header stays a constant height. The
   .pagefind-ui__hidden state keeps display:none, so an empty search shows no
   overlay. */
.kb-search .pagefind-ui__drawer {
  position: absolute; top: calc(100% + 10px); left: 0; right: 0;
  z-index: 40;
  max-height: min(70vh, 560px); overflow-y: auto;
  padding: 10px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.kb-console-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg2); padding: 7px 11px; border-radius: 8px; }
.kb-console-link:hover { color: var(--fg1); background: var(--bg2); }

/* mobile sidebar toggle — hidden on desktop, shown under the 900px drawer breakpoint */
.kb-menu-btn { display: none; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--fg1); align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

/* ============================================================
   PAGE SHELL / LAYOUT
   ============================================================ */
.kb-shell { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* two-column layout used on category + article pages: sidebar on desktop,
   CSS-only drawer under 900px (toggled by the checkbox hack below — no JS). */
.kb-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; align-items: start; padding: 28px 0 72px; }
.kb-main { min-width: 0; }

/* sidebar */
.kb-sidebar { position: sticky; top: 78px; background: var(--kb-tan); border: 1px solid var(--border); border-radius: 12px; padding: 16px 12px; }
.kb-side-cap { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; color: var(--fg3); padding: 0 10px 8px; }
.kb-side-cat > a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--fg1);
}
.kb-side-cat > a:hover { background: var(--surface); }
.kb-side-cat.on > a { color: var(--meranti-link); font-weight: 600; }
.kb-side-articles { list-style: none; margin: 2px 0 6px; padding: 0 0 0 8px; }
.kb-side-articles li a {
  display: block; padding: 6px 10px 6px 26px; margin-left: 3px;
  border-left: 1px solid var(--border);
  font-size: 13px; color: var(--fg2); line-height: 1.35;
}
.kb-side-articles li a:hover { color: var(--fg1); border-left-color: var(--fg4); }
.kb-side-articles li a.on { color: var(--meranti-link); font-weight: 500; border-left-color: var(--meranti-link); }

/* mobile drawer toggle — CSS-only checkbox hack (see LayoutRenderer): the
   hidden checkbox's :checked state drives .kb-sidebar's open transform and
   the scrim below via the ~ sibling combinator. No JS required. */
.kb-drawer-toggle { position: absolute; opacity: 0; pointer-events: none; }

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.kb-crumbs { max-width: 1160px; margin: 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--fg3); padding: 16px 24px 0; }
.kb-crumbs a { color: var(--fg2); }
.kb-crumbs a:hover { color: var(--fg1); }
.kb-crumbs .ic { color: var(--fg4); }
.kb-crumbs .cur { color: var(--fg1); }

/* Chrome headings follow the site's font pairing, as `.site` headings do.
   Page-specific h1 rules below must not set a weight back. */
.kb-hero h1, .kb-cat-hero h1, .kb-article-head h1 {
  font-family: var(--font-display);
  font-weight: var(--site-font-heading-weight);
}

/* ============================================================
   HOME
   ============================================================ */
.kb-hero { text-align: center; padding: 64px 24px 52px; }
.kb-hero h1 { font-size: 38px; letter-spacing: -0.03em; margin: 0 0 12px; line-height: 1.1; }
.kb-hero p { font-size: 16px; color: var(--fg2); margin: 0 auto; max-width: 560px; }
.kb-hero-empty { text-align: center; padding: 0 24px 72px; color: var(--fg2); font-size: 15px; }

.kb-grid { max-width: 1160px; margin: 0 auto; padding: 0 24px 80px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.kb-cat-card {
  background: var(--kb-tan); border: 1px solid var(--border); border-radius: 12px; padding: 22px 22px 10px;
  display: flex; flex-direction: column; transition: border-color var(--dur-150) var(--ease-out), box-shadow var(--dur-150) var(--ease-out);
}
.kb-cat-card:hover { border-color: var(--fg4); box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 14px 30px -22px rgb(0 0 0 / .3); }
.kb-cat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.kb-cat-title { font-size: 16px; font-weight: 600; }
.kb-cat-desc { font-size: 13px; color: var(--fg2); margin: 0 0 12px; line-height: 1.5; }
.kb-cat-links { list-style: none; margin: 0 0 4px; padding: 0; border-top: 1px solid var(--border); }
.kb-cat-links li a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 2px; font-size: 14px; color: var(--fg1);
  border-bottom: 1px solid var(--border);
}
.kb-cat-links li:last-child a { border-bottom: 0; }
.kb-cat-links li a:hover { color: var(--meranti-link); }
.kb-cat-links li a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-cat-all {
  margin-top: auto; padding: 12px 2px 14px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--meranti-link);
}

/* ============================================================
   CATEGORY PAGE
   ============================================================ */
.kb-cat-hero { display: flex; align-items: flex-start; gap: 16px; padding: 8px 0 22px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.kb-cat-hero h1 { font-size: 28px; letter-spacing: -0.025em; margin: 2px 0 6px; }
.kb-cat-hero p { font-size: 15px; color: var(--fg2); margin: 0; max-width: 640px; }
.kb-cat-count { font-size: 12px; color: var(--fg3); margin-top: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

.kb-articles { list-style: none; margin: 0; padding: 0; }
.kb-article-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 8px; border-bottom: 1px solid var(--border);
  margin: 0 -8px; border-radius: 8px;
}
.kb-article-row:hover { background: var(--bg2); }
.kb-article-row .a-body { min-width: 0; flex: 1; }
.kb-article-row .a-title { font-size: 16px; font-weight: 600; color: var(--fg1); }
.kb-article-row:hover .a-title { color: var(--meranti-link); }
.kb-article-row .a-excerpt { font-size: 14px; color: var(--fg2); margin: 4px 0 0; line-height: 1.5; }

/* ============================================================
   ARTICLE PAGE
   ============================================================ */
.kb-article { max-width: 720px; }
.kb-article-head { padding: 6px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
/* Same size and line height as a body `.site h1`, so the title is never
   outranked by a heading inside the article. */
.kb-article-head h1 { font-size: 2.5rem; line-height: 1.2; letter-spacing: -0.03em; margin: 6px 0 0; }
@media (max-width: 768px) {
  .kb-article-head h1 { font-size: 2rem; }
}
.kb-eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; color: var(--meranti-link); }

/* Article body: wrapped in `.site` (LayoutRenderer.render_article/7), so
   base.css styles it exactly as the editor canvas does, section padding and
   backgrounds included. Add a rule here only where the Help Center must differ
   from the canvas; anything else reintroduces canvas/published drift. */
.kb-article .site { background: transparent; }
/* Sections fill the article column, and an unfilled section's text lines up
   with the article title rather than the canvas's side gutter. Do not zero the
   padding of a filled section or a hero: a fill is painted on .section-inner
   and a hero image on .section, so its text would sit flush against the edge. */
.kb-article .section-inner { max-width: none; margin: 0; }
.kb-article .section-bg-none:not(.section-hero) > .section-inner { padding-left: 0; padding-right: 0; }

/* prev/next within category */
.kb-nextnav { display: flex; gap: 14px; margin-top: 40px; }
.kb-nextnav a { flex: 0 1 calc(50% - 7px); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: var(--surface); }
.kb-nextnav a:hover { border-color: var(--fg4); }
.kb-nextnav .nn-cap { font-size: 12px; color: var(--fg3); display: flex; align-items: center; gap: 5px; }
.kb-nextnav .nn-title { font-size: 14px; font-weight: 600; color: var(--fg1); margin-top: 4px; }
.kb-nextnav a:hover .nn-title { color: var(--meranti-link); }
.kb-nextnav .next { text-align: right; margin-left: auto; }
.kb-nextnav .next .nn-cap { justify-content: flex-end; }

/* ============================================================
   FOOTER
   ============================================================ */
.kb-footer { border-top: 1px solid var(--border); flex-shrink: 0; }
.kb-footer-in { max-width: 1160px; margin: 0 auto; padding: 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.kb-footer .f-copy { font-size: 13px; color: var(--fg3); }

/* ============================================================
   RESPONSIVE — CSS-only mobile drawer
   ============================================================ */
.kb-scrim { position: fixed; inset: 0; background: rgb(15 23 42 / .4); z-index: 45; display: none; }

@media (max-width: 960px) {
  .kb-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .kb-layout { grid-template-columns: minmax(0, 1fr); }
  .kb-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 46;
    background: var(--kb-tan); border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 18px 14px; overflow-y: auto;
    transform: translateX(-100%); transition: transform var(--dur-200) var(--ease-out);
  }
  .kb-menu-btn { display: flex; }

  /* :checked drives both the sidebar transform and the scrim visibility —
     the checkbox lives immediately before .kb-sidebar in the DOM so the
     sibling combinator reaches it (see LayoutRenderer chrome markup). */
  .kb-drawer-toggle:checked ~ .kb-sidebar { transform: translateX(0); }
  .kb-drawer-toggle:checked ~ .kb-scrim { display: block; }
}
@media (max-width: 720px) {
  .kb-grid { grid-template-columns: 1fr; }
  .kb-header-in { flex-wrap: wrap; }
  .kb-search { order: 3; flex-basis: 100%; max-width: none; }
  .kb-console-link span { display: none; }
  .kb-hero h1 { font-size: 30px; }
}

@media print { .kb-scrim { display: none !important; } }
