/* ══════════════════════════════════════════════════════════════════
   HSC Mastery System — Main Stylesheet
   Design: Scholarly dark UI, gold/amber accent, Playfair Display serif
   ══════════════════════════════════════════════════════════════════ */

/* ── 1. Google Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap');

/* ── 2. Design Tokens ────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:    #0c0e14;
  --bg-surface: #11141c;
  --bg-raised:  #171b26;
  --bg-card:    #1c2030;
  --bg-hover:   #222840;

  /* Gold/Amber brand */
  --gold:       #c9a840;
  --gold-light: #e4c55a;
  --gold-dim:   rgba(201, 168, 64, 0.15);
  --gold-glow:  rgba(201, 168, 64, 0.25);
  --amber:      #e07838;
  --teal:       #3ab5a8;

  /* Text */
  --text-100: #eae5d5;
  --text-200: #9890a8;
  --text-300: #585468;

  /* Borders */
  --border:     #1e2436;
  --border-mid: #2a3148;

  /* Status */
  --green:  #3abf7a;
  --red:    #e05555;
  --yellow: #f0a830;
  --blue:   #5b8df0;

  /* Tier colours (used on badges + card accents) */
  --tier1-c: #4f8ef7;
  --tier2-c: #9b59b6;
  --tier3-c: #e67e22;
  --tier4-c: #e74c3c;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  56px;

  /* Shared aliases (used by JS-generated HTML) */
  --accent-primary:   var(--gold);
  --accent-secondary: var(--amber);
  --bg-primary:   var(--bg-base);
  --bg-secondary: var(--bg-surface);
  --bg-tertiary:  var(--bg-raised);
  --text-primary:   var(--text-100);
  --text-secondary: var(--text-200);
  --text-muted:     var(--text-300);
  --border-color:   var(--border);
  --success: var(--green);
  --warning: var(--yellow);
  --error:   var(--red);

  /* Tokens */
  --radius:    10px;
  --radius-lg: 16px;
  --trans:     0.18s ease;
  --trans-md:  0.3s ease;

  /* Domain event colours */
  --domain-political:   #e05555;
  --domain-military:    #c4973a;
  --domain-cultural:    #7c5cbf;
  --domain-economic:    #4caf7d;
  --domain-social:      #6c8ebf;
  --domain-religious:   #e8a0bf;
  --domain-scientific:  #5bc8af;
  --domain-environmental: #8bc34a;
}

[data-theme="light"] {
  --bg-base:    #faf7f0;
  --bg-surface: #f2ece0;
  --bg-raised:  #e8e0d0;
  --bg-card:    #ffffff;
  --bg-hover:   #f0e8d8;

  --gold:       #9a7a14;
  --gold-light: #b89018;
  --gold-dim:   rgba(154, 122, 20, 0.12);
  --gold-glow:  rgba(154, 122, 20, 0.2);
  --amber:      #c05a20;
  --teal:       #2a9890;

  --text-100: #1a1610;
  --text-200: #5c5448;
  --text-300: #9a9288;

  --border:     #ddd4c0;
  --border-mid: #ccc4b0;
}

/* ── 3. Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-100);
  line-height: 1.65;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg, video, canvas, iframe, embed {
  display: block;
  max-width: 100%;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--trans);
}
a:hover { color: var(--gold-light); }

ul, ol { list-style: none; }

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ── 4. Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-300); }

/* ── 5. Typography ───────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-100);
}

h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.4rem); }
h4 { font-size: 1.1rem; font-family: 'Inter', sans-serif; font-weight: 600; }
h5 { font-size: 0.95rem; font-family: 'Inter', sans-serif; font-weight: 600; }
h6 { font-size: 0.875rem; font-family: 'Inter', sans-serif; font-weight: 600; }

p { color: var(--text-200); line-height: 1.75; margin-bottom: 0.9em; }
p:last-child { margin-bottom: 0; }

strong, b { font-weight: 600; color: var(--text-100); }
em { font-style: italic; }

code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-raised);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--gold);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── 6. Utility ──────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}
.hidden { display: none !important; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-300); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.placeholder-text { color: var(--text-300); font-size: 0.9rem; text-align: center; padding: 2rem 0; }
.optional { font-size: 0.8em; color: var(--text-300); }

/* ── 7. Loading Overlay ──────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.loading-emblem {
  font-size: 3rem;
  color: var(--gold);
  animation: emblem-pulse 2s ease-in-out infinite;
}

@keyframes emblem-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-mid);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.85rem;
  color: var(--text-300);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: fade-pulse 1.5s ease-in-out infinite;
}

@keyframes fade-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── 8. Toast Notifications ──────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-100);
  pointer-events: auto;
  animation: toast-in 0.25s ease forwards;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border-left: 3px solid var(--gold);
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.info    { border-left-color: var(--blue); }
.toast.fadeout { animation: toast-out 0.25s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ── 9. Modal ────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(8, 10, 16, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text-200);
  font-size: 1.1rem;
  transition: all var(--trans);
}

.modal-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-100);
}

/* ── 10. App Shell Layout ────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── 11. Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  transition: transform var(--trans-md);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-emblem {
  font-size: 1.6rem;
  color: var(--gold);
  line-height: 1;
}

.brand-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-100);
  letter-spacing: -0.01em;
}

.brand-dot { color: var(--gold); }

.nav-list {
  flex: 1;
  padding: 0.75rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  border-radius: 8px;
  color: var(--text-200);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  border-left: 2px solid transparent;
  white-space: nowrap;
}

.nav-icon {
  font-size: 1.05rem;
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--bg-raised);
  color: var(--text-100);
  border-left-color: var(--border-mid);
}

.nav-link.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-left-color: var(--gold);
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.theme-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.875rem;
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text-200);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--trans);
  border: 1px solid var(--border);
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-100);
  border-color: var(--border-mid);
}

.theme-icon { font-size: 1rem; }
.theme-label { font-size: 0.875rem; }

/* sidebar backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.7);
  z-index: 999;
  backdrop-filter: blur(2px);
}

/* ── 12. Mobile Topbar ───────────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
  flex-shrink: 0;
}

.topbar-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-100);
}

.topbar-spacer { flex: 1; }

/* Hamburger */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
  flex-shrink: 0;
}

.hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-200);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
}

/* ── 13. Main Content ────────────────────────────────────────────── */
#main-content {
  flex: 1;
}

/* ── 14. Views ───────────────────────────────────────────────────── */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 0.25s ease forwards;
}

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

.view-header {
  padding: 2.5rem 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.view-header-contained {
  max-width: 1200px;
  margin: 0 auto;
}

.view-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.3rem;
}

.view-subtitle {
  color: var(--text-200);
  font-size: 0.95rem;
  margin: 0;
}

/* Full-width views (timeline, graph) need no inner padding */
.view-full > .view-header { padding-left: 2rem; padding-right: 2rem; }

/* ── 15. Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.35rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all var(--trans);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Gold / Primary */
.btn-gold, .btn-primary {
  background: var(--gold);
  color: #0c0e14;
  border-color: var(--gold);
  font-weight: 600;
}
.btn-gold:hover, .btn-primary:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  box-shadow: 0 4px 16px var(--gold-glow);
  transform: translateY(-1px);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--text-200);
  border-color: var(--border-mid);
}
.btn-outline:hover {
  background: var(--bg-raised);
  color: var(--text-100);
  border-color: var(--gold);
  color: var(--gold);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-200);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-raised);
  color: var(--text-100);
}

/* Sizes */
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; border-radius: 10px; }
.btn-sm { padding: 0.4rem 0.875rem; font-size: 0.82rem; border-radius: 6px; }

/* ── 16. Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-tier1 { background: rgba(79,142,247,0.15); color: var(--tier1-c); border: 1px solid rgba(79,142,247,0.3); }
.badge-tier2 { background: rgba(155,89,182,0.15); color: var(--tier2-c); border: 1px solid rgba(155,89,182,0.3); }
.badge-tier3 { background: rgba(230,126,34,0.15);  color: var(--tier3-c); border: 1px solid rgba(230,126,34,0.3); }
.badge-tier4 { background: rgba(231,76,60,0.15);   color: var(--tier4-c); border: 1px solid rgba(231,76,60,0.3); }
.badge-gold  { background: var(--gold-dim); color: var(--gold); border: 1px solid var(--gold); }

/* ── 17. Form Controls ───────────────────────────────────────────── */
.ctrl-select,
.ctrl-search {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  color: var(--text-100);
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}

.ctrl-select:focus,
.ctrl-search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.ctrl-select option { background: var(--bg-surface); }

.ctrl-search::placeholder { color: var(--text-300); }

.ctrl-slider {
  -webkit-appearance: none;
  height: 4px;
  background: var(--border-mid);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.ctrl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
}

.ctrl-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-200);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ctrl-value {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  min-width: 2ch;
}

.ctrl-slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── 18. Progress Bars ───────────────────────────────────────────── */
.progress-bar-track {
  height: 4px;
  background: var(--border-mid);
  border-radius: 2px;
  overflow: hidden;
  flex: 1;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 2px;
  transition: width 0.5s ease;
  min-width: 0;
}

/* ── 19. Cards ───────────────────────────────────────────────────── */
.topic-card,
.domain-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--trans), box-shadow var(--trans), transform var(--trans);
  position: relative;
  overflow: hidden;
}

.topic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--tier-color, var(--gold));
  opacity: 0;
  transition: opacity var(--trans);
}

.topic-card:hover {
  border-color: var(--border-mid);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px var(--gold-dim);
  transform: translateY(-2px);
}

.topic-card:hover::before { opacity: 1; }

.card-icon {
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.card-tier-badge {
  align-self: flex-start;
}

.card-title {
  font-size: 1.05rem;
  font-family: 'Playfair Display', serif;
  color: var(--text-100);
  margin: 0.1rem 0 0;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-200);
  line-height: 1.55;
  flex: 1;
  margin: 0;
}

.card-concepts {
  font-size: 0.78rem;
  color: var(--text-300);
  margin: 0;
}

.card-concepts strong { color: var(--text-200); }

.card-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.level-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 0.15em 0.5em;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.progress-label {
  font-size: 0.72rem;
  color: var(--text-300);
  white-space: nowrap;
  flex-shrink: 0;
}

.card-cta { margin-top: 0.5rem; align-self: flex-start; }

/* ── 20. Section Headings ────────────────────────────────────────── */
.section-title {
  font-size: 1.2rem;
  color: var(--text-100);
  margin-bottom: 0.15rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-link {
  font-size: 0.85rem;
  color: var(--gold);
}

.section-link:hover { color: var(--gold-light); }

/* ── 21. HOME VIEW ───────────────────────────────────────────────── */

/* Hero */
.hero {
  min-height: calc(100svh - 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5rem 2rem 4rem;
  position: relative;
  overflow: hidden;
  gap: 3rem;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 25% 50%, rgba(201,168,64,0.05) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 30%, rgba(58,181,168,0.04) 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-base) 0%, var(--bg-surface) 100%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  max-width: 560px;
  z-index: 1;
}

.hero-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 1px;
  background: var(--gold);
}

.hero-title {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.08;
  margin-bottom: 1.25rem;
  color: var(--text-100);
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-200);
  line-height: 1.7;
  margin-bottom: 2rem;
  max-width: 460px;
}

.hero-actions {
  display: flex;
  gap: 0.875rem;
  flex-wrap: wrap;
}

/* Ornament */
.hero-ornament {
  position: relative;
  width: 240px;
  height: 240px;
  flex-shrink: 0;
  z-index: 1;
}

.ornament-ring {
  position: absolute;
  border: 1px solid;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: ornament-spin linear infinite;
}

.ornament-ring-1 {
  width: 220px; height: 220px;
  border-color: rgba(201,168,64,0.12);
  animation-duration: 30s;
}
.ornament-ring-2 {
  width: 160px; height: 160px;
  border-color: rgba(201,168,64,0.18);
  animation-duration: 20s;
  animation-direction: reverse;
}
.ornament-ring-3 {
  width: 100px; height: 100px;
  border-color: rgba(201,168,64,0.25);
  animation-duration: 12s;
}

@keyframes ornament-spin {
  from { transform: translate(-50%,-50%) rotate(0deg); }
  to   { transform: translate(-50%,-50%) rotate(360deg); }
}

.ornament-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  color: var(--gold);
  opacity: 0.6;
}

/* Stats row */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.stat-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
}

.stat-pill:last-child { border-right: none; }

.stat-num {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.stat-lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-300);
  margin-top: 0.3rem;
}

/* Home sections */
.home-section {
  padding: 3rem 2rem;
  border-bottom: 1px solid var(--border);
}

.home-section:last-child { border-bottom: none; }

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

/* Paths */
.paths-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.path-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  transition: border-color var(--trans);
}

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

.path-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.path-body {
  flex: 1;
  min-width: 0;
}

.path-title {
  font-size: 1rem;
  color: var(--text-100);
  margin-bottom: 0.25rem;
}

.path-desc {
  font-size: 0.82rem;
  color: var(--text-300);
  margin-bottom: 0.6rem;
}

.path-progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── 22. TOPICS VIEW ─────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 1.25rem 2rem;
}

.filter-tab {
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-200);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: all var(--trans);
}

.filter-tab:hover {
  border-color: var(--border-mid);
  color: var(--text-100);
}

.filter-tab.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: var(--gold);
}

/* Domain filter tabs (legacy class) */
.domain-filter-tabs { display: flex; gap: 0.4rem; padding: 1.25rem 2rem; flex-wrap: wrap; }
.tab-btn { padding: 0.4rem 1rem; border-radius: 999px; font-size: 0.82rem; font-weight: 500; color: var(--text-200); background: var(--bg-raised); border: 1px solid var(--border); transition: all var(--trans); cursor: pointer; }
.tab-btn:hover { border-color: var(--border-mid); color: var(--text-100); }
.tab-btn.active { background: var(--gold-dim); color: var(--gold); border-color: var(--gold); }

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
  padding: 0 2rem 2.5rem;
}

/* ── 23. LESSON VIEW ─────────────────────────────────────────────── */
.lesson-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-300);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--text-300); }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb-sep { color: var(--text-300); }

.lesson-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.lesson-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  margin-bottom: 0.75rem;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.lesson-time {
  font-size: 0.82rem;
  color: var(--text-300);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.lesson-xp {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 0.2em 0.6em;
  border-radius: 4px;
}

/* Lesson content */
.lesson-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-200);
}

.lesson-content h2,
.lesson-content h3 {
  color: var(--text-100);
  margin: 2rem 0 0.75rem;
}

.lesson-content p { margin-bottom: 1em; }

.lesson-content ul,
.lesson-content ol {
  list-style: none;
  padding-left: 1rem;
  margin-bottom: 1em;
}

.lesson-content ul li::before {
  content: '▸';
  color: var(--gold);
  margin-right: 0.5rem;
}

.lesson-content ol { counter-reset: lesson-ol; }
.lesson-content ol li { counter-increment: lesson-ol; }
.lesson-content ol li::before {
  content: counter(lesson-ol) '.';
  color: var(--gold);
  font-weight: 600;
  margin-right: 0.5rem;
}

/* Content blocks */
.lesson-hook,
.lesson-introduction,
.lesson-mental-model,
.lesson-misconceptions,
.lesson-connections,
.lesson-objectives,
.lesson-further-explore,
.lesson-index {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.lesson-hook {
  border-left: 3px solid var(--gold);
  background: linear-gradient(135deg, var(--bg-card), var(--bg-raised));
}

.lesson-hook p {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-100);
  margin: 0;
}

.lesson-mental-model { border-left: 3px solid var(--teal); }
.lesson-misconceptions { border-left: 3px solid var(--amber); }
.lesson-connections { border-left: 3px solid var(--blue); }
.lesson-objectives { border-left: 3px solid var(--green); }

.key-term-box {
  display: inline-flex;
  flex-direction: column;
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  margin: 0.2rem 0;
}

.key-term-box strong { color: var(--gold); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }

/* Lesson nav */
.lesson-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* ── 24. TIMELINE VIEW ───────────────────────────────────────────── */
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 2rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.timeline-container {
  width: 100%;
  min-height: 600px;
  overflow: hidden;
  background: var(--bg-base);
}

.timeline-container svg { width: 100%; }

/* ── 25. KNOWLEDGE GRAPH VIEW ────────────────────────────────────── */
.graph-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 280px;
  height: calc(100svh - 140px);
  min-height: 500px;
}

.graph-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.graph-container {
  background: var(--bg-base);
  overflow: hidden;
  position: relative;
}

.graph-container svg { width: 100%; height: 100%; }

.node-detail-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
}

.panel-placeholder {
  color: var(--text-300);
  font-size: 0.875rem;
  text-align: center;
  padding: 2rem 0;
}

/* ── 26. QUIZ VIEW ───────────────────────────────────────────────── */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.quiz-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-200);
  white-space: nowrap;
  min-width: 4ch;
}

.quiz-progress-track {
  flex: 1;
  height: 6px;
  background: var(--border-mid);
  border-radius: 3px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.quiz-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
}

.quiz-score-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-300);
  line-height: 1;
}

.quiz-score-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.quiz-card {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.quiz-question {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--text-100);
  margin-bottom: 2rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.quiz-option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-200);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: all var(--trans);
  cursor: pointer;
}

.quiz-option-btn:hover {
  background: var(--bg-hover);
  border-color: var(--gold);
  color: var(--text-100);
}

.quiz-option-btn.selected {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
}

.quiz-option-btn.correct-answer {
  border-color: var(--green);
  background: rgba(58,191,122,0.1);
  color: var(--green);
}

.quiz-option-btn.wrong-answer {
  border-color: var(--red);
  background: rgba(224,85,85,0.1);
  color: var(--red);
}

.quiz-option-btn:disabled { cursor: default; }

/* Fill-blank & chrono quiz buttons */
.quiz-fill-input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-100);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--trans);
}

.quiz-fill-input:focus { border-color: var(--gold); }
.quiz-fill-input.correct-answer { border-color: var(--green); }
.quiz-fill-input.wrong-answer { border-color: var(--red); }

.quiz-chrono-btn {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-200);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--trans);
  text-align: left;
}

.quiz-chrono-btn:hover { background: var(--bg-hover); border-color: var(--gold); }
.quiz-chrono-btn.correct-answer { border-color: var(--green); color: var(--green); }
.quiz-chrono-btn.wrong-answer { border-color: var(--red); color: var(--red); }

/* Feedback */
.quiz-feedback {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
}

.feedback-result {
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.feedback-correct { background: rgba(58,191,122,0.12); border: 1px solid rgba(58,191,122,0.3); color: var(--text-100); }
.feedback-correct .feedback-result { color: var(--green); }
.feedback-incorrect { background: rgba(224,85,85,0.1); border: 1px solid rgba(224,85,85,0.3); color: var(--text-100); }
.feedback-incorrect .feedback-result { color: var(--red); }

/* Quiz nav */
.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 2rem 2rem;
  max-width: 680px;
  margin: 0 auto;
}

/* Quiz Results */
.quiz-results {
  max-width: 560px;
  margin: 0 auto;
  padding: 3rem 2rem;
  text-align: center;
}

.results-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.results-title {
  font-size: 2rem;
}

.results-score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) 0deg, var(--border-mid) 0deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.results-score-ring::before {
  content: '';
  position: absolute;
  inset: 12px;
  background: var(--bg-base);
  border-radius: 50%;
}

.results-pct {
  position: relative;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  font-family: 'Playfair Display', serif;
  line-height: 1;
}

.results-score-ring small {
  position: relative;
  font-size: 0.7rem;
  color: var(--text-300);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.results-breakdown {
  margin: 1.5rem 0;
  text-align: left;
}

.results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* ── 27. PROGRESS VIEW ───────────────────────────────────────────── */
.progress-dashboard {
  display: flex;
  gap: 1.5rem;
  padding: 2rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.progress-ring-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ring-pct {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.ring-label small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-300);
  margin-top: 0.2rem;
}

.progress-stats-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 220px;
}

.streak-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.streak-flame { font-size: 1.5rem; }
.streak-num { font-family: 'Playfair Display', serif; font-size: 1.8rem; font-weight: 700; color: var(--amber); }
.streak-lbl { font-size: 0.8rem; color: var(--text-300); text-transform: uppercase; letter-spacing: 0.06em; }

.stats-quad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
}

.stat-block-num {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-100);
  line-height: 1;
}

.stat-block-lbl {
  font-size: 0.7rem;
  color: var(--text-300);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.3rem;
}

/* Domain progress list */
.domain-progress-list {
  padding: 1.25rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.domain-progress-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
}

.domain-progress-icon { font-size: 1.2rem; flex-shrink: 0; }
.domain-progress-name { font-size: 0.9rem; font-weight: 500; color: var(--text-100); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.domain-progress-pct { font-size: 0.8rem; color: var(--gold); font-weight: 600; white-space: nowrap; flex-shrink: 0; }

/* Activity list */
.activity-list {
  padding: 0 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.activity-icon { font-size: 1rem; flex-shrink: 0; }
.activity-desc { color: var(--text-200); flex: 1; }
.activity-date { font-size: 0.75rem; color: var(--text-300); white-space: nowrap; }

/* Section title in views */
#view-progress .section-title,
#view-achievements .section-title {
  padding: 1.75rem 2rem 0.5rem;
  border-top: 1px solid var(--border);
}

/* ── 28. ACHIEVEMENTS VIEW ───────────────────────────────────────── */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.875rem;
  padding: 1.25rem 2rem 2.5rem;
}

.achievement-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--trans);
}

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

.achievement-card.earned {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--bg-card), rgba(201,168,64,0.05));
}

.achievement-card.locked {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.achievement-badge {
  font-size: 2rem;
  line-height: 1;
}

.achievement-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-100);
}

.achievement-desc {
  font-size: 0.8rem;
  color: var(--text-200);
  margin: 0;
}

.achievement-progress {
  margin-top: 0.25rem;
}

/* ── 29. SEARCH VIEW ─────────────────────────────────────────────── */
.search-bar-wrap {
  display: flex;
  gap: 0.5rem;
  padding: 1.5rem 2rem 0.5rem;
}

.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-100);
  padding: 0.8rem 1.25rem;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
}

.search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.search-input::placeholder { color: var(--text-300); }

.search-btn {
  flex-shrink: 0;
  padding: 0.8rem 1.25rem;
  font-size: 1rem;
}

.search-results {
  padding: 1.25rem 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.search-result-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color var(--trans), transform var(--trans);
}

.search-result-item:hover {
  border-color: var(--gold);
  transform: translateX(4px);
}

.search-result-type {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.search-result-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-100);
  margin-bottom: 0.2rem;
}

.search-result-excerpt {
  font-size: 0.82rem;
  color: var(--text-300);
  line-height: 1.5;
  margin: 0;
}

mark {
  background: var(--gold-dim);
  color: var(--gold);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── 30. COMPARISON VIEW ─────────────────────────────────────────── */
.comparison-selectors {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

.civ-select-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 150px;
}

.comparison-output {
  padding: 1.5rem 2rem 2.5rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.comparison-table-wrapper {
  flex: 1;
  min-width: 300px;
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.comparison-table th,
.comparison-table td {
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.comparison-table th {
  color: var(--text-300);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  background: var(--bg-surface);
}

.comparison-table tr:last-child td { border-bottom: none; }

.comparison-radar-container {
  width: 300px;
  height: 300px;
  flex-shrink: 0;
}

/* ── 31. PATTERNS VIEW ───────────────────────────────────────────── */
.patterns-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 500px;
}

.pattern-list {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
}

.pattern-item {
  padding: 0.7rem 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-200);
  font-size: 0.875rem;
  transition: all var(--trans);
  border-left: 2px solid transparent;
}

.pattern-item:hover {
  background: var(--bg-raised);
  color: var(--text-100);
}

.pattern-item.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-left-color: var(--gold);
}

.pattern-detail {
  padding: 2rem;
  overflow-y: auto;
}

/* ── 32. SOCRATIC VIEW ───────────────────────────────────────────── */
.socratic-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.socratic-setup {
  display: flex;
  align-items: flex-end;
  gap: 0.875rem;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.socratic-setup .ctrl-label {
  display: block;
  margin-bottom: 0.4rem;
}

.socratic-setup .ctrl-select {
  flex: 1;
  min-width: 200px;
}

.dialogue-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dialogue-message {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.65;
  max-width: 85%;
}

.dialogue-message.system {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-200);
  align-self: flex-start;
  border-left: 2px solid var(--gold);
}

.dialogue-message.user {
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  color: var(--text-100);
  align-self: flex-end;
}

.reflection-output {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.reflection-title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.reflection-content { color: var(--text-200); font-size: 0.9rem; line-height: 1.7; }

/* ── 33. FOOTER ──────────────────────────────────────────────────── */
#main-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 2rem;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--text-100);
  font-size: 1rem;
}

.footer-tagline {
  font-size: 0.8rem;
  color: var(--text-300);
  margin: 0;
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-nav a {
  font-size: 0.82rem;
  color: var(--text-300);
}

.footer-nav a:hover { color: var(--gold); }

/* ── 34. D3 Visualization Overrides ─────────────────────────────── */
.node circle { cursor: pointer; transition: r 0.2s; }
.node:hover circle { r: 10; }
.node text { fill: var(--text-200); font-size: 10px; pointer-events: none; }
.link { stroke: var(--border-mid); stroke-opacity: 0.6; fill: none; }
.link:hover { stroke-opacity: 1; }

/* Timeline D3 */
.timeline-axis text { fill: var(--text-300); font-size: 11px; }
.timeline-axis line, .timeline-axis path { stroke: var(--border); }
.timeline-event { cursor: pointer; transition: r 0.15s; }
.timeline-event:hover { r: 8; }
.timeline-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 0.6rem 0.875rem;
  font-size: 0.82rem;
  color: var(--text-100);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-width: 240px;
  z-index: 500;
}

/* ── 35. Light Theme Overrides ───────────────────────────────────── */
[data-theme="light"] .hero-bg {
  background:
    radial-gradient(ellipse 60% 50% at 25% 50%, rgba(154,122,20,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 30%, rgba(42,152,144,0.04) 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-base) 0%, var(--bg-surface) 100%);
}

[data-theme="light"] .node text { fill: var(--text-200); }
[data-theme="light"] .timeline-axis text { fill: var(--text-300); }

/* ── 36. Responsive ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .topics-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 1023px) {
  /* Sidebar becomes drawer on mobile */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  .sidebar.nav-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
  }

  /* Show topbar */
  .topbar { display: flex; }

  /* Unlatch main from sidebar */
  .main-wrapper { margin-left: 0; }

  /* Hero adjustments */
  .hero {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    min-height: auto;
    padding: 3rem 1.5rem 2.5rem;
  }

  .hero-eyebrow { justify-content: center; }
  .hero-actions { justify-content: center; }
  .hero-subtitle { margin: 0 auto 2rem; }
  .hero-ornament { display: none; }

  .stats-row { gap: 0; }
  .stat-pill { padding: 1rem 0.5rem; }
  .stat-num { font-size: 1.5rem; }

  .view-header { padding: 1.75rem 1.5rem 1rem; }

  .featured-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .graph-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 400px auto;
    height: auto;
  }

  .graph-controls { grid-column: 1; }
  .node-detail-panel { border-left: none; border-top: 1px solid var(--border); }

  .patterns-layout {
    grid-template-columns: 1fr;
  }

  .pattern-list { border-right: none; border-bottom: 1px solid var(--border); }

  .comparison-output { flex-direction: column; }
  .comparison-radar-container { width: 100%; }
}

@media (max-width: 640px) {
  .hero-title { font-size: 2rem; }
  .hero-actions { flex-direction: column; align-items: center; }

  .topics-grid,
  .featured-grid,
  .achievement-grid {
    grid-template-columns: 1fr;
  }

  .lesson-container { padding: 1.5rem 1.25rem 3rem; }
  .quiz-card { padding: 1.5rem 1.25rem; }
  .quiz-nav { flex-wrap: wrap; }

  .progress-dashboard { flex-direction: column; align-items: center; }

  .section-header { flex-direction: column; gap: 0.25rem; }

  .timeline-controls { flex-wrap: wrap; }

  .comparison-selectors { flex-direction: column; }
  .civ-select-group { min-width: unset; }

  .home-section { padding: 2rem 1.25rem; }
  .domain-progress-list,
  .activity-list { padding: 1rem 1.25rem 2rem; }
  .search-results { padding: 1rem 1.25rem 2rem; }
  .filter-tabs { padding: 1rem 1.25rem; }
  .topics-grid { padding: 0 1.25rem 2rem; }
}

/* ── 37. Focus Styles ────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── 38. Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, #main-footer { display: none; }
  .main-wrapper { margin-left: 0; }
  #loading-overlay { display: none; }
}
