/**
 * LBC Accessibility Enhancements
 *
 * @package LBC_Theme
 * @version 1.0.0
 *
 * This file contains:
 * - Color contrast fixes (WCAG AA compliance)
 * - Focus state improvements
 * - Reduced motion preferences
 * - Screen reader utilities
 */

/* ==========================================================================
   COLOR CONTRAST FIXES (Phase 4 - PageSpeed Accessibility)

   WCAG AA requires:
   - Normal text: 4.5:1 contrast ratio
   - Large text (18px+ or 14px+ bold): 3:1 contrast ratio
   - UI components: 3:1 contrast ratio
   ========================================================================== */

/* Muted text that may have low contrast */
.text-muted,
.text-soft,
.times-note,
.expect-lead,
.hero-lead,
.meta-text,
.sermon-date,
.event-date-text,
.archive-intro p,
.faq-answer p {
  color: #4b5563; /* gray-600 - passes AA on white/cream backgrounds */
}

/* On dark backgrounds, ensure sufficient contrast */
/* NOTE: .cta-section .cta-text removed - not all CTA sections have dark backgrounds */
/* Page-specific CSS should handle text color for dark CTA sections */
.hero-overlay + * .hero-lead,
.dark-section p,
[class*="navy-bg"] p {
  color: rgba(255, 255, 255, 0.9); /* High contrast on dark backgrounds */
}

/* Gold text on light backgrounds - darken for contrast */
.gold-text,
.accent-text,
.hero-kicker {
  color: #b48e4d; /* Darker gold passes AA on white */
}

/* Gold text on dark backgrounds - can be lighter */
.dark-section .gold-text,
.hero-overlay + * .hero-kicker {
  color: #d0a75f; /* Original gold is fine on dark */
}

/* Placeholder text contrast fix */
input::placeholder,
textarea::placeholder {
  color: #6b7280; /* gray-500 - minimum for placeholders */
  opacity: 1;
}

/* Link contrast on various backgrounds */
a {
  color: #1e40af; /* blue-800 - high contrast on light backgrounds */
}

.dark-section a,
[class*="navy-bg"] a {
  color: #93c5fd; /* blue-300 - visible on dark backgrounds */
}

a:hover {
  text-decoration: underline;
}

/* Button contrast fixes */
.btn-outline {
  border-width: 2px; /* Thicker border for better visibility */
}

/* Disabled states - must still be readable */
button:disabled,
.btn:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==========================================================================
   FOCUS STATE IMPROVEMENTS
   ========================================================================== */

/* High-visibility focus ring */
:focus-visible {
  outline: 3px solid #d0a75f;
  outline-offset: 2px;
}

/* Remove default focus for mouse users, keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link styling */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 999999;
}

.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: 1rem 1.5rem;
  background: var(--lbc-navy, #0b1021);
  color: var(--lbc-white, #ffffff);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 999999;
}

/* Focus within navigation */
.lbc-nav-link:focus-visible,
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-outline:focus-visible {
  outline: 3px solid var(--lbc-gold, #d0a75f);
  outline-offset: 2px;
}

/* Form focus states */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--lbc-gold, #d0a75f);
  outline-offset: 1px;
  border-color: var(--lbc-gold, #d0a75f);
}

/* Card focus (for keyboard navigation) */
.card:focus-within,
.event-card:focus-within,
.ministry-card:focus-within {
  box-shadow: 0 0 0 3px var(--lbc-gold, #d0a75f);
}

/* ==========================================================================
   REDUCED MOTION PREFERENCES
   ========================================================================== */

@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;
  }

  /* Disable parallax effects */
  .parallax {
    background-attachment: scroll !important;
  }

  /* Disable auto-playing carousels */
  .carousel,
  .slideshow {
    animation: none !important;
  }
}

/* ==========================================================================
   SCREEN READER UTILITIES
   ========================================================================== */

/* Visually hidden but accessible to screen readers */
.sr-only,
.screen-reader-text,
.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;
}

/* Allow screen reader text to become visible when focused */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (forced-colors: active) {
  /* Ensure borders are visible in high contrast mode */
  .btn,
  .card,
  input,
  textarea,
  select {
    border: 2px solid currentColor;
  }

  /* Ensure focus is visible */
  :focus {
    outline: 3px solid currentColor;
  }

  /* Links should have underlines */
  a {
    text-decoration: underline;
  }
}

/* ==========================================================================
   TOUCH TARGET SIZES
   Minimum 44x44px for touch targets (WCAG 2.5.5)
   ========================================================================== */

/* Ensure buttons and links have adequate touch targets */
.btn,
.btn-primary,
.btn-outline,
.lbc-nav-link,
.mobile-toggle,
.mobile-icon-link,
.social-link {
  min-height: 44px;
  min-width: 44px;
}

/* Small buttons need adequate padding */
.btn-sm {
  min-height: 36px;
  padding: 0.5rem 1rem;
}

/* Icon buttons */
.btn-icon,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

/* Checkbox and radio - larger touch targets */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* ==========================================================================
   SPACING FOR READABILITY
   ========================================================================== */

/* Adequate line height for body text */
body {
  line-height: 1.6;
}

/* Paragraph spacing */
p + p {
  margin-top: 1em;
}

/* List spacing */
ul, ol {
  padding-left: 1.5em;
}

li + li {
  margin-top: 0.5em;
}

/* ==========================================================================
   TEXT RESIZE SUPPORT
   ========================================================================== */

/* Ensure text can resize up to 200% without breaking layout */
html {
  font-size: 100%; /* 16px base - don't fix to px */
}

/* Use rem/em units throughout - already done in tokens */

/* Prevent horizontal scroll on text resize */
body {
  overflow-x: hidden;
}

/* ==========================================================================
   ERROR STATE ACCESSIBILITY
   ========================================================================== */

/* Error messages should be clearly visible */
.error-message,
.form-error,
.validation-error {
  color: #dc2626; /* red-600 - high contrast */
  font-weight: 600;
  margin-top: 0.5rem;
}

/* Error borders */
.has-error input,
.has-error textarea,
.has-error select,
input.error,
textarea.error,
select.error {
  border-color: #dc2626;
  border-width: 2px;
}

/* Success messages */
.success-message,
.form-success {
  color: #16a34a; /* green-600 */
  font-weight: 600;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  /* Ensure text is black on white for printing */
  body {
    color: #000;
    background: #fff;
  }

  /* Hide navigation and interactive elements */
  .lbc-header,
  .lbc-nav,
  .mobile-overlay,
  .btn,
  nav,
  footer {
    display: none !important;
  }

  /* Ensure links show their URLs */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Don't break images across pages */
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  /* Avoid breaking headings from their content */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
}
