/* Accessibility Widget & Overrides */

:root {
    --acc-primary: #0056b3;
    --acc-bg: #ffffff;
    --acc-text: #212529;
    --acc-focus: #ffb700;
}

/* 1. Focus Visibility - Critical for Keyboard Nav */
*:focus-visible {
    outline: 3px solid var(--acc-focus) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.5) !important;
    z-index: 9999;
}

/* 2. Skip Link */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 1rem 2rem;
    z-index: 99999;
    font-weight: bold;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* 3. Accessibility Widget (FAB) */
#acc-widget-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    /* Hebrew/RTL friendly usually puts tools on left or right universally, keeping left for now */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #003366;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    cursor: pointer;
    z-index: 10000;
    transition: transform 0.2s;
}

#acc-widget-btn:hover,
#acc-widget-btn:focus {
    transform: scale(1.1);
}

#acc-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 9999;
    display: none;
}

#acc-menu-overlay.active {
    display: block;
}

#acc-menu {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 300px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 16px;
    z-index: 10000;
    display: none;
    /* Hidden by default */
    font-family: 'Heebo', sans-serif;
    color: #1e293b;
}

#acc-menu.active {
    display: block;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.acc-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.acc-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 5px;
}

.acc-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.acc-subgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    grid-column: 1 / -1;
}

.acc-subgrid .acc-option-btn[data-value='xl'] {
    grid-column: 1 / -1;
}

.acc-option-btn,
.acc-link-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    gap: 5px;
    text-decoration: none;
}

.acc-option-btn:hover,
.acc-link-btn:hover {
    background: #e2e8f0;
}

.acc-option-btn.active {
    background: #003366;
    color: white;
    border-color: #003366;
}

.acc-reset-btn {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.acc-reset-btn:hover {
    background: #dc2626;
}

/* 4. Accessibility Modes (Applied to HTML/Body) */

/* Large Text */
html.acc-text-large {
    font-size: 120%;
}

html.acc-text-xl {
    font-size: 140%;
}

/* High Contrast */
html.acc-high-contrast {
    filter: none;
}

html.acc-high-contrast body {
    background: #000 !important;
    color: #fff !important;
}

/* Base: make all elements high contrast black/white */
html.acc-high-contrast *:not(#acc-menu):not(#acc-menu *):not(#acc-widget-btn):not(#acc-widget-btn *):not(img):not(svg):not(video) {
    background-color: transparent !important;
    background-image: none !important;
    color: #fff !important;
    border-color: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* Force utility background surfaces to dark backgrounds in high contrast mode */
html.acc-high-contrast [class*='bg-']:not(#acc-menu):not(#acc-menu *):not(#acc-widget-btn):not(#acc-widget-btn *) {
    background-color: #000 !important;
    background-image: none !important;
}

/* Buttons: visible with yellow accent for clickable elements */
html.acc-high-contrast a:not(#acc-menu a),
html.acc-high-contrast button:not(#acc-widget-btn):not(#acc-close-btn):not(#acc-reset-btn):not(.acc-option-btn):not(.acc-close) {
    background-color: #000 !important;
    color: #FFD700 !important;
    border: 2px solid #FFD700 !important;
    text-decoration: none !important;
}

html.acc-high-contrast a:not(#acc-menu a):hover,
html.acc-high-contrast a:not(#acc-menu a):focus,
html.acc-high-contrast button:not(#acc-widget-btn):not(#acc-close-btn):not(#acc-reset-btn):not(.acc-option-btn):not(.acc-close):hover,
html.acc-high-contrast button:not(#acc-widget-btn):not(#acc-close-btn):not(#acc-reset-btn):not(.acc-option-btn):not(.acc-close):focus {
    background-color: #FFD700 !important;
    color: #000 !important;
}

/* SVGs inside buttons/links should inherit text color */
html.acc-high-contrast a svg,
html.acc-high-contrast button svg {
    color: inherit !important;
    fill: currentColor !important;
    stroke: currentColor !important;
    filter: none !important;
    background: transparent !important;
}

/* Images: keep visible, subtle border for clarity */
html.acc-high-contrast img {
    filter: none !important;
    background: transparent !important;
    border: 1px solid #fff !important;
}

/* Carousel dots: visible in high contrast */
html.acc-high-contrast .dot,
html.acc-high-contrast .t-dot {
    border: 1px solid #fff !important;
}

html.acc-high-contrast .dot::before,
html.acc-high-contrast .t-dot::before {
    background-color: #666 !important;
}

html.acc-high-contrast .dot.active::before,
html.acc-high-contrast .t-dot.active::before {
    background-color: #FFD700 !important;
}

/* Navigation Glass panel */
html.acc-high-contrast .glass {
    background: #000 !important;
    border: 2px solid #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Force decorative/gradient text to remain readable in high contrast */
html.acc-high-contrast .text-gradient {
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
    -webkit-text-fill-color: #fff !important;
    color: #fff !important;
}

/* Cookie & Modal override */
html.acc-high-contrast .cookie-card,
html.acc-high-contrast .modal-container,
html.acc-high-contrast .modal-header {
    background: #000 !important;
    border: 2px solid #fff !important;
    backdrop-filter: none !important;
}

/* Floating blobs: hide in high contrast (visual noise) */
html.acc-high-contrast .fixed.inset-0.pointer-events-none,
html.acc-high-contrast .fixed.inset-0.pointer-events-none * {
    display: none !important;
}

/* Accessibility widget itself: keep styled normally */
html.acc-high-contrast #acc-menu {
    background: #fff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}

html.acc-high-contrast #acc-menu * {
    color: #1e293b !important;
}

html.acc-high-contrast .acc-option-btn {
    background: #f8fafc !important;
    color: #334155 !important;
    border-color: #cbd5e1 !important;
}

html.acc-high-contrast .acc-option-btn.active {
    background: #003366 !important;
    color: white !important;
    border: 2px solid #FFD700 !important;
}

html.acc-high-contrast .acc-reset-btn {
    background: #ef4444 !important;
    color: white !important;
}


/* Grayscale */
html.acc-grayscale {
    filter: grayscale(100%);
}

/* Readable Font */
html.acc-readable-font * {
    font-family: Arial, Helvetica, sans-serif !important;
    letter-spacing: 0.5px !important;
}

/* Underline Links */
html.acc-links-underline a,
html.acc-links-underline [role='link'] {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 2px !important;
}

/* Also highlight accessibility-tool controls inside the menu */
html.acc-links-underline #acc-menu .acc-option-btn span:last-child,
html.acc-links-underline #acc-menu .acc-link-btn span:last-child {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 2px !important;
}

/* Keep link highlighting visible even when high-contrast mode is enabled */
html.acc-high-contrast.acc-links-underline a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 2px !important;
    text-decoration-color: currentColor !important;
}

/* Stop Animations */
html.acc-stop-animations *,
html.acc-stop-animations *::before,
html.acc-stop-animations *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* Big Cursor */
html.acc-big-cursor {
    --acc-cursor-arrow: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0OCcgaGVpZ2h0PSc0OCcgdmlld0JveD0nMCAwIDI0IDI0Jz48cGF0aCBmaWxsPScjMDAwJyBkPSdNMyAydjE2bDQtNCAzIDggMi0xLTMtOGg2TDMgMnonLz48L3N2Zz4=") 2 2;
    --acc-cursor-hand: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc1MicgaGVpZ2h0PSc1Micgdmlld0JveD0nMCAwIDI0IDI0JyBmaWxsPSdub25lJz48cGF0aCBmaWxsPScjMDAwJyBzdHJva2U9JyMwMDAnIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCcgc3Ryb2tlLXdpZHRoPScxLjknIGQ9J00xMS41IDIyQzQuNyAyMiAzIDE2LjMzMyAzIDEzLjVWMTBjMC0uMzMzLjItMSAxLTFzMSAuNjY3IDEgMXYyYzAgLjUuMyAxLjUgMS41IDEuNVM4IDEyLjUgOCAxMlYzYzAtLjMzMy4yLTEgMS0xczEgLjY2NyAxIDF2N2MuNS41LjggMS4yIDIgMFY4YzAtLjMzMy4yLTEgMS0xczEgLjY2NyAxIDF2MWgxYzAtLjMzMy4yLTEgMS0xczEgLjY2NyAxIDF2MWgxYzAtLjMzMy4yLTEgMS0xczEgLjY2NyAxIDF2My41YzAgMi44MzMtMS43IDguNS04LjUgOC41eicvPjwvc3ZnPg==") 13 2;
    --acc-cursor-text: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0OCcgaGVpZ2h0PSc0OCcgdmlld0JveD0nMCAwIDI0IDI0Jz48cGF0aCBmaWxsPScjMDAwJyBkPSdNNyAzaDEwdjJoLTR2MTRoNHYySDd2LTJoNFY1SDd6Jy8+PC9zdmc+") 12 12;
}

html.acc-big-cursor,
html.acc-big-cursor body,
html.acc-big-cursor body * {
    cursor: var(--acc-cursor-arrow), auto !important;
}

html.acc-big-cursor a[href],
html.acc-big-cursor area[href],
html.acc-big-cursor button,
html.acc-big-cursor [role='button'],
html.acc-big-cursor label[for],
html.acc-big-cursor summary,
html.acc-big-cursor select,
html.acc-big-cursor .cursor-pointer {
    cursor: var(--acc-cursor-hand), pointer !important;
}

html.acc-big-cursor input:not([type]),
html.acc-big-cursor input[type='text'],
html.acc-big-cursor input[type='search'],
html.acc-big-cursor input[type='email'],
html.acc-big-cursor input[type='url'],
html.acc-big-cursor input[type='tel'],
html.acc-big-cursor input[type='password'],
html.acc-big-cursor input[type='number'],
html.acc-big-cursor textarea,
html.acc-big-cursor [contenteditable='true'] {
    cursor: var(--acc-cursor-text), text !important;
}

html.acc-big-cursor :disabled,
html.acc-big-cursor [aria-disabled='true'] {
    cursor: var(--acc-cursor-arrow), not-allowed !important;
}

#acc-statement-link {
    grid-column: 1 / -1;
}

/* Respect system-level 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;
    }
}
