/**
 * WCAG 2.1 Level AA Compliance Styles
 * Ensures color contrast ratios of 4.5:1 for normal text
 * and 3:1 for large text
 */

/* Updated color variables for WCAG compliance */
:root {
    /* Primary colors - maintain brand while ensuring contrast */
    --primary: #0070f3;
    --primary-dark: #0051a8;
    --primary-light: #3b9eff;

    /* Secondary - adjusted for 4.5:1 contrast on dark */
    --secondary: #00d4aa;
    --secondary-dark: #00a88a;

    /* Background colors */
    --dark: #0a1628;
    --darker: #050d1a;

    /* Text colors - WCAG compliant */
    --light: #e4e8f0;
    --gray: #9ca3af; /* Updated from #6b7280 for 4.5:1 contrast */
    --gray-light: #d1d5db;
    --white: #ffffff;

    /* Focus indicator color - high contrast */
    --focus-color: #fbbf24;
    --focus-outline: 3px solid var(--focus-color);

    /* Error/Success colors */
    --error: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
}

/* Enhanced focus indicators for keyboard navigation */
*:focus {
    outline: var(--focus-outline);
    outline-offset: 3px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 3px;
}

/* Skip link - visible on focus */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: var(--focus-outline);
    outline-offset: -3px;
}

/* Ensure text has proper contrast */
body {
    color: var(--light);
    background-color: var(--darker);
}

/* Links - ensure visible focus and hover states */
a {
    color: var(--primary-light);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--secondary);
    text-decoration-thickness: 2px;
}

a:focus-visible {
    outline: var(--focus-outline);
    border-radius: 4px;
}

/* Buttons - high contrast states */
button,
.btn {
    min-height: 44px; /* WCAG touch target size */
    min-width: 44px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:focus-visible,
.btn:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 3px;
}

button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form inputs - accessible styling */
input,
select,
textarea {
    min-height: 44px;
    padding: 12px 16px;
    border: 2px solid var(--gray);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--light);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.3);
    outline: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--gray);
    opacity: 1;
}

/* Error states */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--error);
}

input[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.3);
}

/* Labels - ensure association */
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--light);
}

/* Required field indicator */
label[data-required]::after {
    content: " *";
    color: var(--error);
}

/* Error messages */
.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 4px;
}

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

/* Reduced motion preference */
@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: more) {
    :root {
        --gray: #ffffff;
        --primary: #4da6ff;
        --secondary: #33ffcc;
    }

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

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

/* Print styles - ensure readability */
@media print {
    body {
        color: #000000;
        background: #ffffff;
    }

    a {
        color: #000000;
        text-decoration: underline;
    }

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

/* Interactive element states for better visibility */
.interactive {
    position: relative;
}

.interactive::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    pointer-events: none;
    transition: box-shadow 0.2s ease;
}

.interactive:focus-visible::after {
    box-shadow: 0 0 0 3px var(--focus-color);
}

/* Ensure images maintain aspect ratio and don't cause CLS */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Tables - accessible structure */
table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray);
}

th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

/* Caption for tables */
caption {
    padding: 12px;
    font-weight: 600;
    text-align: left;
}
