/**
 * Hello Middleton - Accessibility Enhancements
 * Skip links, reduced motion, high contrast, focus states
 *
 * @requires tokens.css
 * @since 2.1.4
 */

/* ==========================================================================
   SKIP TO CONTENT LINK
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--hm-primary);
    color: white;
    padding: var(--space-3) var(--space-4);
    z-index: 10000;
    transition: top var(--duration-fast);
    font-weight: 600;
    text-decoration: none;
}

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

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Specific component overrides */
    .hm-ticker-track {
        animation: none;
    }

    /* Disable scroll-triggered animations */
    .fade-in,
    .slide-up,
    .scale-in {
        opacity: 1 !important;
        transform: none !important;
    }
}

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

@media (prefers-contrast: high) {
    /* Increase border visibility on cards */
    .unh-card,
    .ct-card,
    .sidebar-events,
    .sidebar-classifieds,
    .lc-card,
    .rank-card,
    .rule {
        border-width: 2px;
    }

    /* More visible active states */
    .unh-tab.active,
    .wnh-tab.active {
        border-width: 3px;
    }

    /* Ensure sufficient color contrast */
    .text-muted,
    [class*="-muted"],
    [class*="-secondary"] {
        color: #44403C !important;
    }

    /* High contrast buttons */
    button,
    .button,
    .btn {
        border-width: 2px;
    }

    /* Links more visible */
    a {
        text-decoration-thickness: 2px;
    }
}

/* ==========================================================================
   FOCUS STATES - Desktop
   ========================================================================== */

/* Focus states - accessibility */
:focus-visible {
    outline: 2px solid var(--hm-primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Card focus-within for keyboard navigation */
.ct-card:focus-within,
.unh-card:focus-within,
.wnh-card:focus-within,
.lc-card:focus-within {
    outline: 2px solid var(--hm-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   FOCUS STATES - Mobile
   ========================================================================== */

@media (max-width: 768px) {
    /* Visible focus states */
    :focus-visible {
        outline: 3px solid var(--hm-primary, #B45309) !important;
        outline-offset: 2px !important;
    }

    /* Remove focus outline on tap (touch devices handle this differently) */
    :focus:not(:focus-visible) {
        outline: none !important;
    }
}

/* ==========================================================================
   TOUCH DEVICE OPTIMIZATIONS
   ========================================================================== */

@media (pointer: coarse) {
    /* Larger touch targets for coarse pointers (fingers) */
    .lc-btn,
    .lc-action-btn,
    .unh-tab,
    .wnh-tab {
        min-height: 48px !important;
    }

    /* Disable hover transforms on touch devices */
    .lc-card:hover,
    .lc-action-btn:hover,
    .unh-card:hover,
    .wnh-card:hover {
        transform: none !important;
    }

    /* Add active state feedback instead */
    .lc-card:active,
    .lc-action-btn:active {
        transform: scale(0.98) !important;
        opacity: 0.9 !important;
    }
}

/* ==========================================================================
   TOUCH UTILITIES - Mobile
   ========================================================================== */

@media (max-width: 768px) {
    /* Disable hover transforms on touch-only devices */
    @media (hover: none) {
        *:hover {
            transform: none !important;
        }
    }

    /* Active state feedback */
    a:active,
    button:active {
        opacity: 0.85 !important;
        transform: scale(0.98) !important;
    }

    /* Prevent text selection on buttons */
    button,
    a {
        -webkit-user-select: none !important;
        user-select: none !important;
    }

    /* Custom tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(180, 83, 9, 0.1) !important;
    }
}

/* ==========================================================================
   SCREEN READER ONLY
   ========================================================================== */

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

/* Allow focus on screen reader elements when focused */
.sr-only:focus,
.screen-reader-text:focus,
.visually-hidden:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ==========================================================================
   COLOR BLINDNESS CONSIDERATIONS
   ========================================================================== */

/* Don't rely solely on color - add patterns/icons for status */
.status-success::before,
.status-error::before,
.status-warning::before {
    margin-right: 6px;
}

.status-success::before {
    content: "✓ ";
}

.status-error::before {
    content: "✗ ";
}

.status-warning::before {
    content: "⚠ ";
}

/* ==========================================================================
   PRINT STYLES - Accessibility
   ========================================================================== */

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

    /* Ensure links show their URLs */
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        font-weight: normal;
    }

    /* Hide purely decorative elements */
    [aria-hidden="true"] {
        display: none !important;
    }
}
