/*
 * Timeless: Modular Grokking & Mechanistic Interpretability
 * Premium CSS Stylesheet
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500;600&display=swap');

:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #11131c;
  --bg-glass: rgba(17, 19, 28, 0.7);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-glass-hover: rgba(255, 255, 255, 0.12);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* HSL Neon Colors */
  --accent-purple: hsl(263, 90%, 62%);
  --accent-purple-glow: hsla(263, 90%, 62%, 0.3);
  --accent-cyan: hsl(180, 90%, 50%);
  --accent-cyan-glow: hsla(180, 90%, 50%, 0.3);
  --accent-pink: hsl(325, 90%, 55%);
  --accent-pink-glow: hsla(325, 90%, 55%, 0.3);
  --accent-green: hsl(142, 70%, 50%);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  --gradient-secondary: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  --gradient-dark: linear-gradient(180deg, #0a0b10 0%, #11131c 100%);
  --gradient-glow: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 60%);
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-neon: 0 0 20px var(--accent-purple-glow);
  
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s ease;
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--gradient-dark);
  background-attachment: fixed;
  line-height: 1.6;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #232533;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-purple);
}

/* Layout Containers */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: var(--transition-smooth);
}

.brand {
  margin-bottom: 3rem;
  text-align: left;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  flex-direction: column;
}

.brand span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 0.25rem;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.nav-item a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active a {
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(6, 182, 212, 0.05));
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.05);
}

.nav-item.active a svg {
  stroke: var(--accent-cyan);
}

.sidebar-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-glass);
}

.designer-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.designer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #000;
  font-size: 1.1rem;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.designer-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.designer-info p {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 3rem;
  max-width: 1200px;
}

/* Content Sections */
.section {
  display: none;
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typography elements */
h2.section-title {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 1.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h3.subtitle {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 2.5rem 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

h3.subtitle::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 24px;
  background: var(--gradient-primary);
  border-radius: 4px;
}

p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  font-weight: 400;
}

p strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Glassmorphism Cards */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 2.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
  box-shadow: 0 22px 40px -10px rgba(0, 0, 0, 0.4), 0 0 30px rgba(99, 102, 241, 0.05);
}

/* Metrics & Stats Cards grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.metric-card {
  text-align: center;
  padding: 1.75rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
}

.metric-card h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.metric-card .value {
  font-size: 2.25rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Highlights Callout Alert */
.highlight-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(6, 182, 212, 0.04) 100%);
  border-left: 4px solid var(--accent-purple);
  padding: 1.5rem;
  border-radius: 0 16px 16px 0;
  margin: 1.5rem 0;
}

.highlight-box p {
  margin-bottom: 0;
  font-style: italic;
}

/* Dashboard Interactive Visuals */
.visualizer-container {
  position: relative;
  background: #0d0f17;
  border-radius: 16px;
  border: 1px solid var(--border-glass);
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow: hidden;
}

.interactive-canvas {
  width: 100%;
  height: 350px;
  background: #090a0f;
  border-radius: 12px;
  display: block;
}

.visualizer-controls {
  display: flex;
  gap: 1rem;
  margin-top: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Button & Controls styling */
.btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-purple);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
}

.btn-primary {
  background: var(--gradient-primary);
  border: none;
  color: #000;
}

.btn-primary:hover {
  background: var(--gradient-primary);
  filter: brightness(1.1);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

/* Form Range Slider Input */
.slider-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.4rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
}

.slider-control input[type="range"] {
  -webkit-appearance: none;
  width: 120px;
  background: #232533;
  height: 6px;
  border-radius: 3px;
  outline: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  transition: var(--transition-fast);
}

.slider-control input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  transform: scale(1.1);
}

/* Code Blocks Styling */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #151824;
  border: 1px solid var(--border-glass);
  border-bottom: none;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  padding: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.code-lang {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
}

.code-lang::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ff5f56;
  border-radius: 50%;
  box-shadow: 12px 0 0 #ffbd2e, 24px 0 0 #27c93f;
}

.btn-copy {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.btn-copy:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.code-container {
  margin-bottom: 2rem;
}

.code-container pre {
  margin: 0;
}

.code-block {
  background: #0c0e16;
  border: 1px solid var(--border-glass);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  padding: 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e5e7eb;
}

/* Code Highlight Tokens */
.keyword { color: #f43f5e; font-weight: 500; }
.builtin { color: #3b82f6; }
.class { color: #10b981; }
.function { color: #6366f1; }
.string { color: #eab308; }
.number { color: #ec4899; }
.comment { color: var(--text-muted); font-style: italic; }
.param { color: #06b6d4; }

/* SVG Simulation Charts */
.svg-chart {
  width: 100%;
  height: 280px;
  background: #0c0e15;
  border-radius: 12px;
  margin-top: 1rem;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.axis-line {
  stroke: #2e3142;
  stroke-width: 1.5;
}

.grid-line {
  stroke: #191b26;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.axis-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-sans);
}

.chart-title {
  fill: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.legend-text {
  fill: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-sans);
}

.line-train {
  stroke: var(--accent-cyan);
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-test {
  stroke: var(--accent-purple);
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-excluded {
  stroke: var(--accent-pink);
  stroke-width: 2.5;
  fill: none;
  stroke-dasharray: 3 3;
}

/* Physics potential energy wells sandbox */
.sandbox-hud {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
}

.sandbox-hud span span {
  color: var(--accent-cyan);
  font-weight: bold;
}

/* GitHub Terminal Guide widget */
.terminal-window {
  background: #090a0f;
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: 1.5rem 0;
}

.terminal-header {
  background: #11131c;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
}

.terminal-buttons {
  display: flex;
  gap: 0.5rem;
}

.t-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.t-btn-red { background: #ff5f56; }
.t-btn-yellow { background: #ffbd2e; }
.t-btn-green { background: #27c93f; }

.terminal-title {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.terminal-body {
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #c9d1d9;
  min-height: 280px;
  max-height: 400px;
  overflow-y: auto;
}

.terminal-line {
  margin-bottom: 0.5rem;
  display: flex;
}

.terminal-prompt {
  color: var(--accent-cyan);
  margin-right: 0.75rem;
  user-select: none;
}

.terminal-cmd {
  color: #fff;
  font-weight: bold;
}

.terminal-output {
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
  white-space: pre-wrap;
  padding-left: 1.25rem;
}

.terminal-input-container {
  display: flex;
  align-items: center;
}

.terminal-input {
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  flex: 1;
}

/* Math blocks styling */
.math-block {
  text-align: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  font-size: 1.15rem;
  font-family: 'Times New Roman', Times, serif;
  margin: 1.5rem 0;
  overflow-x: auto;
  white-space: nowrap;
}

.math-inline {
  font-family: 'Times New Roman', Times, serif;
  font-style: italic;
  font-size: 1.05rem;
}

/* Footer layout */
.footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-glass);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer p {
  margin-bottom: 0.25rem;
}

/* Mobile Responsive Adjustments */
@media (max-width: 1024px) {
  .sidebar {
    width: 80px;
    padding: 2rem 0.5rem;
    align-items: center;
  }
  
  .brand h1, .brand span, .nav-item span, .designer-info, .sidebar-footer {
    display: none;
  }
  
  .sidebar-footer {
    border: none;
    padding: 0;
  }
  
  .nav-item a {
    justify-content: center;
    padding: 0.85rem;
  }
  
  .main-content {
    margin-left: 80px;
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    justify-content: space-between;
    padding: 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border-glass);
  }
  
  .nav-links {
    flex-direction: row;
    gap: 0.25rem;
    flex-grow: 0;
  }
  
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
  
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  
  h2.section-title {
    font-size: 2rem;
  }
}
