/* ============================================================
   HSC Software Engineering Notes — Premium Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Custom Properties ── */
:root {
  --primary:        #6366F1;
  --primary-dark:   #4338CA;
  --primary-light:  #EEF2FF;
  --secondary:      #8B5CF6;
  --accent:         #06B6D4;

  --year12:         #3B82F6;
  --year12-light:   #EFF6FF;
  --year12-dark:    #1D4ED8;

  --year11:         #10B981;
  --year11-light:   #ECFDF5;
  --year11-dark:    #065F46;

  --danger:         #EF4444;
  --warning:        #F59E0B;
  --success:        #22C55E;
  --info:           #06B6D4;

  --bg:             #F4F6FE;   /* lavender-white page bg — no white-on-white */
  --bg-secondary:   #ECEFFE;   /* soft indigo wash for section panels */
  --bg-tertiary:    #F8FAFC;   /* near-white for code blocks */
  --surface:        #FFFFFF;    /* pure white card surfaces pop from page bg */
  --surface-hover:  #EEF1FD;   /* gentle lavender hover */
  --border:         #D8DEF2;    /* soft blue-lavender, elegant */
  --border-strong:  #B0BDDB;    /* medium blue-lavender */

  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-inverse:   #F8FAFC;

  --nav-bg:         #0F172A;
  --nav-text:       #CBD5E1;
  --nav-active:     #6366F1;

  --shadow-sm:   0 1px 2px 0 rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --shadow-xl:   0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);

  --radius-sm:   .375rem;
  --radius-md:   .5rem;
  --radius-lg:   .75rem;
  --radius-xl:   1rem;
  --radius-2xl:  1.5rem;
  --radius-full: 9999px;

  --transition: 200ms cubic-bezier(.4,0,.2,1);

  /* ── Z-index scale ── */
  --z-base:     1;
  --z-raised:   2;
  --z-dropdown: 100;
  --z-sticky:   900;
  --z-navbar:   1000;
  --z-mobile:   999;
  --z-modal:    2000;
  --z-toast:    2001;
  --z-skip:     10000;
}

/* Dark mode */
[data-theme="dark"] {
  --bg:             #0F172A;
  --bg-secondary:   #1E293B;
  --bg-tertiary:    #334155;
  --surface:        #1E293B;
  --surface-hover:  #334155;
  --border:         #2A3449;   /* blue-tinted dark border, matches indigo language */
  --border-strong:  #374563;   /* slightly brighter, still refined */

  --text-primary:   #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted:     #94A3B8;

  --primary-light:  #1E1B4B;
  --year12-light:   #172554;
  --year11-light:   #022C22;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

/* ── Skip Link (Accessibility) ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--primary);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  z-index: var(--z-skip);
  transition: top 200ms ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* ── Focus Indicators (Accessibility) ── */
a:focus-visible,
button:focus-visible,
.topic-card:focus-visible,
.nav-links a:focus-visible,
.toc-list a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.search-input:focus-visible {
  outline: none; /* handled by box-shadow */
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ── Navigation ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
  /* overflow: visible so dropdown menus can extend below the bar.
     Do NOT use overflow:hidden/auto/scroll — those break position:sticky. */
  overflow: visible;
}

/* ── Reading Progress Bar ── */
.reading-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: calc(var(--scroll-pct, 0) * 1%);
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 80ms linear;
  pointer-events: none;
  opacity: 0;
}

.has-toc .reading-progress { opacity: 1; }

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 0 0 4px rgba(99,102,241,.2);
  transition: transform 280ms cubic-bezier(.34,1.56,.64,1),
              box-shadow var(--transition);
}
.nav-brand:hover .nav-logo {
  transform: scale(1.1) rotate(-6deg);
  box-shadow: 0 0 0 6px rgba(99,102,241,.28);
}

.nav-title {
  font-weight: 700;
  font-size: .95rem;
  color: #F1F5F9;
  line-height: 1.2;
}

.nav-subtitle {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
  flex: 1;
  justify-content: center;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .4rem .75rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  color: var(--nav-text);
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.1);
  color: #F8FAFC;
}

.nav-links .badge {
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: var(--radius-full);
  letter-spacing: .03em;
}

/* ── Badge base colours (light-bg contexts: topic pages, main content) ── */
.badge-12 { background: rgba(59,130,246,.15); color: var(--year12-dark); border: 1px solid rgba(59,130,246,.3); }
.badge-11 { background: rgba(16,185,129,.15); color: var(--year11-dark); border: 1px solid rgba(16,185,129,.3); }
[data-theme="dark"] .badge-12 { background: rgba(59,130,246,.2); color: #93C5FD; border-color: rgba(59,130,246,.35); }
[data-theme="dark"] .badge-11 { background: rgba(16,185,129,.2); color: #6EE7B7; border-color: rgba(16,185,129,.35); }

/* ── Badge colours — nav context (always dark bg, needs light text) ── */
.nav-links .badge-12,
.nav-dropdown-btn .badge-12 {
  color: #93C5FD;
  background: rgba(59,130,246,.25);
  border-color: rgba(59,130,246,.4);
}
.nav-links .badge-11,
.nav-dropdown-btn .badge-11 {
  color: #6EE7B7;
  background: rgba(16,185,129,.25);
  border-color: rgba(16,185,129,.4);
}

/* ── Nav Dropdown ── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .4rem .75rem;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  color: var(--nav-text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.nav-dropdown-btn:hover,
.nav-dropdown.open .nav-dropdown-btn {
  background: rgba(255,255,255,.1);
  color: #F8FAFC;
}

/* Active year group — tinted trigger so it's clear where you are */
.nav-dropdown.nav-dropdown--has-active.nav-dropdown-y12 .nav-dropdown-btn {
  background: rgba(59,130,246,.18);
  color: #93C5FD;
  font-weight: 600;
}
.nav-dropdown.nav-dropdown--has-active.nav-dropdown-y11 .nav-dropdown-btn {
  background: rgba(16,185,129,.18);
  color: #6EE7B7;
  font-weight: 600;
}

/* Active item in menu — small coloured dot + bold text */
.nav-dropdown-menu a.active::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: -.125rem; /* optical balance */
}
.nav-dropdown-y12 .nav-dropdown-menu a.active::before { background: var(--year12); }
.nav-dropdown-y11 .nav-dropdown-menu a.active::before { background: var(--year11); }

.nav-chevron {
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  transition: transform 220ms cubic-bezier(.4,0,.2,1);
  opacity: .7;
}
.nav-dropdown.open .nav-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* ── Dropdown menu panel ── */
/* Pure-transition approach: no keyframe/transition property conflict.
   The visibility delay trick: `0s 180ms` on hide keeps the element
   screen-reader-invisible only after the fade is done; `0s 0s` on show
   makes it visible immediately so the fade is visible. */
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  min-width: 230px;
  background: #1E293B;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-xl);
  padding: .375rem;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.04);
  z-index: var(--z-dropdown);
  transition: opacity 180ms ease,
              transform 180ms cubic-bezier(.4,0,.2,1),
              visibility 0s linear 180ms;
}

.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.nav-dropdown-y12 .nav-dropdown-menu::before { background: linear-gradient(90deg, var(--year12), #6366F1); }
.nav-dropdown-y11 .nav-dropdown-menu::before { background: linear-gradient(90deg, var(--year11), #06B6D4); }

.nav-dropdown.open .nav-dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 180ms ease,
              transform 180ms cubic-bezier(.4,0,.2,1),
              visibility 0s linear 0s;
}

.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .6rem .875rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  color: #94A3B8;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  white-space: nowrap;
}

.nav-dropdown-menu a:hover {
  color: #F8FAFC;
  transform: translateX(3px);
}
.nav-dropdown-y12 .nav-dropdown-menu a:hover { background: rgba(59,130,246,.15); }
.nav-dropdown-y11 .nav-dropdown-menu a:hover { background: rgba(16,185,129,.15); }

.nav-dropdown-menu a.active {
  color: #F8FAFC;
  font-weight: 600;
}
.nav-dropdown-y12 .nav-dropdown-menu a.active { background: rgba(59,130,246,.2); }
.nav-dropdown-y11 .nav-dropdown-menu a.active { background: rgba(16,185,129,.2); }

/* ── Focus ring on dropdown button ── */
.nav-dropdown-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}



.nav-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05);
  color: var(--nav-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: rgba(255,255,255,.12);
  color: #F8FAFC;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: .5rem;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--nav-text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* Mobile menu */
.mobile-menu {
  position: fixed;
  inset: 64px 0 0 0;
  background: var(--nav-bg);
  z-index: var(--z-mobile);
  padding: 1.5rem;
  overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,.08);
  transform: translateX(-100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 280ms cubic-bezier(.4,0,.2,1),
              opacity    280ms cubic-bezier(.4,0,.2,1),
              visibility 280ms;
}

.mobile-menu.open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

.mobile-menu-section {
  margin-bottom: 1.5rem;
}

.mobile-menu-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .5rem;
  padding: 0 .5rem;
}

.mobile-menu a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem .75rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--nav-text);
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: .25rem;
}

.mobile-menu a:hover { background: rgba(255,255,255,.07); color: #F8FAFC; }

/* ── Layout ── */
.page-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 64px);
  padding: 0 1.5rem;
  gap: 2rem;
}

.sidebar {
  position: sticky;
  top: 80px;
  height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 1.5rem 0;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }

.toc-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .75rem;
  padding: 0 .5rem;
}

.sidebar-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  padding: .75rem 0 .1rem;
  list-style: none; /* Ensure no bullets if used in a list */
}

.sidebar-label:first-child {
  padding-top: .25rem;
}

.toc-list { list-style: none; }

.toc-list a {
  display: block;
  padding: .4rem .75rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: .82rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

.toc-list a:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-left-color: var(--primary);
}

.toc-list a.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left: 3px solid var(--primary);
  font-weight: 600;
  padding-left: calc(.75rem - 1px);
}

.toc-list .toc-sub a {
  padding-left: 1.75rem;
  font-size: .78rem;
}

.page-content {
  padding: clamp(1.5rem, 2vw, 2rem) 0 clamp(2rem, 3vw, 4rem);
  min-width: 0;
}

/* ── Hero Section ── */
.hero {
  background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 50%, #0F172A 100%);
  padding: clamp(2.5rem, 4vw, 4.5rem) 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(99,102,241,.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(139,92,246,.15) 0%, transparent 50%);
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.07) 1px, transparent 1px);
  background-size: 40px 40px;
}

.hero-inner {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(99,102,241,.15);
  border: 1px solid rgba(99,102,241,.3);
  color: #A5B4FC;
  padding: .375rem 1rem;
  border-radius: var(--radius-full);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  color: #F8FAFC;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -.02em;
}

.hero h1 span {
  background: linear-gradient(135deg, #818CF8, #C084FC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.1rem;
  color: #94A3B8;
  max-width: 600px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.hero-stat {
  text-align: center;
  position: relative;
}

/* Thin divider between hero stats */
.hero-stat + .hero-stat::before {
  content: '';
  position: absolute;
  left: -1.25rem;   /* sits in the middle of the 2.5rem gap */
  top: 15%;
  height: 70%;
  width: 1px;
  background: rgba(255,255,255,.14);
}

.hero-stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: #F8FAFC;
  line-height: 1;
}

.hero-stat-label {
  font-size: .8rem;
  color: #94A3B8;
  margin-top: .25rem;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(99,102,241,.4);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  transform: translateX(-100%);
  transition: transform 420ms ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,.5);
}

.btn-primary:hover::after {
  transform: translateX(100%);
}

/* ── Button glow pulse on page load ── */
@keyframes button-glow-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(99,102,241,.4); }
  50%       { box-shadow: 0 4px 24px rgba(99,102,241,.6), 0 0 20px rgba(99,102,241,.3); }
}
/* Stop pulsing while hovered so the hover box-shadow is never overridden by animation */
.hero-cta .btn-primary:not(:hover) {
  animation: button-glow-pulse 2.5s ease-in-out 2s infinite;
}

.btn-outline {
  background: transparent;
  color: #CBD5E1;
  border: 1px solid rgba(255,255,255,.2);
}

.btn-outline:hover {
  background: rgba(255,255,255,.08);
  color: #F8FAFC;
}

/* ── Main Content Area ── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1.5rem, 2vw, 2.5rem) 1.5rem clamp(2rem, 2.5vw, 3rem) 1.5rem;
}

/* ── Section Headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.section-title .year-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: .25rem .6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.year-badge-12 { background: var(--year12-light); color: var(--year12-dark); }
.year-badge-11 { background: var(--year11-light); color: var(--year11-dark); }

[data-theme="dark"] .year-badge-12 { background: rgba(59,130,246,.2); color: #93C5FD; }
[data-theme="dark"] .year-badge-11 { background: rgba(16,185,129,.2); color: #6EE7B7; }

/* ── Topic Cards ── */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3.5rem;
}

.topic-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
  position: relative;
  overflow: clip;   /* clip: no scroll context, no corner-cropping on transform */
  height: 100%;
  box-shadow: var(--shadow-sm);
}

.topic-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.topic-card.year12 {
  border-top: 3px solid var(--year12);
  background: linear-gradient(150deg, var(--surface) 75%, rgba(59,130,246,.07));
}
.topic-card.year11 {
  border-top: 3px solid var(--year11);
  background: linear-gradient(150deg, var(--surface) 75%, rgba(16,185,129,.07));
}

.topic-card.year12:hover { box-shadow: 0 12px 30px rgba(59,130,246,.2); }
.topic-card.year11:hover { box-shadow: 0 12px 30px rgba(16,185,129,.2); }

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.year12 .card-icon { background: var(--year12-light); }
.year11 .card-icon { background: var(--year11-light); }

[data-theme="dark"] .year12 .card-icon { background: rgba(59,130,246,.15); }
[data-theme="dark"] .year11 .card-icon { background: rgba(16,185,129,.15); }

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 1.25rem;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-muted);
}

.card-topics {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}

.topic-tag {
  font-size: .7rem;
  padding: .2rem .55rem;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

/* Year-tinted tags */
.year12 .topic-tag {
  background: rgba(59,130,246,.08);
  color: var(--year12-dark);
  border-color: rgba(59,130,246,.22);
}
.year11 .topic-tag {
  background: rgba(16,185,129,.08);
  color: var(--year11-dark);
  border-color: rgba(16,185,129,.22);
}
[data-theme="dark"] .year12 .topic-tag { color: #93C5FD; border-color: rgba(59,130,246,.28); }
[data-theme="dark"] .year11 .topic-tag { color: #6EE7B7; border-color: rgba(16,185,129,.28); }

.card-arrow {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition);
}

.topic-card:hover .card-arrow { transform: translateX(5px); }
.topic-card.year12:hover .card-arrow { color: var(--year12); }
.topic-card.year11:hover .card-arrow { color: var(--year11); }

/* ── Feature Banners ── */
.features-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  padding: clamp(1.75rem, 2.5vw, 2.25rem) 1.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.feature-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

[data-theme="dark"] .feature-icon { background: rgba(99,102,241,.15); }

.feature-text strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.feature-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Topic Page Header ── */
.topic-header {
  background: linear-gradient(135deg, #0F172A, #1E293B);
  padding: clamp(1.75rem, 2.5vw, 3rem) 1.5rem;
  position: relative;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.topic-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 30% 50%, rgba(99,102,241,.12) 0%, transparent 60%);
}

.topic-header-inner {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
}

.topic-breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: #94A3B8;
  margin-bottom: 1rem;
}

.topic-breadcrumb a {
  color: #94A3B8;
  text-decoration: none;
  transition: color var(--transition);
}

.topic-breadcrumb a:hover { color: #E2E8F0; }

.topic-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  color: #F8FAFC;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-bottom: .75rem;
}

.topic-header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .3rem .75rem;
  border-radius: var(--radius-full);
  font-size: .78rem;
  font-weight: 600;
  background: rgba(255,255,255,.08);
  color: #CBD5E1;
  border: 1px solid rgba(255,255,255,.12);
}

.meta-pill.year12 { background: rgba(59,130,246,.15); color: #93C5FD; border-color: rgba(59,130,246,.3); }
.meta-pill.year11 { background: rgba(16,185,129,.15); color: #6EE7B7; border-color: rgba(16,185,129,.3); }

/* ── Content Typography ── */
.content-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2.5rem 0 1rem;
  padding-top: .5rem;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* ── Syllabus Phase Heading (minor — individual syllabus items) ── */
.content-body h2.syllabus-phase {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--secondary) 100%);
  color: #fff;
  padding: 1.2rem 1.125rem 0.65rem 1.25rem;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0 0;
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  border: 1px solid rgba(99,102,241,0.4);
  border-left: 6px solid var(--accent);
  cursor: pointer;
  user-select: none;
  transition: all 260ms cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
}

/* Subtle top-left shine for depth */
.content-body h2.syllabus-phase::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, transparent 55%);
  pointer-events: none;
  border-radius: inherit;
}

.content-body > section:first-child h2 {
  margin-top: 0;
}

.content-body h2.syllabus-phase:hover {
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
  transform: translateX(3px);
  filter: brightness(1.05);
}

.content-body h2.syllabus-phase.section-collapsed {
  margin-bottom: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.14);
  border-radius: var(--radius-md);
}

.content-body h2.syllabus-phase::before {
  display: none;
}

/* Outcome badges inside the header bar */
h2.syllabus-phase .outcome-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  font-size: 0.65rem;
  order: 1;
  flex-basis: 100%;
}

h2.syllabus-phase .outcome-badge {
  background: rgba(255,255,255,.22);
  color: #fff;
  font-size: 0.6rem;
  padding: 0.2rem 0.6rem;
  box-shadow: none;
}

h2.syllabus-phase .outcome-badge:hover {
  background: rgba(255,255,255,.35);
  transform: none;
  box-shadow: none;
}

[data-theme="dark"] .content-body h2.syllabus-phase {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.18);
}

[data-theme="dark"] h2.syllabus-phase .outcome-badge {
  background: rgba(255,255,255,.18);
}

/* Syllabus concept statement inside the header bar */
h2.syllabus-phase .syllabus-concept {
  flex-basis: 100%;
  order: 2;
  margin: 0.1rem 0 0;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.45;
  letter-spacing: 0;
}

h2.syllabus-phase .syllabus-concept em {
  font-style: italic;
}

h2.syllabus-phase .syllabus-concept strong {
  font-weight: 700;
  color: #fff;
}

/* Chevron indicator (injected by JS) */
.section-chevron {
  margin-left: auto;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 360ms cubic-bezier(.4,0,.2,1),
              background 220ms;
}

.section-chevron svg {
  display: block;
  width: 16px;
  height: 16px;
  stroke: rgba(255,255,255,.95);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h2.syllabus-phase.section-collapsed .section-chevron {
  transform: rotate(-90deg);
}

h2.syllabus-phase:hover .section-chevron {
  background: rgba(255,255,255,.35);
}

/* ── Collapsible Section Body ── */
.section-body {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;              /* clips leaking margins/padding */
  transition: grid-template-rows 380ms cubic-bezier(.4,0,.2,1),
              background 260ms cubic-bezier(.4,0,.2,1);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin-top: 0;
  box-shadow: inset 0 3px 8px rgba(99,102,241,0.04);  /* subtle inner depth */
}

.section-body.section-collapsed {
  grid-template-rows: 0fr;
  background: transparent;
  border-radius: 0;
  margin-top: 0;
  max-height: 0;
}

/* Clear gap between sections (collapsed or expanded) */
.part-group-inner > section + .divider + section > h2.syllabus-phase,
.part-group-inner > section + section > h2.syllabus-phase {
  margin-top: 0.75rem;
}

/* Ensure first h2 in section doesn't have excess top margin */
section > h2.syllabus-phase:first-child {
  margin-top: 0;
}

.section-body-inner {
  min-height: 0;                 /* allows grid row to compress to 0 */
  overflow: hidden;              /* establishes BFC, prevents content leaking when collapsed */
  padding: 1.75rem;
}

/* Subtle dividers between h3 blocks within a section */
.section-body-inner * + h3,
.content-body section * + h3 {
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
}

/* First h3 in a section body already has padding from the container —
   suppress its own top margin so the gap isn't doubled */
.section-body-inner > h3:first-child {
  margin-top: 0;
}

/* ── Major Syllabus Part Heading (top-level syllabus divisions) ── */
.part-block {
  background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 50%, var(--primary-dark) 100%);
  color: #fff;
  padding: 1.6rem 3.5rem 1.2rem 2rem; /* Adjusted for perceptual vertical centering */
  border-radius: var(--radius-md);
  margin: 2.5rem 0 1.75rem;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.4);
  border-left: 6px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: .3rem;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 240ms ease, transform 200ms ease;
}

.content-body > .part-block:first-child {
  margin-top: 0;
  margin-bottom: 1.75rem;
}

.part-block:hover {
  box-shadow: 0 10px 36px rgba(99, 102, 241, 0.55);
  transform: translateY(-1px);
}

.part-block:active { transform: translateY(0); }

.part-block .part-number {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  opacity: .65;
  color: var(--accent);
}

.part-block .part-name {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -.025em;
  line-height: 1.2;
}

/* Chevron injected by JS */
.part-chevron {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.18);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 200ms ease, transform 200ms ease;
}

.part-chevron svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: rgba(255,255,255,.95);
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 380ms cubic-bezier(.4,0,.2,1);
}

.part-block.part-collapsed .part-chevron svg {
  transform: rotate(-90deg);
}

.part-block:hover .part-chevron {
  background: rgba(255,255,255,.3);
}

/* Collapsed indicator: slightly dim the title text */
.part-block.part-collapsed .part-name {
  opacity: .8;
}

/* ── Collapsible Part Group (wraps sections belonging to a part) ── */
.part-group {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 420ms cubic-bezier(.4,0,.2,1);
  margin: 1rem 0;
}

.part-group.part-collapsed {
  grid-template-rows: 0fr;
  margin: 0;
}

.part-group-inner {
  min-height: 0;
  overflow: clip;
  padding: 0 0 1.5rem 0;
  background: transparent;
  border-radius: var(--radius-lg);
  transition: background 260ms cubic-bezier(.4,0,.2,1),
              border-radius 260ms cubic-bezier(.4,0,.2,1);
}

.part-group.part-collapsed .part-group-inner {
  background: transparent;
  border-radius: 0;
  padding: 0;
}

[data-theme="dark"] .part-block {
  background: linear-gradient(135deg, #0F172A 0%, var(--primary-dark) 100%);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.2);
}

/* ── TOC Part Label Active State ── */
.toc-part-label {
  transition: color 200ms ease, opacity 200ms ease;
}

.toc-part-label.toc-part-active {
  color: var(--primary);
  opacity: 1;
}

.content-body h2::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.5rem;
  background: var(--primary);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.content-body h3 {
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.75rem 0 .75rem;
}

.content-body h4 {
  font-size: clamp(0.95rem, 1.1vw, 1rem);
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.25rem 0 .5rem;
}

/* Outcome codes subtitle (moved below headings) */
.outcome-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  font-size: .8rem;
  font-weight: 600;
  margin: 0.5rem 0 1rem 0;
  padding-left: 0;
}

/* Individual outcome badge */
.outcome-badge {
  display: inline-block;
  background: var(--primary);
  color: #ffffff;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(99, 102, 241, 0.22);
  transition: all var(--transition);
}

.outcome-badge:hover {
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

[data-theme="dark"] .outcome-badge {
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

[data-theme="dark"] .outcome-badge:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

/* Command verb headings (NESA syllabus directives) */
.content-body h2 em,
.content-body h3 em,
.content-body h4 em {
  font-style: italic;
}

.command-verb {
  font-style: italic;
}

.content-body p {
  color: var(--text-secondary);
  margin-bottom: .75rem;
  line-height: 1.7;
  font-size: .95rem;
}

.content-body ul, .content-body ol {
  color: var(--text-secondary);
  margin: .75rem 0 .75rem 1.5rem;
  font-size: .95rem;
}

.content-body li { margin-bottom: .35rem; line-height: 1.6; }

.content-body strong { color: var(--text-primary); font-weight: 600; }

.content-body a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(99,102,241,.3);
  transition: all var(--transition);
}

.content-body a:hover {
  border-bottom-color: var(--primary);
}

/* ── Callout Boxes ── */
.callout {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.125rem 1.5rem;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  border: 2px solid;
  border-left-width: 6px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.callout:has(.callout-icon) {
  flex-direction: row;
  gap: 1rem;
}

.callout:hover {
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.callout-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

.callout-content strong {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.callout-content p, .callout-content ul {
  font-size: .88rem;
  margin-bottom: 0;
  color: inherit;
}

.callout-content ul { margin-top: .25rem; }

.callout.info     { background: rgba(6,182,212,.12);  border-color: rgba(6,182,212,.35);  color: #0E7490; }
.callout.warning  { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); color: #92400E; }
.callout.danger   { background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.35);  color: #991B1B; }
.callout.success  { background: rgba(34,197,94,.12);  border-color: rgba(34,197,94,.35);  color: #14532D; }
.callout.key      { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.35); color: #3730A3; }
.callout.tip      { background: rgba(34,197,94,.12);  border-color: rgba(34,197,94,.35);  color: #14532D; }
.callout.exam-tip { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.35); color: #3730A3; }
.callout.assessor { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.35); color: #3730A3; }

[data-theme="dark"] .callout.info     { color: #67E8F9; }
[data-theme="dark"] .callout.warning  { color: #FCD34D; }
[data-theme="dark"] .callout.danger   { color: #FCA5A5; }
[data-theme="dark"] .callout.success  { color: #86EFAC; }
[data-theme="dark"] .callout.key      { color: #A5B4FC; }
[data-theme="dark"] .callout.tip      { color: #86EFAC; }
[data-theme="dark"] .callout.exam-tip { color: #A5B4FC; }
[data-theme="dark"] .callout.assessor { color: #A5B4FC; }

/* ── Code Blocks ── */
.code-block {
  position: relative;
  margin: 1.25rem 0;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  padding: .6rem 1rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 2px solid var(--border-strong);
}

[data-theme="dark"] .code-header {
  background: #1E293B;
  border-bottom-color: rgba(255,255,255,.15);
}

.code-lang {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

[data-theme="dark"] .code-lang {
  color: #94A3B8;
}

.code-dots {
  display: flex;
  gap: .375rem;
}

.code-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

[data-theme="dark"] .code-dots span {
  background: #334155;
}

/* Light mode code blocks */
pre {
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 1.25rem 1.25rem;
  overflow-x: auto;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-top: none;
  box-shadow: var(--shadow-sm);
}

pre code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .83rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* Dark mode code blocks */
[data-theme="dark"] pre {
  background: #0D1117;
  border: 1px solid rgba(255,255,255,.08);
  border-top: none;
}

[data-theme="dark"] pre code {
  color: #E2E8F0;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .85em;
  background: var(--bg-secondary);
  color: var(--primary);
  padding: .15em .4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

/* Inline code in dark mode */
[data-theme="dark"] code {
  background: #1E293B;
  color: #60A5FA;
  border-color: rgba(255,255,255,.18);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

pre.text-diagram {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .83rem;
  line-height: 1.6;
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  white-space: pre;
}

[data-theme="dark"] pre.text-diagram {
  background: #0D1117;
  border-color: rgba(255,255,255,.08);
}

/* Syntax colours — Light mode */
.kw  { color: #7C3AED; }  /* keywords */
.fn  { color: #2563EB; }  /* functions */
.str { color: #16A34A; }  /* strings */
.num { color: #D97706; }  /* numbers */
.cm  { color: #6B7280; font-style: italic; }  /* comments */
.cl  { color: #C026D3; }  /* classes */
.op  { color: #475569; }  /* operators */

/* Syntax colours — Dark mode */
[data-theme="dark"] .kw  { color: #C084FC; }  /* keywords */
[data-theme="dark"] .fn  { color: #60A5FA; }  /* functions */
[data-theme="dark"] .str { color: #86EFAC; }  /* strings */
[data-theme="dark"] .num { color: #FDBA74; }  /* numbers */
[data-theme="dark"] .cm  { color: #64748B; }  /* comments */
[data-theme="dark"] .cl  { color: #F0ABFC; }  /* classes */
[data-theme="dark"] .op  { color: #94A3B8; }  /* operators */

/* ── Definition Cards ── */
.def-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin: .75rem 0;
  box-shadow: 0 1px 4px rgba(99,102,241,0.06), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.def-card:hover {
  box-shadow: 0 4px 16px rgba(99,102,241,0.14), 0 2px 6px rgba(0,0,0,0.06);
  border-color: rgba(99,102,241,0.5);
  transform: translateY(-1px);
}

.def-term {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .35rem;
}

.def-meaning {
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Info Grid ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  box-shadow: 0 1px 4px rgba(99,102,241,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.info-card:hover {
  box-shadow: 0 4px 16px rgba(99,102,241,0.14), 0 2px 6px rgba(0,0,0,0.06);
  border-color: rgba(99,102,241,0.4);
  transform: translateY(-1px);
}

.info-card-icon {
  font-size: 1.5rem;
  margin-bottom: .75rem;
}

.info-card h4 {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--text-primary);
}

.info-card p {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* ── Comparison Tables ── */
.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  /* Horizontal scroll shadow indicators */
  background:
    linear-gradient(to right, var(--bg) 30%, transparent),
    linear-gradient(to left, var(--bg) 30%, transparent),
    linear-gradient(to right, rgba(0,0,0,.12), transparent 15px),
    linear-gradient(to left, rgba(0,0,0,.12), transparent 15px);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 20px 100%, 20px 100%, 15px 100%, 15px 100%;
  background-attachment: local, local, scroll, scroll;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}

thead th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

tbody td {
  padding: .7rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) td {
  background: rgba(99, 102, 241, 0.02);
}

tbody tr:hover td {
  background: rgba(99, 102, 241, 0.06);
}

tbody tr:last-child td { border-bottom: none; }

/* ── Key Terms List ── */
.key-terms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.key-term-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.125rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  border-bottom: 2px solid var(--border);
  font-size: .85rem;
  line-height: 1.6;
  transition: all var(--transition);
}

.key-term-item:last-child {
  border-bottom: 1px solid transparent;
}

.key-term-item:nth-child(odd) {
  background: var(--primary-light);
  border-color: rgba(99, 102, 241, 0.12);
}

.key-term-item:nth-child(even) {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.key-term-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.key-term-item > strong {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.3;
  display: block;
}

.key-term-item > span {
  color: var(--text-secondary);
  font-size: .84rem;
}

/* Dark mode divider styling */
[data-theme="dark"] .key-term-item {
  border-bottom-color: rgba(148, 163, 184, 0.2);
}

/* ── Content Dividers for Structured Lists ── */
.structured-content > h4 {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.structured-content > h4:first-child {
  margin-top: 0;
  border-bottom: none;
}

[data-theme="dark"] .structured-content > h4 {
  border-bottom-color: rgba(148, 163, 184, 0.25);
}

/* ── Definition/Error Type Section Dividers ── */
section h4 {
  margin-top: 1.5rem;
  padding-top: 1rem;
  padding-bottom: 0.5rem;
  border-top: 2px solid var(--border);
}

section h4:first-of-type {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

[data-theme="dark"] section h4 {
  border-top-color: rgba(148, 163, 184, 0.25);
}

/* ── Steps / Process ── */
.steps {
  counter-reset: step;
  list-style: none;
  margin: 1rem 0;
  position: relative;
}

.step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  counter-increment: step;
  position: relative;
}

/* Vertical connecting line between step numbers */
.step:not(:last-child) .step-num::after {
  content: '';
  position: absolute;
  left: 16px;
  top: 36px;
  width: 2px;
  bottom: -1.25rem;
  background: linear-gradient(to bottom, var(--primary), rgba(99,102,241,.15));
  border-radius: 1px;
}

.step-num {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 2px 6px rgba(99,102,241,.25);
  transition: all var(--transition);
}

.step:hover .step-num {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(99,102,241,.35);
}

.step-content {
  transition: all var(--transition);
}

.step:hover .step-content {
  transform: translateX(2px);
}

.step-content h4 { margin-top: .1rem; }

/* ── Progress Bar ── */
.progress-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: var(--radius-full);
  transition: width .6s ease;
}

/* ── Footer ── */
footer {
  background: var(--nav-bg);
  color: #94A3B8;
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

.footer-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.footer-name {
  font-weight: 700;
  color: #E2E8F0;
  font-size: .95rem;
}

.footer-desc {
  font-size: .82rem;
  line-height: 1.6;
  color: #64748B;
}

.footer-col h4 {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #CBD5E1;
  margin-bottom: .75rem;
}

.footer-col a {
  display: block;
  font-size: .82rem;
  color: #64748B;
  text-decoration: none;
  margin-bottom: .4rem;
  transition: color var(--transition);
}

.footer-col a:hover {
  color: #CBD5E1;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(203,213,225,.4);
}

.footer-bottom {
  max-width: 1280px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .78rem;
  color: #475569;
}

/* ── Search ── */
.search-bar {
  position: relative;
  max-width: 520px;
  margin: 0 auto 3.5rem;
}

.search-input {
  width: 100%;
  padding: .75rem 1rem .75rem 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-primary);
  font-size: .9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-input:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99,102,241,.1);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18), 0 4px 12px rgba(99,102,241,.12);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Utility ── */
.section-spacer {
  margin-top: 3.5rem;
  margin-bottom: 1.5rem;
}

.tag {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 600;
}

.highlight-box {
  background: linear-gradient(135deg, var(--primary-light), rgba(139,92,246,.08));
  border: 1px solid rgba(99,102,241,.2);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  margin: 3rem 0 1.5rem 0;
}

[data-theme="dark"] .highlight-box {
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(139,92,246,.08));
  border-color: rgba(99,102,241,.25);
}

.divider {
  border: none;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--border-strong) 18%,
    var(--border-strong) 82%,
    transparent 100%);
  margin: 2.75rem 0;
}

/* Hide dividers when adjacent sections are collapsed */
section:has(> h2.section-collapsed) + .divider {
  display: none;
}
.divider:has(+ section > h2.section-collapsed) {
  display: none;
}

/* ── Responsive ── */
/* ── Large Tablet & Desktop (1200px+) ── */
@media (min-width: 1200px) {
  .sidebar { display: block; }

  .page-layout {
    grid-template-columns: 260px 1fr;
  }

  .footer-inner {
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
  }
}

/* ── Large Tablet (1024px - 1199px) ── */
@media (max-width: 1199px) {
  .page-layout {
    grid-template-columns: 1fr;
  }

  .sidebar { display: none; }

  .footer-inner {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
  }
}

/* ── Ultra-Wide Screens (1400px+) ── */
@media (min-width: 1400px) {
  .page-layout {
    gap: 2.5rem;
    padding: 0 2rem;
  }

  .nav-inner {
    padding: 0 2rem;
  }

  .hero {
    padding: clamp(3.5rem, 4.5vw, 4.5rem) 2rem;
  }

  .features-bar {
    padding: clamp(2rem, 3vw, 2.25rem) 2rem;
  }
}

/* ── Tablet Portrait (768px and below) ── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }

  .hero { padding: 3.5rem 1.25rem; }
  .hero-stats { gap: 2rem; }

  .topics-grid { grid-template-columns: 1fr; gap: 1.25rem; }

  .features-bar { grid-template-columns: 1fr 1fr; gap: 1.25rem; }

  .footer-inner { grid-template-columns: 1fr; }

  .info-grid { grid-template-columns: 1fr; }

  .key-terms {
    grid-template-columns: 1fr;
    gap: 0.875rem;
    margin: 1.25rem 0;
  }

  .key-term-item {
    padding: 0.875rem 1rem;
    font-size: .84rem;
  }

  /* Diagram mobile styles */
  .diagram-block {
    padding: 1.5rem;
    margin: 2rem 0;
  }

  .mermaid {
    padding: 1.5rem 1rem;
    min-height: 240px;
    font-size: 0.8rem;
  }

  .diagram-block h4 {
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 480px) {
  .hero { padding: 3rem 1rem; margin-bottom: 0.5rem; }
  .hero h1 { font-size: 1.75rem; margin-bottom: 1rem; }
  .hero p { font-size: 1rem; margin-bottom: 2rem; }
  .hero-stats { flex-direction: column; gap: 1.25rem; align-items: center; margin-bottom: 2rem; }
  .features-bar { grid-template-columns: 1fr; gap: 1rem; padding: 2rem 1rem; }
  .hero-cta { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; justify-content: center; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.5rem; }
}

/* ── Course Tools & Utilities ── */
.badge-all { background: rgba(255, 255, 255, 0.15); color: #F1F5F9; }

.text-muted-dark { color: #94A3B8; }
.max-w-600 { max-width: 600px; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.fs-sm { font-size: .95rem; }
.lh-base { line-height: 1.6; }

/* ── Diagram Animation Keyframes ── */
@keyframes diagramSlideInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Diagram Blocks ── */
.diagram-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;     /* clips flush h4 header to rounded corners */
  margin: 2.75rem 0;
  padding: 0;           /* padding lives inside h4 and diagram-body */
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  box-shadow: 0 2px 8px rgba(99,102,241,0.08), 0 1px 3px rgba(0,0,0,0.05);
  animation: diagramSlideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.diagram-block:hover {
  box-shadow: 0 10px 28px rgba(99,102,241,0.18), 0 4px 8px rgba(0,0,0,0.07);
  transform: translateY(-3px);
  border-color: rgba(99,102,241,0.3);
}

[data-theme="dark"] .diagram-block {
  background: #1a2640;
  border-color: var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

[data-theme="dark"] .diagram-block:hover {
  box-shadow: 0 10px 32px rgba(99, 102, 241, 0.25);
  background: #1e2e4c;
  border-color: rgba(99,102,241,0.35);
}

/* ── Diagram Block Header ── */
.diagram-block h4 {
  margin: 0;
  padding: 1.1rem 1.5rem 0.85rem;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  user-select: none;
  transition: filter var(--transition), box-shadow var(--transition);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--secondary) 100%);
  border-radius: 0;  /* parent overflow:hidden clips to outer radius */
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.2);
  position: relative;
  overflow: hidden;
}

/* Subtle top-left shine */
.diagram-block h4::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, transparent 55%);
  pointer-events: none;
}

.diagram-block h4 > span:first-child {
  flex: 1;
  position: relative;  /* above ::before shine layer */
  z-index: 1;
}

.diagram-block h4:hover {
  filter: brightness(1.07);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

[data-theme="dark"] .diagram-block h4 {
  background: linear-gradient(135deg, #312e81 0%, #6366F1 55%, #8B5CF6 100%);
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .diagram-block h4:hover {
  filter: brightness(1.1);
  box-shadow: 0 5px 20px rgba(99, 102, 241, 0.5);
}

/* ── Chevron Indicator ── */
.diagram-block h4::after {
  content: '\25BE';  /* ▾ small downward triangle */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  background: rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.9;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: transform var(--transition), background var(--transition);
}

.diagram-block h4:hover::after {
  background: rgba(255,255,255,0.28);
}

.diagram-block.diagram-collapsed h4::after {
  transform: rotate(-90deg);
}

.diagram-block.diagram-collapsed h4 {
  box-shadow: none;
}

/* ── Diagram Content Body ── */
.diagram-body {
  overflow-x: auto;
  padding: 1.5rem;
  transition: max-height 380ms cubic-bezier(.4,0,.2,1), opacity 280ms ease;
}

.diagram-collapsed .diagram-body {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
}

/* Highlight styling for key terms in titles */
.diagram-highlight {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

[data-theme="dark"] .diagram-highlight {
  background: rgba(255, 255, 255, 0.18);
}

/* Diagram subtitle for secondary information */
.diagram-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0.5rem 0 0 0;
  font-style: italic;
  letter-spacing: -0.2px;
}

[data-theme="dark"] .diagram-subtitle {
  color: #cbd5e1;
}

/* Description section above mermaid diagram */
.diagram-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 1.25rem 0 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius-md);
  line-height: 1.6;
}

[data-theme="dark"] .diagram-description {
  background: rgba(99, 102, 241, 0.04);
  border-left-color: #6366F1;
}

.diagram-figure {
  margin: 2rem 0;
  text-align: center;
}

.diagram-figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.diagram-figure figcaption {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-style: italic;
}

.diagram-caption {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2rem;
  padding: 1.75rem;
  border-top: 3px solid var(--primary);
  line-height: 1.8;
  letter-spacing: 0.3px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.04) 0%, rgba(99, 102, 241, 0.02) 100%);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

[data-theme="dark"] .diagram-caption {
  border-top-color: #6366F1;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0.04) 100%);
}

.diagram-caption strong {
  color: var(--text-primary);
  display: block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  width: fit-content;
}

[data-theme="dark"] .diagram-caption strong {
  color: #ffffff;
  background: #6366F1;
}

.diagram-caption strong::after {
  content: '';
}

.diagram-caption br {
  display: none;
}

/* ── Mermaid Diagrams ── */
.mermaid {
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fc 100%);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid #e5e7eb;
  overflow-x: auto;
  overflow-y: visible;
  margin: 1.75rem 0;
  min-height: 300px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04), 0 2px 6px rgba(99,102,241,0.08);
  transition: all var(--transition);
}

.mermaid:hover {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04), 0 6px 16px rgba(99,102,241,0.14);
  border-color: #d1d5e0;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.mermaid text {
  font-family: inherit !important;
  font-size: 0.875rem !important;
}

/* ── Mermaid Dark Mode ── */
[data-theme="dark"] .mermaid {
  background: linear-gradient(135deg, #0f172a 0%, #151e35 100%);
  border-color: #475569;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3), 0 2px 6px rgba(99,102,241,0.2);
}

[data-theme="dark"] .mermaid:hover {
  border-color: #64748b;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3), 0 6px 16px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .mermaid svg text,
[data-theme="dark"] .mermaid svg tspan {
  fill: #e2e8f0 !important;
}

[data-theme="dark"] .mermaid svg .label text {
  fill: #e2e8f0 !important;
}

[data-theme="dark"] .mermaid svg rect[fill="#fff"],
[data-theme="dark"] .mermaid svg rect[fill="#ffffff"],
[data-theme="dark"] .mermaid svg rect[fill="#FFF"],
[data-theme="dark"] .mermaid svg rect[fill="#FFFFFF"],
[data-theme="dark"] .mermaid svg ellipse[fill="#fff"],
[data-theme="dark"] .mermaid svg ellipse[fill="#ffffff"],
[data-theme="dark"] .mermaid svg circle[fill="#fff"],
[data-theme="dark"] .mermaid svg circle[fill="#ffffff"],
[data-theme="dark"] .mermaid svg polygon[fill="#fff"],
[data-theme="dark"] .mermaid svg polygon[fill="#ffffff"] {
  fill: #1e293b !important;
  stroke: #475569 !important;
}

[data-theme="dark"] .mermaid svg [fill="#000"],
[data-theme="dark"] .mermaid svg [fill="#000000"] {
  fill: #f1f5f9 !important;
}

[data-theme="dark"] .mermaid svg [stroke="#333"],
[data-theme="dark"] .mermaid svg [stroke="#333333"],
[data-theme="dark"] .mermaid svg [stroke="#999"],
[data-theme="dark"] .mermaid svg [stroke="#999999"] {
  stroke: #64748b !important;
}

/* Brightened strokes for dark mode visibility */
[data-theme="dark"] .mermaid svg [stroke="#1976D2"] { stroke: #60a5fa !important; }
[data-theme="dark"] .mermaid svg [stroke="#2E7D32"] { stroke: #4ade80 !important; }
[data-theme="dark"] .mermaid svg [stroke="#E64A19"] { stroke: #fb923c !important; }
[data-theme="dark"] .mermaid svg [stroke="#F57F17"] { stroke: #fbbf24 !important; }
[data-theme="dark"] .mermaid svg [stroke="#6A1B9A"] { stroke: #d084fc !important; }
[data-theme="dark"] .mermaid svg [stroke="#C62828"] { stroke: #f87171 !important; }
[data-theme="dark"] .mermaid svg [stroke="#C2185B"] { stroke: #fb7185 !important; }

/* Sequence diagram elements */
[data-theme="dark"] .mermaid svg .actor {
  fill: #1e293b !important;
  stroke: #475569 !important;
}

[data-theme="dark"] .mermaid svg [fill="#CCCCFF"] {
  fill: rgba(99, 102, 241, 0.2) !important;
}

[data-theme="dark"] .mermaid svg [fill="#CCFFFF"] {
  fill: rgba(99, 102, 241, 0.15) !important;
}

[data-theme="dark"] .mermaid svg .labelBox {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .mermaid svg foreignObject {
  background: #1e293b;
}

[data-theme="dark"] .mermaid svg .label {
  background: transparent;
}

.btn-mobile-theme {
  width: 100%;
  justify-content: center;
  background: rgba(255, 255, 255, .07);
  color: #CBD5E1;
  border: 1px solid rgba(255, 255, 255, .12);
}

/* ─────────────────────────────────────────────────────────────────────────────────── */
/*  DIAGRAM LIGHTBOX MODAL                                                              */
/* ─────────────────────────────────────────────────────────────────────────────────── */

.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.lightbox-modal.active,
.lightbox-modal[aria-hidden="false"] {
  display: flex;
}

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: background 300ms ease;
}

.lightbox-container {
  position: relative;
  width: 90vw;
  height: 90vh;
  max-width: 1200px;
  max-height: 900px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: slideUp 300ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: var(--z-toast);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.lightbox-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.lightbox-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  flex-shrink: 0;
}

.lightbox-close:hover,
.lightbox-close:focus {
  background: var(--surface-hover);
  color: var(--text-primary);
  outline: none;
}

.lightbox-canvas {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--surface);
}

.lightbox-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* canvas handles clipping; visible avoids unwanted scrollbars */
  transform-origin: center center;
  cursor: grab;
  /* No transition on transform — causes laggy pan; controlled per-action instead */
  padding: 2rem;
  will-change: transform;
}

.lightbox-content.panning {
  cursor: grabbing;
}

.lightbox-content > svg,
.lightbox-content > img {
  /* Fit the diagram to the canvas at zoom-level 1, preserving aspect ratio.
     Zoom / pan enlarges via transform on the parent .lightbox-content. */
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

[data-theme="dark"] .lightbox-content > svg {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.lightbox-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-hover);
  flex-wrap: wrap;
}

.lightbox-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.lightbox-btn:hover,
.lightbox-btn:focus {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  outline: none;
}

.lightbox-btn:active {
  transform: translateY(0);
}

.lightbox-zoom-level {
  min-width: 65px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  padding: 0.5rem;
}

.lightbox-info {
  padding: 0.875rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.lightbox-info kbd {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Responsive Lightbox */
@media (max-width: 1024px) {
  .lightbox-container {
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
  }
}

@media (max-width: 768px) {
  .lightbox-container {
    width: 95vw;
    height: 95vh;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
  }

  .lightbox-header {
    padding: 1rem;
  }

  .lightbox-title {
    font-size: 1rem;
  }

  .lightbox-controls {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .lightbox-btn {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .lightbox-info {
    font-size: 0.75rem;
    padding: 0.625rem 1rem;
  }

  .lightbox-content {
    padding: 1rem;
  }
}

/* Dark mode lightbox adjustments */
[data-theme="dark"] .lightbox-container {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .lightbox-canvas {
  background: #131c2e;
}

[data-theme="dark"] .lightbox-header,
[data-theme="dark"] .lightbox-info {
  border-color: #334155;
  background: #1e293b;
}

[data-theme="dark"] .lightbox-title {
  color: #f1f5f9;
}

[data-theme="dark"] .lightbox-close {
  color: #cbd5e1;
}

[data-theme="dark"] .lightbox-close:hover,
[data-theme="dark"] .lightbox-close:focus {
  background: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .lightbox-controls {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .lightbox-btn {
  background: var(--primary);
}

[data-theme="dark"] .lightbox-btn:hover,
[data-theme="dark"] .lightbox-btn:focus {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .lightbox-zoom-level {
  color: #f1f5f9;
}

[data-theme="dark"] .lightbox-info {
  background: #1e293b;
  color: #cbd5e1;
}

[data-theme="dark"] .lightbox-info kbd {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}

/* ── Scroll-to-Top Button ── */
.scroll-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99,102,241,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: var(--z-sticky);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 260ms ease, visibility 260ms ease, transform 260ms ease,
              background 200ms ease, box-shadow 200ms ease;
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(99,102,241,.5);
  transform: translateY(-2px);
}

.scroll-top-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

[data-theme="dark"] .scroll-top-btn {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  box-shadow: 0 4px 14px rgba(99,102,241,.4);
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 768px) {
  .scroll-top-btn {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* ── Copy Code Button ── */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: rgba(255,255,255,.08);
  color: #CBD5E1;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
  font-family: inherit;
  z-index: var(--z-raised);
}

.copy-btn:hover {
  background: rgba(255,255,255,.16);
  color: #F1F5F9;
}

.copy-btn.copied {
  background: rgba(16,185,129,.25);
  color: #6EE7B7;
  border-color: rgba(16,185,129,.4);
}

.copy-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Fade-in Animation ── */
.fade-in {
  animation: fadeInUp .4s ease forwards;
}

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

/* ── Screen-reader only utility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Search no-results message ── */
.search-no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: .95rem;
  padding: 2rem 0;
}

/* ============================================================
   HOME PAGE VIBRANT ENHANCEMENTS — EXTENDED
   ============================================================ */

/* ── Hero Floating Particles ── */
@keyframes particle-float-1 {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  5%   { opacity: 0.4; }
  95%  { opacity: 0.1; }
  100% { transform: translateY(-800px) translateX(120px) rotate(720deg); opacity: 0; }
}
@keyframes particle-float-2 {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  5%   { opacity: 0.5; }
  95%  { opacity: 0.1; }
  100% { transform: translateY(-900px) translateX(-100px) rotate(-720deg); opacity: 0; }
}
@keyframes particle-float-3 {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  5%   { opacity: 0.35; }
  95%  { opacity: 0.1; }
  100% { transform: translateY(-750px) translateX(80px) rotate(540deg); opacity: 0; }
}
@keyframes particle-float-4 {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  5%   { opacity: 0.45; }
  95%  { opacity: 0.1; }
  100% { transform: translateY(-850px) translateX(-140px) rotate(-540deg); opacity: 0; }
}
@keyframes particle-float-5 {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  5%   { opacity: 0.3; }
  95%  { opacity: 0.1; }
  100% { transform: translateY(-820px) translateX(110px) rotate(600deg); opacity: 0; }
}

.hero-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.hero-particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
  box-shadow: 0 0 6px rgba(99,102,241,.4);
  will-change: transform;
}
.particle-1 { left: 20%; bottom: 0; animation: particle-float-1 6s ease-out infinite 0.2s; }
.particle-2 { left: 50%; bottom: 0; animation: particle-float-2 7s ease-out infinite 0.4s; }
.particle-3 { left: 75%; bottom: 0; animation: particle-float-3 6.5s ease-out infinite 0.1s; }
.particle-4 { left: 35%; bottom: 0; animation: particle-float-4 7.5s ease-out infinite 0.3s; }
.particle-5 { left: 65%; bottom: 0; animation: particle-float-5 6s ease-out infinite 0.5s; }

/* ── Hero Animated Orbs ── */
@keyframes orb-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(40px, -60px) scale(1.08); }
  66%       { transform: translate(-25px, 30px) scale(0.94); }
}
@keyframes orb-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-50px, 40px) scale(1.1); }
  75%       { transform: translate(30px, -40px) scale(0.9); }
}
@keyframes orb-drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(25px, -50px) scale(1.06); }
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.hero-orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(99,102,241,.38), transparent 65%);
  top: -160px; left: -80px;
  animation: orb-drift-1 14s ease-in-out infinite;
}
.hero-orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(139,92,246,.32), transparent 65%);
  top: -60px; right: -100px;
  animation: orb-drift-2 18s ease-in-out infinite;
}
.hero-orb-3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(6,182,212,.28), transparent 65%);
  bottom: -60px; left: 42%;
  animation: orb-drift-3 11s ease-in-out infinite;
}

/* ── Hero Gradient Animation ── */
@keyframes hero-bg-shift {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}
.hero {
  background: linear-gradient(135deg, #0A0F1E 0%, #1E1B4B 35%, #0F1629 65%, #0F172A 100%);
  background-size: 250% 250%;
  animation: hero-bg-shift 18s ease infinite;
  overflow: hidden;
}

/* ── Hero Pill — pulsing dot ── */
.hero-pill-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #818CF8;
  box-shadow: 0 0 0 0 rgba(129,140,248,.6);
  animation: dot-pulse 2.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(129,140,248,.6); }
  60%  { box-shadow: 0 0 0 7px rgba(129,140,248,0); }
  100% { box-shadow: 0 0 0 0 rgba(129,140,248,0); }
}

/* ── Hero Stat Nums — gradient text ── */
.hero-stat-num {
  background: linear-gradient(135deg, #FFFFFF 30%, #A5B4FC 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Hero Stat — count-up animation ── */
@keyframes stat-pop {
  0%   { opacity: 0; transform: scale(.6) translateY(10px); }
  70%  { transform: scale(1.1) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.hero-stat-num.stat-animated {
  animation: stat-pop .6s cubic-bezier(.34,1.56,.64,1) both;
}

/* ── Feature Bar Enhancements ── */
/* Use individual transform properties so float animation and hover don't conflict.
   `translate` is animated by the keyframe; `scale` + `rotate` are only set by hover,
   so they are entirely separate properties with no cascade fight. */
@keyframes icon-float {
  0%, 100% { translate: 0 0; }
  50%       { translate: 0 -6px; }
}

.feature-item {
  padding: .75rem 1rem;
  border-radius: var(--radius-lg);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  cursor: default;
  position: relative;
}
.feature-item:hover {
  background: var(--surface);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.feature-item:hover .feature-icon {
  scale: 1.15;
  rotate: -8deg;
}
.feature-icon {
  transition: scale 260ms cubic-bezier(.34,1.56,.64,1),
              rotate 260ms cubic-bezier(.34,1.56,.64,1);
  animation: icon-float 3s ease-in-out infinite;
}
/* Stagger the animation for each feature */
.feature-item:nth-child(1) .feature-icon { animation-delay: 0s; }
.feature-item:nth-child(2) .feature-icon { animation-delay: 0.4s; }
.feature-item:nth-child(3) .feature-icon { animation-delay: 0.8s; }
.feature-item:nth-child(4) .feature-icon { animation-delay: 1.2s; }

.feature-icon.feature-indigo {
  background: linear-gradient(135deg, #6366F1, #4338CA);
}
.feature-icon.feature-amber {
  background: linear-gradient(135deg, #F59E0B, #EF4444);
}
.feature-icon.feature-cyan {
  background: linear-gradient(135deg, #06B6D4, #3B82F6);
}
.feature-icon.feature-violet {
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
}
/* keep emoji visible over dark gradient bg */
.feature-icon.feature-indigo,
.feature-icon.feature-amber,
.feature-icon.feature-cyan,
.feature-icon.feature-violet {
  font-size: 1.35rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}

/* ── Topic Card — shimmer sweep on hover ── */
@keyframes card-shimmer {
  0%   { transform: translateX(-120%) skewX(-18deg); }
  100% { transform: translateX(220%)  skewX(-18deg); }
}
.topic-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 25%,
    rgba(255,255,255,.12) 50%,
    transparent 75%
  );
  transform: translateX(-120%) skewX(-18deg);
  pointer-events: none;
}
.topic-card:hover::after {
  animation: card-shimmer .65s ease;
}

/* ── Topic Card — scroll entrance ── */
/* JS sets hidden state via inline style, adds .card-visible to enable the slow entrance
   transition, then removes .card-visible on transitionend — restoring the fast hover
   transition (transition:all var(--transition)) from the base .topic-card rule. */
.topic-card {
  will-change: transform, opacity, box-shadow;
}
.topic-card.card-visible {
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(.4,0,.2,1);
}

/* ── Topic Card — improved hover glow ── */
.topic-card.year12:hover {
  box-shadow: 0 16px 40px rgba(59,130,246,.28), 0 0 0 1px rgba(59,130,246,.2);
}
.topic-card.year11:hover {
  box-shadow: 0 16px 40px rgba(16,185,129,.28), 0 0 0 1px rgba(16,185,129,.2);
}

/* ── Learning Path Section ── */
.learning-path {
  background: var(--bg-secondary);
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.learning-path-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.path-stage {
  text-align: center;
  flex: 1;
  min-width: 200px;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  position: relative;
  box-shadow: 0 2px 8px rgba(99,102,241,0.06), 0 1px 3px rgba(0,0,0,0.04);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.path-stage:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(99,102,241,0.15), 0 4px 8px rgba(0,0,0,0.06);
  border-color: var(--primary);
}
.path-stage-y11 { border-top: 4px solid var(--year11); }
.path-stage-y12 { border-top: 4px solid var(--year12); }

.path-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: inline-block;
  transition: transform 300ms cubic-bezier(.34,1.56,.64,1);
}
.path-stage:hover .path-icon {
  transform: scale(1.2) rotate(10deg);
}
.path-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.path-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.path-count {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
/* Year-specific path count colours */
.path-stage-y12 .path-count { background: var(--year12-light); color: var(--year12-dark); }
.path-stage-y11 .path-count { background: var(--year11-light); color: var(--year11-dark); }
[data-theme="dark"] .path-stage-y12 .path-count { background: rgba(59,130,246,.18); color: #93C5FD; }
[data-theme="dark"] .path-stage-y11 .path-count { background: rgba(16,185,129,.15); color: #6EE7B7; }

.path-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  font-size: 2rem;
  color: var(--primary);
  font-weight: 700;
  animation: arrow-pulse 1.5s ease-in-out infinite;
}
@keyframes arrow-pulse {
  0%, 100% { opacity: 0.5; transform: translateX(0); }
  50%       { opacity: 1; transform: translateX(4px); }
}

@media (max-width: 640px) {
  .learning-path { padding: 2rem 1rem; }
  .learning-path-inner { gap: 1rem; flex-direction: column; }
  /* Use individual `rotate` property — doesn't conflict with the translateX in arrow-pulse */
  .path-connector { min-height: 40px; font-size: 1.5rem; rotate: 90deg; animation: none; }
}

/* ── Section Header — gradient accent line ── */
.section-header {
  position: relative;
}
.section-header::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 80px; height: 4px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

/* Topic count label (replaces inline style) */
.topic-count {
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Study Guide Section ── */
.study-guide-section {
  margin-top: 3.5rem;
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
}
.study-guide-header {
  text-align: center;
  margin-bottom: 2rem;
}
.study-guide-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .4rem;
}
.study-guide-subtitle {
  font-size: .88rem;
  color: var(--text-muted);
}
.study-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}
.study-guide-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem 1.5rem 1.5rem;
  overflow: clip;   /* clip avoids corner-cropping during hover transform */
  box-shadow: 0 1px 4px rgba(99,102,241,0.06), 0 1px 2px rgba(0,0,0,0.04);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.study-guide-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(99,102,241,0.14), 0 4px 8px rgba(0,0,0,0.06);
  border-color: rgba(99,102,241,0.45);
}
.study-guide-step {
  position: absolute;
  top: 1.25rem; right: 1.25rem;
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
  color: var(--border);
  letter-spacing: -.04em;
  pointer-events: none;
  transition: color var(--transition);
}
.study-guide-card:hover .study-guide-step {
  color: var(--border-strong);
}
.study-guide-icon-wrap {
  width: 48px; height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1rem;
  transition: transform 260ms cubic-bezier(.34,1.56,.64,1);
}
.study-guide-card:hover .study-guide-icon-wrap {
  transform: scale(1.15) rotate(-6deg);
}
.sg-indigo { background: linear-gradient(135deg, #6366F1, #4338CA); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.sg-amber  { background: linear-gradient(135deg, #F59E0B, #EF4444); box-shadow: 0 4px 12px rgba(245,158,11,.3); }
.sg-cyan   { background: linear-gradient(135deg, #06B6D4, #3B82F6); box-shadow: 0 4px 12px rgba(6,182,212,.3); }

.study-guide-card h3 {
  font-size: .98rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .5rem;
}
.study-guide-card p {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* ── Reduced Motion: disable animations ── */
@media (prefers-reduced-motion: reduce) {
  .hero-orb,
  .hero-particle,
  .hero-pill-dot,
  .feature-icon,
  .path-connector,
  .path-icon,
  .topic-card,
  .btn-primary,
  .nav-dropdown-menu {
    animation: none !important;
  }
  .path-stage:hover,
  .feature-item:hover,
  .topic-card:hover,
  .study-guide-card:hover,
  .nav-brand:hover .nav-logo,
  .nav-dropdown-menu a:hover {
    transform: none !important;
  }
}

/* ── Print: hide decorative new elements ── */
@media print {
  .hero-orb, .hero-particle, .hero-pill-dot, .study-guide-section, .learning-path { display: none !important; }
}

/* ── Print Styles ── */
@media print {
  /* Hide non-content UI */
  .navbar,
  .mobile-menu,
  .sidebar,
  .scroll-top-btn,
  .reading-progress,
  .copy-btn,
  .lightbox-modal,
  #theme-toggle,
  #theme-toggle-mobile {
    display: none !important;
  }

  /* Full-width single-column layout */
  .page-layout {
    display: block;
  }

  .page-content {
    max-width: 100%;
    padding: 0;
  }

  /* Expand all collapsed sections */
  .section-body.section-collapsed,
  .part-group.part-collapsed {
    grid-template-rows: 1fr !important;
    max-height: none !important;
    display: block !important;
  }

  .section-body-inner {
    overflow: visible !important;
  }

  /* Avoid page breaks inside cards and code blocks */
  .topic-card,
  .info-card,
  .def-card,
  .callout,
  .code-block,
  .table-wrap {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Ensure headings don't orphan at bottom of page */
  h2, h3, h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Reset colors for printing */
  body {
    color: #000 !important;
    background: #fff !important;
  }

  a[href]::after {
    content: ' (' attr(href) ')';
    font-size: .75em;
    color: #555;
  }

  /* Don't print hash anchors */
  a[href^="#"]::after {
    content: none;
  }
}

.pl-list {
  margin-top: 10px;
  margin-left: 20px;
}

/* ── NDB Mock Form ── */
.mock-form-container {
  margin-top: 2rem;
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.ndb-mock-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.ndb-mock-form label {
  font-weight: bold;
  display: block;
  margin-bottom: 5px;
}
.ndb-mock-form textarea {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--noteBorderColor);
  padding: 8px;
}
.ndb-mock-form .checkbox-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}
.ndb-mock-form .submit-btn {
  align-self: flex-start;
  margin-top: 10px;
}

/* ── SDLC Badges ── */
.badge-phase1 { background: #6366F1; }
.badge-phase2 { background: #3B82F6; }
.badge-phase3 { background: #10B981; }
.badge-phase4 { background: #F59E0B; }

/* ── Mermaid Universal Dark Mode Fix ── */
[data-theme="dark"] .mermaid text,
[data-theme="dark"] .mermaid tspan,
[data-theme="dark"] .mermaid .nodeLabel,
[data-theme="dark"] .mermaid span.nodeLabel,
[data-theme="dark"] .mermaid .classLabel,
[data-theme="dark"] .mermaid .classText,
[data-theme="dark"] .mermaid .messageText,
[data-theme="dark"] .mermaid .noteText,
[data-theme="dark"] .mermaid .actor,
[data-theme="dark"] .mermaid .taskText,
[data-theme="dark"] .mermaid .taskTextOutsideRight,
[data-theme="dark"] .mermaid .taskTextOutsideLeft,
[data-theme="dark"] .mermaid .tick text,
[data-theme="dark"] .mermaid p,
[data-theme="dark"] .mermaid span {
  color: #f1f5f9 !important;
  fill: #f1f5f9 !important;
}

[data-theme="dark"] .mermaid .nodeLabel,
[data-theme="dark"] .mermaid span.nodeLabel {
  background-color: transparent !important;
}

[data-theme="dark"] .mermaid .edgeLabel,
[data-theme="dark"] .mermaid .labelBkg {
  background-color: var(--bgLayer) !important;
  color: #f1f5f9 !important;
}

/* ── Automated Glossary Auto-Links ── */
.glossary-link {
  text-decoration: none;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1.5px dashed var(--primary);
  padding-bottom: 0.1em;
  transition: all var(--transition);
  position: relative;
  cursor: help;
}
.glossary-link::after {
  content: "📖";
  font-size: 0.75em;
  margin-left: 0.25em;
  vertical-align: super;
  opacity: 0.5;
  transition: opacity var(--transition);
}
.glossary-link:hover {
  background-color: var(--primary-light);
  border-bottom-style: solid;
}
.glossary-link:hover::after {
  opacity: 1;
}
[data-theme="dark"] .glossary-link:hover {
  background-color: rgba(99, 102, 241, 0.15);
}
