/*
 * =============================================================================
 * Copyright (c) 2026 Paseo Platform LLC. All rights reserved.
 *
 * CONFIDENTIAL AND PROPRIETARY
 *
 * This file is part of the Paseo Platform software system and constitutes
 * proprietary trade secret information of Paseo Platform LLC. This source
 * code is protected under applicable trade secret laws and may not be
 * copied, modified, distributed, or disclosed without the express written
 * permission of Paseo Platform LLC.
 *
 * For licensing inquiries: www.paseoplatform.com
 * =============================================================================
 */

/**
 * Paseo Platform - Accessibility Enhancements
 * Section 6: Accessibility Compliance
 * WCAG 2.1 AAA Level Compliance Styles
 * Version: 3.0.0
 */

/* ===================================================================
   SKIP LINKS (WCAG 2.4.1)
   Bypass blocks for keyboard navigation
   =================================================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    z-index: 9999;
    padding: 12px 24px;
    background: var(--color-primary, #4527a0);
    color: var(--color-white, #FFFFFF);
    font-weight: var(--font-semibold, 600);
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--color-accent, #7c4dff);
    outline-offset: 2px;
}

.skip-link-group {
    position: absolute;
    top: -100px;
    left: 0;
    z-index: 9999;
    display: flex;
    gap: 4px;
}

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

/* ===================================================================
   FOCUS INDICATORS (WCAG 2.4.7)
   Enhanced focus visibility for all interactive elements
   =================================================================== */

*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--color-accent, #7c4dff);
    outline-offset: 2px;
    border-radius: var(--radius-sm, 4px);
}

/* Specific focus styles for buttons */
.btn:focus-visible,
button:focus-visible {
    outline: 3px solid var(--color-accent, #7c4dff);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(124, 77, 255, 0.2);
}

/* Focus styles for links */
a:focus-visible {
    outline: 3px solid var(--color-accent, #7c4dff);
    outline-offset: 2px;
    text-decoration: underline;
}

/* Focus styles for form inputs */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--color-primary, #4527a0);
    box-shadow: 0 0 0 3px rgba(69, 39, 160, 0.15),
                0 0 0 6px rgba(124, 77, 255, 0.2);
}

/* Focus styles for checkboxes and radio buttons */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid var(--color-accent, #7c4dff);
    outline-offset: 2px;
}

/* ===================================================================
   COLOR CONTRAST (WCAG 1.4.3, 1.4.6)
   AAA Level: 7:1 for normal text, 4.5:1 for large text
   =================================================================== */

/* High contrast text colors */
.text-high-contrast {
    color: var(--color-black, #111827) !important;
}

.text-high-contrast-inverse {
    color: var(--color-white, #FFFFFF) !important;
}

/* AAA compliant link colors */
.link-accessible {
    color: #0747a6; /* 7.2:1 contrast on white */
    text-decoration: underline;
}

.link-accessible:hover {
    color: #053580;
}

/* AAA compliant muted text */
.text-muted-accessible {
    color: #4a5157; /* 7:1 contrast on white */
}

/* ===================================================================
   TEXT SIZING (WCAG 1.4.4)
   Support for 200% text zoom without loss of functionality
   =================================================================== */

/* Ensure text scales properly */
html {
    font-size: 100%; /* Respect user preferences */
}

body {
    font-size: 1rem;
    line-height: 1.6;
}

/* Minimum touch target size (WCAG 2.5.5) */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===================================================================
   REDUCED MOTION (WCAG 2.3.3)
   Respect user motion preferences
   =================================================================== */

@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;
    }
}

/* ===================================================================
   FORM ACCESSIBILITY (WCAG 3.3)
   Error identification and prevention
   =================================================================== */

/* Error states with multiple cues */
.field-error {
    border-color: var(--color-danger, #EF4444) !important;
    border-width: 2px;
    background-color: #FEF2F2;
}

.field-error::before {
    content: "!";
    position: absolute;
    left: -24px;
    width: 16px;
    height: 16px;
    background: var(--color-danger, #EF4444);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-message {
    color: var(--color-danger-dark, #991B1B);
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-message::before {
    content: "";
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23991B1B'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E") no-repeat center;
    flex-shrink: 0;
}

/* Required field indicators */
.required-indicator::after {
    content: " *";
    color: var(--color-danger, #EF4444);
    font-weight: normal;
}

/* Visual required field legend */
.required-legend {
    font-size: 0.875rem;
    color: var(--color-gray-600, #4B5563);
    margin-bottom: 16px;
}

.required-legend .asterisk {
    color: var(--color-danger, #EF4444);
    font-weight: bold;
}

/* ===================================================================
   SCREEN READER ONLY (WCAG)
   Visually hidden but accessible to screen readers
   =================================================================== */

.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: normal;
}

/* ===================================================================
   LIVE REGIONS (WCAG 4.1.3)
   Announce dynamic content changes
   =================================================================== */

.live-region {
    position: relative;
}

[aria-live="polite"],
[aria-live="assertive"] {
    /* Ensure content changes are announced */
}

.status-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ===================================================================
   IMAGES AND ICONS (WCAG 1.1.1)
   =================================================================== */

/* Decorative images should be hidden from AT */
img[alt=""],
[role="presentation"],
[aria-hidden="true"] {
    speak: never;
}

/* Ensure icons have proper aria labels */
.icon-only {
    font-size: 0;
    line-height: 0;
}

.icon-only::before {
    font-size: 1.25rem;
    line-height: 1;
}

/* ===================================================================
   TABLE ACCESSIBILITY (WCAG 1.3.1)
   =================================================================== */

.table-accessible {
    border-collapse: collapse;
    width: 100%;
}

.table-accessible caption {
    caption-side: top;
    text-align: left;
    font-weight: var(--font-semibold, 600);
    padding: 12px 0;
    color: var(--color-gray-800, #1F2937);
}

.table-accessible th {
    text-align: left;
    background: var(--color-gray-50, #F9FAFB);
    font-weight: var(--font-semibold, 600);
}

.table-accessible th,
.table-accessible td {
    padding: 12px 16px;
    border: 1px solid var(--color-gray-200, #E1E7ED);
}

/* Row headers */
.table-accessible th[scope="row"] {
    background: transparent;
    font-weight: var(--font-medium, 500);
}

/* ===================================================================
   MODAL ACCESSIBILITY (WCAG 2.4.3)
   Focus trapping and keyboard navigation
   =================================================================== */

.modal-accessible {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.modal-accessible[aria-hidden="true"] {
    display: none;
}

.modal-accessible-content {
    background: var(--color-white, #FFFFFF);
    border-radius: var(--radius-lg, 12px);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.modal-accessible-content:focus {
    outline: none;
}

/* Close button in top right */
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    color: var(--color-gray-500, #6B7280);
    transition: background 0.15s ease;
}

.modal-close:hover {
    background: var(--color-gray-100, #F0F3F6);
}

.modal-close:focus-visible {
    outline: 3px solid var(--color-accent, #7c4dff);
    outline-offset: 2px;
}

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

@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }

    a {
        text-decoration: underline !important;
    }

    button,
    .btn {
        border: 2px solid currentColor !important;
    }

    :focus-visible {
        outline: 3px solid currentColor !important;
        outline-offset: 3px !important;
    }
}

/* ===================================================================
   FORCED COLORS MODE (Windows High Contrast)
   =================================================================== */

@media (forced-colors: active) {
    .btn-primary,
    .btn-accent {
        forced-color-adjust: none;
        background: ButtonFace;
        color: ButtonText;
        border: 2px solid ButtonText;
    }

    a {
        color: LinkText;
    }

    :focus-visible {
        outline: 3px solid Highlight !important;
    }
}

/* ===================================================================
   PRINT ACCESSIBILITY
   =================================================================== */

@media print {
    /* Ensure links show URLs */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }

    /* Remove decorative elements */
    .decorative,
    [aria-hidden="true"]:not(svg) {
        display: none !important;
    }

    /* Ensure sufficient contrast */
    * {
        color: #000 !important;
        background: #fff !important;
    }
}
