/* =============================
   ACCESSIBILITY IMPROVEMENTS
   WCAG 2.1 AA Compliance Layer
   ============================= */

/* Skip-to-content link — hidden by default, visible on keyboard focus */
.skip-link {
    position: absolute;
    top: -9999px;
    left: -9999px;
    z-index: 999;
    padding: 1em;
    background-color: var(--neta-primary);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
}

.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    left: 0;
}

/* Preloader: keep the overlay visually stable.
   The bouncing dots in style.css already provide motion feedback;
   animating the full-screen loader container causes a page-wide flash
   on first paint. */
.loader {
    animation: none !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Automatic OS/browser dark-mode override removed to preserve the intended light theme. */

/* Improved focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--neta-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Better error message styling with ARIA support */
[aria-invalid="true"],
[aria-invalid="true"]:focus {
    border-color: #d32f2f !important;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

/* Error messages with proper ARIA semantics */
[role="alert"],
[aria-live="polite"],
[aria-live="assertive"] {
    padding: 12px 14px;
    border-radius: var(--neta-radius);
    background-color: rgba(211, 47, 47, 0.08);
    border-left: 3px solid #d32f2f;
    color: #c41c00;
    font-size: 14px;
    margin-bottom: 12px;
}

[aria-live="polite"].success,
[aria-live="assertive"].success {
    background-color: rgba(56, 142, 60, 0.08);
    border-left-color: #388e3c;
    color: #1b5e20;
}

/* Improved contrast for muted text in dark sections */
.neta-section--dark .neta-section__lead {
    color: #a8b5c8;
}

.neta-section--dark p,
.neta-section--dark li {
    color: #b8c2d5;
}

/* Form label styling for better clarity */
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--neta-ink);
}

label.required::after {
    content: " *";
    color: #d32f2f;
    font-weight: 700;
}

/* Input and textarea styling */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--neta-line);
    border-radius: var(--neta-radius);
    font-family: inherit;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
    border-color: var(--neta-accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
    outline: none;
}

/* Breadcrumb navigation semantics */
nav[aria-label="Breadcrumb"] ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

nav[aria-label="Breadcrumb"] li {
    display: flex;
    align-items: center;
}

nav[aria-label="Breadcrumb"] li::after {
    content: "/";
    margin: 0 8px;
    color: var(--neta-muted);
}

nav[aria-label="Breadcrumb"] li:last-child::after {
    content: "";
    margin: 0;
}

/* Dropdown menu keyboard accessibility improvements */
[aria-haspopup="menu"]:focus-visible {
    outline: 2px solid var(--neta-accent);
    outline-offset: 2px;
}

[role="menuitem"] {
    cursor: pointer;
}

[role="menuitem"]:hover,
[role="menuitem"]:focus {
    background-color: rgba(31, 111, 235, 0.08);
}

/* Loading state indicators */
button[aria-busy="true"],
.btn-loading {
    opacity: 0.7;
    pointer-events: none;
}

button[aria-busy="true"]::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* SVG decorative elements should be hidden from screen readers */
svg[aria-hidden="true"] {
    pointer-events: none;
}

/* Improve table accessibility */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

th {
    background-color: var(--neta-bg-soft);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--neta-line);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--neta-line);
}

/* Improve list styling for accessibility */
ul, ol {
    margin-left: 1.5em;
    line-height: 1.8;
}

li {
    margin-bottom: 8px;
}

/* Code block accessibility */
code, pre {
    font-family: 'Courier New', monospace;
    background-color: var(--neta-bg-soft);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

pre {
    padding: 16px;
    overflow-x: auto;
    line-height: 1.5;
}

/* Visible focus indicator for mobile users */
@media (hover: none) and (pointer: coarse) {
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--neta-accent);
        outline-offset: 2px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    :root {
        --neta-line: #aaa;
        --neta-muted: #333;
    }
    
    .neta-header {
        border-bottom: 2px solid var(--neta-line);
    }
}

/* Ensure video/iframe is accessible */
iframe {
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

/* Improve button cursor visibility */
button,
a.thm-btn,
[role="button"] {
    cursor: pointer;
}

button:disabled,
a.thm-btn:disabled,
[role="button"][aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.6;
}
