:root {
  /* Light theme colors */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --secondary: #6366f1;
  --accent: #f59e0b;
  
  --background: #ffffff;
  --background-alt: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --gradient-card: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

[data-theme="dark"] {
  /* Dark theme colors */
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #93c5fd;
  --secondary: #818cf8;
  --accent: #fbbf24;
  
  --background: #0f172a;
  --background-alt: #1e293b;
  --surface: #1e293b;
  --surface-hover: #334155;
  
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --border: #334155;
  --border-light: #475569;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
  
  --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --gradient-card: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
}

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

html {
  scroll-behavior: smooth;
  text-wrap: pretty;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

:is(a, button):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Header Styles */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-text h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.header-text p {
  color: var(--text-secondary);
  font-size: clamp(0.9rem, 2vw, 1.125rem);
  font-weight: 400;
  text-wrap: pretty;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.theme-toggle:hover svg {
  color: var(--text-inverse);
}

.theme-toggle svg {
  transition: all 0.3s ease;
  color: var(--text-secondary);
}

[data-theme="dark"] .sun-icon {
  display: block;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

[data-theme="light"] .sun-icon,
:root:not([data-theme]) .sun-icon {
  display: none;
}

[data-theme="light"] .moon-icon,
:root:not([data-theme]) .moon-icon {
  display: block;
}

/* Main Content */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  flex: 1;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.filter-btn {
  padding: 0.875rem 1.25rem;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.filter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 0;
}

.filter-btn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.filter-btn:hover::before {
  left: 0;
  opacity: 0.1;
}

.filter-btn.active {
  background: var(--gradient-primary);
  border-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.filter-text {
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.filter-count {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  min-width: 1.5rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

.filter-btn:not(.active) .filter-count {
  background: var(--background-alt);
  color: var(--text-muted);
}

/* Stats */
.stats {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Resources Grid */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  min-height: 400px;
}

.resource-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.resource-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
  transform-origin: left;
}

.resource-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.resource-card:hover::before {
  transform: scaleX(1);
}

.resource-card h3 {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.resource-card h3 svg {
  color: var(--primary);
  flex-shrink: 0;
}

.resource-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.resource-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.resource-meta span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--background-alt);
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-light);
}

.resource-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  text-align: center;
  justify-content: center;
  margin-top: auto;
}

.resource-link:hover {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Loading Animation */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Disclaimer */
.disclaimer {
  background: var(--background-alt);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.disclaimer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}

.disclaimer p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
}

.disclaimer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.disclaimer a:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}

.footer-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* SVG Icons */
svg {
  display: inline-block;
  vertical-align: middle;
}

/* Hidden utility */
.hidden {
  display: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .resources-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .header-content {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .header-text h1 {
    margin-bottom: 0.5rem;
  }
  
  main {
    padding: 1.5rem 1rem;
  }
  
  .filters {
    gap: 0.5rem;
  }
  
  .filter-btn {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }
  
  .resources-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .resource-card {
    padding: 1.25rem;
  }
  
  .disclaimer-content {
    padding: 1.5rem 1rem;
  }
  
  .footer-content {
    padding: 1.5rem 1rem;
  }
}

@media (max-width: 480px) {
  .filters {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .filter-btn {
    padding: 1rem;
    flex-direction: column;
  }
  
  .resource-card {
    padding: 1rem;
  }
  
  .resource-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Print styles */
@media print {
  :root {
    --background: #ffffff;
    --surface: #ffffff;
    --text: #000000;
    --border: #cccccc;
  }

  body {
    color: #000000;
    background: #ffffff;
  }

  header,
  .theme-toggle,
  .filters,
  .disclaimer,
  footer {
    display: none;
  }

  main {
    padding: 0;
  }
  
  .resource-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .resource-link {
    display: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text-muted: #000000;
  }
  
  [data-theme="dark"] {
    --border: #ffffff;
    --text-muted: #ffffff;
  }
}

/* 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;
    scroll-behavior: auto !important;
  }
}