/* ==========================================================================
   Design System — matthewheyman.com v2
   ========================================================================== */

/* Design tokens, typography, spacing, colors, and "Operating System" visual
   language. CSS Zen Garden principles: semantic HTML + CSS for presentation.
   Lightweight-inspired: clean, premium, confident. */

/* ==========================================================================
   1. Design Tokens
   ========================================================================== */

:root {
  /* Colors — Dark theme with soft accents */
  --color-bg-primary: #0f0f0f;
  --color-bg-secondary: #1a1a1a;
  --color-bg-elevated: #242424;
  
  --color-text-primary: #f5f5f5;
  --color-text-secondary: #b8b8b8;
  --color-text-tertiary: #808080;
  
  --color-accent-primary: #a8c7ff;
  --color-accent-hover: #c5d9ff;
  --color-accent-glow: rgba(168, 199, 255, 0.15);
  
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-border-medium: rgba(255, 255, 255, 0.12);
  
  /* Typography scale */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  
  --font-size-xs: 0.75rem;      /* 12px */
  --font-size-sm: 0.875rem;     /* 14px */
  --font-size-base: 1rem;       /* 16px */
  --font-size-md: 1.125rem;     /* 18px */
  --font-size-lg: 1.25rem;      /* 20px */
  --font-size-xl: 1.5rem;       /* 24px */
  --font-size-2xl: 2rem;        /* 32px */
  --font-size-3xl: 2.5rem;      /* 40px */
  --font-size-4xl: 3rem;        /* 48px */
  --font-size-5xl: 3.75rem;     /* 60px */
  
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  --line-height-tight: 1.2;
  --line-height-snug: 1.4;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;
  
  --letter-spacing-tight: -0.02em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.05em;
  --letter-spacing-wider: 0.1em;
  
  /* Spacing scale (8px base) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */
  --space-32: 8rem;     /* 128px */
  
  /* Layout */
  --max-width-sm: 640px;
  --max-width-md: 768px;
  --max-width-lg: 1024px;
  --max-width-xl: 1280px;
  --max-width-content: 800px;
  --max-width-prose: 65ch;
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Shadows and glows (OS visual language) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  
  --glow-subtle: 0 0 20px var(--color-accent-glow);
  --glow-medium: 0 0 40px var(--color-accent-glow), 0 0 20px var(--color-accent-glow);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme (toggle via terminal: theme light | theme dark) */
[data-theme="light"] {
  --color-bg-primary: #f8f8f8;
  --color-bg-secondary: #eeeeee;
  --color-bg-elevated: #e0e0e0;
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #4a4a4a;
  --color-text-tertiary: #6b6b6b;
  --color-accent-primary: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-glow: rgba(37, 99, 235, 0.12);
  --color-border-subtle: rgba(0, 0, 0, 0.08);
  --color-border-medium: rgba(0, 0, 0, 0.12);
}

/* Pride theme — rainbow accent (terminal: theme pride) */
[data-theme="pride"] {
  --color-accent-primary: #b57edc;
  --color-accent-hover: #d4a8f0;
  --color-accent-glow: rgba(181, 126, 220, 0.2);
}
[data-theme="pride"] a {
  color: var(--color-accent-primary);
  background: linear-gradient(90deg, #e40303, #ff8c00, #ffed00, #008026, #24408e, #732982) no-repeat bottom left / 0 2px;
}
[data-theme="pride"] a:hover {
  color: var(--color-accent-hover);
  background-size: 100% 2px;
}
[data-theme="pride"] .site-header {
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, #e40303, #ff8c00, #ffed00, #008026, #24408e, #732982) 1;
}

/* Font size (terminal: font + | font - | font reset) */
html[data-font-size="large"] {
  font-size: 112.5%;
}
html[data-font-size="larger"] {
  font-size: 125%;
}
html[data-font-size="largest"] {
  font-size: 137.5%;
}

/* Reduced motion override (terminal: motion off | motion on) */
html[data-motion="reduce"] *,
html[data-motion="reduce"] *::before,
html[data-motion="reduce"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
html[data-motion="reduce"] .btn:hover,
html[data-motion="reduce"] .card:hover,
html[data-motion="reduce"] .feature-card:hover,
html[data-motion="reduce"] .action-card:hover {
  transform: none;
}

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

  .btn:hover,
  .card:hover,
  .feature-card:hover,
  .action-card:hover {
    transform: none;
  }
}

/* ==========================================================================
   2. Base Styles
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
}

/* ==========================================================================
   3. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
}

h1 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-2);
}

h2 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
  opacity: 0.7;
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
}

h3 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-3);
}

h4 {
  font-size: var(--font-size-md);
  margin-bottom: var(--space-2);
}

p {
  margin: 0 0 var(--space-4) 0;
  max-width: var(--max-width-prose);
}

a {
  color: var(--color-accent-primary);
  text-decoration: none;
  background: linear-gradient(var(--color-accent-primary), var(--color-accent-primary)) no-repeat bottom left / 0 1px;
  transition: color var(--transition-base), background-size var(--transition-base);
}

a:hover {
  color: var(--color-accent-hover);
  background-size: 100% 1px;
}

a:focus-visible {
  outline: 2px solid var(--color-accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong {
  font-weight: var(--font-weight-semibold);
}

code {
  font-family: var(--font-family-mono);
  font-size: 0.9em;
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   4. Layout Primitives
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--max-width-content);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container--wide {
  max-width: var(--max-width-lg);
}

.container--narrow {
  max-width: var(--max-width-sm);
}

.section {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

.section--compact {
  padding-top: var(--space-10);
  padding-bottom: var(--space-10);
}

/* ==========================================================================
   5. OS Visual Language (Soft glow, grids, structure)
   ========================================================================== */

/* Subtle grid background (optional, can be applied to body or sections) */
.grid-bg {
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Glow accent (for hero, featured sections, or interactive elements) */
.glow-accent {
  box-shadow: var(--glow-subtle);
}

.glow-accent:hover {
  box-shadow: var(--glow-medium);
  transition: box-shadow var(--transition-base);
}

/* Elevated card/panel */
.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
  border-color: var(--color-border-medium);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: var(--space-10) 0;
}

/* ==========================================================================
   6. Utility Classes
   ========================================================================== */

/* Text utilities */
.text-secondary {
  color: var(--color-text-secondary);
}

.text-tertiary {
  color: var(--color-text-tertiary);
}

.text-uppercase {
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

/* Spacing utilities */
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }

.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }

/* Responsive utilities */
@media (max-width: 768px) {
  :root {
    --font-size-4xl: 2.5rem;  /* Scale down h1 on mobile */
    --space-16: 3rem;
    --space-20: 4rem;
  }
  
  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}

@media (max-width: 480px) {
  .container {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
}

/* ==========================================================================
   7. Animations (Subtle, respects prefers-reduced-motion)
   ========================================================================== */

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

.fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

/* Scroll-triggered reveal (CSS-only fallback; can enhance with JS) */
@supports (animation-timeline: scroll()) {
  .scroll-reveal {
    animation: fadeIn linear;
    animation-timeline: view();
    animation-range: entry 0% entry 50%;
  }
}
