/* =========================
   CSS VARIABLES
   ========================= */
:root {
  --primary-blue: #2747a08f;
  --primary: #1E3A8A;
  --accent: #2563EB;

  --text-primary: #111827;
  --text-secondary: #6B7280;

  --border-light: #E5E7EB;
  --bg-light: #F9FAFB;
}

/* Dark mode support - override colors */
[data-theme="dark"] {
  --primary-blue: #60a5fa;
  --primary: #3b82f6;
  --accent: #60a5fa;
  
  --text-primary: #e8edf5;
  --text-secondary: #b0c4de;
  
  --border-light: #2a405c;
  --bg-light: #0f1a2b;
  
  /* Additional dark mode colors for components */
  --card-bg-dark: #1a2a40;
  --card-alt-dark: #1f3450;
  --highlight-dark: #1e3a5f;
  --solution-bg-dark: #1e3a5f;
  --problem-bg-dark: #1f3450;
}

/* =========================
   RESET & BASE
   ========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* =========================
   MAIN CONTENT
   ========================= */
.main-content {
  max-width: 1200px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

/* =========================
   HERO SECTION
   ========================= */
.hero {
  background-color: var(--math-card-bg);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 3rem;
  margin-bottom: 3rem;
}

.hero h2 {
  font-size: 2.2rem;
  color: var(--primary-blue);
  margin-bottom: 1rem;
}

.hero p {
  max-width: 700px;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* =========================
   GRADES SECTION
   ========================= */
.grades h3 {
  margin-bottom: 1.5rem;
}

.grade-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.grade-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;

  background-color: var(--math-card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-light);

  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-blue);
  text-decoration: none;

  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grade-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

/* =========================
   TABLES
   ========================= */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background-color: var(--math-card-bg);
  font-size: 0.95rem;
}

th, td {
  border: 1px solid var(--border-light);
  padding: 0.75rem;
  text-align: center;
  color: var(--text-primary);
}

th {
  background-color: var(--primary);
  color: #ffffff;
}

/* =========================
   INFO BOXES
   ========================= */
.formula-box {
  background-color: var(--math-highlight);
  border-left: 5px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-family: monospace;
  color: var(--text-primary);
}

.note-box {
  background-color: var(--note-bg);
  border-left: 5px solid var(--math-accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--note-text);
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 768px) {
  .hero {
    padding: 2rem 1.5rem;
  }

  .hero h2 {
    font-size: 1.6rem;
  }
}

/* =========================
   DOWNLOAD NOTES SECTION
   ========================= */

.download-notes {
  background: var(--math-card-alt);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 2rem 2.5rem;
  margin: 4rem 0;

  display: flex;
  flex-direction: column;
  gap: 1rem;

  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.05);
}

/* Heading */
.download-notes h2 {
  font-size: 1.4rem;
  color: var(--primary-blue);
}

/* Description text */
.download-notes p {
  max-width: 620px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Download button */
.download-btn {
  align-self: flex-start;

  display: inline-flex;
  align-items: center;
  gap: 0.5rem;

  padding: 0.75rem 1.5rem;
  margin-top: 0.5rem;

  background-color: var(--primary-blue);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;

  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(30, 58, 138, 0.3);

  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* Hover & focus */
.download-btn:hover,
.download-btn:focus {
  background-color: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(30, 58, 138, 0.35);
  outline: none;
}

/* Active click */
.download-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(30, 58, 138, 0.25);
}

/* Mobile */
@media (max-width: 768px) {
  .download-notes {
    padding: 1.6rem;
  }

  .download-notes h2 {
    font-size: 1.25rem;
  }

  .download-btn {
    width: 100%;
    justify-content: center;
  }
}

/* =========================
   STUDY IMAGES (FIXED)
   ========================= */

.study-figure {
  margin: 2.5rem auto;
  max-width: 520px;
  text-align: center;
}

.study-figure img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--math-card-bg);
}

.study-figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Mobile */
@media (max-width: 768px) {
  .study-figure {
    max-width: 100%;
  }
}

/* ===============================
   PAGE TITLE
================================ */

.main-content h1 {
  font-size: 2rem;
  margin-bottom: 1.2rem;
  color: var(--text-primary);
}

/* ===============================
   SUBJECT GRID
================================ */

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.4rem;
}

/* ===============================
   SUBJECT CARD
================================ */

.subject-card {
  background-color: var(--math-card-alt);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.4rem 1rem;
  text-align: center;

  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 1rem;

  transition: transform 0.18s ease, box-shadow 0.18s ease,
              border-color 0.18s ease;
}

.subject-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-blue);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  color: var(--primary-blue);
}

/* ===============================
   MOBILE OPTIMIZATION
================================ */

@media (max-width: 600px) {
  .hero {
    padding: 2.2rem 1.4rem;
  }

  .hero h2 {
    font-size: 1.6rem;
  }

  .main-content h1 {
    font-size: 1.6rem;
  }
}

/* ===============================
   PAST PAPERS WRAPPER
================================ */

.past-papers-wrapper {
  margin-top: 3rem;
  padding: 2.5rem 2rem;

  background-color: var(--math-card-alt);
  border: 1px solid var(--border-light);
  border-radius: 14px;
}

/* Ensure spacing between years */
.past-papers-wrapper .year-section:not(:last-child) {
  margin-bottom: 4rem;
}

/* Headings inside wrapper */
.past-papers-wrapper h2,
.past-papers-wrapper h3 {
  scroll-margin-top: 100px;
}

/* ===============================
   TOPIC NAV (BACK LINK)
================================ */

.topic-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-start;
}

.topic-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;

  color: var(--primary-blue);
  background-color: var(--math-highlight);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;

  transition: background-color 0.15s ease, transform 0.15s ease;
}

.topic-nav a:hover {
  background-color: var(--math-primary);
  color: white;
  transform: translateX(-2px);
}

/* Quadratic Functions - Example Styles (Dark mode compatible) */

/* Example Section Container */
.example-section {
  background: var(--math-card-alt);
  border-left: 2px solid var(--primary-blue);
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
  border-radius: 8px;
}

.example-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-light);
}

.example-icon {
  background-color: var(--primary-blue);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
}

.example-title {
  color: var(--text-primary);
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

/* Problem Box */
.problem-box {
  background: var(--math-card-bg);
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
  line-height: 1.4;
}

.problem-label {
  display: inline-block;
  background-color: var(--math-accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Solution Box - FIXED FOR DARK MODE */
.solution-box {
  background: var(--math-highlight);
  color: var(--text-primary);
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
  line-height: 1.4;
}

.solution-label {
  display: inline-block;
  background-color: var(--math-success);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Step List */
.step-list {
  counter-reset: step-counter;
  margin: 0;
  padding: 0;
}

.step-list li {
  counter-increment: step-counter;
  list-style: none;
  margin-bottom: 0.5rem;
  padding-left: 1.8rem;
  position: relative;
  color: var(--text-secondary);
}

.step-list li::before {
  content: counter(step-counter) ".";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary-blue);
  font-weight: 600;
  font-size: 0.85rem;
}

/* Math Formulas */
.math-formula {
  font-family: "SF Mono", Monaco, "Courier New", monospace;
  background: var(--math-card-alt);
  padding: 3px 6px;
  border-radius: 4px;
  display: inline-block;
  margin: 1px 0;
  font-size: 0.85rem;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

/* Key Points */
.key-point {
  background: var(--math-highlight);
  border-left: 2px solid var(--math-accent);
  padding: 0.6rem;
  margin: 0.6rem 0;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.key-point strong {
  color: var(--math-accent);
}

/* Method Container */
.method-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.method-box {
  background: var(--math-card-bg);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.8rem;
  transition: border-color 0.2s ease;
}

.method-box:hover {
  border-color: var(--primary-blue);
}

.method-number {
  display: inline-block;
  background: var(--primary-blue);
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  text-align: center;
  line-height: 26px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

.method-box h3 {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.method-box p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 0.6rem;
}

/* Application Boxes */
.application-box {
  background: var(--math-card-bg);
  border: 1px solid var(--border-light);
  padding: 0.8rem;
  border-radius: 12px;
  margin: 0.8rem 0;
}

.application-box h3 {
  color: var(--text-primary);
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 0.6rem;
}

.projectile-app {
  border-top: 2px solid var(--primary-blue);
}

.optimization-app {
  border-top: 2px solid var(--math-accent);
}

/* Assessment Boxes */
.assessment-box {
  background: var(--math-card-alt);
  border: 1px solid var(--border-light);
  padding: 0.8rem;
  border-radius: 12px;
  margin: 0.6rem 0;
}

.assessment-box h3 {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.assessment-box ul {
  margin: 0.4rem 0;
  padding-left: 1rem;
}

.assessment-box li {
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Headings */
h2 {
  font-size: 1.3rem;
  margin: 1.2rem 0 0.8rem 0;
  color: var(--text-primary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.1rem;
  margin: 1rem 0 0.6rem 0;
  color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .method-container {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
  
  .example-section {
    padding: 0.7rem;
  }
  
  .method-box,
  .application-box {
    padding: 0.7rem;
  }
}

@media (max-width: 480px) {
  .example-section {
    padding: 0.6rem;
  }
  
  .problem-box,
  .solution-box {
    padding: 0.6rem;
  }
  
  .step-list li {
    padding-left: 1.5rem;
  }
}

/* ===== UNIVERSAL CONTENT SIZING ===== */

/* Apply to your main content container */
.main-content,
.page-container,
[class*="content"],
[class*="container"] {
    max-width: 900px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 3rem !important;
    padding-right: 3rem !important;
    width: 100% !important;
}

/* Tablets – reduce padding but keep side breathing */
@media (max-width: 900px) {
    .main-content,
    .page-container,
    [class*="content"],
    [class*="container"] {
        padding-left: 2.5rem !important;
        padding-right: 2.5rem !important;
    }
}

/* Large phones – still plenty of side space */
@media (max-width: 600px) {
    .main-content,
    .page-container,
    [class*="content"],
    [class*="container"] {
        padding-left: 1.8rem !important;
        padding-right: 1.8rem !important;
    }
}

/* Small phones – minimum side margins */
@media (max-width: 400px) {
    .main-content,
    .page-container,
    [class*="content"],
    [class*="container"] {
        padding-left: 1.2rem !important;
        padding-right: 1.2rem !important;
    }
}

/* Limit paragraph width for better readability */
p, li, .text-block {
    max-width: 700px;
}

/* Ensure images and embeds stay inside container */
img, iframe, video, .responsive-media {
    max-width: 100%;
    height: auto;
}

/* Tables – prevent overflow */
.table-responsive,
.table-wrapper {
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    background: var(--math-card-bg);
}

/* Force tables to be scrollable */
table {
    min-width: 450px;
    width: 100%;
    border-collapse: collapse;
}

/* ===== HERO SECTION TEXT COLOR FIXES ===== */
/* Hero section text remains white */
.subject-hero h1, 
.subject-hero .hero-subtitle, 
.subject-hero .curriculum-badge {
    color: white !important;
}

/* Hero icon color */
.subject-hero .hero-icon i {
    color: white;
}

/* Ensure any text inside hero stays white */
.subject-hero p,
.subject-hero span,
.subject-hero div {
    color: white;
}

/* ===== LIFE SCIENCES PREV/NEXT MOBILE NAV ===== */
@media (max-width: 768px) {
    .bio-navigation,
    .module-navigation {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 1.25rem auto !important;
        padding: 0 0.75rem !important;
        box-sizing: border-box !important;
    }

    .bio-nav-button,
    .module-nav-button,
    .nav-module {
        flex: none !important;
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0.7rem 0.8rem !important;
        gap: 0.45rem !important;
        border-radius: 10px !important;
        box-sizing: border-box !important;
    }

    .bio-nav-button .nav-arrow,
    .module-nav-button .nav-arrow,
    .nav-module .nav-arrow {
        font-size: 1.05rem !important;
        min-width: 0 !important;
        flex: 0 0 auto !important;
    }

    .bio-nav-button .nav-label,
    .module-nav-button .nav-label,
    .nav-module .nav-label {
        font-size: 0.72rem !important;
        line-height: 1.1 !important;
        margin-bottom: 0.12rem !important;
    }

    .bio-nav-button .nav-title,
    .module-nav-button .nav-title,
    .nav-module .nav-title {
        font-size: 0.9rem !important;
        line-height: 1.2 !important;
        overflow-wrap: anywhere !important;
    }

    .bio-nav-button .nav-content,
    .module-nav-button .nav-content,
    .nav-module .nav-content,
    .module-nav-button > div,
    .bio-nav-button > div,
    .nav-module > div {
        min-width: 0 !important;
    }
}

@media (max-width: 420px) {
    .bio-navigation,
    .module-navigation {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.45rem !important;
        margin: 0.8rem auto !important;
        padding: 0 0.35rem !important;
    }

    .bio-nav-button,
    .module-nav-button,
    .nav-module {
        min-height: 0 !important;
        padding: 0.48rem 0.55rem !important;
        gap: 0.3rem !important;
        border-radius: 8px !important;
    }

    .bio-nav-button .nav-label,
    .module-nav-button .nav-label,
    .nav-module .nav-label {
        display: none !important;
    }

    .bio-nav-button .nav-title,
    .module-nav-button .nav-title,
    .nav-module .nav-title {
        font-size: 0.78rem !important;
        line-height: 1.15 !important;
    }

    .bio-nav-button .nav-arrow,
    .module-nav-button .nav-arrow,
    .nav-module .nav-arrow,
    .bio-nav-button .nav-arrow i,
    .module-nav-button .nav-arrow i,
    .nav-module .nav-arrow i {
        width: 0.85rem !important;
        height: 0.85rem !important;
        font-size: 0.85rem !important;
    }
}
