/* ============================================================
   UPLEVEL SYSTEMS — Knowledge Base styles
   Layered on top of main.css. Uses the same CSS variables
   (--bg-base, --accent, --text-primary, etc.) so light/dark
   theming and brand colors propagate automatically.
   ============================================================ */

/* ── Shared page-hero patterns mirroring the static pages ────── */
.page-hero {
  padding: 120px 0 60px;
  border-bottom: 1px solid var(--border-subtle);
}
.page-hero .breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.page-hero .breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color .2s var(--ease);
}
.page-hero .breadcrumb a:hover { color: var(--text-primary); }
.page-hero .breadcrumb span { margin: 0 6px; opacity: .4; }

.page-hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  max-width: 820px;
}
.page-hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin-top: 16px;
  line-height: 1.6;
}

.page-body { padding: 60px 0 80px; }
.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 48px 0 20px;
  letter-spacing: -0.02em;
}
.section-title:first-child { margin-top: 0; }

/* ── KB hero with embedded search ─────────────────────────────── */
.kb-hero .kb-search {
  margin-top: 32px;
  max-width: 720px;
}

/* PageFind default UI overrides — re-skin to match the site's
   dark-purple aesthetic without losing the built-in functionality.
   PageFind uses CSS custom properties prefixed with --pagefind-ui-*,
   which makes this a one-shot variable override. */
.kb-search {
  --pagefind-ui-scale: 0.95;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text-primary);
  --pagefind-ui-background: var(--bg-surface);
  --pagefind-ui-border: var(--border-light);
  --pagefind-ui-tag: var(--bg-raised);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 14px;
  --pagefind-ui-image-border-radius: 8px;
  --pagefind-ui-image-box-ratio: 3 / 2;
  --pagefind-ui-font: var(--font-body);
}
.kb-search .pagefind-ui__search-input {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.kb-search .pagefind-ui__search-input::placeholder {
  color: var(--text-muted);
}
.kb-search .pagefind-ui__result-link {
  color: var(--text-primary);
}
.kb-search .pagefind-ui__result-link:hover { color: var(--accent-light); }
.kb-search .pagefind-ui__result-excerpt { color: var(--text-secondary); }
.kb-search mark { background: var(--accent-subtle); color: var(--text-primary); }

/* ── Card grids (home page + category pages) ──────────────────── */
.kb-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 16px;
}
/* Category grid: tighter tiles, more per row, visually distinct
   from the article grid below it. */
.kb-card-grid--categories {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 48px;
}

.kb-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-decoration: none;
  color: inherit;
  transition: transform .25s var(--ease),
              border-color .25s var(--ease),
              background .25s var(--ease);
  position: relative;
  overflow: hidden;
}
.kb-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity .25s var(--ease);
}
.kb-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  background: var(--bg-raised);
}
.kb-card:hover::before { opacity: 1; }

.kb-card__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.kb-card__summary {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  flex: 1;
  margin-bottom: 16px;
}
.kb-card__cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
  letter-spacing: 0.01em;
}
.kb-card__count {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-top: auto;
}
.kb-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.kb-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-subtle);
  color: var(--accent-light);
  border: 1px solid var(--border-subtle);
}

.kb-empty {
  font-size: 15px;
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
}

.kb-back-link {
  margin-top: 48px;
  font-size: 14px;
}
.kb-back-link a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
}
.kb-back-link a:hover { text-decoration: underline; }

/* ── Article meta row beneath the hero title ──────────────────── */
.kb-article__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.kb-article__updated {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Article body layout (two-column with aside) ──────────────── */
.kb-article__container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 56px;
  align-items: start;
}
@media (max-width: 900px) {
  .kb-article__container {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
  }
}

/* ── Article typography (markdown-rendered prose) ─────────────── */
.kb-article__body {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-secondary);
  max-width: 760px;
}
.kb-article__body > * + * { margin-top: 1em; }

.kb-article__body h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-top: 2.2em;
  margin-bottom: 0.6em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.kb-article__body h3 {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}
.kb-article__body h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1.6em;
  margin-bottom: 0.4em;
}

.kb-article__body p { color: var(--text-secondary); }
.kb-article__body strong { color: var(--text-primary); font-weight: 600; }
.kb-article__body em { color: var(--text-primary); }

.kb-article__body a {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(168, 85, 200, 0.4);
  transition: text-decoration-color .2s var(--ease);
}
.kb-article__body a:hover {
  text-decoration-color: var(--accent-light);
}

.kb-article__body ul,
.kb-article__body ol {
  padding-left: 22px;
  margin: 1em 0;
}
.kb-article__body ul { list-style: disc; }
.kb-article__body ol { list-style: decimal; }
.kb-article__body li { margin-bottom: 0.5em; }
.kb-article__body li::marker { color: var(--accent-light); }
.kb-article__body ul ul,
.kb-article__body ol ol,
.kb-article__body ul ol,
.kb-article__body ol ul {
  margin: 0.4em 0;
}

.kb-article__body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
  background: var(--bg-raised);
  color: var(--accent-light);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}
.kb-article__body pre {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  overflow-x: auto;
  margin: 1.4em 0;
  font-size: 13.5px;
  line-height: 1.6;
}
.kb-article__body pre code {
  background: transparent;
  color: var(--text-primary);
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: inherit;
}

.kb-article__body blockquote {
  margin: 1.6em 0;
  padding: 16px 22px;
  border-left: 3px solid var(--accent);
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-primary);
  font-size: 0.95em;
}
.kb-article__body blockquote p { color: var(--text-primary); }
.kb-article__body blockquote > :first-child { margin-top: 0; }
.kb-article__body blockquote > :last-child { margin-bottom: 0; }

.kb-article__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 14.5px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.kb-article__body th,
.kb-article__body td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.kb-article__body th {
  background: var(--bg-raised);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.kb-article__body tr:last-child td { border-bottom: 0; }

.kb-article__body hr {
  border: 0;
  height: 1px;
  background: var(--border-subtle);
  margin: 2em 0;
}

.kb-article__body img {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin: 1.4em 0;
}

/* ── Article aside ─────────────────────────────────────────────── */
.kb-article__aside {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (max-width: 900px) { .kb-article__aside { position: static; } }

.kb-aside-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.kb-aside-card h4 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 14px;
}
.kb-aside-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.kb-aside-list li { margin-bottom: 8px; }
.kb-aside-list a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color .2s var(--ease);
}
.kb-aside-list a:hover { color: var(--text-primary); }
.kb-aside-card--support p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ── Category cards: visually distinct from article cards ─────── */
/* Category cards are directory-style entry points. They get a flatter,
   denser look so they read as navigation, not as content. The article
   cards keep the more substantial "preview card" treatment below. */
.kb-card--category {
  padding: 18px 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  min-height: 0;
}
.kb-card--category::before { display: none; }
.kb-card--category:hover {
  background: var(--accent-subtle);
  border-color: var(--border-subtle);
  border-left-color: var(--gold, #D3AF37);
  transform: translateY(-1px);
}
.kb-card--category .kb-card__title {
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--accent-light);
}
.kb-card--category .kb-card__summary {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.kb-card--category .kb-card__count {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Article cards keep their existing styling — explicit class so any
   future tweaks land here, not on the base .kb-card. */
.kb-card--article {
  /* inherits .kb-card */
}

/* Hidden-by-default article cards, revealed by the "Load more" button. */
.kb-card.is-hidden { display: none; }

/* ── "Load more articles" button ──────────────────────────────── */
.kb-load-more-wrap {
  display: flex;
  justify-content: center;
  margin: 28px 0 8px;
}
.kb-load-more {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 32px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  cursor: pointer;
  transition: background .2s var(--ease),
              border-color .2s var(--ease),
              transform .2s var(--ease);
}
.kb-load-more:hover:not(:disabled) {
  background: var(--accent-subtle);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.kb-load-more:disabled,
.kb-load-more.is-done {
  cursor: default;
  opacity: 0.65;
}
.kb-load-more__label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-light);
}
.kb-load-more.is-done .kb-load-more__label {
  color: var(--text-muted);
}
.kb-load-more__count {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ── Pagefind UI: fix the unstyled Clear button and the empty filter pill ─── */
/* Clear button: Pagefind renders it as a bare <button> with placeholder
   styling. Re-skin to match the rest of the site. */
.kb-search .pagefind-ui__search-clear {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .2s var(--ease),
              border-color .2s var(--ease),
              color .2s var(--ease);
}
.kb-search .pagefind-ui__search-clear:hover {
  background: var(--accent-subtle);
  color: var(--accent-light);
  border-color: var(--accent);
}

/* Filter pill: Pagefind ships the filter panel collapsed with only a
   caret as the affordance. Surface the label and make the chevron more
   prominent so the panel is discoverable; pair this with the
   openFilters: ['category'] option in PagefindUI() to open it by default. */
.kb-search .pagefind-ui__filter-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.kb-search details.pagefind-ui__filter-block summary,
.kb-search .pagefind-ui__filter-name {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-light);
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kb-search details.pagefind-ui__filter-block summary::after,
.kb-search .pagefind-ui__filter-name::after {
  content: "▾";
  margin-left: 8px;
  font-size: 14px;
  color: var(--text-muted);
  transition: transform .2s var(--ease);
}
.kb-search details.pagefind-ui__filter-block[open] summary::after {
  transform: rotate(180deg);
}
.kb-search .pagefind-ui__filter-value {
  color: var(--text-secondary);
  font-size: 13px;
}
.kb-search .pagefind-ui__filter-value:hover {
  color: var(--text-primary);
}


[data-theme="light"] .kb-card {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .kb-card:hover {
  background: #fafafa;
  border-color: rgba(0,0,0,0.15);
}
[data-theme="light"] .kb-aside-card {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .kb-article__body pre,
[data-theme="light"] .kb-article__body code {
  background: #f4f1f8;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .kb-article__body blockquote {
  background: rgba(132, 56, 184, 0.06);
}
[data-theme="light"] .kb-search .pagefind-ui__search-input {
  background: #ffffff;
}

/* Light-theme overrides for the new components */
[data-theme="light"] .kb-card--category {
  background: #f7f3fb;
  border-color: rgba(0,0,0,0.06);
  border-left-color: var(--accent);
}
[data-theme="light"] .kb-card--category:hover {
  background: #f0e8f7;
}
[data-theme="light"] .kb-load-more {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .kb-load-more:hover:not(:disabled) {
  background: rgba(132, 56, 184, 0.06);
}
[data-theme="light"] .kb-search .pagefind-ui__search-clear {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .kb-search .pagefind-ui__search-clear:hover {
  background: rgba(132, 56, 184, 0.06);
}
[data-theme="light"] .kb-search .pagefind-ui__filter-panel {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}
