/* ══════════════════════════════════════════════════════════════════════════════
   Knowledge Hub  ·  knowledge-hub.css
   Loaded only on the knowledge-hub page slug.
   Depends on dynamic-pages.css (.wrap, footer, body resets).
══════════════════════════════════════════════════════════════════════════════ */

/* ── Page shell ─────────────────────────────────────────────────────────────── */
.kh-page {
  --kh-section-gap: 56px;

  --bg: #fff;
  --text: #0b1220;
  --muted: #5b677a;
  --border: rgba(15,23,42,.10);
  --brand: #F97316;
  --brand2: #EA580C;

  padding-bottom: 80px;
}

/* ── Masthead ────────────────────────────────────────────────────────────────── */
.kh-masthead {
  padding: 52px 0 44px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.kh-masthead__eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: #9a3412;
}

.kh-masthead__title {
  margin: 0 0 10px;
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1.08;
  letter-spacing: -.03em;
  color: var(--text);
}

.kh-masthead__lead {
  margin: 0 0 32px;
  font-size: clamp(15px, 1.8vw, 17px);
  line-height: 1.6;
  color: var(--muted);
  max-width: 52ch;
}

/* ── Controls row (search + filter) ─────────────────────────────────────────── */
.kh-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Search ─────────────────────────────────────────────────────────────────── */
.kh-search__field {
  position: relative;
  display: flex;
  align-items: center;
  width: 320px;
}

.kh-search__icon {
  position: absolute;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
}

.kh-search__input {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
  transition: border-color .18s, box-shadow .18s;
  appearance: none;
  -webkit-appearance: none;
}
.kh-search__input::placeholder { color: #94a3b8; }
.kh-search__input::-webkit-search-cancel-button,
.kh-search__input::-webkit-search-decoration { display: none; }
.kh-search__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}

.kh-search__clear {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.kh-search__clear:hover { background: #f1f5f9; color: var(--text); }
.kh-search__clear[hidden] { display: none; }

/* ── Filter dropdown (nav-style) ─────────────────────────────────────────── */
.kh-filter-dropdown {
  position: static;
  display: inline-block;
}

/* Trigger */
.kh-filter-trigger {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  transition: color .2s ease, background .2s ease;
}
.kh-filter-trigger:hover {
  background: #f1f5f9;
  color: #0b1220;
}

/* Underline animation on trigger text — mirrors .nav-dropdown-trigger-text */
.kh-filter-trigger-text {
  position: relative;
}
.kh-filter-trigger-text::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .25s ease;
}
.kh-filter-dropdown.open .kh-filter-trigger-text::before { transform: scaleX(1); }

/* Arrow state — mirrors .nav-dropdown.open arrow swap */
.kh-filter-dropdown.open .nav-arrow-down { opacity: 0; }
.kh-filter-dropdown.open .nav-arrow-up  { opacity: 1; }

/* Panel — mirrors .nav-dropdown-menu */
.kh-filter-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 10px;
  min-width: min(760px, calc(100vw - 40px));
  width: max-content;
  max-width: min(920px, calc(100vw - 40px));
  overflow: visible;
  padding: 12px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0;
  box-shadow: 0 12px 40px rgba(15,23,42,.12), 0 4px 12px rgba(15,23,42,.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  z-index: 30;
}
.kh-filter-dropdown.open .kh-filter-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.kh-filter-menu-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 28px;
  padding: 0 4px;
}

.kh-filter-column {
  flex: 1 1 180px;
  min-width: 180px;
  max-width: 240px;
}

.kh-filter-column--reset {
  flex: 0 0 140px;
  min-width: 140px;
  max-width: 160px;
}

/* Section subheadings — mirrors .nav-dropdown-menu .nav-dropdown-subhead */
.kh-filter-subhead {
  display: block;
  min-height: 2.6em;
  padding: 4px 12px 8px;
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  line-height: 1.35;
  white-space: normal;
}

/* Options — mirrors .nav-dropdown-menu .nav-dropdown-item */
.kh-filter-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  margin: 4px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 10px;
  transition: background .2s ease, color .2s ease;
  line-height: 1.3;
  white-space: normal;
}
.kh-filter-option:hover,
.kh-filter-option--active {
  background: rgba(249,115,22,.08);
  color: var(--brand);
}

/* "All articles" reset option — slightly softer weight */
.kh-filter-option--all {
  font-weight: 500;
  color: var(--muted);
}

/* ── Section ─────────────────────────────────────────────────────────────────── */
.kh-filter-clear {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  margin: 8px 0 0;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  line-height: 1.3;
  transition: color .2s ease;
}
.kh-filter-clear:hover {
  color: var(--brand);
}

.kh-section {
  margin-bottom: var(--kh-section-gap);
}
.kh-section[hidden] { display: none; }

/*
  Section heading: styled like videos & tutorials section titles —
  clamp(22px→30px), with a brand gradient vertical bar before the text.
*/
/* ── Tab panels ──────────────────────────────────────────────────────────────── */
.kh-section__title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0 20px;
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--text);
}
.kh-section__title::before {
  content: "";
  flex-shrink: 0;
  width: 4px;
  height: 1.1em;
  border-radius: 2px;
  background: var(--kh-color, var(--brand));
}

.kh-section__reveal {
  overflow: hidden;
  transition: max-height .34s ease;
  will-change: max-height;
}

.kh-card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  padding: 0 20px;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
/* ── Cards — title-focused, 5 per page ──────────────────────────────────────── */
.kh-section__actions {
  display: flex;
  justify-content: center;
  padding: 18px 20px 0;
}

.kh-section__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(249,115,22,.24);
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(249,115,22,.12);
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.kh-section__toggle:hover {
  border-color: rgba(249,115,22,.44);
  background: #ffedd5;
  box-shadow: 0 7px 20px rgba(249,115,22,.18);
  transform: translateY(-1px);
}
.kh-section__toggle svg {
  flex-shrink: 0;
  transition: transform .24s ease;
}
.kh-section.is-expanded .kh-section__toggle svg {
  transform: rotate(180deg);
}
.kh-section__toggle[hidden] { display: none; }

.kh-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 196px;
  overflow: visible;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  position: relative;
  transition: box-shadow .22s, transform .22s, border-color .22s;
}
.kh-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  pointer-events: none;
  transition: border-color .22s;
  z-index: 2;
}
.kh-card[hidden] { display: none; }
.kh-card:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: -3px;
  z-index: 1;
}

/* Hover animations */
.kh-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(15,23,42,.14);
  z-index: 1;
}
.kh-card:hover::before            { border-color: rgba(249,115,22,.32); }
.kh-card:hover .kh-card__title   { color: var(--kh-color, var(--brand2)); }
.kh-card:hover .kh-card__body    { background: #fffaf5; }

/* Slim section accent */
.kh-card__stripe {
  flex: 0 0 5px;
  height: 5px;
  border-radius: 6px 6px 0 0;
  background: var(--kh-color, var(--brand));
  opacity: .9;
}

/* Card content */
.kh-card__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 13px 13px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  transition: background .22s;
  overflow: visible;
}

.kh-card__signal {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--kh-color, var(--brand));
  box-shadow: 0 0 0 3px rgba(249,115,22,.10), 0 0 15px var(--kh-color, var(--brand));
  flex: 0 0 auto;
}

.kh-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  transition: color .22s;
  letter-spacing: -.01em;
}

.kh-card__sub {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* Card tags */
.kh-card__tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  margin-top: auto;
  padding-top: 4px;
  min-width: 0;
  position: relative;
  z-index: 3;
}

.kh-card__tag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 100%;
  min-height: 21px;
  padding: 3px 7px 4px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kh-card__tag[hidden] {
  display: none;
}

.kh-card__tag--selected {
  border-color: rgba(249,115,22,.42);
  background: #fff7ed;
  color: #9a3412;
  box-shadow: 0 0 0 2px rgba(249,115,22,.12), 0 0 14px rgba(249,115,22,.24);
}

.kh-card__tag--more {
  position: relative;
  overflow: visible;
  border-color: rgba(249,115,22,.22);
  background: #fff7ed;
  color: #9a3412;
  cursor: help;
}

.kh-card__tag-popover {
  position: fixed;
  top: var(--kh-popover-top, 0);
  left: var(--kh-popover-left, 0);
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  width: max-content;
  max-width: min(280px, calc(100vw - 40px));
  padding: 10px;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 14px 34px rgba(15,23,42,.16);
  white-space: normal;
  z-index: 1000;
  pointer-events: none;
}

.kh-card__tag-popover::after {
  content: "";
  position: absolute;
  left: var(--kh-popover-arrow-left, 24px);
  bottom: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #fff;
}

.kh-card__tag-popover--floating.is-visible {
  display: flex;
}

.kh-card__tag-popover-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px 4px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
}

.kh-card__tag-popover-chip--selected {
  border-color: rgba(249,115,22,.42);
  background: #fff7ed;
  color: #9a3412;
  box-shadow: 0 0 0 2px rgba(249,115,22,.12), 0 0 14px rgba(249,115,22,.22);
}

/* ── Filter column overflow (>8 options) ────────────────────────────────────── */
.kh-filter-overflow-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.kh-filter-overflow-wrap.is-expanded {
  grid-template-rows: 1fr;
}
.kh-filter-overflow-inner {
  overflow: hidden;
}

.kh-filter-overflow-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 10px 16px;
  margin: 4px 0 0;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  line-height: 1.3;
  transition: color .2s;
}
.kh-filter-overflow-toggle:hover { color: var(--brand); }
.kh-filter-overflow-toggle svg {
  flex-shrink: 0;
  transition: transform .3s ease;
}
.kh-filter-overflow-toggle.is-expanded svg {
  transform: rotate(180deg);
}

/* ── Empty / no-results states ───────────────────────────────────────────────── */
.kh-empty,
.kh-no-results {
  padding: 56px 0;
  color: var(--muted);
  font-size: 15px;
}
.kh-no-results[hidden] { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kh-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .kh-filter-menu {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .kh-filter-menu-inner {
    flex-direction: column;
    gap: 6px;
  }
  .kh-filter-column,
  .kh-filter-column--reset {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .kh-filter-subhead {
    min-height: 0;
    margin-top: 6px;
  }
}

@media (max-width: 560px) {
  .kh-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 14px;
  }
  .kh-page { --kh-section-gap: 36px; }
  .kh-masthead { padding: 32px 0 28px; margin-bottom: 28px; }
  .kh-controls { flex-direction: column; align-items: flex-start; }
  .kh-search__field { width: 100%; }
}

@media (max-width: 420px) {
  .kh-card-grid {
    grid-template-columns: 1fr;
  }
}
