/**
 * Accessibility Enhancements - WCAG AAA Compliance
 * Hijri Calendars - October 2025
 */

/* ========================================
   SKIP NAVIGATION LINK
   ======================================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    z-index: 10000;
    font-weight: bold;
    border-radius: 0 0 4px 0;
    transition: top 0.3s ease;
}

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

/* ========================================
   ENHANCED FOCUS INDICATORS
   ======================================== */
*:focus {
    outline: 3px solid #0056b3;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus,
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 3px solid #0056b3;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.25);
}

/* Remove default Bootstrap outline */
.btn:focus,
.form-control:focus,
.form-select:focus {
    border-color: #0056b3;
}

/* ========================================
   HIGH CONTRAST COLORS (WCAG AAA)
   Contrast Ratio: 7:1 minimum
   ======================================== */
:root {
    --primary-dark: #0056b3;
    --primary-darker: #004085;
    --success-dark: #155724;
    --success-darker: #0c3d17;
    --danger-dark: #721c24;
    --danger-darker: #4a1419;
    --warning-dark: #856404;
    --warning-darker: #5a4202;
    --info-dark: #004085;
    --info-darker: #002752;
}

.btn-primary {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-darker) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-darker) !important;
    border-color: #003066 !important;
}

.btn-success {
    background-color: var(--success-dark) !important;
    border-color: var(--success-darker) !important;
}

.btn-success:hover,
.btn-success:focus {
    background-color: var(--success-darker) !important;
    border-color: #082b0f !important;
}

.btn-danger {
    background-color: var(--danger-dark) !important;
    border-color: var(--danger-darker) !important;
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: var(--danger-darker) !important;
    border-color: #2d0c10 !important;
}

.btn-warning {
    background-color: var(--warning-dark) !important;
    border-color: var(--warning-darker) !important;
    color: #fff !important;
}

.btn-warning:hover,
.btn-warning:focus {
    background-color: var(--warning-darker) !important;
    border-color: #3d2b01 !important;
    color: #fff !important;
}

.btn-info {
    background-color: var(--info-dark) !important;
    border-color: var(--info-darker) !important;
}

.btn-info:hover,
.btn-info:focus {
    background-color: var(--info-darker) !important;
    border-color: #001a3d !important;
}

/* Background Colors */
.bg-primary {
    background-color: var(--primary-dark) !important;
}

.bg-success {
    background-color: var(--success-dark) !important;
}

.bg-danger {
    background-color: var(--danger-dark) !important;
}

.bg-warning {
    background-color: var(--warning-dark) !important;
}

.bg-info {
    background-color: var(--info-dark) !important;
}

/* Text Colors */
.text-primary {
    color: var(--primary-darker) !important;
}

.text-success {
    color: var(--success-darker) !important;
}

.text-danger {
    color: var(--danger-darker) !important;
}

.text-warning {
    color: var(--warning-darker) !important;
}

.text-info {
    color: var(--info-darker) !important;
}

.text-muted {
    color: #495057 !important; /* Darker for AAA contrast */
}

/* ========================================
   FONT RESIZABILITY (rem units)
   ======================================== */
html {
    font-size: 100%; /* Allow browser zoom */
}

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

h1, .h1 {
    font-size: 2.5rem;
}

h2, .h2 {
    font-size: 2rem;
}

h3, .h3 {
    font-size: 1.75rem;
}

h4, .h4 {
    font-size: 1.5rem;
}

h5, .h5 {
    font-size: 1.25rem;
}

h6, .h6 {
    font-size: 1rem;
}

.lead {
    font-size: 1.25rem;
}

.small, small {
    font-size: 0.875rem;
}

/* ========================================
   KEYBOARD NAVIGATION HELPER
   ======================================== */
.keyboard-focused:focus-visible {
    outline: 3px dashed #0056b3;
    outline-offset: 4px;
}

/* Visible focus for keyboard users only */
:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 3px solid #0056b3;
    outline-offset: 2px;
}

/* ========================================
   ARIA LIVE REGIONS
   ======================================== */
[aria-live="polite"],
[aria-live="assertive"] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ========================================
   SCREEN READER ONLY TEXT
   ======================================== */
.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:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ========================================
   CARD FOCUS STATES
   ======================================== */
.card:focus-within {
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.25);
    border-color: #0056b3;
}

/* ========================================
   LINK UNDERLINES (Accessibility)
   ======================================== */
a:not(.btn):not(.nav-link):not(.navbar-brand) {
    text-decoration: underline;
}

a:not(.btn):not(.nav-link):not(.navbar-brand):hover {
    text-decoration: none;
}

/* ========================================
   FORM VALIDATION ACCESSIBILITY
   ======================================== */
.form-control:invalid:focus {
    border-color: var(--danger-dark);
    box-shadow: 0 0 0 4px rgba(114, 28, 36, 0.25);
}

.form-control:valid:focus {
    border-color: var(--success-dark);
    box-shadow: 0 0 0 4px rgba(21, 87, 36, 0.25);
}

/* ========================================
   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;
    }

    .skip-link {
        transition: none;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px !important;
    }

    *:focus {
        outline-width: 4px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */
@media (prefers-color-scheme: dark) {
    .skip-link {
        background: #fff;
        color: #000;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .skip-link,
    .navbar,
    .btn,
    footer {
        display: none !important;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}
