/**
 * Base Styles
 *
 * Note: All CSS variables (colors, fonts, spacing) are defined in design-tokens.css
 * This file uses those tokens for consistency across the application.
 */

/* Legacy variable aliases for backwards compatibility */
:root {
  --primary-teal: var(--color-primary);
  --primary-teal-dark: var(--color-primary-dark);
  --primary-teal-darker: var(--color-primary-darker);
  --accent-orange: var(--color-accent);
  --accent-orange-light: var(--color-accent-light);
  --light-cyan: var(--color-cyan-50);
  --lighter-cyan: var(--color-cyan-100);
  --bg-table-hover: var(--bg-hover);
  --shadow-light: var(--shadow-sm);
  --shadow: var(--shadow-md);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  overflow-x: hidden;
  width: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  background: var(--bg-main);
  padding: 2rem 1rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-heading);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.5rem;
  margin-top: 0;
}

h2 {
  font-size: 2rem;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0.5rem;
}

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

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

a:visited {
  color: var(--text-link);
}

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

/* ============================================
   WCAG 2.2 AAA Text Spacing (1.4.12)
   ============================================ */

/* Default paragraph spacing - 2× font size */
p, li, dd, .program-benefit {
  margin-bottom: 2em;
}

/* Enhanced spacing mode - User can toggle for better readability */
body[data-text-spacing="enhanced"] {
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
}

body[data-text-spacing="enhanced"] p,
body[data-text-spacing="enhanced"] li,
body[data-text-spacing="enhanced"] dd,
body[data-text-spacing="enhanced"] .program-benefit {
  margin-bottom: 2em !important;
  line-height: 1.8 !important;
}

/* Ensure buttons and compact UI elements don't get excessive spacing */
body[data-text-spacing="enhanced"] button,
body[data-text-spacing="enhanced"] .filter-btn,
body[data-text-spacing="enhanced"] .program-badge,
body[data-text-spacing="enhanced"] .eligibility-badge,
body[data-text-spacing="enhanced"] select {
  letter-spacing: normal !important;
  word-spacing: normal !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  box-shadow: 0 2px 8px var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

thead {
  background: var(--light-cyan);
  color: var(--text-heading);
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
  background: var(--bg-table-hover);
}

th, td {
  padding: 1rem;
  text-align: left;
}

/* ============================================
   Footer (WCAG 2.2 AAA aligned)
   ============================================ */
.site-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-footer);
  color: var(--text-primary);
  font-size: 0.9em;
}

.site-footer .footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-footer .footer-brand,
.site-footer .footer-support,
.site-footer .footer-links {
  margin: 0;
}

.site-footer .footer-brand strong {
  color: var(--text-heading);
}

.site-footer .footer-logo-link {
  display: inline-block;
  text-decoration: none;
}

.site-footer .footer-logo {
  display: block;
  max-width: 120px;
  height: auto;
  transition: opacity 0.2s ease;
}

.site-footer .footer-logo-link:hover .footer-logo {
  opacity: 0.85;
}

.site-footer .footer-links a,
.site-footer .footer-support a {
  display: inline-block; /* Ensure adequate target area */
  padding: 6px 6px; /* Increases target size without visual bulk */
  min-height: 28px; /* Meets/Exceeds WCAG 2.2 AA 24px; practical for inline text */
  border-radius: 6px;
  text-decoration: underline; /* Clear affordance */
}

.site-footer a:focus {
  outline: 3px solid var(--text-heading);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .site-footer * {
    transition: none !important;
    animation: none !important;
  }
}

/* Visually hidden utility for landmark labeling */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}


th {
  font-weight: 600;
}

.table-search {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  width: 100%;
  max-width: 400px;
}

/* ============================================
   Standard Content Wrapper
   Use class="content-wrapper" for consistent page styling
   ============================================ */

.content-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.content-wrapper h1 {
  font-size: 2.5rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.3;
}

.content-wrapper h2 {
  font-size: 2rem;
  margin-top: 2.5rem;
  margin-bottom: 1.25rem;
  color: var(--text-heading);
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
}

.content-wrapper h3 {
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.4;
}

.content-wrapper h4 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.4;
}

.content-wrapper p {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.8;
}

.content-wrapper a {
  color: var(--text-link);
  text-decoration: underline;
  transition: color 0.2s ease;
}

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

.content-wrapper a:visited {
  color: var(--text-link);
}

.content-wrapper strong {
  color: var(--text-heading);
  font-weight: 700;
}

.content-wrapper em {
  font-style: italic;
}

.content-wrapper code {
  padding: 0.2em 0.4em;
  background: #f6f8fa;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: 'Monaco', 'Courier New', monospace;
  color: #24292e;
  white-space: pre-wrap;
  word-break: break-word;
}

.content-wrapper hr {
  border: none;
  border-top: 2px solid var(--border-light);
  margin: 2.5rem 0;
  opacity: 0.8;
}

.content-wrapper ul,
.content-wrapper ol {
  margin-bottom: 1.5rem;
  padding-left: 2.5rem;
}

.content-wrapper li {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  line-height: 1.8;
}

.content-wrapper blockquote {
  margin: 1.5rem 0;
  padding-left: 1.25rem;
  border-left: 4px solid var(--border-light);
  color: var(--text-primary);
  font-style: italic;
  opacity: 0.9;
}

/* Dark mode support for content wrapper */
@media (prefers-color-scheme: dark) {
  .content-wrapper code {
    background: #1c2128;
    color: #e8eef5;
    border: 1px solid #30363d;
  }
  
  .content-wrapper blockquote {
    border-left-color: #1b3a3a;
  }
}

body[data-theme="dark"] .content-wrapper code {
  background: #1c2128;
  color: #e8eef5;
  border: 1px solid #30363d;
}

body[data-theme="dark"] .content-wrapper blockquote {
  border-left-color: #1b3a3a;
}

/* Dark mode support for content wrapper */
@media (prefers-color-scheme: dark) {
  .content-wrapper code {
    background: #1c2128;
    color: var(--text-link);
    border: 1px solid #30363d;
  }
}

body[data-theme="dark"] .content-wrapper code {
  background: #1c2128;
  color: var(--text-link);
  border: 1px solid #30363d;
}

body[data-theme="light"] .content-wrapper code {
  background: #f6f8fa;
  color: #24292e;
  border: none;
}

body[data-theme="light"] .content-wrapper blockquote {
  border-left-color: var(--border-light);
}

.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;
}

footer {
  background: var(--bg-footer);
  border-top: 1px solid var(--border-color);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-primary);
  margin-top: auto;
}

.actions-block {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

/* Inline-style extractions from markdown pages */
@media (prefers-color-scheme: dark) {
  .heading-dark-adjust h1,
  .heading-dark-adjust h2,
  .heading-dark-adjust h3,
  .heading-dark-adjust h4,
  .heading-dark-adjust h5,
  .heading-dark-adjust h6 {
    color: #79d8eb;
  }

  .heading-dark-adjust p {
    color: #e8eef5;
  }

  .heading-dark-adjust a {
    color: #79d8eb;
    text-decoration: underline;
  }

  .heading-dark-adjust a:visited {
    color: #79d8eb;
  }

  .heading-dark-adjust a:hover {
    color: #a8e6f1;
  }

  .heading-dark-adjust strong {
    color: #a8e6f1;
  }

  .heading-dark-adjust em {
    color: #c9d1d9;
  }

  .heading-dark-adjust .program-card p {
    color: #c9d1d9;
  }

  .heading-dark-adjust .filter-section-title {
    color: #e8eef5;
  }

  .heading-dark-adjust ul,
  .heading-dark-adjust ol {
    color: #e8eef5;
  }

  .heading-dark-adjust li {
    color: #e8eef5;
  }

  .heading-dark-adjust blockquote {
    color: #c9d1d9;
  }
}

body[data-theme="dark"] .heading-dark-adjust h1,
body[data-theme="dark"] .heading-dark-adjust h2,
body[data-theme="dark"] .heading-dark-adjust h3,
body[data-theme="dark"] .heading-dark-adjust h4,
body[data-theme="dark"] .heading-dark-adjust h5,
body[data-theme="dark"] .heading-dark-adjust h6 {
  color: #79d8eb;
}

body[data-theme="dark"] .heading-dark-adjust p,
body[data-theme="dark"] .heading-dark-adjust li,
body[data-theme="dark"] .heading-dark-adjust dd {
  color: #e8eef5;
}

body[data-theme="dark"] .heading-dark-adjust strong {
  color: #a8e6f1;
}

body[data-theme="dark"] .heading-dark-adjust em {
  color: #c9d1d9;
}

/* Light mode manual override - reset heading-dark-adjust when user selects light theme */
body[data-theme="light"] .heading-dark-adjust h1,
body[data-theme="light"] .heading-dark-adjust h2,
body[data-theme="light"] .heading-dark-adjust h3,
body[data-theme="light"] .heading-dark-adjust h4,
body[data-theme="light"] .heading-dark-adjust h5,
body[data-theme="light"] .heading-dark-adjust h6 {
  color: var(--text-heading);
}

body[data-theme="light"] .heading-dark-adjust p,
body[data-theme="light"] .heading-dark-adjust li,
body[data-theme="light"] .heading-dark-adjust dd {
  color: var(--text-primary);
}

body[data-theme="light"] .heading-dark-adjust a {
  color: var(--text-link);
}

body[data-theme="light"] .heading-dark-adjust a:hover {
  color: var(--text-link-hover);
}

body[data-theme="light"] .heading-dark-adjust strong {
  color: var(--text-heading);
}

body[data-theme="light"] .heading-dark-adjust em {
  color: var(--text-secondary);
}

body[data-theme="light"] .heading-dark-adjust ul,
body[data-theme="light"] .heading-dark-adjust ol,
body[data-theme="light"] .heading-dark-adjust blockquote {
  color: var(--text-primary);
}

.toast-message {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #f9fafb;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 3000;
}

.no-results {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: #f9fafb;
  color: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
  .no-results {
    background: #1f2937;
    border-color: #30363d;
  }
}

body[data-theme="dark"] .no-results {
  background: #1f2937;
  border-color: #30363d;
}

body[data-theme="light"] .no-results {
  background: #f9fafb;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus-visible {
  position: fixed;
  left: 50%;
  top: 4rem;
  transform: translateX(-50%);
  width: auto;
  height: auto;
  padding: 0.75rem 1rem;
  background: #2563eb;
  color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 2000;
}

/* Consistent focus ring for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.filter-btn:focus-visible,
.favorite-toggle:focus-visible,
.action-btn:focus-visible,
.favorites-toggle-btn:focus-visible,
.back-to-top:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

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

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

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

@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  main { padding: 1rem 0.5rem; }
  table { margin: 1rem 0; }
  th, td { padding: 0.75rem 0.5rem; font-size: 0.9rem; }
}

/* Favorite toggle accessibility */
.favorite-toggle {
  border: 2px solid #e5e7eb;
  background: white;
  color: #ef4444;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.favorite-toggle:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.favorite-toggle.active {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.favorite-toggle:focus-visible {
  outline: 3px solid #1e40af;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(30, 64, 175, 0.3);
}

/* Enhanced focus for all interactive elements */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid #1e40af;
  outline-offset: 2px;
}
