/**
 * Custom CSS Utilities for Accessibility and UX
 * Complements Tailwind CSS with additional utilities
 */

/* ==========================================================================
   Screen Reader Only - Visually hidden but accessible
   ========================================================================== */
.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;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: inherit;
}

/* ==========================================================================
   Skeleton Loading States
   ========================================================================== */
.skeleton {
    pointer-events: none;
    user-select: none;
}

.skeleton-line,
.skeleton-text {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    height: 16px;
    margin: 8px 0;
}

.skeleton-text {
    width: 100%;
}

.skeleton-line.short { width: 25%; }
.skeleton-line.medium { width: 50%; }
.skeleton-line.long { width: 75%; }
.skeleton-line.full { width: 100%; }

.skeleton-circle {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 50%;
}

.skeleton-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    margin: 8px 0;
}

.skeleton-card .skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-card .skeleton-content {
    height: 16px;
    width: 100%;
    margin: 8px 0;
}

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

/* ==========================================================================
   Focus Styles - Enhanced visibility
   ========================================================================== */
.focus-ring {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.focus-ring-inset {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* High contrast focus for dark backgrounds */
.focus-ring-white {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ==========================================================================
   Skip Link - For keyboard navigation
   ========================================================================== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e40af;
    color: white;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    font-weight: 600;
    z-index: 9999;
    transition: top 0.2s;
}

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

/* ==========================================================================
   Modal/Dialog Utilities
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 9999;
}

/* ==========================================================================
   Reduced Motion - Accessibility
   ========================================================================== */
@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 Support
   ========================================================================== */
@media (prefers-contrast: high) {
    .focus-ring {
        outline-width: 3px;
    }
    
    button,
    a {
        border: 2px solid currentColor;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .no-print,
    .skip-link,
    #cookieBanner,
    [inert] {
        display: none !important;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}
