/* CSS Custom Properties for theming */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96%;
  --secondary-foreground: 222.2 84% 4.9%;
  --muted: 210 40% 96%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96%;
  --accent-foreground: 222.2 84% 4.9%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 222.2 84% 4.9%;
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 4.9%;
  --card-foreground: 210 40% 98%;
  --primary: 210 40% 98%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 85%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
  --ring: 212.7 26.8% 83.9%;
}

/* Typography and accessibility improvements */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --foreground: 0 0% 0%;
    --background: 0 0% 100%;
    --primary: 0 0% 0%;
    --border: 0 0% 50%;
  }
  
  .dark {
    --foreground: 0 0% 100%;
    --background: 0 0% 0%;
    --primary: 0 0% 100%;
    --border: 0 0% 50%;
  }
}

/* Focus management for accessibility */
:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 8px;
  border: 2px solid hsl(var(--ring));
  border-radius: 4px;
  text-decoration: none;
  z-index: 1000;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 6px;
}

/* 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;
}

/* Font configurations */
h1, h2, h3, h4, h5, h6 {
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  line-height: 1.25;
  font-weight: 600;
}

p, span, div:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.6;
}

/* Link styles for better accessibility */
a {
  color: hsl(var(--primary));
  text-decoration-skip-ink: auto;
}

a:hover {
  text-decoration: underline;
}

/* Button base styles */
button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Improved list styles */
ul, ol {
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.25rem;
}

/* Table accessibility */
table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  border: 1px solid hsl(var(--border));
  padding: 0.5rem;
  text-align: left;
}

th {
  background-color: hsl(var(--muted));
  font-weight: 600;
}

/* Form accessibility */
input, textarea, select {
  font: inherit;
  border: 1px solid hsl(var(--border));
  border-radius: 0.25rem;
  padding: 0.5rem;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Loading and performance optimizations */
img {
  max-width: 100%;
  height: auto;
}

/* Print styles */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a, a:visited {
    text-decoration: underline;
  }
  
  .no-print {
    display: none !important;
  }
}
