/**
 * Accessibility Utilities
 * 
 * Screen reader only content, focus management, and WCAG compliance utilities
 */

@use '../abstracts' as *;

// Screen reader only content
.presszone-comments-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;
}

// Focus management
.presszone-comments-focus-trap {
    // Ensure focus stays within modals
    &:focus {
        outline: none;
    }
}

// Enhanced focus indicators
.presszone-comments-btn,
.presszone-comments-action,
.presszone-comments-vote-btn,
.presszone-comments-tool-btn,
.presszone-comments-editable,
.presszone-comments-title-input {
    &:focus {
        outline: 2px solid $presszone-comments-primary;
        outline-offset: 2px;
        box-shadow: 0 0 0 2px rgba(31, 113, 221, 0.2);
    }
    
    &:focus:not(:focus-visible) {
        outline: none;
        box-shadow: none;
    }
    
    &:focus-visible {
        outline: 2px solid $presszone-comments-primary;
        outline-offset: 2px;
        box-shadow: 0 0 0 2px rgba(31, 113, 221, 0.2);
    }
}

// High contrast mode support
@media (prefers-contrast: high) {
    .presszone-comments-btn,
    .presszone-comments-action,
    .presszone-comments-vote-btn {
        border: 2px solid currentColor;
        
        &:focus {
            outline: 3px solid;
            outline-offset: 2px;
        }
    }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {
    .presszone-comments-btn,
    .presszone-comments-action,
    .presszone-comments-vote-btn,
    .presszone-comments-modal,
    .presszone-comments-toast {
        transition: none !important;
        animation: none !important;
    }
}

// Color contrast improvements for inherit theme
.presszone-comments-theme--inherit {
    // Ensure minimum contrast ratios
    .presszone-comments-text-muted {
        opacity: 0.8;
        font-weight: 500; // Slightly bolder for better readability
    }
    
    .presszone-comments-btn--ghost {
        background: rgba(128, 128, 128, 0.1);
        border: 1px solid rgba(128, 128, 128, 0.3);
        
        &:hover {
            background: rgba(128, 128, 128, 0.2);
        }
    }
    
    // Ensure vote buttons have sufficient contrast
    .presszone-comments-vote-btn {
        background: rgba(128, 128, 128, 0.1);
        border: 1px solid rgba(128, 128, 128, 0.2);
        
        &:hover {
            background: rgba(128, 128, 128, 0.15);
        }
        
        &.presszone-comments-active {
            background: $presszone-comments-primary;
            color: white;
            border-color: $presszone-comments-primary;
        }
    }
}

// Field descriptions and labels
.presszone-comments-field-description {
    font-size: $presszone-comments-font-size-sm;
    margin-top: $presszone-comments-spacing-xs;
    margin-bottom: $presszone-comments-spacing-md;
    
    @include theme-props(('color': 'text-muted'));
}

.presszone-comments-title-label,
.presszone-comments-editor-label {
    display: block;
    font-weight: 600;
    margin-bottom: $presszone-comments-spacing-xs;
    
    @include theme-props(('color': 'text-primary'));
}

// Required field indicator
.presszone-comments-required-indicator {
    color: $presszone-comments-error;
    font-weight: 700;
}

// Confirm modal message
.presszone-comments-confirm-message {
    font-size: $presszone-comments-font-size-base;
    line-height: 1.6;
    margin: 0;
    
    @include theme-props(('color': 'text-primary'));
}

// Skip link for keyboard navigation - improved robustness
.presszone-comments-skip-link {
    position: absolute;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
    
    background: $presszone-comments-primary;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    font-size: 14px;
    font-weight: 600;
    
    &:focus {
        clip: auto;
        clip-path: none;
        width: auto;
        height: auto;
        margin: 0;
        padding: 8px 16px;
        top: 6px;
        left: 6px;
        outline: 3px solid $presszone-comments-primary;
        outline-offset: 2px;

        // Mobile adjustment to prevent obscuring content
        @media (max-width: #{$presszone-comments-breakpoint-sm}) {
            top: 60px;
        }
    }
}
