/* ==========================================================================
   WP A11y Toolbar - CSS Styles
   ========================================================================== */

/* 1. Import Accessible Font (Atkinson Hyperlegible from Google Fonts) */
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* 2. Global CSS Variables */
:root {
    /* UI Variables */
    --a11y-primary-color: #0056b3;
    --a11y-primary-hover: #004494;
    --a11y-bg-color: #ffffff;
    --a11y-text-color: #333333;
    --a11y-border-color: #dddddd;
    --a11y-z-index: 999999;
    
    /* WCAG AA Compliant Panel Colors */
    --a11y-panel-bg: #f9f9f9;
    --a11y-btn-bg: #e0e0e0;
    --a11y-btn-text: #1a1a1a;
    --a11y-btn-active-bg: var(--a11y-primary-color);
    --a11y-btn-active-text: #ffffff;
}

/* ==========================================================================
   3. Base State Styling Overrides
   ========================================================================== */

/* Typography Scaling (Variables driven by JS) */
html.a11y-active-typography body,
html.a11y-active-typography body *,
html.a11y-active-typography .elementor-element,
html.a11y-active-typography .elementor-widget-container,
html.a11y-active-typography .elementor-widget-container * {
    font-size: calc(1rem * var(--a11y-text-size-ratio, 1)) !important;
    word-spacing: var(--a11y-text-spacing, 0px) !important;
    line-height: var(--a11y-line-height-ratio, 1.5) !important;
    letter-spacing: var(--a11y-letter-spacing, 0px) !important;
}

/* Readable Font */
html.a11y-font-readable body,
html.a11y-font-readable body *,
html.a11y-font-readable .elementor-element,
html.a11y-font-readable .elementor-widget-container,
html.a11y-font-readable .elementor-widget-container * {
    font-family: 'Atkinson Hyperlegible', sans-serif !important;
}

/* ==========================================================================
   4. Contrast Modes
   ========================================================================== */

/* Dark Contrast */
html.a11y-contrast-dark,
html.a11y-contrast-dark body,
html.a11y-contrast-dark body *,
html.a11y-contrast-dark .elementor-element,
html.a11y-contrast-dark .elementor-widget-container,
html.a11y-contrast-dark .elementor-widget-container * {
    background-color: #121212 !important;
    color: #ffffff !important;
    border-color: #ffff00 !important;
}
html.a11y-contrast-dark a,
html.a11y-contrast-dark a * {
    color: #ffff00 !important;
}
/* Ensure toolbar itself retains correct contrast */
html.a11y-contrast-dark .a11y-toolbar-container * {
    border-color: initial !important;
}

/* Light Contrast */
html.a11y-contrast-light,
html.a11y-contrast-light body,
html.a11y-contrast-light body *,
html.a11y-contrast-light .elementor-element,
html.a11y-contrast-light .elementor-widget-container,
html.a11y-contrast-light .elementor-widget-container * {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #000000 !important;
}
html.a11y-contrast-light a,
html.a11y-contrast-light a * {
    color: #000000 !important;
    text-decoration: underline !important;
}

/* ==========================================================================
   5. Saturation Modes
   ========================================================================== */
html.a11y-saturation-high { filter: saturate(200%) !important; }
html.a11y-saturation-low { filter: saturate(50%) !important; }
html.a11y-saturation-monochrome { filter: grayscale(100%) !important; }

/* ==========================================================================
   6. Toggles & Utilities
   ========================================================================== */

/* Bigger Cursor */
html.a11y-bigger-cursor,
html.a11y-bigger-cursor *,
html.a11y-bigger-cursor .elementor-element * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24"><path fill="black" stroke="white" stroke-width="2" d="M3,3 L10,21 L13,14 L20,11 L3,3 Z"/></svg>'), auto !important;
}

/* Highlight Links & Titles */
html.a11y-highlight-links a,
html.a11y-highlight-links a *,
html.a11y-highlight-links h1,
html.a11y-highlight-links h2,
html.a11y-highlight-links h3,
html.a11y-highlight-links h4,
html.a11y-highlight-links h5,
html.a11y-highlight-links h6,
html.a11y-highlight-links .elementor-widget-heading *,
html.a11y-highlight-links .elementor-heading-title {
    outline: 3px solid #ffcc00 !important;
    outline-offset: 2px !important;
    text-decoration: underline !important;
    text-decoration-color: #ffcc00 !important;
    text-decoration-thickness: 3px !important;
}

/* Stop Animations */
html.a11y-stop-animations,
html.a11y-stop-animations *,
html.a11y-stop-animations .elementor-element * {
    animation: none !important;
    transition: none !important;
}

/* Hide Images */
html.a11y-hide-images img,
html.a11y-hide-images picture,
html.a11y-hide-images video,
html.a11y-hide-images svg,
html.a11y-hide-images .elementor-widget-image,
html.a11y-hide-images [style*="background-image"],
html.a11y-hide-images .elementor-background-overlay {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Reading Mask Layer */
.a11y-reading-mask-layer {
    position: fixed;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: calc(var(--a11y-z-index) - 1);
    pointer-events: none;
    display: none;
}
html.a11y-reading-mask .a11y-reading-mask-layer {
    display: block;
}

/* ==========================================================================
   7. Toolbar UI Styling
   ========================================================================== */

/* Main Container */
.a11y-toolbar-container {
    position: fixed;
    bottom: 20px;
    z-index: var(--a11y-z-index);
    font-family: Arial, Helvetica, sans-serif !important; /* Independent from site fonts */
    color: var(--a11y-text-color);
}
.a11y-toolbar-container * {
    box-sizing: border-box;
}

/* Positioning Modifiers */
.a11y-position-right {
    right: 20px;
}
.a11y-position-left {
    left: 20px;
}

/* Toggle Button */
.a11y-toggle-btn {
    background-color: var(--a11y-primary-color);
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s;
    padding: 0;
    position: absolute;
    bottom: 0;
}
.a11y-position-right .a11y-toggle-btn {
    right: 0;
}
.a11y-position-left .a11y-toggle-btn {
    left: 0;
}
.a11y-toggle-btn:hover,
.a11y-toggle-btn:focus {
    transform: scale(1.05);
    background-color: var(--a11y-primary-hover);
    outline: 3px solid #ffcc00; /* High contrast focus indicator */
    outline-offset: 4px;
}

/* Panel / Modal */
.a11y-panel {
    position: absolute;
    bottom: 80px; /* Above toggle button */
    width: 320px;
    max-height: 75vh;
    background-color: var(--a11y-panel-bg);
    border: 1px solid var(--a11y-border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.a11y-position-right .a11y-panel {
    right: 0;
}
.a11y-position-left .a11y-panel {
    left: 0;
}
.a11y-panel[aria-hidden="false"] {
    display: flex;
    opacity: 1;
}

/* Panel Header */
.a11y-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: var(--a11y-primary-color);
    color: #ffffff;
    border-bottom: 2px solid var(--a11y-primary-hover);
}
.a11y-panel-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffffff;
}
.a11y-close-btn {
    background: transparent;
    color: #ffffff;
    border: 2px solid transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
    border-radius: 4px;
}
.a11y-close-btn:hover,
.a11y-close-btn:focus {
    border-color: #ffcc00;
    outline: none;
}

/* Panel Body */
.a11y-panel-body {
    padding: 16px;
    overflow-y: auto;
    background: var(--a11y-bg-color);
}

/* Sections */
.a11y-section {
    margin-bottom: 24px;
}
.a11y-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--a11y-text-color);
    border-bottom: 2px solid var(--a11y-border-color);
    padding-bottom: 6px;
}

/* Buttons */
.a11y-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.a11y-btn {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background-color: var(--a11y-btn-bg);
    color: var(--a11y-btn-text);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.2s ease;
}
.a11y-btn.active,
.a11y-btn[aria-pressed="true"] {
    background-color: var(--a11y-btn-active-bg);
    color: var(--a11y-btn-active-text);
    border-color: var(--a11y-primary-hover);
}
.a11y-btn:hover,
.a11y-btn:focus {
    outline: none;
    border-color: var(--a11y-primary-color);
    background-color: #d0d0d0;
}
.a11y-btn.active:hover {
    background-color: var(--a11y-primary-hover);
}

/* Sliders */
.a11y-control-group {
    margin-bottom: 16px;
}
.a11y-control-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--a11y-text-color);
}
.a11y-control-group input[type="range"] {
    width: 100%;
    cursor: pointer;
}
.a11y-control-group input[type="range"]:focus {
    outline: 2px solid var(--a11y-primary-color);
    outline-offset: 2px;
}

/* Reset Button */
.a11y-section-reset {
    margin-top: 32px;
    border-top: 1px solid var(--a11y-border-color);
    padding-top: 16px;
}
.a11y-btn-reset {
    background-color: #d9534f;
    color: #ffffff;
    text-align: center;
    border: 2px solid transparent;
}
.a11y-btn-reset:hover,
.a11y-btn-reset:focus {
    background-color: #c9302c;
    border-color: #ac2925;
}
