/* =========================================
   THEME VARIABLES (Light + Dark)
========================================= */
:root {
  --primary: #7B1FA2;
  --primary-hover: #8E44AD;
  --secondary: #D32F2F;
  --accent-red-bg: #FFEBEE;
  --accent-purple-light: #f4ecf7;

  --text-dark: #2c3e50;
  --text-body: #5f6c7b;
  --text-light: #94a3b8;

  --bg-card: #ffffff;
  --border-color: #f0f0f0;

  --shadow-sm: 0 10px 40px rgba(0,0,0,.05);
  --shadow-md: 0 14px 45px rgba(0,0,0,.08);
  --shadow-hover: 0 25px 60px rgba(123,31,162,.18);

  --radius-lg: 28px;
  --radius-md: 20px;
}

/* Dark mode variables */
body.dark-mode {
  --primary: #c084fc;
  --primary-hover: #a855f7;
  --secondary: #f87171;

  --text-dark: #f1f5f9;
  --text-body: #cbd5e1;
  --text-light: #94a3b8;

  --bg-card: #0f172a;
  --border-color: rgba(148,163,184,.08);

  --shadow-sm: 0 10px 30px rgba(0,0,0,.6);
  --shadow-md: 0 14px 40px rgba(0,0,0,.7);
  --shadow-hover: 0 25px 60px rgba(192,132,252,.35);

  --accent-purple-light: rgba(255,255,255,.08);
}

/* =========================================
   GLASS HEADER (Redesigned)
========================================= */
header.glass-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 0.8rem 0;
  transition: all 0.3s ease;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}



.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.desktop-nav ul {
  display: flex;
  gap: 30px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.desktop-nav a {
  color: var(--text-dark);
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
  transition: color 0.3s;
}

.desktop-nav a:hover, .desktop-nav a.active {
  color: var(--primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mobile First Header Adjustments */
@media (max-width: 768px) {
  .desktop-nav { display: none; }
  .header-search input { width: 0; padding: 0; opacity: 0; }
  .header-search { background: transparent; padding: 0; }
  .header-search .search-icon { font-size: 1.2rem; margin: 0; padding: 10px; cursor: pointer; }
  
  /* Expand search on focus/active */
  .header-search:focus-within {
    position: absolute;
    top: 60px;
    left: 10px;
    right: 10px;
    background: #fff;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    padding: 10px 15px;
    z-index: 999;
  }
  .header-search:focus-within input { width: 100%; opacity: 1; }
  .install-app-btn .btn-text { display: inline-block !important; }

  /* Sticky Install Button on Mobile */
  .install-app-btn {
    position: fixed !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 9999 !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3) !important;
  }
}

/* =========================================
   CLASS & CAROUSEL CARDS
========================================= */
.class-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 2.4rem 2.2rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 340px;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1;
}

.class-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 40px rgba(123, 31, 162, 0.15);
  border-color: rgba(123, 31, 162, 0.2);
}

/* Decorative Background Number */
.card-bg-text {
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 10rem;
  font-weight: 900;
  color: var(--primary);
  opacity: 0.04;
  z-index: -1;
  transition: transform 0.4s ease;
}

.class-card:hover .card-bg-text {
  transform: scale(1.1) rotate(-5deg);
  opacity: 0.08;
}

.class-card h3 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 .8rem 0;
}

.class-card p {
  font-size: 1rem;
  color: var(--text-body);
  line-height: 1.6;
  margin-bottom: 1.8rem;
}

/* Background icon (huge faded number / icon) */
.card-bg-icon {
  position: absolute;
  top: -30px;
  right: -30px;
  font-size: 7rem;
  opacity: .06;
  pointer-events: none;
  color: var(--primary);
  transform: rotate(10deg);
}

/* =========================================
   BADGES
========================================= */
.class-badge,
.card-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 1.2rem;
  background: var(--accent-purple-light);
  color: var(--primary);
}

.badge-board {
  background: #fef3c7;
  color: #f59e0b;
}

.badge-final {
  background: #fee2e2;
  color: #ef4444;
}

.live-badge {
  background: var(--accent-red-bg);
  color: var(--secondary);
  animation: pulse-red 2s infinite;
}

/* =========================================
   CARD ACTION LINKS
========================================= */
.card-action,
.explore-link,
.feature-link {
  font-weight: 700;
  font-size: .95rem;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: gap .25s ease, color .25s ease;
}

.card-action:hover,
.explore-link:hover,
.feature-link:hover {
  gap: 14px;
  color: var(--primary-hover);
}

/* =========================================
   PWA INSTALL BUTTON (Redesigned)
========================================= */
.install-app-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff !important; /* Force white text */
  border: none;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(123, 31, 162, 0.25);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.install-app-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(123, 31, 162, 0.4);
}

.install-app-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50px;
  z-index: -1;
  animation: pulse-install 2s infinite;
}

@keyframes pulse-install {
  0% { box-shadow: 0 0 0 0 rgba(123, 31, 162, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(123, 31, 162, 0); }
  100% { box-shadow: 0 0 0 0 rgba(123, 31, 162, 0); }
}

/* =========================================
   HERO SLIDER DOTS
========================================= */
.hero-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 1.8rem;
}

.hero-dots .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d1d5db;
  transition: transform .25s, background .25s;
}

.hero-dots .dot.active {
  background: var(--primary);
  transform: scale(1.2);
}

/* Hero Slider Animation Base */
.hero-slide {
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 1;
}

.hero-slide.active {
  opacity: 1;
  z-index: 2;
}

/* =========================================
   HEADER SEARCH BAR
========================================= */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--accent-purple-light);
  border-radius: 50px;
  padding: 5px 15px;
  transition: all 0.3s ease;
}

.header-search:focus-within {
  background: #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.header-search .search-icon {
  color: var(--primary);
  font-size: 0.9rem;
  margin-right: 8px;
}

.header-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.9rem;
  width: 120px;
  color: var(--text-dark);
  transition: width 0.3s ease;
}

.header-search input:focus {
  width: 200px;
}

/* =========================================
   CAROUSEL ARROWS (Amazon Style)
========================================= */
.card-carousel-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
  padding: 10px 0 30px 0;
}

.card-carousel-track {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: 10px 5px;
  padding-bottom: 20px; /* Space for scrollbar */
  -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}


/* Custom Scrollbar (The "Slider") */
.card-carousel-track::-webkit-scrollbar {
  display: block;
  height: 6px;
}

.card-carousel-track::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
  margin: 0 5px;
}

.card-carousel-track::-webkit-scrollbar-thumb {
  background: rgba(123, 31, 162, 0.3); /* Primary color with opacity */
  border-radius: 10px;
  transition: background 0.3s;
}

.card-carousel-track::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.carousel-item {
  min-width: 280px;
  max-width: 320px;
  flex: 0 0 auto;
  scroll-snap-align: center;
}

.card-carousel-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 10px 25px rgba(0,0,0,.25);
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-carousel-button:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 16px 35px rgba(0,0,0,.35);
}

.card-carousel-button.prev { left: -10px; }
.card-carousel-button.next { right: -10px; }

@media (max-width: 768px) {
  .card-carousel-button { display: none; } /* Hide arrows on mobile, use swipe */
  .carousel-item { min-width: 85vw; } /* Full width cards on mobile */
  .card-carousel-track { padding-left: 20px; padding-right: 20px; }
}

/* =========================================
   DARK TOGGLE BUTTON ICON POLISH
========================================= */
.dark-toggle i {
  transition: transform .4s ease;
}

body.dark-mode .dark-toggle i {
  transform: rotate(180deg);
}

/* =========================================
   FEATURE CARDS (Why Choose SJMaths)
========================================= */
.feature-card {
  background: var(--bg-card);
  padding: 2.5rem 2rem;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

a.feature-card {
  text-decoration: none;
  cursor: pointer;
  color: inherit;
}

.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 15px 35px rgba(0,0,0,0.1);
  background: var(--primary);
}

.feature-card .f-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  margin-bottom: 1.3rem;
  font-size: 1.4rem;
  background: var(--accent-purple-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s ease;
}

.feature-card:hover .f-icon {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
  transform: scale(1.1);
}

.feature-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: .5rem;
  transition: color 0.3s;
}

.feature-card p {
  font-size: .95rem;
  color: var(--text-body);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  flex-grow: 1;
  transition: color 0.3s;
}

.feature-link {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: auto;
  transition: color 0.3s;
}

/* Hover Text Colors for Feature Card */
.feature-card:hover h3,
.feature-card:hover p,
.feature-card:hover .feature-link {
  color: #ffffff;
}

/* =========================================
   MASTERY / LIVE CARDS (Dark Theme)
========================================= */
.big-card {
  border-radius: 24px;
  padding: 2.5rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.3s ease;
}

/* Anchor tag specific overrides for big-card */
a.big-card {
  text-decoration: none;
  cursor: pointer;
}

.big-card:hover {
  transform: translateY(-5px);
}

.card-mastery {
  background: linear-gradient(135deg, #2c3e50 0%, #000000 100%);
}

.card-live {
  background: linear-gradient(135deg, #c0392b 0%, #8e44ad 100%);
}

.card-test {
  background: linear-gradient(135deg, #d35400 0%, #f39c12 100%);
}

.big-card h3 {
  font-size: 1.5rem;
  margin: 1rem 0;
  color: #fff;
}

.big-card p {
  color: rgba(255,255,255,0.8);
  margin-bottom: 1.5rem;
}

.big-card .link {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* =========================================
   AUTH BUTTON PILL
========================================= */
.auth-btn-pill {
  padding: 8px 20px;
  border: 2px solid var(--primary);
  border-radius: 50px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.auth-btn-pill:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(123, 31, 162, 0.3);
}

/* =========================================
   RECENTLY VIEWED SECTION
========================================= */
.recent-section {
  padding: 2rem 8%;
  background: var(--accent-purple-light);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.section-header-recent {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header-recent h2 {
  font-size: 1.4rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header-recent h2 i {
  color: var(--primary);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: .9rem;
}

.clear-btn:hover {
  color: var(--secondary);
  text-decoration: underline;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px,1fr));
  gap: 1.5rem;
}

.recent-card {
  background: var(--bg-card);
  padding: 1.2rem;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 15px;
  border: 1px solid var(--border-color);
  transition: transform .2s, box-shadow .2s;
}

.recent-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.recent-icon {
  width: 45px;
  height: 45px;
  background: var(--accent-purple-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.2rem;
}

.recent-type {
  font-size: .7rem;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
}

.recent-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================
   COMING SOON CARD
========================================= */
.coming-soon-hero {
  max-width: 600px;
  margin: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-hover);
}

.coming-soon-hero .badge {
  display: inline-block;
  background: rgba(142,68,173,.15);
  color: var(--primary);
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.coming-soon-hero h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: .8rem;
}

.coming-soon-hero p {
  color: var(--text-light);
  margin-bottom: 2rem;
}

/* =========================================
   DARK MODE OVERRIDES
========================================= */
body.dark-mode .feature-card,
body.dark-mode .recent-card,
body.dark-mode .coming-soon-hero {
  background: #0f172a;
  border-color: rgba(148,163,184,.08);
  box-shadow: var(--shadow-md);
}

body.dark-mode .recent-section {
  background: rgba(255,255,255,.04);
}

body.dark-mode .feature-card h3,
body.dark-mode .recent-title,
body.dark-mode .coming-soon-hero h1 {
  color: #f8fafc;
}

body.dark-mode .feature-card p,
body.dark-mode .coming-soon-hero p {
  color: #cbd5e1;
}

body.dark-mode header.glass-header {
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* =========================================
   ANIMATIONS
========================================= */
@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(211,47,47,0.4); }
  70% { box-shadow: 0 0 0 10px rgba(211,47,47,0); }
  100% { box-shadow: 0 0 0 0 rgba(211,47,47,0); }
}

/* =========================================
   CLASS CARD VARIANTS
========================================= */
.card-9 .card-bg-icon { color: #3498db; }
.card-9:hover { border-color: rgba(52, 152, 219, 0.3); box-shadow: 0 20px 40px rgba(52, 152, 219, 0.15); }
.card-9 .class-badge { background: #e1f5fe; color: #0288d1; }

.card-10 .card-bg-icon { color: #f39c12; }
.card-10:hover { border-color: rgba(243, 156, 18, 0.3); box-shadow: 0 20px 40px rgba(243, 156, 18, 0.15); }

.card-11 .card-bg-icon { color: #9b59b6; }
.card-11:hover { border-color: rgba(155, 89, 182, 0.3); box-shadow: 0 20px 40px rgba(155, 89, 182, 0.15); }

.card-12 .card-bg-icon { color: #e74c3c; }
.card-12:hover { border-color: rgba(231, 76, 60, 0.3); box-shadow: 0 20px 40px rgba(231, 76, 60, 0.15); }

.card-maths-mastery { background: linear-gradient(135deg, #2c3e50, #000); color: white; }
.card-maths-mastery h3, .card-maths-mastery p { color: white; }
.card-maths-mastery .card-bg-icon { color: rgba(255,255,255,0.1); }
.card-maths-mastery .card-action { color: #f1c40f; }

/* =========================================
   ANIMATION STAGGER
========================================= */
.stagger-1 { transition-delay: 100ms; }
.stagger-2 { transition-delay: 200ms; }
.stagger-3 { transition-delay: 300ms; }
.stagger-4 { transition-delay: 400ms; }

/* Prevent header overflow on small screens */
@media (max-width: 480px) {
  .install-app-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    gap: 6px;
  }
}
