/* ── Theme Variables ── */
:root {
  --glass: rgba(255, 255, 255, 0.6);
  --btn-hover: #5b3ce4;
}

body[data-theme^="dark"] {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);

  /* Override internal classes.css variables to map to the new dark theme colors */
  --bg: var(--bg-primary);
  --bg-2: #1e293b;
  --bg-3: #334155;
  --card: var(--bg-card);
  --card-c1: var(--text-primary);
  --card-c2: var(--text-secondary);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --border: var(--border-color);
  --glass: rgba(30, 41, 59, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
  --primary: var(--accent);
  --btn-hover: var(--accent-hover);
  --accent: #6c4df6;
  --accent-hover: #5b3ce4;
  --shadow: rgba(0, 0, 0, 0.4);
  --surface: #334155;
}

/* Explicit Typography Overrides for Dark Mode */
body[data-theme^="dark"] {
  color: var(--text-primary);
}

body[data-theme^="dark"] h1,
body[data-theme^="dark"] h2,
body[data-theme^="dark"] h3,
body[data-theme^="dark"] h4,
body[data-theme^="dark"] h5,
body[data-theme^="dark"] h6 {
  color: var(--text-primary) !important;
}

body[data-theme^="dark"] .sn-section-title {
  color: #ffffff !important;
}

body[data-theme^="dark"] p,
body[data-theme^="dark"] label,
body[data-theme^="dark"] span:not(.stage-badge):not(.bullet-check):not(.sn-hamburger span):not(.hero-emoji),
body[data-theme^="dark"] .card-desc,
body[data-theme^="dark"] .stage-desc,
body[data-theme^="dark"] .topic-list li {
  color: var(--text-secondary) !important;
}

body[data-theme^="dark"] .drawer-stage,
body[data-theme^="dark"] .drawer-note,
body[data-theme^="dark"] .accordion-arrow {
  color: var(--text-muted) !important;
}

body[data-theme^="dark"] .category-card:hover {
  background: #253347;
  box-shadow: 0 20px 50px rgba(108, 77, 246, 0.25);
}

body[data-theme^="dark"] .drawer-btn {
  background: var(--bg-3);
  color: var(--text);
}
body[data-theme^="dark"] .drawer-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Button & Link States */
.drawer-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.drawer-btn:active {
  transform: scale(0.98);
}
.drawer-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.drawer-btn-close {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  margin-top: 8px;
}
.drawer-btn-close:hover {
  background: var(--border);
  color: var(--text);
}

body[data-theme^="dark"] .drawer-btn-close {
  background: #334155 !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
}
body[data-theme^="dark"] .drawer-btn-close:hover {
  background: #475569 !important;
}

body[data-theme^="dark"] .card-action:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body[data-theme^="dark"] .drawer-body::-webkit-scrollbar-thumb {
  background-color: var(--muted);
  border: 3px solid var(--card);
}
body[data-theme^="dark"] .drawer-body::-webkit-scrollbar-track {
  background: var(--border);
}

/* Link States */
.card-action:hover, .card-action:focus {
  filter: brightness(1.2);
}

/* Forms (generic) */
.search-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.search-input:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}
.search-input::placeholder {
  color: var(--muted);
}

/* ── Base Variables & Keyframes ── */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page {
  padding-top: 0px !important;
}

/* ── Global Page Overrides ── */
body.drawer-open {
  overflow: hidden !important;
}

/* ── Section & Stage Container Styles ── */
.section {
  padding: 40px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.stage-container {
  position: relative;
  border-radius: 32px;
  padding: 40px;
  margin-bottom: 80px;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px var(--shadow);
  z-index: 1;
}

/* Dark mode handled by theme variables now */

/* Animated gradient blobs behind stages */
.stage-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  right: -50%;
  bottom: -50%;
  background: var(--stage-bg-gradient);
  background-size: 200% 200%;
  z-index: -1;
  opacity: 0.08;
  animation: stageBgShift 15s ease infinite;
  pointer-events: none;
}

body[data-theme="dark"] .stage-container::before {
  opacity: 0.15;
}

@keyframes stageBgShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

/* Specific gradients for stage backgrounds */
.stage-container.foundation-stage-bg {
  --stage-bg-gradient: radial-gradient(circle, rgba(255, 94, 98, 0.4) 0%, rgba(255, 153, 102, 0.2) 50%, transparent 100%);
}

.stage-container.primary-stage-bg {
  --stage-bg-gradient: radial-gradient(circle, rgba(79, 70, 229, 0.3) 0%, rgba(99, 102, 241, 0.15) 50%, transparent 100%);
}

.stage-container.middle-stage-bg {
  --stage-bg-gradient: radial-gradient(circle, rgba(124, 58, 237, 0.35) 0%, rgba(6, 182, 212, 0.15) 50%, transparent 100%);
}

.stage-header-wrapper {
  text-align: center;
  margin-bottom: 40px;
}

.stage-badge {
  display: inline-flex;
  padding: 8px 18px;
  border-radius: 50px;
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.stage-badge.pink {
  background: linear-gradient(135deg, #ff5e62, #ff9966);
  box-shadow: 0 4px 15px rgba(255, 94, 98, 0.2);
}

.stage-badge.indigo {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

.stage-badge.violet {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.2);
}

.stage-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}

.stage-desc {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 700px;
  margin: 0 auto;
}

/* ── Category Grid ── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 10px;
}

.stage-grid-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 10px;
}

.stage-grid-middle {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  max-width: 900px;
  margin: 0 auto;
}

.category-card {
  position: relative;
  background: var(--card);
  backdrop-filter: blur(18px);
  border-radius: 24px;
  padding: 20px;
  text-align: center;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  animation: slideUp 0.6s ease both;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px var(--shadow);
}

/* Gradient border effect */
.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  padding: 2px;
  background: linear-gradient(135deg, var(--card-c1), var(--card-c2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.4;
  transition: opacity 0.3s;
}

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

.category-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 20px 50px rgba(108, 77, 246, 0.12);
}

.card-img-wrapper {
  background: var(--bg-2);
  border-radius: 18px;
  padding: 8px;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 170px;
  transition: transform 0.3s ease, background 0.3s ease;
}

.class-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.08));
}

.category-card:hover .card-img-wrapper {
  background: var(--surface);
}

.category-card:hover .class-img {
  transform: scale(1.15) rotate(-3deg);
}

.card-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
  flex-grow: 1;
}

.card-action {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--card-c1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: gap 0.3s;
  margin-top: auto;
}

.category-card:hover .card-action {
  gap: 12px;
}

/* Card gradients */
.category-card.c1 {
  --card-c1: #ff5e62;
  --card-c2: #ff9966;
}

.category-card.c2 {
  --card-c1: #f59e0b;
  --card-c2: #fbbf24;
}

.category-card.c3 {
  --card-c1: #10b981;
  --card-c2: #34d399;
}

.category-card.c4 {
  --card-c1: #0ea5e9;
  --card-c2: #38bdf8;
}

.category-card.c5 {
  --card-c1: #6366f1;
  --card-c2: #818cf8;
}

.category-card.c6 {
  --card-c1: #8b5cf6;
  --card-c2: #a78bfa;
}

.category-card.c7 {
  --card-c1: #d946ef;
  --card-c2: #e879f9;
}

.category-card.c8 {
  --card-c1: #06b6d4;
  --card-c2: #22d3ee;
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* ── Interactive Syllabus Drawer ── */
.syllabus-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.syllabus-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.syllabus-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 520px;
  background: var(--card);
  z-index: 9999;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.syllabus-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
}

.drawer-stage {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.drawer-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  margin-top: 4px;
}

.drawer-close {
  background: var(--bg-3);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.drawer-close:hover {
  background: var(--border);
  color: var(--text);
  transform: scale(1.05);
}

.drawer-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* Custom Scrollbar for drawer body */
.drawer-body::-webkit-scrollbar {
  width: 6px;
}

.drawer-body::-webkit-scrollbar-track {
  background: var(--bg-3);
}

.drawer-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.drawer-body::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.drawer-footer {
  padding: 24px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-note {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
  display: flex;
  gap: 8px;
}

.drawer-note i {
  color: #f59e0b;
  margin-top: 2px;
}

.drawer-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
  border: none;
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 15px var(--shadow);
}

.drawer-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow);
}

/* Accordions inside drawer */
.drawer-accordion {
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--card);
  transition: box-shadow 0.2s;
}

.drawer-accordion:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.accordion-trigger {
  width: 100%;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  outline: none;
}

.subject-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.subject-icon {
  font-size: 1.3rem;
  display: inline-flex;
  width: 32px;
  height: 32px;
  background: var(--bg-3);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
}

.accordion-arrow {
  color: var(--muted);
  transition: transform 0.3s ease;
  font-size: 0.85rem;
}

.accordion-trigger[aria-expanded="true"] .accordion-arrow {
  transform: rotate(180deg);
  color: var(--muted);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-top: 1px solid transparent;
}

.accordion-trigger[aria-expanded="true"]+.accordion-content {
  border-top: 1px solid var(--border);
}

.topic-list {
  padding: 16px 20px 20px 20px;
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.4;
}

.bullet-check {
  color: #10b981;
  font-size: 0.9rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.topic-name {
  font-weight: 500;
}

/* ── Responsive Grid ── */
/* Removed explicit column override for auto-fit to work */

@media (max-width: 1024px) {
  .category-grid,
  .stage-grid-primary,
  .stage-grid-middle {
    gap: 20px;
  }

  .stage-container {
    padding: 32px;
  }
}

@media (max-width: 768px) {
  .category-grid,
  .stage-grid-primary,
  .stage-grid-middle {
    gap: 16px;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .stage-title {
    font-size: 1.8rem;
  }

  .stage-container {
    /* padding: 30px 20px; */
  }

  .stage-header-wrapper {
    margin-bottom: 24px;
  }

  .category-card {
    padding: 20px;
  }

  .card-img-wrapper {
    height: 160px;
    margin-bottom: 16px;
  }
}

@media (max-width: 520px) {
  .syllabus-drawer {
    max-width: 100%;
  }

  .drawer-header {
    padding: 16px 20px;
  }

  .drawer-title {
    font-size: 1.3rem;
  }

  .drawer-body {
    padding: 16px 20px;
  }

  .drawer-footer {
    padding: 16px 20px;
  }

  .accordion-trigger {
    padding: 14px 16px;
  }

  .topic-list {
    padding: 12px 16px 16px 16px;
  }
}

@media (max-width: 480px) {
  .category-grid,
  .stage-grid-primary,
  .stage-grid-middle {
    gap: 20px;
  }

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

  .hero {
    padding: 80px 20px 48px;
    min-height: auto;
  }

  .section {
    padding: 24px 16px;
  }

  .stage-container {
    padding: 24px 16px;
    margin-bottom: 32px;
  }

  .card-img-wrapper {
    height: 160px;
  }
}
