/* Caxton Design System
 * A comprehensive, accessible design system for the Caxton website
 * ============================================================================
 * 1. CSS Custom Properties & Design Tokens
 * ============================================================================ */

:root {
  /* Color System - Using Catppuccin Mocha with WCAG AA compliance */
  --color-base: #1e1e2e;
  --color-mantle: #181825;
  --color-crust: #11111b;
  --color-surface0: #313244;
  --color-surface1: #45475a;
  --color-surface2: #585b70;

  --color-text: #cdd6f4;
  --color-subtext1: #bac2de;
  --color-subtext0: #a6adc8;
  --color-overlay2: #9399b2;
  --color-overlay1: #7f849c;
  --color-overlay0: #6c7086;

  --color-blue: #89b4fa;
  --color-lavender: #b4befe;
  --color-sapphire: #74c7ec;
  --color-sky: #89dceb;
  --color-teal: #94e2d5;
  --color-green: #a6e3a1;
  --color-yellow: #f9e2af;
  --color-peach: #fab387;
  --color-maroon: #eba0ac;
  --color-red: #f38ba8;
  --color-mauve: #cba6f7;
  --color-pink: #f5c2e7;
  --color-flamingo: #f2cdcd;
  --color-rosewater: #f5e0dc;

  /* Semantic Colors */
  --color-primary: var(--color-blue);
  --color-secondary: var(--color-lavender);
  --color-accent: var(--color-sapphire);
  --color-success: var(--color-green);
  --color-warning: var(--color-yellow);
  --color-danger: var(--color-red);
  --color-info: var(--color-sky);

  /* Background Colors */
  --bg-primary: var(--color-base);
  --bg-secondary: var(--color-mantle);
  --bg-tertiary: var(--color-crust);
  --bg-surface: var(--color-surface0);
  --bg-surface-hover: var(--color-surface1);
  --bg-surface-active: var(--color-surface2);

  /* Text Colors with WCAG AA compliance */
  --text-primary: var(--color-text);
  --text-secondary: var(--color-subtext0);
  --text-muted: var(--color-overlay2);
  --text-disabled: var(--color-overlay0);
  --text-on-primary: var(--color-base);
  --text-link: var(--color-blue);
  --text-link-hover: var(--color-sapphire);

  /* Typography Scale */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-md: 1.125rem;
  --font-size-lg: 1.333rem;
  --font-size-xl: 1.777rem;
  --font-size-2xl: 2.369rem;
  --font-size-3xl: 3.157rem;
  --font-size-4xl: 4.209rem;

  /* Font Families */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

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

  /* Line Heights */
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.75;
  --line-height-loose: 2;

  /* Spacing Scale */
  --space-0: 0;
  --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;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.25);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(137, 180, 250, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  --transition-slower: 500ms ease;

  /* Z-index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-tooltip: 600;
  --z-notification: 700;
  --z-top: 9999;

  /* Container Widths */
  --container-xs: 480px;
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-text: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.8);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.6);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-base: 0ms;
    --transition-slow: 0ms;
    --transition-slower: 0ms;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
 * 2. Base Reset & Typography
 * ============================================================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-regular);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-bold);
}

h2 {
  font-size: var(--font-size-2xl);
}

h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }
h6 { font-size: var(--font-size-base); }

@media (max-width: 768px) {
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
}

p {
  margin-bottom: var(--space-4);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

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

code, pre {
  font-family: var(--font-mono);
}

code {
  background-color: var(--bg-surface);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.875em;
}

pre {
  background-color: var(--bg-surface);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

pre code {
  background-color: transparent;
  padding: 0;
}

/* ============================================================================
 * 3. Component Styles
 * ============================================================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-base);
  font-weight: var(--font-medium);
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  min-height: 44px;
  min-width: 44px;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary,
.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-on-primary);
}

.btn--primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background-color: var(--color-sapphire);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn--secondary,
.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--color-surface1);
}

.btn--outline,
.btn-outline {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--success {
  background-color: var(--color-success);
  color: var(--text-on-primary);
}

.badge--warning {
  background-color: var(--color-warning);
  color: var(--text-on-primary);
}

.badge--danger {
  background-color: var(--color-danger);
  color: var(--text-on-primary);
}

.badge--info {
  background-color: var(--color-info);
  color: var(--text-on-primary);
}

.badge--neutral {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

/* ============================================================================
 * 4. Layout Utilities
 * ============================================================================ */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-6);
  }
}

/* ============================================================================
 * 5. Accessibility Utilities
 * ============================================================================ */

/* Screen reader only content */
.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;
}

.sr-only:focus {
  position: absolute;
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  z-index: var(--z-top);
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: var(--text-on-primary);
  padding: var(--space-2) var(--space-4);
  z-index: var(--z-top);
  text-decoration: none;
  border-radius: var(--radius-md);
}

.skip-link:focus {
  top: var(--space-2);
  left: var(--space-2);
}

/* ============================================================================
 * 6. Animation Classes
 * ============================================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.animate-fadeInUp {
  animation: fadeInUp var(--transition-slow) ease-out;
}

.animate-slideInLeft {
  animation: slideInLeft var(--transition-base) ease-out;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ============================================================================
 * 7. Utility Classes
 * ============================================================================ */

/* Display */
.hidden { display: none !important; }
.block { display: block !important; }
.inline-block { display: inline-block !important; }
.flex { display: flex !important; }
.inline-flex { display: inline-flex !important; }
.grid { display: grid !important; }

/* Text */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-justify { text-align: justify !important; }

.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-info { color: var(--color-info) !important; }

/* Font weights */
.font-light { font-weight: var(--font-light) !important; }
.font-regular { font-weight: var(--font-regular) !important; }
.font-medium { font-weight: var(--font-medium) !important; }
.font-semibold { font-weight: var(--font-semibold) !important; }
.font-bold { font-weight: var(--font-bold) !important; }

/* Responsive utilities */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
  .show-desktop { display: block !important; }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }
}
