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

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --secondary: #27ae60;
  --accent: #e67e22;
  --danger: #e74c3c;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dce1e6;
  --success: #27ae60;
  --warning: #f39c12;
  --rag-red: #e74c3c;
  --rag-amber: #f39c12;
  --rag-green: #27ae60;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Header & Nav === */
header {
  background: var(--primary);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
}

.header-top h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header-top h1 a {
  color: white;
  text-decoration: none;
}

.header-top .subtitle {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: 400;
}

.menu-toggle {
  background: none;
  border: 2px solid rgba(255,255,255,0.4);
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  line-height: 1;
}

.menu-toggle:hover {
  border-color: white;
}

nav {
  background: rgba(0,0,0,0.15);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

nav.open {
  max-height: 500px;
}

nav ul {
  list-style: none;
  padding: 0.5rem 0;
}

nav ul li a {
  display: block;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  transition: background 0.2s;
}

nav ul li a:hover,
nav ul li a.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

nav ul li a.active {
  border-left: 3px solid var(--accent);
  font-weight: 600;
}

/* === Main Content === */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* === Hero Section === */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.hero h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 1rem;
  opacity: 0.9;
}

/* === Cards === */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card h3 {
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.card p {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.card-link {
  display: inline-block;
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.card-link:hover {
  text-decoration: underline;
}

.card-tag {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* === Section Headings === */
.section-title {
  font-size: 1.4rem;
  color: var(--primary);
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--primary-light);
}

.section-subtitle {
  font-size: 1.1rem;
  color: var(--primary);
  margin: 1.5rem 0 0.75rem;
}

/* === Content Sections === */
.content-block {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.content-block h3 {
  color: var(--primary);
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}

.content-block p {
  margin-bottom: 0.75rem;
}

.content-block ul, .content-block ol {
  margin-left: 1.2rem;
  margin-bottom: 0.75rem;
}

.content-block li {
  margin-bottom: 0.35rem;
}

/* === Key Definitions === */
.definition {
  background: #eaf2f8;
  border-left: 4px solid var(--primary-light);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.definition strong {
  color: var(--primary);
}

/* === Equations === */
.equation {
  background: #fef9e7;
  border: 1px solid #f9e79f;
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 0.75rem 0;
  font-family: 'Georgia', serif;
  font-size: 1rem;
  text-align: center;
  overflow-x: auto;
}

.equation-word {
  background: #eafaf1;
  border: 1px solid #a9dfbf;
}

/* === Tables === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  background: var(--primary);
  color: white;
  padding: 0.7rem 0.6rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
}

.data-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:nth-child(even) {
  background: #f8f9fa;
}

/* === Higher Tier Badge === */
.higher-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: super;
  margin-left: 0.3rem;
}

/* === Triple Science Only Badge === */
.badge-triple {
  display: inline-block;
  background: #8e44ad;
  color: white;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: super;
  margin-left: 0.3rem;
}

/* === Tip / Warning Boxes === */
.tip-box {
  background: #eafaf1;
  border-left: 4px solid var(--success);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.tip-box::before {
  content: 'Exam Tip';
  display: block;
  font-weight: 700;
  color: var(--success);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.warning-box {
  background: #fef5e7;
  border-left: 4px solid var(--warning);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.warning-box::before {
  content: 'Common Mistake';
  display: block;
  font-weight: 700;
  color: var(--warning);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.rp-box {
  background: #f4ecf7;
  border-left: 4px solid #8e44ad;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.rp-box::before {
  content: 'Required Practical';
  display: block;
  font-weight: 700;
  color: #8e44ad;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

/* === Practice Questions === */
.question-block {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.question-block.mc {
  border-color: var(--primary-light);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.question-number {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9rem;
}

.question-marks {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.question-text {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* MC Options */
.mc-options {
  list-style: none;
  margin: 0;
}

.mc-options li {
  margin-bottom: 0.4rem;
}

.mc-options label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.9rem;
}

.mc-options label:hover {
  background: #f0f4f8;
  border-color: var(--primary-light);
}

.mc-options input[type="radio"] {
  margin-top: 0.15rem;
  accent-color: var(--primary-light);
}

.mc-options label.correct {
  background: #eafaf1;
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}

.mc-options label.incorrect {
  background: #fdedec;
  border-color: var(--danger);
  color: var(--danger);
}

/* Answer reveal */
.answer-reveal {
  display: none;
  margin-top: 0.75rem;
  padding: 1rem;
  background: #eafaf1;
  border-radius: 6px;
  border: 1px solid #a9dfbf;
  font-size: 0.9rem;
}

.answer-reveal.show {
  display: block;
}

.answer-reveal.incorrect-feedback {
  background: #fdedec;
  border-color: #f5b7b1;
}

.answer-header {
  font-weight: 700;
  color: var(--success);
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.answer-reveal.incorrect-feedback .answer-header {
  color: var(--danger);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-light);
  color: white;
}

.btn-primary:hover {
  background: var(--primary);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #c5cdd4;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #219a52;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.show-answer-btn {
  margin-top: 0.5rem;
}

.check-answer-btn {
  margin-top: 0.5rem;
}

/* === RAG Self-Assessment === */
.rag-checklist {
  margin: 1rem 0;
}

.rag-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.rag-item:last-child {
  border-bottom: none;
}

.rag-buttons {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.rag-btn {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.rag-btn:hover {
  transform: scale(1.15);
}

.rag-btn.selected {
  box-shadow: 0 0 0 2px white, 0 0 0 4px currentColor;
  transform: scale(1.1);
}

.rag-btn.red { background: var(--rag-red); color: var(--rag-red); }
.rag-btn.amber { background: var(--rag-amber); color: var(--rag-amber); }
.rag-btn.green { background: var(--rag-green); color: var(--rag-green); }

.rag-text {
  flex: 1;
}

/* === Progress Bar === */
.progress-bar-container {
  background: #e8ecef;
  border-radius: 20px;
  height: 12px;
  margin: 0.5rem 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--rag-green), #2ecc71);
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* === Quiz Score === */
.quiz-score {
  text-align: center;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 2rem 0;
}

.quiz-score .score-number {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
}

.quiz-score .score-total {
  font-size: 1.2rem;
  color: var(--text-light);
}

/* === Pagination / Navigation === */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--primary-light);
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.page-nav a:hover {
  background: var(--primary-light);
  color: white;
}

/* === Reactivity Series Diagram === */
.reactivity-ladder {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 1rem 0;
  max-width: 350px;
}

.ladder-item {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-left: 4px solid;
  position: relative;
}

.ladder-item .arrow {
  position: absolute;
  right: -2rem;
  font-size: 0.7rem;
  color: var(--text-light);
  writing-mode: vertical-rl;
}

.ladder-item.most-reactive {
  background: #fdedec;
  border-color: var(--danger);
  color: var(--danger);
}

.ladder-item.reactive {
  background: #fef5e7;
  border-color: var(--accent);
  color: #b7590a;
}

.ladder-item.moderate {
  background: #fef9e7;
  border-color: var(--warning);
  color: #7d6608;
}

.ladder-item.low {
  background: #eafaf1;
  border-color: var(--success);
  color: #1e8449;
}

.ladder-item.least-reactive {
  background: #eaf2f8;
  border-color: var(--primary-light);
  color: var(--primary);
}

.ladder-label {
  position: absolute;
  right: 0.75rem;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
}

/* === Drag-drop matching (simple click-based) === */
.match-exercise {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0;
}

/* === Footer === */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* === Fill-in input === */
.fill-input {
  border: none;
  border-bottom: 2px solid var(--primary-light);
  background: transparent;
  font-size: inherit;
  font-family: inherit;
  padding: 0.1rem 0.3rem;
  width: 120px;
  color: var(--primary);
  outline: none;
}

.fill-input:focus {
  border-bottom-color: var(--accent);
}

.fill-input.correct-input {
  border-bottom-color: var(--success);
  color: var(--success);
}

.fill-input.incorrect-input {
  border-bottom-color: var(--danger);
  color: var(--danger);
}

/* === Collapsible sections === */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0.75rem 0;
  user-select: none;
}

.collapsible-header::after {
  content: '\25BC';
  font-size: 0.75rem;
  transition: transform 0.2s;
  color: var(--text-light);
}

.collapsible-header.collapsed::after {
  transform: rotate(-90deg);
}

.collapsible-content {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-content.hidden {
  max-height: 0;
}

/* === Responsive Breakpoints === */
@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  main {
    padding: 2rem 1.5rem 3rem;
  }

  .hero {
    padding: 2.5rem 2rem;
  }

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

  .data-table {
    font-size: 0.95rem;
  }
}

@media (min-width: 800px) {
  .header-top h1 {
    font-size: 1.25rem;
  }

  nav {
    max-height: none;
    background: transparent;
  }

  nav ul {
    display: flex;
    padding: 0;
  }

  nav ul li a {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
  }

  nav ul li a.active {
    border-left: none;
    border-bottom: 3px solid var(--accent);
  }

  .menu-toggle {
    display: none;
  }
}

/* === Print styles === */
@media print {
  header { position: static; }
  .btn, .menu-toggle, .rag-buttons { display: none; }
  .answer-reveal { display: block !important; }
  .content-block, .question-block { break-inside: avoid; }
}
