/**
 * Kelid Sazi - Accessibility Styles
 *
 * Accessibility enhancements and fixes:
 * - Enhanced focus states
 * - Screen reader improvements
 * - Reduced motion
 * - Touch target sizing
 * - Skip links
 * - Print styles
 *
 * @package KelidSazi
 * @since   1.0.0
 */

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

/* Global focus visible */
:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: 3px;
    z-index: 1;
    position: relative;
}

/* Inline elements should have tighter focus */
a:focus-visible,
button:focus-visible {
    outline-offset: 2px;
}

/* Dark background elements */
.site-footer :focus-visible,
.hero :focus-visible,
.cta-section :focus-visible,
.site-footer a:focus-visible {
    outline-color: var(--color-white);
}

/* Form elements */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-100);
}

/* Never hide focus outline */
:focus:not(:focus-visible) {
    outline: none;
}

/* Focus within - parent highlights when child is focused */
.product-card:focus-within,
.post-card:focus-within,
.service-card:focus-within {
    box-shadow: 0 0 0 3px var(--color-primary-100), var(--shadow-md);
}

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

.skip-link {
    position: absolute;
    top: -100%;
    inset-inline-start: var(--space-4);
    z-index: 10000;
    padding: var(--space-3) var(--space-5);
    background-color: var(--color-primary);
    color: var(--color-white) !important;
    font-weight: var(--font-bold);
    font-size: var(--text-base);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: top 0.1s ease;
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    top: var(--space-4);
    outline: 3px solid var(--color-white);
    outline-offset: 2px;
}

/* Additional skip links */
.skip-to-products,
.skip-to-filters {
    composes: skip-link;
}

/* ============================================
   SCREEN READER IMPROVEMENTS
   ============================================ */

.screen-reader-text,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Screen reader text that becomes visible on focus */
.screen-reader-text:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Visually hidden but not for screen readers */
.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;
}

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

    /* Ensure content is still accessible without animations */
    .product-card:hover .product-card__image img,
    .service-card:hover .service-card__image img {
        transform: none;
    }

    /* Fade-in animations become instant */
    [class*="fade-in"],
    [class*="animate-"] {
        opacity: 1 !important;
        transform: none !important;
    }

    /* Carousels and sliders should not auto-play */
    .product-gallery__thumbnails {
        scroll-behavior: auto;
    }
}

/* ============================================
   TOUCH TARGET SIZING
   ============================================ */

/* Minimum 44x44px touch targets (WCAG 2.5.5) */
@media (pointer: coarse) {
    a,
    button,
    input[type="submit"],
    input[type="button"],
    input[type="reset"],
    .product-gallery__thumb,
    .quantity-control__btn,
    .mini-cart__link,
    .header-actions__account,
    .header-search__toggle,
    .primary-navigation__toggle,
    .pagination .page-numbers,
    .mobile-navigation__close {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Inline links in text */
    p a,
    li a {
        min-height: auto;
        min-width: auto;
        padding: var(--space-1) 0;
    }

    /* Ensure spacing between touch targets */
    .header-actions {
        gap: var(--space-3);
    }

    .pagination {
        gap: var(--space-2);
    }

    .pagination .page-numbers {
        padding: var(--space-2) var(--space-3);
    }

    /* Spacing for stacked mobile elements */
    .mobile-navigation__menu a {
        min-height: 48px;
        padding: var(--space-3) var(--space-4);
    }
}

/* ============================================
   COLOR CONTRAST ENHANCEMENTS
   ============================================ */

/* Ensure links are distinguishable by more than color */
a:not(.btn):not(.product-card__link):not(.service-card__link) {
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:not(.btn):not(.product-card__link):not(.service-card__link):hover {
    text-decoration-thickness: 2px;
}

/* Placeholder text must meet contrast */
::placeholder {
    color: var(--color-gray-400);
    opacity: 1;
}

/* Disabled buttons */
button:disabled,
input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Required field indicator */
.required {
    color: var(--color-danger);
    font-weight: var(--font-bold);
}

/* ============================================
   ARIA ENHANCEMENTS
   ============================================ */

/* aria-current page indicator */
[aria-current="page"] {
    font-weight: var(--font-bold);
    color: var(--color-primary);
}

/* aria-expanded indicators */
[aria-expanded="true"] .dropdown-toggle svg,
[aria-expanded="true"] .faq-accordion__icon svg {
    transform: rotate(180deg);
}

/* aria-busy loading states */
[aria-busy="true"] {
    cursor: wait;
    opacity: 0.7;
    pointer-events: none;
}

/* aria-live regions */
[aria-live="polite"] {
    /* Allow for smooth announcements */
}

[aria-live="assertive"] {
    /* Bold announcements */
    font-weight: var(--font-bold);
}

/* ============================================
   FORM ACCESSIBILITY
   ============================================ */

/* Ensure form labels are associated */
label {
    display: block;
    font-weight: var(--font-medium);
    margin-bottom: var(--space-1);
    color: var(--color-gray-700);
    cursor: pointer;
}

/* Error states */
.has-error {
    border-color: var(--color-danger) !important;
}

.field-error,
.contact-form__error {
    color: var(--color-danger);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
    display: block;
}

/* Success states */
.has-success {
    border-color: var(--color-success) !important;
}

/* Checkbox and radio labels */
input[type="checkbox"] + label,
input[type="radio"] + label {
    display: inline;
    margin-inline-start: var(--space-2);
}

/* Fieldset and legend */
fieldset {
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

legend {
    font-weight: var(--font-bold);
    padding: 0 var(--space-2);
}

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

/* Ensure all interactive elements have visible focus */
a[href],
button,
input,
select,
textarea,
[tabindex]:not([tabindex="-1"]) {
    /* These are inherently focusable; focus styles above */
}

/* Indicate keyboard-only styles */
.js .keyboard-focus :focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
}

/* Remove focus ring for mouse users (handled by :focus-visible) */
.mouse-focus :focus:not(:focus-visible) {
    outline: none;
}

/* Skip navigation link animation */
@keyframes skip-link-slide-in {
    from {
        top: -100%;
    }
    to {
        top: var(--space-4);
    }
}

.skip-link:focus {
    animation: skip-link-slide-in 0.2s ease forwards;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    /* Hide navigation and interactive elements */
    .site-header,
    .site-footer,
    .primary-navigation,
    .mobile-navigation,
    .header-search,
    .mini-cart,
    .header-actions,
    .skip-link,
    .pagination,
    .related-posts,
    .related-products,
    .related-services,
    .comments-area,
    .sidebar,
    .product-card__actions,
    .single_add_to_cart_button,
    .quantity-control__btn,
    .no-print,
    .breadcrumbs {
        display: none !important;
    }

    /* Reset layout */
    body {
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
        background: #fff;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    /* Links */
    a {
        color: #000;
        text-decoration: underline;
    }

    /* Show URLs after links */
    a[href^="http"]:not([href*="kelidsazi"]):after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Images */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    /* Typography */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    p, li, blockquote {
        orphans: 3;
        widows: 3;
    }

    /* Tables */
    table {
        border-collapse: collapse;
    }

    th, td {
        border: 1px solid #ccc;
        padding: 8px;
    }

    /* Product grid */
    .woocommerce-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}