/**
 * Accessibility Stylesheet - nooh-school.online
 * WCAG 2.1 AA Compliance
 * Version: 1.0
 *
 * This stylesheet provides:
 * - Visible focus indicators
 * - Skip navigation links
 * - Screen reader utilities
 * - High contrast mode support
 * - Reduced motion support
 * - RTL accessibility considerations
 */

/* ==========================================================================
   1. SKIP NAVIGATION LINKS
   ========================================================================== */

/**
 * Skip links allow keyboard users to bypass repetitive navigation
 * They are hidden visually but accessible to screen readers
 * Become visible when focused via keyboard
 */
.skip-links {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10000;
    pointer-events: none;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary-dark, #0a1f2e);
    padding: 12px 24px;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: top 0.3s ease;
    z-index: 10001;
    pointer-events: auto;
    white-space: nowrap;
   
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 2px;
}

[dir="rtl"] .skip-link {
    left: 50%;
    transform: translateX(-50%);
}

/* ==========================================================================
   2. FOCUS INDICATORS
   ========================================================================== */

/**
 * Visible focus indicators for keyboard navigation
 * Uses :focus-visible to avoid showing focus on mouse clicks
 * Provides high contrast outlines meeting WCAG 2.1 requirements
 */

/* Base focus style for all focusable elements */
:focus {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 2px;
}

/* Remove focus ring for mouse users, keep for keyboard users */
:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus-visible styles */
:focus-visible {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.25);
}

/* Link focus styles */
a:focus-visible {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 2px;
    border-radius: 4px;
    text-decoration: underline;
}

/* Button focus styles */
button:focus-visible,
.btn:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.3);
}

/* Input focus styles */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.form-control:focus-visible {
    outline: none;
    border-color: var(--primary-gold, #d4af37);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.2);
}

/* Checkbox and radio focus styles */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 2px;
}

/* Card/interactive element focus */
.program-card:focus-within,
.book-card:focus-within,
.feature-item:focus-within,
.testimonial-card:focus-within {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 4px;
    border-radius: 8px;
}

/* Navigation focus styles */
.nav-links a:focus-visible,
.nav-item a:focus-visible {
    background-color: rgba(212, 175, 55, 0.1);
    border-radius: 4px;
    outline: 2px solid var(--primary-gold, #d4af37);
    outline-offset: 2px;
}

/* Mobile menu toggle focus */
.mobile-menu-toggle:focus-visible {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 4px;
    border-radius: 4px;
}

/* High contrast focus for dark backgrounds */
.hero-section a:focus-visible,
.cta-section a:focus-visible,
.main-footer a:focus-visible,
.page-header a:focus-visible {
    outline-color: #fff;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   3. SCREEN READER UTILITIES
   ========================================================================== */

/**
 * .sr-only: Visually hide content but keep accessible to screen readers
 * .sr-only-focusable: Hidden until focused (for skip links)
 * .aria-live-region: For dynamic content announcements
 */

/* Visually hidden but accessible to screen readers */
.sr-only,
.visually-hidden {
    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;
}

/* Becomes visible when focused */
.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Live region for dynamic announcements */
.aria-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Not hidden visually but announced by screen readers */
[aria-live="polite"],
[aria-live="assertive"] {
    /* These elements will announce changes to screen readers */
}

/* ==========================================================================
   4. TOUCH TARGET SIZES
   ========================================================================== */

/**
 * Ensure all interactive elements meet minimum touch target size
 * WCAG 2.5.5 requires 44x44 CSS pixels minimum
 */

/* Ensure minimum touch target size */
button,
.btn,
[role="button"],
a.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
}

/* Touch targets for icon buttons */
.mobile-menu-toggle,
.social-links a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Spacing between touch targets */
.nav-links a,
.footer-links a {
    display: inline-block;
    padding: 8px 4px;
    min-height: 44px;
    line-height: 28px;
}

/* Form input touch targets */
input,
textarea,
select,
.form-control {
    min-height: 44px;
}

/* Checkbox and radio touch targets */
input[type="checkbox"],
input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
}

/* Increase clickable area for checkboxes */
.checkbox-group,
.form-group.checkbox-group {
    padding: 8px 0;
}

/* ==========================================================================
   5. REDUCED MOTION
   ========================================================================== */

/**
 * Respect user preference for reduced motion
 * Important for users with vestibular disorders
 */

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

    /* Disable specific animations */
    .animate-fade-in,
    .animate-slide-in,
    .animate-scale-in {
        animation: none !important;
    }

    /* Keep hover states but remove transitions */
    .btn:hover,
    .program-card:hover,
    .book-card:hover,
    .feature-item:hover {
        transform: none !important;
    }
}

/* ==========================================================================
   6. HIGH CONTRAST MODE
   ========================================================================== */

/**
 * Support for Windows High Contrast Mode
 * Ensures content remains visible and usable
 */

@media (forced-colors: active) {
    /* Ensure focus indicators are visible */
    :focus,
    :focus-visible {
        outline: 3px solid CanvasText !important;
        outline-offset: 2px !important;
    }

    /* Ensure buttons have visible borders */
    .btn,
    button,
    [role="button"] {
        border: 2px solid ButtonText !important;
    }

    /* Ensure form inputs have visible borders */
    input,
    textarea,
    select,
    .form-control {
        border: 2px solid CanvasText !important;
    }

    /* Ensure links are distinguishable */
    a {
        text-decoration: underline !important;
    }

    /* Cards and sections */
    .program-card,
    .book-card,
    .feature-item,
    .testimonial-card,
    .contact-method {
        border: 2px solid CanvasText !important;
    }
}

/* ==========================================================================
   7. TEXT AND CONTENT ACCESSIBILITY
   ========================================================================== */

/**
 * Ensure text is readable and content is accessible
 */

/* Ensure sufficient line height for readability */
body {
    line-height: 1.6;
}

p, li, dd {
    line-height: 1.7;
}

/* Ensure text can be resized up to 200% without loss of content */
html {
    font-size: 100%;
}

/* Prevent text from being cut off when zoomed */
body {
    overflow-x: hidden;
}

/* Ensure sufficient contrast for placeholder text */
::placeholder {
    color: #666;
    opacity: 1;
}

/* Error state accessibility */
.input-error {
    border-color: #dc2626 !important;
    border-width: 2px;
}

.error-message {
    color: #dc2626;
    font-weight: 500;
}

/* Success state accessibility */
.success-message {
    color: #065f46;
    background-color: #d1fae5;
    border-right: 4px solid #10b981;
    padding: 16px;
}

[dir="ltr"] .success-message {
    border-right: none;
    border-left: 4px solid #10b981;
}

/* ==========================================================================
   8. LANDMARK AND REGION STYLES
   ========================================================================== */

/**
 * Styles for ARIA landmarks and regions
 */

/* Main content area indicator for skip links */
#main-content:target {
    outline: 3px solid var(--primary-gold, #d4af37);
    outline-offset: 8px;
    animation: highlight-main 2s ease-out;
}

@keyframes highlight-main {
    0% {
        outline-color: var(--primary-gold, #d4af37);
    }
    100% {
        outline-color: transparent;
    }
}

/* ==========================================================================
   9. FORM ACCESSIBILITY
   ========================================================================== */

/**
 * Enhanced form accessibility
 */

/* Required field indicator */
.form-group label .required,
.form-group label [aria-hidden="true"] {
    color: #dc2626;
    font-weight: bold;
}

/* Field description styling */
.field-description,
[id*="-help"],
[id*="-description"] {
    color: var(--text-light, #5a6b7a);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* Error announcement for screen readers */
[role="alert"] {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 8px 0;
}

[role="alert"][aria-live="polite"] {
    background-color: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

[role="alert"][aria-live="assertive"] {
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* ==========================================================================
   10. MODAL ACCESSIBILITY
   ========================================================================== */

/**
 * Modal/dialog accessibility improvements
 */

/* Modal backdrop - must be below modal content */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040 !important; /* Below Bootstrap modal (1055) */
}

/* Modal dialog - must be above backdrop */
[role="dialog"],
.modal {
    z-index: 1055 !important; /* Bootstrap 5 default modal z-index */
}

/* Ensure modal-dialog (Bootstrap's inner container) is also properly stacked */
.modal-dialog {
    position: relative;
    z-index: 1056 !important; /* Above modal backdrop */
}

/* Modal content should be clickable */
.modal-content {
    position: relative;
    z-index: 1057 !important; /* Ensure content is above backdrop */
}

[dir="ltr"] [role="dialog"],
[dir="ltr"] .modal {
    right: auto;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Focus trap indicator */
.focus-trap-active {
    /* Visual indicator that focus is trapped */
}

/* ==========================================================================
   11. TABLE ACCESSIBILITY
   ========================================================================== */

/**
 * Table accessibility improvements
 */

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

th {
    text-align: right;
    font-weight: 700;
    background-color: var(--bg-light, #f5f7fa);
}

[dir="ltr"] th {
    text-align: left;
}

/* Ensure table headers are associated with data */
th[scope="col"],
th[scope="row"] {
    padding: 12px 16px;
}

/* Stripe rows for readability */
tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Focus within table cells */
td:focus-within {
    outline: 2px solid var(--primary-gold, #d4af37);
    outline-offset: -2px;
}

/* ==========================================================================
   12. ICON ACCESSIBILITY
   ========================================================================== */

/**
 * Ensure icons are accessible
 */

/* Decorative icons should be hidden from screen readers */
[aria-hidden="true"] {
    /* Icon is decorative */
}

/* Icons that convey meaning need accessible text */
.icon-with-text .icon-label {
    /* Visible text accompanies icon */
}

/* Icon-only buttons need aria-label */
button[aria-label] i,
a[aria-label] i {
    pointer-events: none;
}

/* ==========================================================================
   13. LOADING STATES ACCESSIBILITY
   ========================================================================== */

/**
 * Accessible loading states
 */

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color, #e5e7eb);
    border-top-color: var(--primary-gold, #d4af37);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Respect reduced motion for spinners */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
        border-top-color: var(--primary-gold, #d4af37);
        border-right-color: var(--primary-gold, #d4af37);
    }
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Skeleton loading (accessible) */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-light, #f5f7fa) 25%,
        #e5e7eb 50%,
        var(--bg-light, #f5f7fa) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
        background: var(--bg-light, #f5f7fa);
    }
}

/* ==========================================================================
   14. PRINT ACCESSIBILITY
   ========================================================================== */

@media print {
    /* Ensure links show their URLs */
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        font-weight: normal;
    }

    /* Hide non-essential elements */
    .skip-links,
    .mobile-menu-toggle,
    nav,
    .social-links {
        display: none !important;
    }

    /* Ensure content is readable */
    body {
        color: #000 !important;
        background: #fff !important;
    }
}
