/* ── Knowledge Base Page ───────────────────────────────────────────────── */

/* Nav additions */
.kb-nav {
  justify-content: space-between;
}

.kb-nav-links {
  display: flex;
  gap: 4px;
}

.kb-nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.kb-nav-link:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.kb-nav-link--active {
  color: var(--accent);
  background: #fff8ec;
}

/* Hero */
.kb-hero {
  background: var(--navy);
  padding: 48px 24px 40px;
  text-align: center;
}

.kb-hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.kb-hero-title {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.8px;
  margin-bottom: 10px;
}

.kb-hero-sub {
  font-size: 15px;
  color: rgba(255,255,255,0.65);
  line-height: 1.6;
  margin-bottom: 24px;
}

.kb-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.kb-stat {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
}

.kb-stat strong {
  color: var(--accent);
}

.kb-stat-divider {
  color: rgba(255,255,255,0.3);
}

/* Tab bar */
.kb-tabs-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 57px;
  z-index: 9;
}

.kb-tabs {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.kb-tabs::-webkit-scrollbar { display: none; }

.kb-tab {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  margin-bottom: -1px;
}

.kb-tab:hover { color: var(--text-primary); }

.kb-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Main content */
.kb-main {
  flex: 1;
  padding: 40px 24px 64px;
}

.kb-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* Section */
.kb-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.kb-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid;
  letter-spacing: 0.2px;
}

.kb-section-count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Card grid */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Cards */
.kb-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  padding: 0;
  width: 100%;
}

.kb-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.10);
  transform: translateY(-2px);
  border-color: transparent;
}

.kb-card-strip {
  height: 4px;
  width: 100%;
}

.kb-card-body {
  padding: 20px;
}

.kb-card-icon {
  font-size: 28px;
  margin-bottom: 10px;
  line-height: 1;
}

.kb-card-module {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.kb-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.2px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.kb-card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.kb-card-read {
  font-size: 13px;
  font-weight: 600;
}

/* Error state */
.kb-error {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  padding: 32px;
}

/* ── Reader overlay ────────────────────────────────────────────────────── */
.reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 25, 31, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.reader-overlay--open {
  opacity: 1;
  pointer-events: all;
}

.reader-panel {
  background: var(--bg);
  width: 100%;
  max-width: 680px;
  height: 100%;
  overflow-y: auto;
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  transform: translateX(40px);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.reader-overlay--open .reader-panel {
  transform: translateX(0);
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.reader-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-close:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.reader-body {
  padding: 32px 28px 48px;
  flex: 1;
}

.reader-loading {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 32px 0;
  text-align: center;
}

/* Markdown rendered content */
.reader-body h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

.reader-body h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
  margin-top: 32px;
  margin-bottom: 12px;
}

.reader-body h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 24px;
  margin-bottom: 8px;
}

.reader-body p {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.75;
  margin-bottom: 14px;
}

.reader-body ul,
.reader-body ol {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.75;
  padding-left: 20px;
  margin-bottom: 14px;
}

.reader-body li { margin-bottom: 4px; }

.reader-body strong { color: var(--navy); font-weight: 600; }

.reader-body em { color: var(--text-secondary); }

.reader-body code {
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--navy);
}

.reader-body pre {
  background: var(--navy);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.reader-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e8eaed;
  font-size: 13px;
}

.reader-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}

.reader-body th {
  background: var(--surface);
  color: var(--navy);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.reader-body td {
  padding: 9px 14px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
}

.reader-body tr:nth-child(even) td { background: var(--surface); }

.reader-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 16px 0;
  background: #fff8ec;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.reader-body blockquote p {
  color: var(--navy);
  font-style: italic;
  margin: 0;
}

.reader-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .kb-hero { padding: 32px 20px 28px; }
  .kb-hero-title { font-size: 24px; }
  .kb-grid { grid-template-columns: 1fr 1fr; }
  .reader-panel { max-width: 100%; }
  .reader-body { padding: 24px 20px 40px; }
}

@media (max-width: 480px) {
  .kb-grid { grid-template-columns: 1fr; }
}
