/* ==========================================
   THEME VARIABLE CONFIGURATIONS
   ========================================== */
:root {
  --bg-color: #0f172a;      /* Deep midnight slate canvas */
  --card-bg: #1e293b;       /* Crisp slate-charcoal question cards */
  --primary: #38bdf8;       /* Glowing Electric Cyan/Sky Blue */
  --primary-hover: #0ea5e9; /* Darker vibrant cyan for mouse states */
  --text-main: #f8fafc;     /* Clean, high-contrast off-white reading text */
  --text-muted: #94a3b8;    /* Softer slate-gray for captions and numbers */
  --border: #334155;        /* Subtly integrated component border lines */
}

/* ==========================================
   BASE & STRUCTURAL CONTAINER LAYOUTS
   ========================================== */
body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: background-color 0.3s ease, color 0.3s ease; /* Fluid transitions between theme swaps */
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.app-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

/* Premium Gradient Text Effect for Title Logo */
.app-header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  transition: background 0.3s ease;
}

/* ==========================================
   CONTROLS BAR & ALIGNMENT LOCKS
   ========================================== */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--card-bg);
  padding: 1.2rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05);
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.button-group {
  display: flex;
  align-items: center;
  flex-grow: 1; /* Automatically claims middle space to pin dropdowns perfectly to the right */
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-group select {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  background-color: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  min-width: 160px; /* Uniform width blocks */
  transition: border-color 0.2s ease, background-color 0.3s ease;
}

.filter-group select:focus {
  border-color: var(--primary);
}

/* ==========================================
   BUTTONS & BADGES
   ========================================== */
.btn {
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.subject-btn {
  background: var(--bg-color);
  color: var(--text-muted);
  margin-right: 0.5rem;
}

body:not(.theme-midnight) .subject-btn:hover {
  background: #cbd5e1;
  color: var(--text-main);
}

body.theme-midnight .subject-btn:hover {
  background: #334155;
  color: var(--text-main);
}

.subject-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

body.theme-midnight .subject-btn.active {
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-weight: 700;
}

.topic-badge { 
  background: #fef3c7; 
  color: #92400e; 
}

body.theme-emerald .topic-badge {
  background: #dcfce7;
  color: #15803d;
}

.click-hint { 
  font-size: 0.85rem; 
  color: var(--primary); 
  font-weight: 600; 
}

/* ==========================================
   QUESTION CARDS STYLING
   ========================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px; /* Smooth card corners */
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.02);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.3s ease, border-color 0.3s ease;
}

.card:hover {
  transform: translateY(-4px); /* Evident interactive lift */
  box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.08);
}

body.theme-midnight .card:hover {
  box-shadow: 0 20px 25px -5px rgba(56, 189, 248, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.question-text {
  font-size: 1.15rem;
  line-height: 1.6;
}

.no-questions { 
  color: var(--text-muted); 
  font-style: italic; 
  text-align: center; 
  padding: 2rem; 
}

/* ==========================================
   MARKING SCHEME CONTENT
   ========================================== */
.scheme-toggle-btn {
  background: var(--bg-color);
  color: var(--text-main);
  width: 100%;
  border: 1px dashed var(--text-muted);
  margin-top: 1rem;
}

.marking-scheme {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--border);
  text-align: left;
}

.marking-scheme ul {
  white-space: pre-line;
  list-style-type: none; 
  padding-left: 0;
}

.marking-scheme li { 
  margin-bottom: 0.5rem; 
}

/* ==========================================
   MODAL DIALOG STRUCTURES
   ========================================== */
.modal {
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.8); /* Modern alpha-opacity veil mask */
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--card-bg);
  width: 90%;
  max-width: 700px;
  padding: 2.5rem 2rem;
  border-radius: 20px;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
  max-height: 85vh;
  overflow-y: auto;
  text-align: center;
}

.modal-question-text {
  font-size: 1.35rem;
  font-weight: 500;
  margin: 1.5rem 0;
}

.close-modal-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.close-modal-btn:hover { 
  color: var(--text-main); 
}

.modal-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1.2rem;
}

.nav-btn {
  background-color: var(--text-main);
  color: var(--card-bg);
  min-width: 120px;
}

.nav-btn:hover { 
  opacity: 0.9;
}

/* ==========================================
   IMAGE RUNTIMES & OVERLAYS
   ========================================== */
.question-diagram {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 220px;
  margin: 1.2rem auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #f1f5f9;
  cursor: zoom-in;
  transition: opacity 0.2s ease;
}

.question-diagram:hover {
  opacity: 0.9;
}

.question-diagram.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;  
  max-height: 100vh !important; 
  object-fit: contain !important; 
  background-color: rgba(15, 23, 42, 0.98) !important; 
  padding: 20px;
  box-sizing: border-box;
  z-index: 9999999 !important; 
  cursor: zoom-out;
  margin: 0 !important;
  border: none !important;
}

/* ==========================================
   SCROLL TO TOP COMPONENT
   ========================================== */
#backToTopBtn {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99;
  background-color: var(--primary);
  color: white;
  border: none;
  outline: none;
  padding: 0.75rem 1.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s, transform 0.2s;
}

#backToTopBtn:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}
/* ==========================================
   LEGAL DISCLAIMER FOOTER
   ========================================== */
.app-footer {
  width: 100%;
  background-color: #0b0f19; /* Slightly darker than your midnight canvas for separation */
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  margin-top: 4rem; /* Pushes it down so it sits comfortably below your cards */
  box-sizing: border-box;
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.disclaimer-text, .affiliate-text {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted); /* Keeps it soft so it doesn't distract from learning content */
  margin: 0 0 0.4rem 0;
}

.disclaimer-text strong {
  color: var(--primary); /* Highlights the 'Disclaimer' tag in electric cyan */
}
/* ==========================================
   CUSTOM MIDNIGHT SCROLLBARS
   ========================================== */

/* 1. Target the main page scrollbar */
::-webkit-scrollbar {
  width: 10px;               /* Width of the vertical scrollbar */
  height: 10px;              /* Height of a horizontal scrollbar */
}

/* 2. Style the background track (the path the scrollbar moves on) */
::-webkit-scrollbar-track {
  background: #0b0f19;       /* Deepest dark shade, matches your footer */
}

/* 3. Style the moving draggable thumb itself */
::-webkit-scrollbar-thumb {
  background: var(--border); /* Subtle slate gray so it blends in at rest */
  border-radius: 10px;       /* Smoothly rounded edges */
  border: 2px solid #0b0f19; /* Adds a clean gap around the thumb */
}

/* 4. Glow effect when the user hovers over it */
::-webkit-scrollbar-thumb:hover {
  background: var(--primary); /* Glows Electric Cyan when hovered or dragged! */
}

/* 5. Apply the exact same look inside your scrollable modal mark-scheme box */
#modal-scheme-box::-webkit-scrollbar {
  width: 6px;
}
#modal-scheme-box::-webkit-scrollbar-track {
  background: var(--card-bg);
}
#modal-scheme-box::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}
#modal-scheme-box::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Paste this at the very bottom of your CSS file */
.filter-badge {
    text-transform: capitalize;
}