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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #333;
  background: #fff;
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  padding: 20px 16px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  transition: transform 0.25s ease, width 0.25s ease, min-width 0.25s ease;
  z-index: 100;
}

.sidebar.collapsed {
  transform: translateX(-260px);
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar-title {
  font-weight: 700;
  font-size: 15px;
  color: #1a1a1a;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-toggle {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
}

.sidebar-toggle:hover { background: #eee; }

.sidebar-cluster {
  color: #888;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 4px;
}

.sidebar-link {
  display: block;
  padding: 3px 0 3px 10px;
  color: #555;
  text-decoration: none;
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-link:hover { color: #1565c0; }

.sidebar-link.active {
  color: #1565c0;
  font-weight: 600;
  border-left-color: #1565c0;
}

.sidebar-subsection {
  display: block;
  padding: 1px 0 1px 22px;
  color: #888;
  text-decoration: none;
  font-size: 11.5px;
}

.sidebar-subsection:hover { color: #1565c0; }

/* Floating open button when sidebar is collapsed */
.sidebar-open {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 99;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  display: none;
  color: #555;
}

.sidebar-open:hover { background: #eee; }

.sidebar.collapsed ~ .sidebar-open { display: block; }
.sidebar.collapsed ~ .main-content { margin-left: 0; }

/* === MAIN CONTENT === */
.main-content {
  margin-left: 260px;
  padding: 32px 40px 60px;
  max-width: 780px;
  width: 100%;
  transition: margin-left 0.25s ease;
}

.page-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 26px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 24px;
}

/* === IN-PAGE TOC === */
.page-toc {
  background: #f5f7fa;
  border: 1px solid #e8ecf0;
  border-radius: 4px;
  padding: 14px 18px;
  margin-bottom: 28px;
}

.page-toc-title {
  font-weight: 600;
  font-size: 13px;
  color: #333;
  margin-bottom: 6px;
}

.page-toc a {
  display: block;
  padding: 2px 0;
  color: #1565c0;
  text-decoration: none;
  font-size: 13px;
}

.page-toc a:hover { text-decoration: underline; }

.page-toc .toc-interactive {
  margin-top: 6px;
  font-style: italic;
}

/* === SECTION HEADINGS === */
h2.section-heading {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 36px 0 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

h3.subsection-heading {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 24px 0 8px;
}

/* === CONTENT BOXES === */
.definition-box {
  border-left: 3px solid #1565c0;
  background: #f5f8ff;
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 4px 4px 0;
}

.definition-box .box-label {
  font-size: 11px;
  font-weight: 600;
  color: #1565c0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.insight-box {
  border-left: 3px solid #e67e22;
  background: #fff8f0;
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 4px 4px 0;
}

.insight-box .box-label {
  font-size: 11px;
  font-weight: 600;
  color: #e67e22;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

/* === COLLAPSIBLE SECTIONS === */
.collapsible {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin: 16px 0;
  overflow: hidden;
}

.collapsible-header {
  background: #f8f9fa;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.collapsible-header:hover { background: #f0f1f3; }

.collapsible-header::after {
  content: '\25B8';
  font-size: 12px;
  color: #999;
  transition: transform 0.2s;
}

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

.collapsible-body {
  display: none;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.7;
  border-top: 1px solid #e0e0e0;
}

.collapsible.open .collapsible-body { display: block; }

/* === INTERACTIVE CONTAINER === */
.interactive-container {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 18px;
  margin: 20px 0;
  background: #fafafa;
}

.interactive-label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}

/* === STEP-BY-STEP WALKTHROUGH === */
.walkthrough-steps {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
}

.walkthrough-step-tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  background: #e8ecf0;
  color: #888;
  cursor: pointer;
  border: 1px solid #ddd;
  border-right: none;
  transition: background 0.15s, color 0.15s;
}

.walkthrough-step-tab:first-child { border-radius: 4px 0 0 4px; }
.walkthrough-step-tab:last-child { border-radius: 0 4px 4px 0; border-right: 1px solid #ddd; }

.walkthrough-step-tab.active {
  background: #1565c0;
  color: #fff;
  font-weight: 600;
  border-color: #1565c0;
}

.walkthrough-content {
  margin-bottom: 14px;
}

.walkthrough-nav {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #eee;
  font-size: 13px;
}

.walkthrough-nav button {
  background: none;
  border: none;
  color: #1565c0;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
}

.walkthrough-nav button:disabled { color: #ccc; cursor: default; }
.walkthrough-nav button:hover:not(:disabled) { text-decoration: underline; }

/* === FLASHCARDS === */
.flashcard-container {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 18px;
  margin: 20px 0;
  background: #fff;
}

.flashcard-counter {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-bottom: 8px;
}

.flashcard {
  background: #f5f7fa;
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.flashcard-question {
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.5;
}

.flashcard-answer {
  display: none;
  font-size: 14px;
  color: #444;
  line-height: 1.6;
  margin-top: 12px;
  text-align: left;
  width: 100%;
}

.flashcard-answer.visible { display: block; }

.flashcard-reveal {
  margin-top: 14px;
  font-size: 12px;
  color: #1565c0;
  cursor: pointer;
  border: 1px solid #1565c0;
  padding: 5px 20px;
  border-radius: 3px;
  background: none;
}

.flashcard-reveal:hover { background: #f0f4ff; }

.flashcard-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.flashcard-btn {
  font-size: 12px;
  padding: 5px 16px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid;
  background: none;
}

.flashcard-btn.again { color: #c62828; border-color: #c62828; }
.flashcard-btn.again:hover { background: #fef0f0; }
.flashcard-btn.got-it { color: #2e7d32; border-color: #2e7d32; }
.flashcard-btn.got-it:hover { background: #f0fef0; }

.flashcard-progress {
  text-align: center;
  margin-top: 12px;
  font-size: 11px;
  color: #888;
}

/* === FIGURES === */
.figure-container {
  margin: 20px 0;
  text-align: center;
}

.figure-container img {
  max-width: 100%;
  border: 1px solid #eee;
  border-radius: 4px;
}

.figure-caption {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
  font-style: italic;
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13.5px;
}

th {
  background: #f5f7fa;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #ddd;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

/* === MATH === */
.math-block {
  overflow-x: auto;
  margin: 12px 0;
  padding: 8px;
  background: #fafafa;
  border-radius: 4px;
  text-align: center;
}

/* === REFERENCES === */
.ref-list {
  list-style: none;
  font-size: 13px;
  color: #444;
}

.ref-list li {
  padding: 4px 0 4px 14px;
  border-left: 2px solid #e8ecf0;
  margin: 6px 0;
  line-height: 1.5;
}

.ref-list li em { color: #1a1a1a; }

/* === PREV/NEXT NAVIGATION === */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
  font-size: 13px;
}

.page-nav a {
  color: #1565c0;
  text-decoration: none;
}

.page-nav a:hover { text-decoration: underline; }

/* === SLIDER CONTROLS === */
.slider-group {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.slider-control {
  flex: 1;
  min-width: 150px;
}

.slider-control label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
}

.slider-control label span { font-weight: 600; color: #333; }

.slider-control input[type="range"] {
  width: 100%;
  accent-color: #1565c0;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.open-mobile { transform: translateX(0); }
  .sidebar-open { display: block; }
  .main-content { margin-left: 0; padding: 20px; }
}

/* === LANDING PAGE SPECIFIC === */
.landing-header {
  text-align: center;
  padding: 40px 0 30px;
}

.landing-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.landing-subtitle {
  font-size: 14px;
  color: #888;
}

.concept-map-container {
  margin: 20px 0 40px;
  background: #fafafa;
  border: 1px solid #e8ecf0;
  border-radius: 6px;
  padding: 20px;
}

.module-list {
  margin: 30px 0;
}

.module-list h3 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  color: #1a1a1a;
  margin: 20px 0 8px;
}

.module-list a {
  display: block;
  padding: 4px 0 4px 12px;
  color: #1565c0;
  text-decoration: none;
  font-size: 14px;
}

.module-list a:hover { text-decoration: underline; }

.module-list .module-desc {
  color: #888;
  font-size: 12px;
  margin-left: 4px;
}

.back-link {
  font-size: 13px;
  color: #1565c0;
  text-decoration: none;
  display: inline-block;
  margin-bottom: 10px;
}

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