/* Natuurkunje - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

/* ================================================================= */
/* ==================== 1. ROOT & GLOBAL STYLES ==================== */
/* ================================================================= */

:root {
  --bg: #fbf0d6; /* Golden Parchment */
  --card: #fff;
  --text: #222;
  --muted: #e9e9e9;
  --primary: #3b5998; /* Classic Blue */
  --primary-600: #314a7e;
  --danger: #ff6b6b;
  --danger-600: #ee5a52;
  --ok: #2ed573;
  --radius: 10px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .08);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px clamp(12px, 4vw, 24px);
  font-family: 'Poppins', system-ui, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="%237d6e5b" stroke-width="0.5"/></svg>');
}

/* Softer, more modern focus states for accessibility */
button:focus-visible,
.tab:focus-visible,
input:focus-visible,
.level-card:focus-visible,
.option:focus-visible,
.simulation-card:focus-visible,
.main-nav-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(59, 89, 152, 0.5);
}

/* Hidden attribute handling */
[hidden], .hidden {
  display: none !important;
}


/* ================================================================= */
/* ====================== 2. MAIN LAYOUT & TABS ===================== */
/* ================================================================= */

main {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 1200px;
  justify-content: center;
  flex-wrap: wrap;
}

.tab {
  flex: 1 1 150px;
  padding: 10px 14px;
  font-size: 15px;
  cursor: pointer;
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: all 0.2s ease-out;
}

.tab:hover {
  background: #f6f8ff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tab.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  transform: translateY(-2px);
  font-weight: 500;
}

/* The content area for each tab */
.page {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.page.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}


/* ================================================================= */
/* =================== 3. SHARED COMPONENTS =================== */
/* ================================================================= */

/* General Card Style (Used as a base) */
.card {
  background: var(--card);
  padding: 32px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* General Buttons */
button {
  padding: 10px 14px;
  font-size: 15px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  transition: transform 0.2s;
}

button:hover {
  transform: translateY(-1px);
}

.reset-btn {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-600) 100%);
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* Unified Back Button Styling for all pages */
.back-btn,
.back-btn-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card); /* The solid background color */
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s ease-out;
  font-size: 22px;
  font-weight: bold;
}

.back-btn:hover,
.back-btn-header:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

/* This rule ONLY applies to the back button in the simulation tabs */
.tabs .back-btn {
  margin-right: auto; /* Pushes the tabs to the side */
}

/* ================================================================= */
/* ==================== 4. SIMULATION SPECIFIC ===================== */
/* ================================================================= */

#simulation-content-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-container {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

canvas {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 680px;
  height: auto;
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 680px;
}

fieldset.slider-row {
  border: none;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

fieldset.slider-row legend {
  font-size: 14px;
  min-width: 90px;
  color: #333;
}

input[type="range"] {
  flex-grow: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: #e6e8f0;
  border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .15s;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: transform .15s;
}

.value {
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: right;
  color: #555;
  font-size: 13px;
}

/* Standard Simulation Grid Layout */
.sim-grid-container {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
}

.sim-canvas-wrapper {
  grid-column: 1 / 2;
}

.sim-grid-container .sliders {
  grid-column: 2 / 3;
  max-width: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.sim-canvas-wrapper canvas {
  width: 100%;
  max-width: none;
  height: auto;
}

/* Circuit Simulation Styles */
.sim-canvas-wrapper .circuit-container {
  margin: 0 auto;
}
.circuit-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 400px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
}
.circuit-container .wire { position: absolute; background-color: #222; }
.circuit-container .component-label { position: absolute; font-family: monospace; text-align: center; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.circuit-container .label-symbol, .circuit-container .label-value { font-size: 1.1rem; font-weight: bold; }
.circuit-container #battery { position: absolute; top: 180px; width: 55px; height: 40px; }
.circuit-container #battery::before, .circuit-container #battery::after { content: ''; position: absolute; background: #222; left: 50%; transform: translateX(-50%); }
.circuit-container #battery::before { width: 100%; height: 3px; top: 0; }
.circuit-container #battery::after { width: 50%; height: 3px; bottom: 0; }
.circuit-container #voltage-label { top: 190px; font-size: 1.1rem; font-weight: bold; color: #007bff; }
.circuit-container .current-path-arrow { position: absolute; width: 3px; background-color: #d9534f; }
.circuit-container .current-path-arrow::after { content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 10px solid #d9534f; }
.circuit-container .voltage-line { position: absolute; border-color: #007bff; border-style: dotted; border-width: 0; }
.circuit-container .voltage-dot { position: absolute; width: 8px; height: 8px; background-color: #007bff; border-radius: 50%; }
.circuit-container .resistor-body { position: absolute; width: 75px; background: #eee; border: 2px solid #222; }
#circuit-simple #battery { left: 20%; }
#circuit-simple #voltage-label { left: 20%; }
#circuit-simple #wire-top { top: 40px; left: 22.74%; width: 55.4%; height: 3px; }
#circuit-simple #wire-bottom { bottom: 40px; left: 22.74%; width: 55.4%; height: 3px; }
#circuit-simple #wire-left-top { top: 40px; left: 22.74%; width: 3px; height: 140px; }
#circuit-simple #wire-left-bottom { top: 220px; left: 22.74%; width: 3px; height: 140px; }
#circuit-simple #wire-right { top: 40px; left: 78%; width: 3px; height: 320px; }
#circuit-simple #resistor { position: absolute; left: calc(78% - 37.5px); top: 120px; width: 75px; height: 160px; background: #eee; border: 2px solid #222; }
#circuit-simple #resistance-label { left: calc(78% - 37.5px); width: 75px; top: 185px; color: #333; }
#circuit-simple #current-arrow { left: calc(78% + 50px); top: 120px; height: 160px; }
#circuit-simple #current-label { left: calc(78% + 60px); top: 170px; color: #d9534f; }
#circuit-simple #voltage-line-vertical { left: calc(78% - 80px); top: 100px; height: 200px; border-left-width: 2px; }
#circuit-simple #voltage-line-top { left: calc(78% - 80px); top: 100px; width: 80px; border-top-width: 2px; }
#circuit-simple #voltage-line-bottom { left: calc(78% - 80px); top: 300px; width: 80px; border-bottom-width: 2px; }
#circuit-simple #resistor-voltage-label { left: calc(78% - 150px); top: 200px; color: #007bff; }
#circuit-simple #v-dot-top { top: 96px; left: calc(78% - 3px); }
#circuit-simple #v-dot-bottom { top: 296px; left: calc(78% - 3px); }
#circuit-serie #battery { left: 20%; }
#circuit-serie #voltage-label { left: 20%; }
#circuit-serie #wire-top { top: 40px; left: 22.74%; width: 55.4%; height: 3px; }
#circuit-serie #wire-bottom { bottom: 40px; left: 22.74%; width: 55.4%; height: 3px; }
#circuit-serie #wire-left-top { top: 40px; left: 22.74%; width: 3px; height: 140px; }
#circuit-serie #wire-left-bottom { top: 220px; left: 22.74%; width: 3px; height: 140px; }
#circuit-serie #wire-right-top { top: 40px; left: 78%; width: 3px; height: 60px; }
#circuit-serie #wire-right-middle { top: 180px; left: 78%; width: 3px; height: 60px; }
#circuit-serie #wire-right-bottom { top: 320px; left: 78%; width: 3px; height: 40px; }
#circuit-serie .resistor-body { left: calc(78% - 37.5px); }
#circuit-serie #resistor1 { top: 100px; height: 80px; }
#circuit-serie #resistor2 { top: 240px; height: 80px; }
#circuit-serie #resistance1-label { left: calc(78% - 37.5px); width: 75px; top: 130px; color: #333; }
#circuit-serie #resistance2-label { left: calc(78% - 37.5px); width: 75px; top: 270px; color: #333; }
#circuit-serie #current1-arrow { left: calc(78% + 50px); top: 100px; height: 80px; }
#circuit-serie #current2-arrow { left: calc(78% + 50px); top: 240px; height: 80px; }
#circuit-serie #current1-label { left: calc(78% + 60px); top: 130px; color: #d9534f; }
#circuit-serie #current2-label { left: calc(78% + 60px); top: 270px; color: #d9534f; }
#circuit-serie #voltage1-line-v { left: calc(78% - 80px); top: 80px; height: 120px; border-left-width: 2px; }
#circuit-serie #voltage1-line-t { left: calc(78% - 80px); top: 80px; width: 80px; border-top-width: 2px; }
#circuit-serie #voltage1-line-b { left: calc(78% - 80px); top: 200px; width: 80px; border-top-width: 2px; }
#circuit-serie #resistor1-voltage-label { left: calc(78% - 150px); top: 130px; color: #007bff; }
#circuit-serie #v1-dot-top { top: 76px; left: calc(78% - 3px); }
#circuit-serie #v1-dot-bottom { top: 196px; left: calc(78% - 3px); }
#circuit-serie #voltage2-line-v { left: calc(78% - 80px); top: 220px; height: 120px; border-left-width: 2px; }
#circuit-serie #voltage2-line-t { left: calc(78% - 80px); top: 220px; width: 80px; border-top-width: 2px; }
#circuit-serie #voltage2-line-b { left: calc(78% - 80px); top: 340px; width: 80px; border-bottom-width: 2px; }
#circuit-serie #resistor2-voltage-label { left: calc(78% - 150px); top: 270px; color: #007bff; }
#circuit-serie #v2-dot-top { top: 216px; left: calc(78% - 3px); }
#circuit-serie #v2-dot-bottom { top: 336px; left: calc(78% - 3px); }
#circuit-parallel #battery { left: 10%; }
#circuit-parallel #voltage-label { left: 10%; }
#circuit-parallel #wire-left-top { top: 40px; left: 12.8%; width: 3px; height: 140px; }
#circuit-parallel #wire-left-bottom { top: 220px; left: 12.8%; width: 3px; height: 140px; }
#circuit-parallel #wire-top-bus { top: 40px; left: 12.8%; width: 72.5%; height: 3px; }
#circuit-parallel #wire-bottom-bus { bottom: 40px; left: 12.8%; width: 72.5%; height: 3px; }
#circuit-parallel #wire-r1-top { top: 40px; left: 50%; width: 3px; height: 80px; }
#circuit-parallel #wire-r1-bottom { top: 280px; left: 50%; width: 3px; height: 80px; }
#circuit-parallel #wire-r2-top { top: 40px; left: 85%; width: 3px; height: 80px; }
#circuit-parallel #wire-r2-bottom { top: 280px; left: 85%; width: 3px; height: 80px; }
#circuit-parallel #total-current-label { left: 20%; top: 10px; color: #d9534f; font-size: 1.1rem; font-weight: bold; }
#circuit-parallel #arrow-horizontal { position:absolute; top:55px; left:21%; width:100px; height:3px; background-color:#d9534f; }
#circuit-parallel #arrow-horizontal::after { content:''; position:absolute; right:-8px; top:50%; transform:translateY(-50%); width:0; height:0; border-top:6px solid transparent; border-bottom:6px solid transparent; border-left:10px solid #d9534f; }
#circuit-parallel #resistor1 { position: absolute; left: calc(50% - 37.5px); top: 120px; width: 75px; height: 160px; background: #eee; border: 2px solid #222; }
#circuit-parallel #resistance1-label { left: calc(50% - 37.5px); width: 75px; top: 185px; color: #333; }
#circuit-parallel #resistor2 { position: absolute; left: calc(85% - 37.5px); top: 120px; width: 75px; height: 160px; background: #eee; border: 2px solid #222; }
#circuit-parallel #resistance2-label { left: calc(85% - 37.5px); width: 75px; top: 185px; color: #333; }
#circuit-parallel #current1-arrow { left: calc(50% + 50px); top: 120px; height: 160px; }
#circuit-parallel #current1-label { left: calc(50% + 60px); top: 170px; color: #d9534f; }
#circuit-parallel #current2-arrow { left: calc(85.5% + 50px); top: 120px; height: 160px; }
#circuit-parallel #current2-label { left: calc(85.5% + 60px); top: 170px; color: #d9534f; }
#circuit-parallel #voltage1-line-v { left: calc(50% - 60px); top: 100px; height: 200px; border-left-width: 2px; }
#circuit-parallel #voltage1-line-t { left: calc(50% - 60px); top: 100px; width: 60px; border-top-width: 2px; }
#circuit-parallel #voltage1-line-b { left: calc(50% - 60px); top: 300px; width: 60px; border-bottom-width: 2px; }
#circuit-parallel #resistor1-voltage-label { left: calc(50% - 130px); top: 200px; color: #007bff; }
#circuit-parallel #v1-dot-top { top: 96px; left: calc(50% - 3px); }
#circuit-parallel #v1-dot-bottom { top: 296px; left: calc(50% - 3px); }
#circuit-parallel #voltage2-line-v { left: calc(85% - 60px); top: 100px; height: 200px; border-left-width: 2px; }
#circuit-parallel #voltage2-line-t { left: calc(85% - 60px); top: 100px; width: 60px; border-top-width: 2px; }
#circuit-parallel #voltage2-line-b { left: calc(85% - 60px); top: 300px; width: 60px; border-bottom-width: 2px; }
#circuit-parallel #resistor2-voltage-label { left: calc(85% - 130px); top: 200px; color: #007bff; }
#circuit-parallel #v2-dot-top { top: 96px; left: calc(85% - 3px); }
#circuit-parallel #v2-dot-bottom { top: 296px; left: calc(85% - 3px); }

/* Pendulum Styles */
.pendulum-visual-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.pendulum-visual-card .energy-column {
  display: flex;
  flex-direction: column;
  background-color: #f7f7f7;
}
.pendulum-visual-card .pendulum-column { }
.pendulum-visual-card #energyCanvas {
  flex-grow: 1;
  width: 100%;
}
.pendulum-visual-card #canvas {
  width: 100%;
  height: auto;
  display: block;
  background: var(--card);
  box-shadow: none;
}
.energy-column .energy-legend {
  padding: 10px 8px;
  display: flex;
  justify-content: space-around;
  border-top: 1px solid #eee;
}
.energy-column .legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 500;
}
.energy-column .legend-color {
  width: 20px;
  height: 8px;
  border-radius: 4px;
}
@media (max-width: 820px) {
  .pendulum-grid-container {
    grid-template-columns: 1fr;
  }
  .pendulum-wrapper,
  .pendulum-grid-container .energy-card,
  .pendulum-grid-container .sliders {
    grid-column: 1 / 2;
  }
  .pendulum-wrapper { grid-row: 1; }
  .energy-card    { grid-row: 2; }
  .pendulum-grid-container .sliders { grid-row: 3; }
}

/* Full-Width Simulation Layout */
.sim-full-width-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.sim-full-width-container canvas {
  max-width: 1200px;
  width: 100%;
}

/* Vector Addition Specific Styles */
#vectorCanvas {
  width: 100%;
  max-width: 800px;
  height: auto;
  /* THE FIX: Change from 1/1 to a wider 3/2 aspect ratio */
  aspect-ratio: 3 / 2;
}
/* Vector Addition Custom Number Inputs */
.vector-inputs .vector-component {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vector-inputs .custom-number-input {
  display: flex;
  align-items: center;
}

/* Hide the default browser arrows (spinners) */
.custom-number-input input[type="number"] {
  -webkit-appearance: none;
  -moz-appearance: textfield; /* This hides arrows in Firefox */
  appearance: none;
  border: 1px solid #ccc;
  border-left: none;
  border-right: none;
  border-radius: 0;
  width: 50px;
  height: 38px;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  padding: 0;
}

.custom-number-input .btn-num-control {
  width: 38px;
  height: 38px;
  background: var(--muted);
  border: 1px solid #ccc;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.15s ease;
}
.custom-number-input .btn-num-control:hover {
  background: #dcdcdc;
}
.custom-number-input .btn-num-control:active {
  background: #ccc;
}

/* Round the corners of the outer buttons */
.custom-number-input .btn-decrement {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
.custom-number-input .btn-increment {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Coulomb's Law Styles */
#coulomb-sim .coulomb-inputs {
  width: 100%;
  max-width: 500px;
}
#coulomb-sim .control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: center;
}
#coulomb-sim fieldset { border: none; padding: 0; margin: 0; }
#coulomb-sim legend { font-weight: 600; font-size: 1.1rem; margin-bottom: 8px; }
#coulomb-sim .radio-group { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 0 auto; width: fit-content; }
#coulomb-sim .radio-group label { cursor: pointer; display: flex; align-items: center; gap: 6px; }

/* Collision Simulation Styles */
#collision-sim .collision-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: 150px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-bottom: 3px solid #333;
  overflow: hidden;
}
#collision-sim .cube {
  position: absolute;
  bottom: 0;
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: monospace;
  font-weight: bold;
  color: white;
  border: 2px solid #222;
}
#collision-sim #cube1 { left: 20px; background: #d9534f; }
#collision-sim #cube2 { left: calc(100% - 100px); background: #007bff; }
#collision-sim .cube-label { font-size: 0.9rem; }
#collision-sim .sliders { max-width: 800px; width: 100%; }


/* ================================================================= */
/* ================= 5. EXPLANATION & QUIZ PAGES =================== */
/* ================================================================= */

#explanation .card,
#quiz .card {
  width: 100%;
}

.explanation-content h2,
.quiz-title {
  color: var(--primary);
  margin-bottom: 16px;
}

.explanation-content p,
.question p {
  font-size: 1rem;
  line-height: 1.7;
}

.formula {
  background: var(--muted);
  padding: 12px;
  border-radius: 10px;
  margin: 16px 0;
  text-align: center;
  font-size: 17px;
}

/* Quiz Specific */
.question {
  margin-bottom: 24px;
  padding: 18px;
  background: var(--muted);
  border-radius: 10px;
}

.question h3 {
  color: var(--primary);
  margin-bottom: 8px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.option {
  padding: 12px 14px;
  background: #fff;
  border: 2px solid #e6e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s ease;
}

.option:hover {
  border-color: var(--primary-600);
  background: #f6f8ff;
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

#quizSummary {
  margin-top: 20px;
  padding: 16px;
  border-radius: 10px;
  background: #eef5ff;
  color: #204080;
  text-align: center;
  font-weight: 500;
  font-size: 1.1rem;
}


/* ================================================================= */
/* ================= 6. HOMEPAGE & MAIN NAVIGATION ================= */
/* ================================================================= */

/* --- General Header for both index.html and applets.html --- */
.home-header {
  text-align: center;
  margin-bottom: 20px;
  max-width: 800px;
  width: 100%;
  position: relative; /* Needed for positioning the back button */
}

.home-header h1 {
  font-size: 2.5rem;
  color: var(--primary);
}

.home-header p {
  font-size: 1.1rem;
  color: #555;
  margin-top: 8px;
}

/* --- NEW: Header navigation for applets.html --- */
.header-nav {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

/* --- NEW: Main Navigation Buttons (for index.html) --- */
.main-nav-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  max-width: 900px;
  margin-top: 20px;
}

.main-nav-button {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 32px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  gap: 24px;
  align-items: center;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
  border: 2px solid transparent;
}

.main-nav-button:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.main-nav-button.disabled {
  background-color: #f9f9f9;
  color: #aaa;
  cursor: not-allowed;
}

.main-nav-button.disabled:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: transparent;
}

.main-nav-button.disabled .nav-button-icon {
  filter: grayscale(100%);
}

.nav-button-icon {
  font-size: 3.5rem;
  background-color: var(--muted);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-button-text h3 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.main-nav-button.disabled .nav-button-text h3 {
  color: #999;
}

.nav-button-text p {
  font-size: 1rem;
  line-height: 1.5;
  color: #555;
}

/* --- Applet Cards Grid (for applets.html) --- */
.home-main {
  width: 100%;
  max-width: 1200px;
}

.simulation-grid {
  display: grid;
  gap: 24px;
  width: 100%;
  grid-template-columns: repeat(3, 1fr);
}

.simulation-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  gap: 20px;
  align-items: center;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
  border: 2px solid transparent;
}

.simulation-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.sim-card-icon {
  font-size: 2.5rem;
  background-color: var(--muted);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sim-card-content h3 {
  font-size: 1.2rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.sim-card-content p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #555;
}


/* ================================================================= */
/* =================== 7. RESPONSIVE ADJUSTMENTS =================== */
/* ================================================================= */
@media (max-width: 1024px) {
  .simulation-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 800px) {
  /* Stack the main navigation buttons on smaller screens */
  .main-nav-container {
    grid-template-columns: 1fr;
  }
  .header-nav {
    display: none; /* Hide header back button on smaller screens to save space */
  }
}

@media (max-width: 720px) {
  /* Default container stacking for simulations */
  .canvas-container {
    flex-direction: column;
    align-items: center;
  }
  
  /* Make the standard simulation grid stack vertically on smaller screens */
  .sim-grid-container {
    grid-template-columns: 1fr;
  }
  .sim-canvas-wrapper,
  .sim-grid-container .sliders {
    grid-column: 1 / 2;
  }
}

@media (max-width: 600px) {
  .simulation-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .tab {
    flex: 1 1 100%;
  }

  .simulation-card {
    flex-direction: column;
    text-align: center;
  }

  .main-nav-button {
    flex-direction: column;
    text-align: center;
  }
}
