/* ==========================================================================
   SEO & Accessibility Enhancements
   ========================================================================== */

/* Skip to main content link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100000;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* Visually hidden but focusable (Bootstrap class enhancement) */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
    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;
}

.visually-hidden-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Improved touch targets for mobile (minimum 48x48px) */
@media (max-width: 768px) {
    .header-section .menu--style1 > li > a,
    .trk-btn,
    button,
    input[type="button"],
    input[type="submit"],
    .header-bar {
        min-height: 48px;
        min-width: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
    }
    
    /* Social links touch target */
    .footer__social li a {
        min-height: 48px;
        min-width: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Link focus styles for accessibility */
a:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

a:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible {
    outline: 2px solid #0A4FD5;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Button focus styles */
button:focus,
.trk-btn:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
.trk-btn:focus:not(:focus-visible) {
    outline: none;
}

button:focus-visible,
.trk-btn:focus-visible {
    outline: 2px solid #0A4FD5;
    outline-offset: 2px;
}

/* Ensure links are distinguishable (underline on hover/focus) */
a:not(.trk-btn):not(.header-section a):hover,
a:not(.trk-btn):not(.header-section a):focus {
    text-decoration: underline;
}

/* Font display swap override for better performance */
@font-face {
    font-family: 'FontAwesome';
    font-display: swap !important;
}

/* 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;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    a:focus,
    button:focus,
    input:focus,
    textarea:focus {
        outline: 3px solid currentColor;
        outline-offset: 3px;
    }
}

/* Image aspect ratio to prevent CLS */
img {
    height: auto;
    max-width: 100%;
}

img[width][height] {
    aspect-ratio: attr(width) / attr(height);
}

/* Loading state for lazy images */
img[loading="lazy"] {
    content-visibility: auto;
}

/* Improved form field spacing for touch */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    textarea,
    select {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Dialog/Modal accessibility */
[role="dialog"],
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

[role="dialog"]:focus,
.modal:focus {
    outline: 2px solid #0A4FD5;
}

/* ARIA live regions */
[aria-live] {
    position: relative;
}

/* Screen reader only text (sr-only alternative) */
.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;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Improve color contrast for better readability */
/* Note: Specific color values should be audited and adjusted based on WCAG requirements */

/* Ensure sufficient spacing between interactive elements */
button + button,
a + a {
    margin-left: 8px;
}

/* Print styles */
@media print {
    .skip-link,
    .header-bar,
    .lightdark-switch,
    .banner__shape,
    nav,
    .footer {
        display: none !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}
