/**
 * Accessibility Improvements
 * WCAG AA compliance: keyboard navigation, focus indicators, color contrast
 * 
 * @package Modeo
 * @since 1.0.0
 */

/* ========================================
   Focus Indicators
   ======================================== */

/* High contrast focus indicators for all interactive elements */
*:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove default focus outline for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus for buttons */
button:focus-visible,
.button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Focus for product cards */
.modeo-product-card:focus-visible,
.product-card:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 4px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Focus for filter items */
.modeo-filter-item:focus-visible,
.filter-item:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    background-color: #eff6ff;
}

/* Focus for navigation items */
.modeo-header nav a:focus-visible,
.modeo-header nav button:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    background-color: #eff6ff;
    border-radius: 4px;
}

/* ========================================
   Keyboard Navigation
   ======================================== */

/* Skip to main content link */
.skip-to-main-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000000;
    color: #ffffff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
}

.skip-to-main-content:focus {
    top: 0;
}

/* Ensure all interactive elements are keyboard accessible */
button,
a,
input,
select,
textarea,
[tabindex]:not([tabindex="-1"]) {
    /* Already accessible by default */
}

/* Disable pointer events for non-interactive elements */
[aria-hidden="true"] {
    pointer-events: none;
}

/* ========================================
   Color Contrast (WCAG AA)
   ======================================== */

/* Text colors - minimum 4.5:1 contrast ratio */
body {
    color: #1f2937;
    /* Gray-800 - 4.5:1 on white */
}

.text-gray-600 {
    color: #4b5563;
    /* Gray-600 - 4.5:1 on white */
}

.text-gray-700 {
    color: #374151;
    /* Gray-700 - 4.5:1 on white */
}

/* Links - minimum 4.5:1 contrast ratio */
a {
    color: #000;
    /* Blue-600 - 4.5:1 on white */
}

a:hover,
a:focus {
    color: #cc1616;
    /* Blue-700 - 7:1 on white */
}

/* Primary button - minimum 4.5:1 contrast ratio */
.button-primary,
.button.primary,
.bg-primary {
    background-color: #cc1616;
    /* Primary red */
    color: #ffffff;
    /* White - 4.5:1 on red */
}

.button-primary:hover,
.button.primary:hover,
.bg-primary:hover {
    background-color: #b31313;
    /* Darker red */
    color: #ffffff;
}

/* Secondary button - minimum 4.5:1 contrast ratio */
.button-secondary,
.button.secondary {
    background-color: #6b7280;
    /* Gray-500 */
    color: #ffffff;
    /* White - 4.5:1 on gray */
}

/* Error states - minimum 4.5:1 contrast ratio */
.text-error,
.text-red-600 {
    color: #dc2626;
    /* Red-600 - 4.5:1 on white */
}

.bg-error,
.bg-red-600 {
    background-color: #dc2626;
    color: #ffffff;
    /* White - 4.5:1 on red */
}

/* Success states - minimum 4.5:1 contrast ratio */
.text-success,
.text-green-600 {
    color: #16a34a;
    /* Green-600 - 4.5:1 on white */
}

.bg-success,
.bg-green-600 {
    background-color: #16a34a;
    color: #ffffff;
    /* White - 4.5:1 on green */
}

/* ========================================
   ARIA Labels & Screen Readers
   ======================================== */

/* Hide decorative images from screen readers */
img[alt=""] {
    /* Already handled by alt="" */
}

/* Ensure icons are hidden from screen readers when decorative */
.material-icons[aria-hidden="true"],
.icon[aria-hidden="true"] {
    /* Already handled by aria-hidden */
}

/* Show content only to screen readers */
.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;
}

/* ========================================
   Touch Targets (Mobile)
   ======================================== */

/* Minimum 44x44px touch targets */
button,
.button,
a.button,
.modeo-product-card,
.filter-item,
.modeo-filter-item {
    min-height: 44px;
    min-width: 44px;
}

/* Ensure padding for touch targets */
button,
.button {
    padding: 12px 24px;
}

@media (max-width: 768px) {

    /* Larger touch targets on mobile */
    button,
    .button,
    a.button {
        min-height: 48px;
        padding: 14px 28px;
    }

    /* Mobile filter button - larger touch target */
    #mobile-filter-button {
        min-width: 56px;
        min-height: 56px;
        width: 56px;
        height: 56px;
    }

    /* Product gallery - touch-friendly */
    .product-image-gallery,
    .woocommerce-product-gallery {
        touch-action: pan-y pinch-zoom;
    }

    /* Thumbnails - larger touch targets */
    .product-thumbnail,
    .woocommerce-product-gallery__thumb {
        min-width: 60px;
        min-height: 60px;
    }
}

/* ========================================
   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;
    }
}

/* ========================================
   High Contrast Mode
   ======================================== */

@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }

    button,
    .button {
        border: 2px solid currentColor;
    }

    .modeo-product-card {
        border: 2px solid currentColor;
    }
}

/* ========================================
   Form Accessibility
   ======================================== */

/* Required field indicators */
.required-field::after {
    content: ' *';
    color: #dc2626;
    font-weight: bold;
}

/* Error states */
input:invalid:not(:focus):not(:placeholder-shown),
select:invalid:not(:focus):not(:placeholder-shown),
textarea:invalid:not(:focus):not(:placeholder-shown) {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Success states */
/* Success states removed as per user request */

/* ========================================
   Skip Links
   ======================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000000;
    color: #ffffff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
}

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

.category-button {
    min-width: auto;
    min-height: auto;
}