/* ============================================================
   Accessibility Widget Styles
   ============================================================ */

/* --- Skip to Main Content Link --- */
.a11y-skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #1565C0;
    color: #fff !important;
    padding: 12px 24px;
    z-index: 1000000;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}
.a11y-skip-link:focus {
    top: 0;
    outline: 3px solid #FFD600;
    outline-offset: 2px;
}
html[dir="rtl"] .a11y-skip-link,
body.a11y-rtl .a11y-skip-link {
    left: auto;
    right: 0;
    border-radius: 0 0 0 8px;
}

/* --- Floating Toggle Button --- */
button.a11y-widget-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    height: auto;
    width: auto;
    border-radius: 30px;
    background: #1565C0 !important;
    color: #fff !important;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s, transform 0.2s;
    padding: 10px 18px;
    line-height: 1;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    overflow: visible;
    font-family: Arial, Helvetica, sans-serif;
}
button.a11y-widget-toggle:hover,
button.a11y-widget-toggle:focus {
    background: #0D47A1 !important;
    transform: scale(1.05);
    outline: 3px solid #FFD600;
    outline-offset: 2px;
}
button.a11y-widget-toggle svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    display: block;
    flex-shrink: 0;
}
.a11y-toggle-label {
    font-size: 14px;
    font-weight: 700;
    color: #fff !important;
    white-space: nowrap;
}

/* RTL: move button to left side */
html[dir="rtl"] .a11y-widget-toggle,
body.a11y-rtl .a11y-widget-toggle {
    right: auto;
    left: 20px;
}

/* --- Panel --- */
.a11y-widget-panel {
    position: fixed;
    bottom: 88px;
    right: 20px;
    z-index: 999998;
    width: 320px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    overflow: hidden;
    display: none;
    flex-direction: column;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #222;
}
.a11y-widget-panel.a11y-panel-open {
    display: flex;
}

/* RTL panel */
html[dir="rtl"] .a11y-widget-panel,
body.a11y-rtl .a11y-widget-panel {
    right: auto;
    left: 20px;
}

/* --- Panel Header --- */
.a11y-panel-header {
    background: #1565C0;
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.a11y-panel-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}
.a11y-panel-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: 4px;
}
.a11y-panel-close:hover,
.a11y-panel-close:focus {
    background: rgba(255,255,255,0.2);
    outline: 2px solid #FFD600;
}

/* --- Panel Body --- */
.a11y-panel-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    flex: 1;
    min-height: 0;
}

/* --- Feature Groups --- */
.a11y-group {
    margin-bottom: 14px;
}
.a11y-widget-panel .a11y-group-label {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    color: #888 !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 6px !important;
    padding: 0 2px !important;
    display: block !important;
    visibility: visible !important;
}

/* --- Feature Buttons --- */
.a11y-widget-panel .a11y-btn {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    background: #f5f5f5 !important;
    border: 2px solid transparent !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
    margin-bottom: 6px !important;
    cursor: pointer !important;
    transition: background 0.15s, border-color 0.15s;
    text-align: left !important;
    font-size: 14px !important;
    color: #333 !important;
    gap: 10px !important;
    overflow: visible !important;
    height: auto !important;
    line-height: 1.3 !important;
    text-indent: 0 !important;
    visibility: visible !important;
}
html[dir="rtl"] .a11y-widget-panel .a11y-btn,
body.a11y-rtl .a11y-widget-panel .a11y-btn {
    text-align: right !important;
}
.a11y-widget-panel .a11y-btn:hover {
    background: #e3f2fd !important;
}
.a11y-widget-panel .a11y-btn:focus {
    outline: 3px solid #1565C0;
    outline-offset: -1px;
}
.a11y-widget-panel .a11y-btn.a11y-active {
    background: #e3f2fd !important;
    border-color: #1565C0 !important;
    color: #0D47A1 !important;
    font-weight: 600 !important;
}
.a11y-widget-panel .a11y-btn.a11y-active .a11y-btn-label {
    color: #0D47A1 !important;
    font-weight: 600 !important;
}
.a11y-btn-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    border-radius: 6px;
    background: #e0e0e0;
    color: #333;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1;
}
.a11y-btn.a11y-active .a11y-btn-icon {
    background: #1565C0;
    color: #fff;
}
.a11y-widget-panel .a11y-btn-label {
    flex: 1 !important;
    display: inline-block !important;
    visibility: visible !important;
    color: #333 !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    text-indent: 0 !important;
    opacity: 1 !important;
    overflow: visible !important;
    height: auto !important;
    width: auto !important;
    position: static !important;
    clip: auto !important;
}

/* --- Font Size Controls --- */
.a11y-font-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
}
.a11y-font-controls span {
    flex: 1;
    font-size: 14px;
    color: #333;
}
.a11y-font-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 2px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    padding: 0;
}
.a11y-font-btn:hover {
    background: #e3f2fd;
    border-color: #1565C0;
}
.a11y-font-btn:focus {
    outline: 3px solid #1565C0;
    outline-offset: -1px;
}
.a11y-font-size-display {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #555;
}

/* --- Panel Footer --- */
.a11y-panel-footer {
    padding: 10px 14px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.a11y-reset-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: 8px;
    border: 2px solid #d32f2f;
    background: #fff;
    color: #d32f2f;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}
.a11y-reset-btn:hover {
    background: #ffebee;
}
.a11y-reset-btn:focus {
    outline: 3px solid #d32f2f;
    outline-offset: -1px;
}
.a11y-statement-link {
    flex: 1;
    padding: 9px 12px;
    border-radius: 8px;
    border: 2px solid #1565C0;
    background: #fff;
    color: #1565C0;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    text-decoration: none;
    display: block;
    transition: background 0.15s;
}
.a11y-statement-link:hover {
    background: #e3f2fd;
}
.a11y-statement-link:focus {
    outline: 3px solid #1565C0;
    outline-offset: -1px;
}

/* --- Reading Guide Line --- */
.a11y-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 0, 0, 0.6);
    z-index: 999997;
    pointer-events: none;
    display: none;
    box-shadow: 0 1px 4px rgba(255,0,0,0.3);
}

/* ============================================================
   Body-level accessibility classes
   ============================================================ */

/* High Contrast — page */
body.a11y-high-contrast,
body.a11y-high-contrast * {
    background-color: #000 !important;
    color: #FFD600 !important;
    border-color: #FFD600 !important;
}
body.a11y-high-contrast a {
    color: #00E5FF !important;
    text-decoration: underline !important;
}
body.a11y-high-contrast img {
    background-color: transparent !important;
}

/* High Contrast — widget: full restyle so every element is readable */
body.a11y-high-contrast button.a11y-widget-toggle {
    background: #000 !important;
    color: #FFD600 !important;
    border: 2px solid #FFD600 !important;
    box-shadow: 0 0 0 2px #000 !important;
}
body.a11y-high-contrast button.a11y-widget-toggle svg {
    fill: #FFD600 !important;
}
body.a11y-high-contrast button.a11y-widget-toggle .a11y-toggle-label {
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-widget-panel {
    background: #000 !important;
    border: 2px solid #FFD600 !important;
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-panel-header {
    background: #000 !important;
    border-bottom: 2px solid #FFD600 !important;
}
body.a11y-high-contrast .a11y-panel-header h2 {
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-panel-close {
    background: #000 !important;
    color: #FFD600 !important;
    border: 1px solid #FFD600 !important;
}
body.a11y-high-contrast .a11y-panel-close:hover,
body.a11y-high-contrast .a11y-panel-close:focus {
    background: #FFD600 !important;
    color: #000 !important;
}
body.a11y-high-contrast .a11y-panel-body {
    background: #000 !important;
}
body.a11y-high-contrast .a11y-group-label {
    color: #aaa !important;
    border-color: #555 !important;
}
body.a11y-high-contrast .a11y-btn {
    background: #111 !important;
    border: 2px solid #555 !important;
    color: #FFD600 !important;
}
/* Specificity fix: .a11y-widget-panel .a11y-btn-label {color:#333 !important} is
   (0,2,0) which beats body.a11y-high-contrast * (0,1,1), so labels stay dark (#333)
   in HC. This rule at (0,3,1) wins and keeps all labels yellow. */
body.a11y-high-contrast .a11y-widget-panel .a11y-btn-label {
    color: #FFD600 !important;
    font-weight: 400 !important;
}
body.a11y-high-contrast .a11y-btn:hover {
    background: #222 !important;
    border-color: #FFD600 !important;
}
/* Active state: yellow text on dark background — bright border signals ON.
   Never flip to black text; that breaks the HC yellow-on-black scheme. */
body.a11y-high-contrast .a11y-btn.a11y-active {
    background: #1a1a00 !important;
    border: 2px solid #FFD600 !important;
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-widget-panel .a11y-btn.a11y-active .a11y-btn-label {
    color: #FFD600 !important;
    font-weight: 700 !important;
}
body.a11y-high-contrast .a11y-btn-icon {
    background: #222 !important;
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-btn.a11y-active .a11y-btn-icon {
    background: #333 !important;
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-font-controls {
    background: #111 !important;
    border: 1px solid #555 !important;
}
body.a11y-high-contrast .a11y-font-controls span {
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-font-btn {
    background: #000 !important;
    border-color: #FFD600 !important;
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-font-btn:hover {
    background: #FFD600 !important;
    color: #000 !important;
}
body.a11y-high-contrast .a11y-font-size-display {
    color: #FFD600 !important;
}
body.a11y-high-contrast .a11y-panel-footer {
    background: #000 !important;
    border-top-color: #555 !important;
}
body.a11y-high-contrast .a11y-reset-btn {
    background: #000 !important;
    border-color: #ff6b6b !important;
    color: #ff6b6b !important;
}
body.a11y-high-contrast .a11y-reset-btn:hover {
    background: #ff6b6b !important;
    color: #000 !important;
}
body.a11y-high-contrast .a11y-statement-link {
    background: #000 !important;
    border-color: #00E5FF !important;
    color: #00E5FF !important;
}
body.a11y-high-contrast .a11y-statement-link:hover {
    background: #00E5FF !important;
    color: #000 !important;
}

/* Fancybox lightbox: restore original backgrounds so images are not covered.
   The body.a11y-high-contrast * rule sets background:#000 on everything,
   which blacks out fancybox-outer (normally white frame) and bg corner sprites. */
body.a11y-high-contrast #fancybox-wrap,
body.a11y-high-contrast #fancybox-outer,
body.a11y-high-contrast #fancybox-content,
body.a11y-high-contrast #fancybox-img,
body.a11y-high-contrast #fancybox-title,
body.a11y-high-contrast .fancybox-title-inside,
body.a11y-high-contrast .fancybox-bg,
body.a11y-high-contrast #fancybox-close,
body.a11y-high-contrast #fancybox-left,
body.a11y-high-contrast #fancybox-right,
body.a11y-high-contrast #fancybox-left-ico,
body.a11y-high-contrast #fancybox-right-ico {
    background-color: transparent !important;
}
body.a11y-high-contrast #fancybox-outer {
    background-color: #111 !important;
}

/* Keep Fancybox centered when accessibility zoom is enabled */
body.a11y-zoomed #fancybox-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
}
body.a11y-zoomed #fancybox-wrap {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
}
body.a11y-zoomed #fancybox-content {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    max-width: 90vw !important;
    max-height: 85vh !important;
}
body.a11y-zoomed #fancybox-img,
body.a11y-zoomed #fancybox-content img {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: 90vw !important;
    max-height: 85vh !important;
    margin: 0 auto !important;
}
body.a11y-zoomed #fancybox-frame,
body.a11y-zoomed #fancybox-content iframe,
body.a11y-zoomed #fancybox-content video,
body.a11y-zoomed #fancybox-content object,
body.a11y-zoomed #fancybox-content embed {
    display: block !important;
    width: 90vw !important;
    height: 85vh !important;
    max-width: 90vw !important;
    max-height: 85vh !important;
    margin: 0 auto !important;
}

/* Grayscale */
body.a11y-grayscale #container {
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
}

/* Invert Colors */
body.a11y-invert #container {
    filter: invert(100%);
    -webkit-filter: invert(100%);
}
body.a11y-invert #container img,
body.a11y-invert #container video {
    filter: invert(100%);
    -webkit-filter: invert(100%);
}
/* Counter-invert the widget so it keeps its own usable colors */
body.a11y-invert button.a11y-widget-toggle,
body.a11y-invert .a11y-widget-panel,
body.a11y-invert .a11y-reading-guide {
    filter: invert(100%);
    -webkit-filter: invert(100%);
}

/* Grayscale + Invert combined */
body.a11y-grayscale.a11y-invert #container {
    filter: grayscale(100%) invert(100%);
    -webkit-filter: grayscale(100%) invert(100%);
}
body.a11y-grayscale.a11y-invert button.a11y-widget-toggle,
body.a11y-grayscale.a11y-invert .a11y-widget-panel {
    filter: invert(100%);
    -webkit-filter: invert(100%);
}

/* Highlight Links */
body.a11y-highlight-links a {
    outline: 3px solid #FFD600 !important;
    outline-offset: 2px !important;
    background-color: rgba(255, 214, 0, 0.15) !important;
}

/* Readable Font */
body.a11y-readable-font,
body.a11y-readable-font * {
    font-family: Verdana, Geneva, Tahoma, sans-serif !important;
    letter-spacing: 0.03em !important;
    word-spacing: 0.1em !important;
}

/* Big Cursor */
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M4 4l16 36 6-16 16-6z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* Text Spacing — prevent widget layout from breaking */
body.a11y-text-spacing,
body.a11y-text-spacing * {
    letter-spacing: 0.12em !important;
    word-spacing: 0.25em !important;
    line-height: 1.8 !important;
}
body.a11y-text-spacing .a11y-widget-toggle,
body.a11y-text-spacing .a11y-btn,
body.a11y-text-spacing .a11y-font-btn,
body.a11y-text-spacing .a11y-btn-label,
body.a11y-text-spacing .a11y-toggle-label {
    white-space: nowrap !important;
    line-height: 1.3 !important;
}
body.a11y-text-spacing .a11y-btn-icon {
    line-height: 1 !important;
    letter-spacing: 0 !important;
}

/* Pause Animations */
body.a11y-pause-animations,
body.a11y-pause-animations * {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}
body.a11y-pause-animations .nivoSlider {
    animation: none !important;
}

/* --- Responsive: smaller screens --- */
@media (max-width: 480px) {
    .a11y-widget-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 64px;
        max-height: 75vh;
    }
    html[dir="rtl"] .a11y-widget-panel,
    body.a11y-rtl .a11y-widget-panel {
        right: auto;
        left: 12px;
    }
    button.a11y-widget-toggle {
        bottom: 10px;
        right: 10px;
        padding: 8px 14px;
        font-size: 12px;
    }
    .a11y-toggle-label {
        font-size: 12px;
    }
    html[dir="rtl"] .a11y-widget-toggle,
    body.a11y-rtl .a11y-widget-toggle {
        right: auto;
        left: 10px;
    }
}
