/**
 * Accessibility Styles
 * Enhanced focus states, skip links, and screen reader utilities
 *
 * @package Skitterskoon
 */

/* ============================================
   SKIP LINKS
   ============================================ */

.skip-links {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 99999;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    display: block;
    padding: 0.75rem 1.5rem;
    background: #2563eb;
    color: #fff !important;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 0.5rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: none;
}

.skip-link:hover {
    background: #1d4ed8;
    text-decoration: none;
}

/* ============================================
   SCREEN READER UTILITIES
   ============================================ */

.sr-only,
.visually-hidden,
.screen-reader-text {
    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;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ============================================
   FOCUS STATES
   ============================================ */

/* Remove default outline, add custom focus ring */
*:focus {
    outline: none;
}

/* Custom focus ring for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
    border-radius: 2px;
}

/* High contrast focus for dark backgrounds */
.site-header a:focus-visible,
.hero-section a:focus-visible,
.footer a:focus-visible {
    outline-color: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.5);
}

/* Button focus styles */
.btn:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

/* Form field focus */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Card and interactive container focus */
.card:focus-within,
.service-card:focus-within {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* ============================================
   KEYBOARD NAVIGATION
   ============================================ */

/* Show focus indicators only for keyboard users */
.using-mouse *:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Menu items keyboard navigation */
.header-menu a:focus-visible {
    background: rgba(37, 99, 235, 0.1);
    border-radius: 0.25rem;
}

/* Dropdown focus trap indicator */
.language-list-dropdown li a:focus-visible {
    background: #f0f4ff;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

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

    .skip-link {
        transition: none;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    a:focus-visible,
    button:focus-visible {
        outline: 3px solid currentColor;
        outline-offset: 3px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* ============================================
   TOUCH TARGET SIZE
   ============================================ */

/* Ensure minimum touch target size of 44x44px */
@media (pointer: coarse) {
    button,
    a,
    input[type="button"],
    input[type="submit"],
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .header-menu a {
        padding: 0.75rem 1rem;
    }

    .language-list-dropdown a {
        padding: 1rem;
    }
}

/* ============================================
   LINK UNDERLINES (accessibility)
   ============================================ */

/* Ensure links are distinguishable */
main a:not(.btn):not(.card) {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

main a:not(.btn):not(.card):hover {
    text-decoration-thickness: 2px;
}

/* ============================================
   ERROR STATES
   ============================================ */

.error,
.is-invalid,
[aria-invalid="true"] {
    border-color: #dc2626 !important;
}

.error:focus-visible,
.is-invalid:focus-visible,
[aria-invalid="true"]:focus-visible {
    outline-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.error-message,
.form-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ============================================
   LIVE REGIONS
   ============================================ */

[aria-live="polite"],
[aria-live="assertive"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================
   FORM LABELS
   ============================================ */

label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* Required field indicator */
label.required::after,
.required label::after {
    content: " *";
    color: #dc2626;
}

/* ============================================
   LOADING STATES
   ============================================ */

[aria-busy="true"] {
    cursor: wait;
    opacity: 0.7;
}

.loading-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ============================================
   SELECTION & TEXT
   ============================================ */

::selection {
    background: #2563eb;
    color: #fff;
}

/* Improve text readability */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ============================================
   PRINT STYLES (accessibility)
   ============================================ */

@media print {
    .skip-links,
    .skip-link {
        display: none !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.875em;
    }
}
