/* ============================================
   Design System - Consolidated Design Tokens
   and Component Library
   ============================================ 
   This file establishes a unified design system
   to replace fragmented CSS across multiple files.
   ============================================ */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
  /* Typography Scale */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Source Serif Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  --text-5xl: 3rem;      /* 48px */
  --text-6xl: 3.75rem;   /* 60px */

  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* Letter Spacing */
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* Color System - Primary Palette */
  --accent-color: #2563EB;      /* Blue — primary, professional */
  --accent-hover: #1D4ED8;      /* Blue hover state */
  --accent-light: #DBEAFE;      /* Light blue background */
  
  --accent-warm: #B45309;       /* Amber — personal, creative */
  --accent-warm-hover: #92400E; /* Amber hover */
  --accent-warm-light: #FEF3C7; /* Light amber background */
  
  --accent-code: #059669;       /* Emerald — technical */
  --accent-code-hover: #047857; /* Emerald hover */
  --accent-code-light: #D1FAE5; /* Light emerald */

  /* Neutral Colors */
  --text-color: #1C1917;        /* Primary text */
  --text-secondary: #44403C;    /* Secondary text */
  --text-muted: #78716C;        /* Muted text */
  --text-light: #A8A29E;        /* Light text */
  
  --background-color: #FAFAF8;  /* Page background */
  --surface-card: #FFFFFF;      /* Card background */
  --surface-raised: #FFFFFF;    /* Raised surface */
  --surface-overlay: rgba(255, 255, 255, 0.9);
  
  --border-color: #E7E5E4;      /* Default border */
  --border-light: #F5F5F4;      /* Light border */
  --border-dark: #D6D3D1;       /* Dark border */

  /* Semantic Colors */
  --color-success: #059669;
  --color-warning: #D97706;
  --color-error: #DC2626;
  --color-info: #2563EB;

  /* Spacing Scale */
  --spacing-0: 0;
  --spacing-xs: 0.25rem;   /* 4px */
  --spacing-sm: 0.5rem;    /* 8px */
  --spacing-md: 1rem;      /* 16px */
  --spacing-lg: 1.5rem;    /* 24px */
  --spacing-xl: 2rem;      /* 32px */
  --spacing-2xl: 3rem;     /* 48px */
  --spacing-3xl: 4rem;     /* 64px */
  --spacing-4xl: 6rem;     /* 96px */

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 500ms ease;

  /* Z-Index Scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-tooltip: 600;
}

/* ============================================
   Dark Mode Design Tokens
   ============================================ */
[data-theme="dark"] {
  --text-color: #E7E5E4;
  --text-secondary: #D6D3D1;
  --text-muted: #A8A29E;
  --text-light: #78716C;
  
  --background-color: #1C1917;
  --surface-card: #292524;
  --surface-raised: #44403C;
  --surface-overlay: rgba(28, 25, 23, 0.95);
  
  --border-color: #44403C;
  --border-light: #37352F;
  --border-dark: #57534E;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Base Typography
   ============================================ */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-color);
  background-color: var(--background-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text-color);
  margin-top: 0;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

/* ============================================
   Button System
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Primary Button */
.btn-primary {
  background-color: var(--accent-color);
  color: #FFFFFF;
  border-color: var(--accent-color);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Secondary Button */
.btn-secondary {
  background-color: transparent;
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.btn-secondary:hover {
  background-color: var(--accent-light);
  color: var(--accent-hover);
}

/* Tertiary Button (Ghost) */
.btn-tertiary {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-tertiary:hover {
  color: var(--accent-color);
  background-color: var(--accent-light);
}

/* Button Sizes */
.btn-sm {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

/* ============================================
   Card System
   ============================================ */
.card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-body {
  padding: var(--spacing-lg);
}

.card-title {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--spacing-sm);
  color: var(--text-color);
}

.card-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

/* ============================================
   Link Styles
   ============================================ */
a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Content links - underline on hover */
.post-content a,
article a:not(.btn) {
  text-decoration: none;
}

.post-content a:hover,
article a:not(.btn):hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================
   Form Elements
   ============================================ */
.form-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-color);
  background-color: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder {
  color: var(--text-light);
}

.form-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

/* ============================================
   Navigation Components
   ============================================ */
.nav-link {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--accent-color);
  background-color: var(--accent-light);
}

.nav-link.active {
  color: var(--accent-color);
  font-weight: var(--font-semibold);
}

/* ============================================
   Badge / Tag
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  background-color: var(--accent-light);
  color: var(--accent-color);
}

.badge-warm {
  background-color: var(--accent-warm-light);
  color: var(--accent-warm);
}

.badge-code {
  background-color: var(--accent-code-light);
  color: var(--accent-code);
}

/* ============================================
   Section Spacing
   ============================================ */
.section {
  padding: var(--spacing-3xl) 0;
}

.section-sm {
  padding: var(--spacing-xl) 0;
}

.section-lg {
  padding: var(--spacing-4xl) 0;
}

/* ============================================
   Container
   ============================================ */
.container-custom {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--accent-color); }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

/* ============================================
   Responsive Breakpoints Reference
   ============================================
   Mobile: < 640px
   Tablet: 640px - 1024px
   Desktop: > 1024px
   
   @media (min-width: 640px) { ... }
   @media (min-width: 1024px) { ... }
   @media (max-width: 639px) { ... }
   ============================================ */

/* ============================================
   Accessibility
   ============================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--accent-color);
  color: #FFFFFF;
  border-radius: var(--radius-md);
  z-index: var(--z-tooltip);
  transition: top var(--transition-base);
}

.skip-link:focus {
  top: var(--spacing-md);
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}