/**
 * MarineID Pro - Accessibility Enhancements (508 Compliance / WCAG 2.1 AA)
 * Ensures the application is accessible to users with disabilities
 */

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

/* Enhanced focus styles for keyboard navigation */
*:focus {
    outline: 3px solid #0077BE !important;
    outline-offset: 2px !important;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid #0077BE !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 119, 190, 0.2) !important;
}

/* Focus visible only for keyboard navigation (not mouse clicks) */
*:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

*:focus-visible {
    outline: 3px solid #0077BE !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 119, 190, 0.2) !important;
}

/* =======================
   SKIP LINKS
   ======================= */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    font-weight: bold;
    z-index: 10000;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #0077BE;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

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

@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }

    button,
    a,
    input,
    select,
    textarea {
        border: 2px solid currentColor !important;
    }

    .btn {
        border: 3px solid currentColor !important;
        font-weight: bold !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;
    }
}

/* =======================
   COLOR CONTRAST ENHANCEMENTS
   ======================= */

/* Ensure links have sufficient contrast */
a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* Button contrast improvements */
.btn,
button {
    font-weight: 600;
    min-height: 44px; /* Touch target size for accessibility */
    min-width: 44px;
}

/* =======================
   FORM ACCESSIBILITY
   ======================= */

/* Required field indicator */
.required::after {
    content: " *";
    color: #d32f2f;
    font-weight: bold;
}

/* Error messages */
.error-message {
    color: #d32f2f;
    background: #ffebee;
    border-left: 4px solid #d32f2f;
    padding: 12px;
    margin-top: 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Success messages */
.success-message {
    color: #2e7d32;
    background: #e8f5e9;
    border-left: 4px solid #2e7d32;
    padding: 12px;
    margin-top: 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Form input sizing for touch targets */
input,
textarea,
select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
}

/* =======================
   KEYBOARD NAVIGATION
   ======================= */

/* Ensure all interactive elements are keyboard accessible */
[role="button"],
[onclick],
[tabindex] {
    cursor: pointer;
}

[tabindex="-1"]:focus {
    outline: none !important;
}

/* Modal focus trap */
.modal[aria-modal="true"] {
    outline: none;
}

/* =======================
   ARIA LIVE REGIONS
   ======================= */

.aria-live {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* =======================
   TABLE ACCESSIBILITY
   ======================= */

table {
    border-collapse: collapse;
}

th {
    text-align: left;
    font-weight: bold;
}

caption {
    font-weight: bold;
    margin-bottom: 8px;
    text-align: left;
}

/* =======================
   IMAGE ACCESSIBILITY
   ======================= */

img {
    max-width: 100%;
    height: auto;
}

/* Indicate decorative images */
img[alt=""] {
    opacity: 1;
}

/* =======================
   HEADINGS HIERARCHY
   ======================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: bold;
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

h6 {
    font-size: 1.1rem;
}

/* =======================
   LOADING STATES
   ======================= */

[aria-busy="true"] {
    cursor: wait;
    opacity: 0.6;
}

/* =======================
   DARK MODE ACCESSIBILITY
   ======================= */

body.dark-mode {
    /* Ensure sufficient contrast in dark mode */
    color: #e0e0e0;
    background: #121212;
}

body.dark-mode a {
    color: #64b5f6;
}

body.dark-mode a:hover {
    color: #90caf9;
}

body.dark-mode button:focus,
body.dark-mode a:focus,
body.dark-mode input:focus {
    outline-color: #90caf9 !important;
}

/* =======================
   PRINT STYLES (Accessibility)
   ======================= */

@media print {
    * {
        color: #000 !important;
        background: #fff !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }

    /* Hide non-essential elements */
    nav,
    .no-print,
    button,
    .cookie-consent-banner {
        display: none !important;
    }
}

/* =======================
   RESPONSIVE TOUCH TARGETS
   ======================= */

@media (pointer: coarse) {
    /* Increase touch targets on touch devices */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 12px !important;
    }
}

/* =======================
   LANGUAGE SUPPORT
   ======================= */

[lang] {
    font-family: inherit;
}

/* Right-to-left language support */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* =======================
   STATUS MESSAGES
   ======================= */

[role="status"],
[role="alert"] {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 16px 0;
    font-weight: 600;
}

[role="alert"] {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
}

[role="status"] {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    color: #0c5460;
}

/* =======================
   LANDMARK ROLES
   ======================= */

[role="banner"],
[role="navigation"],
[role="main"],
[role="contentinfo"],
[role="complementary"] {
    display: block;
}

/* =======================
   TOOLTIPS ACCESSIBILITY
   ======================= */

[aria-describedby] {
    position: relative;
}

.tooltip {
    position: absolute;
    z-index: 1000;
    padding: 8px 12px;
    background: #333;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    max-width: 300px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
