/* improved-styles.css */

/* ---
   COLOR SCHEMES
--- */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Crimson Pro', Georgia, serif;
  --font-mono: 'Source Code Pro', 'Courier New', monospace;
  --spacing-unit: 8px;
  --transition-speed: 0.3s;
  --transition-speed-fast: 0.15s;
}

.dark-theme {
  --color-background: #0d1117;
  --color-surface-1: #161b22;
  --color-surface-2: #21262d;
  --color-surface-3: #30363d;
  --color-border: #30363d;
  --color-border-light: #8b949e;
  --color-text-main: #c9d1d9;
  --color-text-muted: #8b949e;
  --color-primary: #58a6ff;
  --color-primary-light: #79c0ff;
  --color-primary-dark: #388bfd;
  --color-accent: #3fb950;
  --color-accent-secondary: #ff7b72;
  --color-heading: #ffffff;
}

.light-theme {
  --color-background: #ffffff;
  --color-surface-1: #f6f8fa;
  --color-surface-2: #e1e4e8;
  --color-surface-3: #d1d5da;
  --color-border: #d1d5da;
  --color-border-light: #8b949e;
  --color-text-main: #24292e;
  --color-text-muted: #586069;
  --color-primary: #0366d6;
  --color-primary-light: #005cc5;
  --color-primary-dark: #0366d6;
  --color-accent: #22863a;
  --color-accent-secondary: #d73a49;
  --color-heading: #24292e;
}

.solarized-theme {
  --color-background: #002b36;
  --color-surface-1: #073642;
  --color-surface-2: #586e75;
  --color-surface-3: #657b83;
  --color-border: #657b83;
  --color-border-light: #839496;
  --color-text-main: #839496;
  --color-text-muted: #586e75;
  --color-primary: #268bd2;
  --color-primary-light: #93a1a1;
  --color-primary-dark: #2aa198;
  --color-accent: #859900;
  --color-accent-secondary: #dc322f;
  --color-heading: #93a1a1;
}

body {
  background-color: var(--color-background);
  color: var(--color-text-main);
  font-family: var(--font-sans);
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

.theme-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
}

.theme-button {
  background-color: var(--color-surface-1);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.palette-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.theme-options {
  display: none;
  position: absolute;
  top: 50px;
  right: 0;
  background-color: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.theme-options button {
  background: none;
  border: none;
  color: var(--color-text-main);
  cursor: pointer;
  padding: 8px 12px;
  width: 100%;
  text-align: left;
  border-radius: 4px;
}

.theme-options button:hover {
  background-color: var(--color-surface-2);
}

.lecture-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  position: sticky;
  top: 100px;
  height: calc(100vh - 120px);
  overflow-y: auto;
}

#toc-container {
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--color-surface-1) 0%, var(--color-surface-2) 100%);
  border-radius: 12px;
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

#toc-container:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border-color: var(--color-border-light);
}

#toc-container h2 {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--color-heading);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-border);
  position: relative;
}

#toc-container h2::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 0.3s ease;
}

#toc-container h2:hover::after {
  width: 100px;
}

.toc-toggle-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.toc-toggle-btn:hover {
  background-color: var(--color-surface-3);
  transform: scale(1.1);
}

.toc-toggle-icon {
  transition: transform 0.3s ease;
}

.toc-toggle-btn.collapsed .toc-toggle-icon {
  transform: rotate(-90deg);
}

#toc {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 1000px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              margin-top 0.3s ease;
}

#toc.toc-collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

#toc ul {
  list-style: none;
  padding-left: 1rem;
}

#toc li {
  margin: 0.25rem 0;
}

#toc a {
  color: var(--color-text-muted);
  text-decoration: none;
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  position: relative;
}

#toc a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  background: var(--color-primary);
  transition: all 0.2s ease;
  border-radius: 0 2px 2px 0;
}

#toc a:hover {
  background-color: var(--color-surface-2);
  color: var(--color-primary);
  transform: translateX(4px);
  border-left-color: var(--color-primary);
}

#toc a:hover::before {
  width: 3px;
  height: 60%;
}

#toc a.active {
  background: linear-gradient(90deg, rgba(107, 184, 255, 0.15), transparent);
  color: var(--color-primary);
  font-weight: 600;
  border-left-color: var(--color-primary);
}

#toc a.active::before {
  width: 3px;
  height: 100%;
}

.lecture-content {
  flex-grow: 1;
  padding-left: 2rem;
}
