/* ─────────────────────────────────────────────────────────────────────────────
   MAIN.CSS — CSS Custom Properties, CSS Reset, Base Styles
   ───────────────────────────────────────────────────────────────────────────── */

/* ─── CSS Custom Properties ─────────────────────────────────────────────────── */

:root {
  /* Color palette */
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-primary-light: #3b82f6;
  --color-secondary: #7c3aed;
  --color-secondary-dark: #6d28d9;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-warning: #ea580c;

  --color-neutral-50: #f9fafb;
  --color-neutral-100: #f3f4f6;
  --color-neutral-200: #e5e7eb;
  --color-neutral-300: #d1d5db;
  --color-neutral-400: #9ca3af;
  --color-neutral-500: #6b7280;
  --color-neutral-600: #4b5563;
  --color-neutral-700: #374151;
  --color-neutral-800: #1f2937;
  --color-neutral-900: #111827;

  --color-text: var(--color-neutral-900);
  --color-text-muted: var(--color-neutral-600);
  --color-bg: var(--color-neutral-50);
  --color-bg-alt: white;
  --color-border: var(--color-neutral-200);
  --color-border-dark: var(--color-neutral-300);

  /* Spacing */
  --space-2xs: 0.25rem;   /* 4px */
  --space-xs: 0.5rem;     /* 8px */
  --space-sm: 0.75rem;    /* 12px */
  --space-md: 1rem;       /* 16px */
  --space-lg: 1.5rem;     /* 24px */
  --space-xl: 2rem;       /* 32px */
  --space-2xl: 3rem;      /* 48px */
  --space-3xl: 4rem;      /* 64px */

  /* Typography */
  --font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-family-mono: 'Courier New', monospace;

  --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-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* Border radius */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 300ms ease-in-out;
  --transition-slow: 500ms ease-in-out;
}

/* ─── CSS Reset ─────────────────────────────────────────────────────────────── */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ─── Base Typography ───────────────────────────────────────────────────────── */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: var(--font-size-4xl);
}

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

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

h4 {
  font-size: var(--font-size-xl);
}

h5 {
  font-size: var(--font-size-lg);
}

h6 {
  font-size: var(--font-size-base);
}

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

a {
  color: var(--color-primary);
  text-decoration: underline;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

a:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* ─── Form Elements ───────────────────────────────────────────────────────── */

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

input,
textarea,
select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-bg-alt);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ─── Lists ─────────────────────────────────────────────────────────────── */

ul,
ol {
  list-style: none;
}

li {
  margin: 0;
  padding: 0;
}

/* ─── Images & Media ────────────────────────────────────────────────────── */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

audio,
video {
  max-width: 100%;
  height: auto;
}

/* ─── Utility Classes ───────────────────────────────────────────────────── */

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

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

/* ─── Page Header ───────────────────────────────────────────────────────── */

header[role="banner"] {
  background-color: var(--color-primary);
  color: white;
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-2xl);
}

header[role="banner"] h1 {
  color: white;
  margin-top: 0;
  margin-bottom: var(--space-xs);
}

header[role="banner"] .subtitle {
  font-size: var(--font-size-lg);
  opacity: 0.95;
  margin-bottom: 0;
}

/* ─── Main Content Area ─────────────────────────────────────────────────── */

main {
  min-height: calc(100vh - 200px);
}

/* ─── Status & Feedback ─────────────────────────────────────────────────── */

#status-message {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border-radius: var(--radius-md);
  background-color: transparent;
  color: inherit;
  font-size: var(--font-size-sm);
}

#status-message[role="status"] {
  min-height: 1.5rem;
}

.error-message {
  background-color: #fee2e2;
  color: #991b1b;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-danger);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Accessibility ────────────────────────────────────────────────────– */

/* Enhanced focus visible styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
[role="tab"]:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  body {
    --color-border: var(--color-neutral-600);
  }

  button:focus-visible,
  input:focus-visible {
    outline: 3px solid var(--color-text);
  }
}

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