/**
 * XRPL.Sale Accessibility Styles
 * Enhanced focus indicators, skip links, and accessibility features
 */

/* ===== SKIP LINKS ===== */
.skip-links {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    /* Hidden container to avoid any visible bar at the top */
    background: transparent;
    border: 0;
    padding: 0;
    height: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    background: #3b82f6;
    color: white !important;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    z-index: 10000;
}

.skip-link:focus-visible {
    top: 0.5rem;
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.skip-link:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* ===== ENHANCED FOCUS INDICATORS ===== */

/* Specific focus styles for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3) !important;
    border-radius: 6px !important;
}

/* Enhanced focus for branded buttons */
.btn-brand:focus-visible,
.bg-gradient-to-r:focus-visible {
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Focus for glass navigation elements */
.glass-nav a:focus-visible,
.glass-nav button:focus-visible {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px !important;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.3),
        0 4px 16px rgba(59, 130, 246, 0.2) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    transform: translateY(-1px) !important;
}

/* ===== SCREEN READER SUPPORT ===== */
.sr-only {
    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;
}

.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    border: inherit !important;
}

/* ===== LIVE REGION ===== */
#live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ===== HIGH CONTRAST MODE SUPPORT ===== */
@media (prefers-contrast: high) {
    *:focus-visible {
        outline: 3px solid #ffffff !important;
        outline-offset: 2px !important;
        background: rgba(0, 0, 0, 0.9) !important;
        color: #ffffff !important;
    }
    
    .skip-link {
        background: #000000 !important;
        color: #ffffff !important;
        border: 3px solid #ffffff !important;
    }
    
    .glass-nav {
        background: rgba(0, 0, 0, 0.95) !important;
        border-bottom: 3px solid #ffffff !important;
    }
    
    .glass-nav a,
    .glass-nav button {
        background: rgba(0, 0, 0, 0.9) !important;
        border: 2px solid rgba(255, 255, 255, 0.8) !important;
        color: #ffffff !important;
    }
    
    .glass-nav a:focus-visible,
    .glass-nav button:focus-visible {
        background: #ffffff !important;
        color: #000000 !important;
        outline: 3px solid #000000 !important;
    }
}

/* ===== REDUCED MOTION SUPPORT ===== */
@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;
    }
    
    .skip-link:focus-visible {
        transition: none !important;
    }

    button:focus-visible,
    a:focus-visible {
        transform: none !important;
        transition: none !important;
    }
}

/* ===== ENHANCED COLOR CONTRAST ===== */
/* Ensure minimum 4.5:1 contrast ratio for WCAG AA compliance */

/* Text contrast improvements */
.text-slate-400 {
    color: #94a3b8 !important; /* Improved from original for better contrast */
}

.text-slate-500 {
    color: #64748b !important; /* Improved contrast */
}

/* Glass morphism contrast improvements */
.glass-nav {
    background: rgba(15, 23, 42, 0.95) !important; /* Increased opacity for better contrast */
    backdrop-filter: blur(20px) saturate(180%);
}

.glass-nav a,
.glass-nav button {
    color: #ffffff !important;
    background: rgba(71, 85, 105, 0.4) !important; /* Better contrast base */
}

.glass-nav a:hover,
.glass-nav button:hover {
    background: rgba(59, 130, 246, 0.3) !important;
    color: #ffffff !important;
}

/* ===== FORM ACCESSIBILITY ===== */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: #3b82f6 !important;
    box-shadow: 
        0 0 0 3px rgba(59, 130, 246, 0.3),
        inset 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

input:invalid,
select:invalid,
textarea:invalid {
    border-color: #ef4444 !important;
    box-shadow: 
        0 0 0 3px rgba(239, 68, 68, 0.3),
        inset 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

/* ===== MODAL ACCESSIBILITY ===== */
[role="dialog"] {
    border: 2px solid rgba(59, 130, 246, 0.3);
}

[role="dialog"]:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* ===== DROPDOWN ACCESSIBILITY ===== */
[role="menu"],
.dropdown-menu {
    border: 1px solid rgba(59, 130, 246, 0.3);
}

[role="menuitem"]:focus-visible,
.dropdown-menu a:focus-visible,
.dropdown-menu button:focus-visible {
    background: rgba(59, 130, 246, 0.1) !important;
    outline: 2px solid #3b82f6 !important;
    outline-offset: -2px !important;
}

/* ===== KEYBOARD NAVIGATION INDICATORS ===== */
.keyboard-navigation-active *:focus-visible {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2) !important;
}

/* ===== ANNOUNCEMENTS ===== */
.accessibility-announcement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    color: #ffffff;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    border: 2px solid #3b82f6;
    z-index: 10001;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.accessibility-announcement.show {
    opacity: 1;
}

/* ===== RESPONSIVE ACCESSIBILITY ===== */
@media (max-width: 768px) {
    .skip-link {
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        text-align: center;
    }
    
    button:focus-visible,
    a:focus-visible {
        outline-offset: 1px !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3) !important;
    }
}

/* ===== DARK MODE ACCESSIBILITY ===== */
@media (prefers-color-scheme: dark) {
    .skip-link {
        background: #1e40af;
        border-color: #3b82f6;
    }
    
    .skip-link:focus-visible {
        outline-color: #60a5fa;
        box-shadow: 0 4px 12px rgba(96, 165, 250, 0.4);
    }
}

/* ===== PRINT ACCESSIBILITY ===== */
@media print {
    .skip-links,
    #live-region,
    .accessibility-announcement {
        display: none !important;
    }
    
    *:focus-visible {
        outline: none !important;
        box-shadow: none !important;
    }
}

/* ===== ACCESSIBILITY SETTINGS MODAL ===== */
#accessibility-settings-modal {
    backdrop-filter: blur(8px);
}

#accessibility-settings-modal .bg-slate-800 {
    background: rgba(30, 41, 59, 0.95) !important;
    border: 2px solid rgba(59, 130, 246, 0.3);
}

#accessibility-settings-modal input[type="checkbox"] {
    background: rgba(71, 85, 105, 0.5);
    border: 2px solid #475569;
    width: 1.25rem;
    height: 1.25rem;
}

#accessibility-settings-modal input[type="checkbox"]:checked {
    background: #3b82f6;
    border-color: #3b82f6;
}

#accessibility-settings-modal input[type="checkbox"]:focus-visible {
    outline: 2px solid #60a5fa !important;
    outline-offset: 2px !important;
}

/* ===== HIGH CONTRAST MODE ===== */
.accessibility-high-contrast {
    filter: contrast(150%) brightness(120%);
}

.accessibility-high-contrast .glass-nav,
.accessibility-high-contrast .bg-slate-800,
.accessibility-high-contrast .bg-slate-900 {
    background: #000000 !important;
    border: 2px solid #ffffff !important;
}

.accessibility-high-contrast .text-slate-400,
.accessibility-high-contrast .text-slate-500 {
    color: #ffffff !important;
}

.accessibility-high-contrast button:focus-visible,
.accessibility-high-contrast a:focus-visible {
    outline: 3px solid #ffff00 !important;
    background: #000000 !important;
    color: #ffffff !important;
}

/* ===== DARK MODE OVERRIDE ===== */
.accessibility-dark-mode {
    background: #000000 !important;
    color: #ffffff !important;
}

.accessibility-dark-mode * {
    background-color: inherit !important;
    color: inherit !important;
}

.accessibility-dark-mode .bg-white {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

/* ===== REDUCED MOTION ===== */
.accessibility-reduce-motion *,
.accessibility-reduce-motion *::before,
.accessibility-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* ===== ACCESSIBILITY NOTIFICATIONS ===== */
.accessibility-notification {
    animation: slideInRight 0.3s ease-out;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.accessibility-reduce-motion .accessibility-notification {
    animation: none !important;
}

/* ===== SECTION NAVIGATION INDICATORS ===== */
.section-navigation-indicator {
    position: fixed;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.section-navigation-indicator.show {
    opacity: 1;
}

.section-navigation-indicator .indicator {
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid #3b82f6;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ===== FOCUSED SECTION HIGHLIGHT ===== */
.accessibility-focused-section {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 4px !important;
    background: rgba(59, 130, 246, 0.05) !important;
    border-radius: 8px !important;
}

/* ===== CONTEXTUAL HELP TOOLTIP ===== */
.accessibility-help-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 2px solid #3b82f6;
    font-size: 0.875rem;
    max-width: 250px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.accessibility-help-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 1rem;
    border: 6px solid transparent;
    border-top-color: #3b82f6;
}

/* ===== FONT SIZE CONTROLS ===== */
.accessibility-font-size-controls {
    position: fixed;
    top: 4rem;
    right: 1rem;
    z-index: 40;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.accessibility-font-size-controls.show {
    opacity: 1;
    pointer-events: auto;
}

.accessibility-font-size-controls button {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 2px solid #3b82f6 !important;
    color: #ffffff !important;
    padding: 0.5rem !important;
    border-radius: 0.375rem !important;
    font-weight: 600 !important;
    min-width: 2.5rem !important;
}

.accessibility-font-size-controls button:hover {
    background: rgba(59, 130, 246, 0.2) !important;
}

/* ===== ENHANCED FOCUS FOR SPECIFIC ELEMENTS ===== */
.accessibility-focus-enhanced [tabindex="0"]:focus,
.accessibility-focus-enhanced [contenteditable="true"]:focus {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2) !important;
}

/* ===== MOBILE ACCESSIBILITY ENHANCEMENTS ===== */
@media (max-width: 768px) {
    .accessibility-notification {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    .section-navigation-indicator {
        left: 0.5rem;
    }
    
    .accessibility-font-size-controls {
        top: auto;
        bottom: 5rem;
        right: 0.5rem;
        flex-direction: column;
    }
    
    #accessibility-settings-modal .bg-slate-800 {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
}