/* ============================================================
   Discrete Math for CS by Mizel Cluett — Site Styles
   ============================================================ */

:root {
  --nav-width: 280px;
  --primary: #1a365d;
  --primary-light: #2a5298;
  --accent: #e2725b;
  --bg: #f7f8fa;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --code-bg: #1e1e2e;
  --slide-bg: #ffffff;
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR NAVIGATION
   ============================================================ */

#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--nav-width);
  height: 100vh;
  background: var(--primary);
  color: #e2e8f0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.nav-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.nav-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.nav-header .author {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  margin-top: 0.25rem;
}

.nav-body {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

/* Nav items */
.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-section-title:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.nav-section-title .chevron {
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.nav-section.open .chevron {
  transform: rotate(90deg);
}

.nav-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

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

.nav-link {
  display: block;
  padding: 0.35rem 1.25rem 0.35rem 2.25rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.nav-link.active {
  color: var(--accent);
  background: rgba(255,255,255,0.05);
  font-weight: 600;
}

/* Dropdown groups (Labs / Assignments) */
.nav-dropdown {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.nav-dropdown .nav-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.5);
}

/* Mobile toggle */
#nav-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 42px; height: 42px;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

#main {
  margin-left: var(--nav-width);
  flex: 1;
  min-height: 100vh;
}

.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary-light);
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

strong { font-weight: 600; }

a {
  color: var(--primary-light);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

blockquote {
  border-left: 4px solid var(--accent);
  margin: 1.25rem 0;
  padding: 0.75rem 1.25rem;
  background: #fef3f0;
  border-radius: 0 8px 8px 0;
  color: #7c2d12;
  font-style: italic;
}

hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 2.5rem 0;
}

ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.75rem;
}

li { margin-bottom: 0.35rem; }

/* ============================================================
   TABLES
   ============================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

thead {
  background: var(--primary);
  color: #fff;
}

th {
  padding: 0.65rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

tbody tr:hover {
  background: #f1f5f9;
}

/* ============================================================
   CODE
   ============================================================ */

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: #f1f5f9;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #b91c1c;
}

pre {
  margin: 1.25rem 0;
  border-radius: 10px;
  overflow-x: auto;
  background: var(--code-bg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

pre code {
  display: block;
  padding: 1.25rem 1.5rem;
  background: none;
  color: #cdd6f4;
  font-size: 0.85rem;
  line-height: 1.65;
  border-radius: 0;
}

/* ============================================================
   MATH (KaTeX)
   ============================================================ */

.katex-display {
  margin: 1.25rem 0;
  overflow-x: auto;
}

/* ============================================================
   SLIDE SECTIONS
   ============================================================ */

.slide {
  background: var(--slide-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 2.25rem;
  margin: 2rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  page-break-inside: avoid;
  break-inside: avoid;
}

.slide h2 {
  margin-top: 0;
  border-bottom-color: var(--accent);
}

.slide h3 {
  margin-top: 1rem;
}

/* Slide mode (presentation view) */
body.slide-mode #main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

body.slide-mode .page-content {
  padding: 0;
  max-width: 100%;
  width: 100%;
}

body.slide-mode .slide {
  display: none;
  min-height: 80vh;
  margin: 1rem;
  padding: 3rem;
  font-size: 1.15rem;
}

body.slide-mode .slide.active-slide {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.slide-mode .non-slide {
  display: none;
}

/* Slide counter */
.slide-controls {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 150;
  gap: 0.75rem;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

body.slide-mode .slide-controls {
  display: flex;
}

.slide-controls button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.slide-controls button:hover {
  background: rgba(255,255,255,0.25);
}

/* View mode toggle */
#view-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: calc(var(--nav-width) + 1.5rem);
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: background 0.15s;
}

#view-toggle:hover {
  background: var(--primary-light);
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.hero {
  text-align: center;
  padding: 4rem 2rem 3rem;
}

.hero h1 {
  font-size: 2.75rem;
  margin-bottom: 0.75rem;
}

.hero .subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.module-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  text-decoration: none;
}

.module-card .module-num {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.module-card h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--primary);
}

.module-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   PROBLEM / SOLUTION SECTIONS
   ============================================================ */

.problem-set {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.25rem 0;
}

.solution-set {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.25rem 0;
}

details {
  margin: 1rem 0;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-light);
  padding: 0.5rem 0;
}

details summary:hover {
  color: var(--primary);
}

/* ============================================================
   PRINT / EXPORT
   ============================================================ */

@media print {
  #sidebar, #nav-toggle, #view-toggle, .slide-controls { display: none !important; }
  #main { margin-left: 0; }
  .slide { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  pre { white-space: pre-wrap; box-shadow: none; }
}

/* ============================================================
   MCQ QUIZ
   ============================================================ */

.quiz-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1.05rem;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.quiz-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.quiz-progress-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.quiz-question-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.quiz-q-number {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.quiz-q-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.quiz-choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.quiz-choice:hover:not([disabled]) {
  border-color: var(--primary-light);
  background: #eef2ff;
  transform: translateX(4px);
}

.quiz-choice-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.quiz-choice.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.quiz-choice.correct .quiz-choice-letter {
  background: #22c55e;
}

.quiz-choice.incorrect {
  border-color: #ef4444;
  background: #fef2f2;
}

.quiz-choice.incorrect .quiz-choice-letter {
  background: #ef4444;
}

.quiz-choice.disabled {
  opacity: 0.5;
  cursor: default;
}

.quiz-explanation {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.quiz-explanation.correct {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
  color: #166534;
}

.quiz-explanation.incorrect {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
  color: #991b1b;
}

.quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.quiz-nav-pos {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.quiz-nav-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.quiz-nav-btn:hover:not([disabled]) {
  background: var(--primary-light);
}

.quiz-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.quiz-results {
  text-align: center;
  padding: 2rem;
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.quiz-results h3 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.quiz-results p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  :root { --nav-width: 260px; }
  .page-content { padding: 2rem 1.25rem 3rem; }
  .hero h1 { font-size: 2rem; }
}

@media (max-width: 700px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #nav-toggle { display: block; }

  #main { margin-left: 0; }

  #view-toggle {
    left: 1.5rem;
  }

  .hero h1 { font-size: 1.6rem; }
  .module-grid { grid-template-columns: 1fr; }
}
