/* ================================================================
   Custom Styles — 5.4 Search Trees Lecture
   Reveal.js White Theme Override
   ================================================================ */

:root {
  --primary: #2e86c1;
  --primary-dark: #1a5276;
  --primary-light: #85c1e9;
  --secondary: #2c3e50;
  --secondary-light: #5d6d7e;
  --accent-green: #2ecc71;
  --accent-green-dark: #27ae60;
  --accent-red: #e74c3c;
  --accent-red-dark: #c0392b;
  --accent-orange: #e67e22;
  --accent-orange-dark: #d35400;
  --accent-purple: #8e44ad;
  --accent-purple-dark: #7d3c98;
  --accent-yellow: #f1c40f;
  --accent-yellow-dark: #d4ac0d;
  --text-dark: #1a1a2e;
  --text-muted: #5d6d7e;
  --card-bg: #ffffff;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 10px;
}

/* ----- Base Overrides ----- */
html, body {
  background: #fff !important;
  overflow: hidden;
}

:root {
  --r-main-font-size: 48px !important;
}

.reveal {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
  font-size: 48px !important;
  background: #fff !important;
}

.reveal .slides section {
  background: #fff !important;
  overflow: hidden;
  box-sizing: border-box;
}


.reveal .slides {
  background: #fff !important;
}

.reveal-viewport {
  background: #fff !important;
}

/* Hide non-current slides completely */
.reveal .slides section.past,
.reveal .slides section.future {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.reveal .slides section.present {
  opacity: 1 !important;
  visibility: visible !important;
  background: #fff !important;
}

.reveal h1, .reveal h2, .reveal h3, .reveal h4 {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  text-transform: none;
  letter-spacing: -0.02em;
}
.reveal h1 { font-size: 1.6em; color: var(--primary-dark); }
.reveal h2 { font-size: 1.3em; color: var(--primary-dark); margin-bottom: 0.2em; }
.reveal h3 { font-size: 0.9em; color: var(--secondary); }
.reveal h4 { font-size: 0.75em; color: var(--secondary); }
.reveal a { color: var(--primary); }
.reveal section img { border: none; box-shadow: none; }

/* ================================================================
   SLIDE 1 — Title
   ================================================================ */
.title-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.tree-hero {
  margin-bottom: 0.2em;
  width: 100%;
  max-width: 320px;
}

.title-tree-svg { width: 100%; height: auto; }

.title-slide h1 {
  font-size: 2.2em;
  margin: 0;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.03em;
}

.title-slide .subtitle {
  font-size: 0.6em;
  color: var(--text-muted);
  margin-top: 0.2em;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.title-slide .subtitle .dot {
  margin: 0 0.3em;
  color: var(--primary-light);
  font-weight: bold;
}

.node-group {
  opacity: 0;
  animation: nodeAppear 0.5s ease forwards;
}
.node-group.n0 { animation-delay: 0.1s; }
.node-group.n1 { animation-delay: 0.25s; }
.node-group.n2 { animation-delay: 0.4s; }
.node-group.n3 { animation-delay: 0.55s; }
.node-group.n4 { animation-delay: 0.7s; }
.node-group.n5 { animation-delay: 0.85s; }
.node-group.n6 { animation-delay: 1.0s; }

.edge {
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  animation: drawEdge 0.5s ease forwards;
}
.edge.e0 { animation-delay: 0.0s; }
.edge.e1 { animation-delay: 0.15s; }
.edge.e2 { animation-delay: 0.3s; }
.edge.e3 { animation-delay: 0.45s; }
.edge.e4 { animation-delay: 0.6s; }
.edge.e5 { animation-delay: 0.75s; }

@keyframes drawEdge { to { stroke-dashoffset: 0; } }
@keyframes nodeAppear {
  0%   { opacity: 0; transform: scale(0); }
  70%  { transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

/* ================================================================
   SLIDE 2 — Course Information
   ================================================================ */
.info-grid {
  display: flex;
  gap: 0.7em;
  justify-content: center;
  margin: 0.2em 0 0.3em;
  flex-wrap: wrap;
}

.info-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.6em 1em;
  flex: 1;
  min-width: 140px;
  max-width: 190px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.info-card i { font-size: 1.2em; margin-bottom: 0.1em; }
.info-card h3 {
  font-size: 0.6em;
  margin: 0.1em 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.info-card p {
  font-size: 0.7em;
  margin: 0;
  line-height: 1.2;
  color: var(--text-dark);
}

.icon-blue  { color: var(--primary); }
.icon-green { color: var(--accent-green); }

.prereq-heading {
  margin-top: 0.15em;
  font-size: 0.7em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prereq-list {
  display: flex;
  gap: 0.5em;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.15em;
}

.prereq-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  background: var(--card-bg);
  border: 2px solid var(--primary-light);
  border-radius: 50px;
  padding: 0.2em 0.7em;
  font-size: 0.65em;
  font-weight: 600;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}
.prereq-badge i { color: var(--primary); font-size: 0.85em; }

/* ================================================================
   SLIDE 3 — Learning Outcomes
   ================================================================ */
.outcomes-intro {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-bottom: 0.2em;
  font-style: italic;
}

.outcomes-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 600px;
  text-align: left;
  columns: 2;
  column-gap: 1.2em;
}

.outcomes-list li {
  display: flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.15em 0;
  font-size: 0.65em;
  font-weight: 500;
  break-inside: avoid;
}

.check-icon {
  color: var(--accent-green);
  font-size: 0.85em;
  flex-shrink: 0;
}

.outcomes-list li.highlight-final {
  color: var(--primary-dark);
  font-weight: 700;
}

/* ================================================================
   SLIDE 4 — Why Search Trees?
   ================================================================ */
.accent-icon { color: var(--primary); font-size: 0.9em; margin-right: 0.25em; }

.comparison-container {
  display: flex;
  justify-content: center;
  margin-top: 0.15em;
}

.comparison-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  max-width: 800px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
}

.comparison-table th {
  background: var(--primary);
  color: #fff;
  padding: 0.35em 0.8em;
  font-size: 0.65em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.comparison-table th:first-child { text-align: left; }
.comparison-table th:not(:first-child) { text-align: center; }

.comparison-table td {
  padding: 0.35em 0.8em;
  font-size: 0.62em;
  border-bottom: 1px solid #eef0f2;
  background: var(--card-bg);
  color: var(--text-dark);
  vertical-align: middle;
}
.comparison-table td:first-child { text-align: left; font-weight: 600; }
.comparison-table td:not(:first-child) { text-align: center; }
.comparison-table td i { margin-right: 0.3em; color: var(--primary-light); }
.comparison-table tr:last-child td { border-bottom: none; }
.comparison-table tr.highlight-row td { background: #eafaf1; font-weight: 600; }
.comparison-table tr.highlight-row .complexity {
  background: var(--accent-green);
  color: #fff;
  padding: 0.1em 0.6em;
  border-radius: 20px;
  font-weight: 700;
}

.complexity { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-weight: 600; color: var(--secondary); }
.complexity.good { color: var(--accent-green-dark); }
.complexity.bad { color: var(--accent-red-dark); }

.label-no {
  display: inline-block;
  background: #fadbd8;
  color: var(--accent-red-dark);
  padding: 0.15em 0.6em;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
}

.label-yes {
  display: inline-block;
  background: #d5f5e3;
  color: var(--accent-green-dark);
  padding: 0.15em 0.6em;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
}

/* ================================================================
   SLIDE 5 — Motivation
   ================================================================ */
.tree-compare {
  display: flex;
  gap: 0.8em;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 0.1em;
}

.tree-panel {
  flex: 1;
  min-width: 200px;
  max-width: 270px;
  text-align: center;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 0.3em 0.5em 0.25em;
  box-shadow: var(--shadow-sm);
}

.tree-panel h4 {
  margin: 0 0 0.1em;
  font-size: 0.65em;
  color: var(--secondary);
  font-weight: 600;
}

.compare-svg { width: 100%; height: auto; max-height: 150px; }

.path-count {
  margin: 0.05em 0 0;
  font-size: 0.6em;
  color: var(--text-muted);
}

.badge-red {
  display: inline-block;
  background: var(--accent-red);
  color: #fff;
  padding: 0.05em 0.5em;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8em;
}

.badge-green {
  display: inline-block;
  background: var(--accent-green);
  color: #fff;
  padding: 0.05em 0.5em;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8em;
}

/* ================================================================
   SLIDE 6 — Applications
   ================================================================ */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4em;
  margin-top: 0.15em;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.app-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.4em 0.3em;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border-top: 3px solid var(--primary);
}

.app-card i { font-size: 1.1em; color: var(--primary); margin-bottom: 0.05em; }
.app-card h3 { font-size: 0.6em; margin: 0.05em 0 0.05em; font-weight: 700; color: var(--text-dark); }
.app-card p { font-size: 0.52em; margin: 0; color: var(--text-muted); line-height: 1.15; }

/* ================================================================
   SLIDE 7 — Overview
   ================================================================ */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em;
  max-width: 650px;
  margin: 0.15em auto 0;
}

.overview-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  padding: 0.35em 0.7em;
  font-size: 0.85em;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.03em;
}
.card-bst   .card-head { background: #2e86c1; }
.card-avl   .card-head { background: #e67e22; }
.card-btree .card-head { background: #8e44ad; }
.card-bplus .card-head { background: #27ae60; }

.card-body { padding: 0.35em 0.7em 0.4em; }
.card-body p { margin: 0; font-size: 0.62em; line-height: 1.25; color: var(--text-dark); }

/* ================================================================
   SLIDE 8 — Transition
   ================================================================ */
.transition-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.transition-title {
  font-size: 2.2em;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 0;
}

.transition-divider {
  width: 60px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  margin: 0.2em auto;
}

.transition-definition {
  font-size: 0.85em;
  font-style: italic;
  color: var(--text-muted);
  max-width: 450px;
  margin: 0.15em auto;
}

.transition-tree {
  margin-top: 0.3em;
  width: 100%;
  max-width: 200px;
}

.mini-tree { width: 100%; height: auto; }

/* ================================================================
   TWO-COLUMN PRESENTATION LAYOUT
   ================================================================ */
.slide-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
  align-items: center;
  text-align: left;
  height: 100%;
  margin-top: 0.1em;
}

.slide-grid-2.align-start {
  align-items: flex-start;
}

.slide-grid-2 h3, .slide-grid-2 h4 {
  margin-top: 0;
}

.col-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.col-right {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.4em;
  position: relative;
  min-height: 250px;
}

.col-right svg {
  width: 100%;
  height: auto;
  max-height: 480px;
}

/* Node Highlighting Classes */
.circle-current {
  fill: var(--primary) !important;
  stroke: var(--primary-dark) !important;
  transition: fill 0.4s ease, stroke 0.4s ease;
}
.circle-visited {
  fill: var(--accent-orange) !important;
  stroke: var(--accent-orange-dark) !important;
  transition: fill 0.4s ease, stroke 0.4s ease;
}
.circle-success {
  fill: var(--accent-green) !important;
  stroke: var(--accent-green-dark) !important;
  transition: fill 0.4s ease, stroke 0.4s ease;
}
.circle-deleted {
  fill: var(--accent-red) !important;
  stroke: var(--accent-red-dark) !important;
  transition: fill 0.4s ease, stroke 0.4s ease;
}
.circle-rotation {
  fill: var(--accent-purple) !important;
  stroke: var(--accent-purple-dark) !important;
  transition: fill 0.4s ease, stroke 0.4s ease;
}
.circle-promoted {
  fill: var(--accent-yellow) !important;
  stroke: var(--accent-yellow-dark) !important;
}

.text-white {
  fill: #ffffff !important;
}

.edge-success {
  stroke: var(--accent-green) !important;
  stroke-width: 4px !important;
  transition: stroke 0.4s ease, stroke-width 0.4s ease;
}
.edge-visited {
  stroke: var(--accent-orange) !important;
  stroke-width: 3.5px !important;
  transition: stroke 0.4s ease, stroke-width 0.4s ease;
}
.edge-rotation {
  stroke: var(--accent-purple) !important;
  stroke-width: 3.5px !important;
}
.edge-hidden {
  opacity: 0;
}

/* Balance Factor Tags and Tree Height Colors */
.bf-tag {
  font-size: 11px;
  font-weight: 700;
}
.bf-green { fill: var(--accent-green-dark) !important; }
.bf-orange { fill: var(--accent-orange-dark) !important; }
.bf-red { fill: var(--accent-red) !important; font-size: 12px; font-weight: 900; }

/* Code Blocks Styles */
pre.code-block-c {
  margin: 0 !important;
  width: 100% !important;
  font-size: 0.45em !important;
  line-height: 1.35 !important;
  border-radius: var(--radius);
}

.algorithm-explanation {
  font-size: 0.6em;
  line-height: 1.3;
  margin-top: 0.4em;
  color: var(--text-muted);
}
.algorithm-explanation p { margin: 0.2em 0; }

/* Bullet Lists and Notes */
.bullet-list-sm {
  margin: 0.2em 0 !important;
  font-size: 0.65em;
  line-height: 1.3;
}
.bullet-list-sm li {
  margin-bottom: 0.3em;
}

/* Callout Box styling */
.callout-box {
  background: #ebf5fb;
  border-left: 5px solid var(--primary);
  padding: 0.4em 0.8em;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.65em;
  margin: 0.3em 0;
  line-height: 1.3;
  text-align: left;
}
.callout-box.danger {
  background: #fdf2f0;
  border-left-color: var(--accent-red);
}
.callout-box.success {
  background: #ebf9f1;
  border-left-color: var(--accent-green);
}
.callout-box.warning {
  background: #fef9e7;
  border-left-color: var(--accent-orange);
}
.callout-box h5 {
  margin: 0 0 0.2em 0 !important;
  font-weight: 800;
  font-size: 1em;
}

/* ================================================================
   B-TREE AND B+ TREE VISUALS
   ================================================================ */
.btree-node-rect {
  fill: #ffffff;
  stroke: var(--secondary);
  stroke-width: 2px;
  rx: 4px;
}
.btree-key-cell {
  fill: #ebf5fb;
  stroke: var(--primary-light);
  stroke-width: 1px;
}
.btree-node-rect.overflow-node {
  stroke: var(--accent-red);
  stroke-dasharray: 4, 3;
}
.btree-split-line {
  stroke: var(--accent-red);
  stroke-width: 2.5px;
  stroke-dasharray: 4, 3;
}

/* Pointer arrows for B Trees */
.btree-arrow {
  stroke: var(--secondary-light);
  stroke-width: 1.5px;
  fill: none;
  marker-end: url(#arrowhead);
}
.btree-arrow-active {
  stroke: var(--accent-green-dark);
  stroke-width: 2.5px;
}

/* LinkedList pointer for B+ Tree Leaves */
.bplus-leaf-link {
  stroke: var(--accent-green-dark);
  stroke-width: 2px;
  stroke-dasharray: 3, 3;
  fill: none;
  marker-end: url(#arrowhead-green);
}

/* Disk block illustration elements */
.disk-platters {
  stroke: var(--secondary);
  stroke-width: 2px;
  fill: #f2f4f4;
}
.disk-block {
  fill: var(--primary-light);
  stroke: var(--primary-dark);
  opacity: 0.8;
}
.disk-block.active-block {
  fill: var(--accent-yellow) !important;
  stroke: var(--accent-orange-dark) !important;
  opacity: 1;
}

/* ================================================================
   COMPOSITE INTERACTIVE VISUALIZER COMPONENT
   ================================================================ */
.visualizer-container {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  width: 100%;
}
.visualizer-controls {
  display: flex;
  gap: 0.4em;
  justify-content: center;
  align-items: center;
}
.visualizer-input {
  padding: 0.3em 0.5em;
  border-radius: var(--radius);
  border: 2px solid var(--primary-light);
  font-size: 0.6em;
  width: 80px;
  text-align: center;
  outline: none;
}
.visualizer-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.35em 0.8em;
  font-size: 0.6em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s ease;
}
.visualizer-btn:hover { background: var(--primary-dark); }
.visualizer-btn.btn-clear { background: var(--secondary-light); }
.visualizer-btn.btn-clear:hover { background: var(--secondary); }

.visualizer-canvas {
  background: #fafbfc;
  border: 1.5px solid #e1e4e6;
  border-radius: var(--radius);
  min-height: 320px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.visualizer-canvas svg {
  width: 100%;
  height: 320px;
}
.visualizer-log {
  background: #f1f3f5;
  border-radius: var(--radius);
  padding: 0.3em 0.6em;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.5em;
  text-align: left;
  max-height: 60px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
}

/* ================================================================
   QUIZ COMPONENT STYLES
   ================================================================ */
.quiz-container {
  max-width: 800px;
  margin: 0.2em auto;
  text-align: left;
}
.quiz-question {
  font-size: 0.8em !important;
  font-weight: 700;
  margin-bottom: 0.4em !important;
  color: var(--primary-dark);
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em;
}
.quiz-option {
  background: var(--card-bg);
  border: 2px solid #e1e4e6;
  border-radius: var(--radius);
  padding: 0.4em 0.8em;
  font-size: 0.65em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.quiz-option:hover {
  border-color: var(--primary-light);
  background: #f4f9fc;
}
.quiz-option.correct {
  border-color: var(--accent-green) !important;
  background: #eafaf1 !important;
  color: var(--accent-green-dark) !important;
  font-weight: 700;
}
.quiz-option.incorrect {
  border-color: var(--accent-red) !important;
  background: #fadbd8 !important;
  color: var(--accent-red-dark) !important;
}
.quiz-answer-panel {
  margin-top: 0.4em;
  background: #fdf2e9;
  border-left: 5px solid var(--accent-orange);
  padding: 0.4em 0.8em;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.6em;
  line-height: 1.35;
  display: none; /* revealed via Reveal fragment classes */
}
.quiz-answer-panel.visible {
  display: block;
}

/* MCQ option labels */
.opt-lbl {
  font-weight: 800;
  color: var(--secondary-light);
}

/* ================================================================
   Fragment Animations
   ================================================================ */
.reveal .slides section .fragment.fade-right {
  opacity: 0;
  transform: translateX(-15px);
  transition: all 0.3s ease;
}
.reveal .slides section .fragment.fade-right.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal .slides section .fragment.fade-up {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.reveal .slides section .fragment.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 1024px) {
  .apps-grid { grid-template-columns: repeat(3, 1fr); }
  .quiz-options { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .reveal { font-size: 18px; }
  .reveal h1 { font-size: 1.4em; }
  .reveal h2 { font-size: 1.1em; }
  .title-slide h1 { font-size: 1.6em; }
  .transition-title { font-size: 1.6em; }
  .outcomes-list { columns: 1; }
  .apps-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; max-width: 300px; }
  .tree-compare { flex-direction: column; align-items: center; }
  .tree-panel { max-width: 240px; }
  .info-grid { flex-direction: column; align-items: center; }
  .info-card { max-width: 220px; }
  .slide-grid-2 { grid-template-columns: 1fr; }
  .col-right { min-height: 180px; }
}

@media (max-width: 480px) {
  .apps-grid { grid-template-columns: 1fr; }
  .comparison-table { font-size: 0.8em; }
}

@media print {
  .reveal .slides section .fragment {
    opacity: 1 !important;
    transform: none !important;
  }
}
