/* ==========================================================================
   Kituwa Learn — Modern Technical Learning Platform (Coinbase x DigitalOcean)
   Zero external CDN dependencies · Pure CSS custom properties · Light & Dark
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fc;
  --bg-elevated: #ffffff;
  --bg-code: #0b1220;
  --bg-code-inline: #eef2ff;
  --text: #0a0f1c;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-code-inline: #0040cc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #0052ff;
  --primary-hover: #0040cc;
  --primary-soft: #ebf2ff;
  --primary-soft-text: #0045d8;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(10, 15, 28, 0.04);
  --shadow-md: 0 6px 20px rgba(10, 15, 28, 0.06);
  --shadow-lg: 0 16px 40px rgba(10, 15, 28, 0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --nav-h: 64px;
  --tabs-h: 54px;
}

[data-theme="dark"] {
  --bg: #070b14;
  --bg-subtle: #0d1424;
  --bg-elevated: #11192c;
  --bg-code: #050811;
  --bg-code-inline: #172554;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-code-inline: #93c5fd;
  --border: #1e293b;
  --border-strong: #334155;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --primary-soft-text: #93c5fd;
  --emerald: #34d399;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --violet: #a78bfa;
  --violet-soft: rgba(139, 92, 246, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.50);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.62;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Brand Logo light/dark swap */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

/* ==========================================================================
   Top Platform Navbar
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-link img {
  height: 32px;
  width: auto;
}

.module-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.module-switcher-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.module-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-bar-mini {
  width: 48px;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar-mini > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ==========================================================================
   Sticky Top Chapter Tabs Bar (Course Navigation)
   ========================================================================== */
.tabs-bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.tabs-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.chapter-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

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

.chapter-tab .tab-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.chapter-tab[aria-selected="true"] {
  color: var(--primary);
}

.chapter-tab[aria-selected="true"] .tab-num {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.chapter-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2.5px;
  border-radius: 2px 2px 0 0;
  background: var(--primary);
}

.chapter-tab .done-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
}

.chapter-tab.is-done .done-dot {
  display: inline-block;
}

/* ==========================================================================
   Hero Banner (Compact, Modern Coinbase / DigitalOcean Style)
   ========================================================================== */
.hero {
  background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 36px 20px 32px;
}

.hero-inner {
  max-width: 1140px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 32px;
  align-items: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.85rem, 3.2vw, 2.65rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero p {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 1.02rem;
  max-width: 58ch;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-visual img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Main Course Container & Chapter Panels
   ========================================================================== */
.main-wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 36px 20px 80px;
}

.chapter-panel {
  display: none;
  animation: fadeSlide 0.22s ease;
}

.chapter-panel.active {
  display: block;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.chapter-kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.chapter-header h2 {
  margin: 0 0 6px;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.chapter-lead {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.98rem;
  max-width: 68ch;
}

.complete-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.complete-toggle:hover {
  border-color: var(--emerald);
}

.complete-toggle.completed {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald);
}

/* Content Sections */
.section-block {
  margin-bottom: 36px;
}

.section-block h3 {
  margin: 0 0 12px;
  font-size: 1.22rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-block p {
  margin: 0 0 14px;
  color: var(--text-secondary);
}

.section-divider {
  width: 100%;
  height: 20px;
  margin: 30px 0;
  display: block;
  opacity: 0.9;
}

/* Grids & Feature Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-title {
  margin: 0 0 6px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card p, .card li {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.card li { margin-bottom: 4px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-blue { background: var(--primary-soft); color: var(--primary-soft-text); }
.badge-green { background: var(--emerald-soft); color: var(--emerald); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-red { background: var(--danger-soft); color: var(--danger); }

/* Callout Boxes */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  background: var(--bg-subtle);
  margin: 18px 0;
  font-size: 0.92rem;
}

.callout.callout-amber { border-left-color: var(--amber); background: var(--amber-soft); }
.callout.callout-green { border-left-color: var(--emerald); background: var(--emerald-soft); }
.callout.callout-violet { border-left-color: var(--violet); background: var(--violet-soft); }
.callout strong { color: var(--text); }

/* Inline Code & Code Blocks */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-code-inline);
  color: var(--text-code-inline);
}

.code-block {
  position: relative;
  margin: 14px 0 18px;
  border-radius: var(--radius-md);
  background: var(--bg-code);
  border: 1px solid #1e293b;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: #94a3b8;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.copy-btn:hover { background: #2563eb; border-color: #3b82f6; color: #fff; }
.copy-btn.copied { background: #059669; border-color: #10b981; color: #fff; }

.code-block pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.58;
  color: #e2e8f0;
}

.code-block pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* Diagrams / Infographics / Screenshots */
.visual-figure {
  margin: 22px 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.visual-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.zoom-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.zoom-btn:hover { border-color: var(--primary); color: var(--primary); }

.visual-frame {
  padding: 12px;
  background: #070c17;
  cursor: zoom-in;
}

.visual-frame img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

.visual-figure figcaption {
  padding: 10px 16px;
  font-size: 0.84rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 16px 0;
  background: var(--bg-elevated);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-subtle);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }

/* Interactive Filter / Recipe Builder */
.filter-input {
  width: 100%;
  max-width: 380px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.recipe-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.recipe-pill {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.recipe-pill.active, .recipe-pill:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Bottom Chapter Pager */
.chapter-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.pager-btn:hover { border-color: var(--primary); color: var(--primary); }
.pager-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.pager-btn.primary:hover { background: var(--primary-hover); color: #ffffff; }

/* Modals (Course Catalog, Quick Search, Lightbox) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 17, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal-card {
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-card.lightbox-card {
  max-width: 1080px;
  padding: 16px;
  background: #070c17;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h3 { margin: 0; font-size: 1.15rem; }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.search-hit {
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
}

.search-hit:hover { border-color: var(--primary); }
.search-hit-title { font-weight: 700; font-size: 0.92rem; }
.search-hit-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 28px 20px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Responsive */
@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; }
  .progress-pill span.progress-label { display: none; }
  .kbd-hint { display: none; }
}

@media (max-width: 560px) {
  .module-switcher-btn .module-version { display: none; }
  .chapter-pager { flex-direction: column; align-items: stretch; }
  .pager-btn { justify-content: center; }
}

/* ------------------------------------------------------------------
   Structural styles moved out of inline attributes (CSP: style-src 'self')
   and the Kituwa Network strip offset.
   ------------------------------------------------------------------ */
#progressBarFill { width: 0; transition: width .25s ease; }
.catalog-intro { margin-top: 0; color: var(--text-secondary); font-size: 0.9rem; }
.catalog-list { grid-template-columns: 1fr; }
.search-full { max-width: 100%; }
.modal-header-tight { margin-bottom: 10px; }
.lightbox-caption { color: #cbd5e1; font-size: 0.86rem; font-weight: 600; }
.lightbox-close { background: #1e293b; color: #f8fafc; border-color: #334155; }
.lightbox-img { width: 100%; height: auto; border-radius: 10px; display: block; }
.catalog-row-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 0.8rem; color: var(--text-muted); }
.pager-btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.search-empty { padding: 12px; color: var(--text-muted); font-size: 0.9rem; }

/* Narrow phones: the header never overlaps. Progress moves into the chapter
   pager, the module pill keeps its dot, and the theme switch keeps its icon. */
@media (max-width: 560px) {
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .brand-group { gap: 8px; }
  .brand-link img { height: 28px; }
  .module-switcher-btn { padding: 6px 8px; }
  .module-switcher-btn .module-name { display: none; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  .progress-pill { display: none; }
  .icon-btn { padding: 8px 10px; }
  .icon-btn .theme-label { display: none; }
}
