/* Theme Variables and Typography Scale */

:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  --link-color: #0056b3;
  --link-hover: #004085;
  --brand-primary: #007bff;
  --brand-primary-hover: #0056b3;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  
  /* Typography Scale - Consistent across all elements */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */
  --font-size-5xl: 3rem;      /* 48px */
  
  /* Line Heights */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;
  
  /* Spacing Scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
}

[data-theme="dark"] {
  /* Dark Theme Colors */
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #a0a0a0;
  --border-color: #404040;
  --link-color: #4da6ff;
  --link-hover: #66b3ff;
  --brand-primary: #4da6ff;
  --brand-primary-hover: #66b3ff;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.5);
}

/* Base Typography */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Heading Scale */
h1, .h1 {
  font-size: var(--font-size-4xl);
  line-height: var(--line-height-tight);
  font-weight: 700;
  margin-bottom: var(--space-6);
  color: var(--text-primary);
}

h2, .h2 {
  font-size: var(--font-size-3xl);
  line-height: var(--line-height-tight);
  font-weight: 600;
  margin-bottom: var(--space-5);
  color: var(--text-primary);
}

h3, .h3 {
  font-size: var(--font-size-2xl);
  line-height: var(--line-height-normal);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

h4, .h4 {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-normal);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

h5, .h5 {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-normal);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

h6, .h6 {
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

/* Paragraph and Text Elements */
p {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

.lead {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-relaxed);
  font-weight: 300;
  color: var(--text-secondary);
}

.small, small {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

/* Theme Toggle Button - Navbar Version */
.theme-toggle {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: var(--space-2);
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.theme-toggle:focus {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle-icon {
  font-size: var(--font-size-lg);
  color: white;
  transition: transform 0.3s ease;
  line-height: 1;
}

.theme-toggle:hover .theme-toggle-icon {
  transform: rotate(180deg);
}

/* Mobile Theme Toggle */
.theme-toggle-mobile {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.75) !important;
  text-align: left;
  padding: var(--space-2) var(--space-4) !important;
}

.theme-toggle-mobile:hover {
  color: white !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

.theme-toggle-mobile:focus {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
  color: white !important;
}

.theme-toggle-mobile .theme-toggle-icon {
  color: inherit;
}

/* Theme-aware Component Overrides */
.card {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.navbar {
  background-color: var(--brand-primary) !important;
  transition: background-color 0.3s ease;
}

.footer {
  background-color: var(--brand-primary);
  transition: background-color 0.3s ease;
}

/* Link Styling */
a {
  color: var(--link-color);
  transition: color 0.3s ease;
}

a:hover {
  color: var(--link-hover);
}

/* Button Theme Support */
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-outline-primary {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-outline-primary:hover {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* Form Elements */
.form-control {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.form-control:focus {
  background-color: var(--bg-primary);
  border-color: var(--brand-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Code Blocks - Theme Aware */
pre, code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

[data-theme="dark"] pre {
  background-color: #1a1a1a;
  border-color: #404040;
}

/* Responsive Typography */
@media (max-width: 768px) {
  h1, .h1 { font-size: var(--font-size-3xl); }
  h2, .h2 { font-size: var(--font-size-2xl); }
  h3, .h3 { font-size: var(--font-size-xl); }
  .lead { font-size: var(--font-size-lg); }
}

@media (max-width: 576px) {
  h1, .h1 { font-size: var(--font-size-2xl); }
  h2, .h2 { font-size: var(--font-size-xl); }
  body { font-size: var(--font-size-sm); }
}
