/* ==================================================
   Accessibility & UX Enhancements
   Covers WCAG Level A compliance, loading states,
   mobile optimization, and screen reader support
   ================================================== */

/* ==================================================
   1. SKIP NAVIGATION LINK (WCAG 2.4.1 Level A)
   ================================================== */

.skip-link {
    position: absolute;
    top: -100px; /* Must be greater than element height (~45px) to be fully hidden */
    left: 0;
    z-index: 10000;
    padding: 8px 16px;
    background-color: #000;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 4px 0;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #4a9eff;
    outline-offset: 2px;
}

/* ==================================================
   2. ARIA LIVE REGIONS (WCAG 4.1.3 Level A)
   ================================================== */

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

.aria-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Cart notification styles (visible to all users) */
.cart-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.cart-notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* ==================================================
   3. FORM ERROR ASSOCIATIONS (WCAG 3.3.1 Level A)
   ================================================== */

.form-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 4px;
    display: block;
}

.form-input-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2;
}

.form-input-error:focus {
    outline-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* ==================================================
   4. LOADING STATES
   ================================================== */

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}

@keyframes btn-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton screens */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 80%;
}

.skeleton-image {
    width: 100%;
    height: 200px;
}

.skeleton-button {
    height: 48px;
    width: 120px;
}

/* Product card skeleton */
.product-skeleton {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.product-skeleton .skeleton-image {
    height: 240px;
    margin-bottom: 12px;
}

/* ==================================================
   5. MOBILE OPTIMIZATION & TOUCH TARGETS
   ================================================== */

/* Minimum touch target size: 48x48px (WCAG 2.5.5 Level AAA) */
.btn,
button,
.button,
a.button,
input[type="submit"],
input[type="button"] {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 24px;
    touch-action: manipulation; /* Prevents double-tap zoom */
}

/* Touch-friendly form inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea,
select {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* Mobile navigation */
.mobile-menu-toggle {
    display: none;
    width: 48px;
    height: 48px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 6px;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 24px;
        height: 2px;
        background-color: currentColor;
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    /* Mobile navigation drawer */
    .mobile-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: white;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        padding: 80px 24px 24px;
    }

    .mobile-nav.active {
        right: 0;
    }

    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 999;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Hide desktop nav on mobile */
    .desktop-nav {
        display: none;
    }

    .mobile-nav nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-nav nav ul li {
        border-bottom: 1px solid #e5e7eb;
    }

    .mobile-nav nav ul li a {
        display: block;
        padding: 16px 0;
        color: #1f2937;
        text-decoration: none;
        font-size: 18px;
        transition: color 0.2s ease;
    }

    .mobile-nav nav ul li a:hover,
    .mobile-nav nav ul li a:focus {
        color: #3b82f6;
    }
}

/* ==================================================
   6. FOCUS INDICATORS (WCAG 2.4.7 Level AA)
   ================================================== */

*:focus {
    outline: 3px solid #4a9eff;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid #4a9eff;
    outline-offset: 2px;
}

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

*:focus-visible {
    outline: 3px solid #4a9eff;
    outline-offset: 2px;
}

/* ==================================================
   7. HIGH CONTRAST MODE SUPPORT
   ================================================== */

@media (prefers-contrast: high) {
    .btn,
    button {
        border: 2px solid currentColor;
    }

    .form-error {
        font-weight: bold;
    }
}

/* ==================================================
   8. REDUCED MOTION SUPPORT (WCAG 2.3.3 Level AAA)
   ================================================== */

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

    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
}

/* ==================================================
   9. PRINT STYLES
   ================================================== */

@media print {
    .skip-link,
    .mobile-menu-toggle,
    .mobile-nav,
    .mobile-overlay,
    .cart-notification {
        display: none !important;
    }
}
