/* =========================================
   ACCESSIBILITY WIDGET STYLES
   Namespace: #acc-widget-container
   ========================================= */

/* Widget Container (Floating Button + Panel) */
#acc-widget-container {
    position: fixed;
    top: 30%;
    /* Slightly lower */
    right: 0;
    z-index: 2147483647;
    /* Max Z-Index to stay on top */
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #333;
}

/* Floating Toggle Button */
#acc-toggle-btn {
    background-color: #0056b3;
    /* Blue readable color */
    color: #ffffff;
    width: 55px;
    /* Larger */
    height: 55px;
    /* Larger */
    border: 2px solid #ffffff;
    /* White border for contrast */
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* Stronger shadow */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, width 0.3s, transform 0.2s;
}

#acc-toggle-btn:hover {
    background-color: #004494;
    width: 60px;
    transform: scale(1.05);
    /* Slight pulse */
}

#acc-toggle-btn svg {
    width: 32px;
    /* Larger icon */
    height: 32px;
    fill: currentColor;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    /* Shadow slightly improves definition */
}

/* Accessibility Panel */
#acc-panel {
    position: absolute;
    top: 0;
    right: -320px;
    /* Hidden by default */
    width: 300px;
    background-color: white;
    box-shadow: -5px 5px 20px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 0 5px;
    padding: 20px;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-left: 4px solid #0056b3;
    max-height: 80vh;
    overflow-y: auto;
}

#acc-panel.active {
    right: 50px;
    /* Align to the left of the button */
}

/* Panel Header */
.acc-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.acc-panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #333;
}

#acc-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

#acc-close-btn:hover {
    color: #d9534f;
}

/* Panel Grid Layout */
.acc-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Option Buttons */
.acc-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.9rem;
    color: #495057;
}

.acc-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-2px);
}

.acc-btn:active {
    transform: translateY(0);
}

.acc-btn.active {
    background-color: #e7f1ff;
    border-color: #0056b3;
    color: #0056b3;
    font-weight: 600;
}

.acc-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 8px;
    fill: currentColor;
}

.acc-btn span {
    line-height: 1.2;
}

/* Full Width Buttons */
.acc-btn.full-width {
    grid-column: span 2;
    flex-direction: row;
    gap: 10px;
}

.acc-btn.full-width svg {
    margin-bottom: 0;
}

/* Reset Button Special Style */
.acc-btn.reset-btn {
    background-color: #fff5f5;
    border-color: #ffc9c9;
    color: #c92a2a;
}

.acc-btn.reset-btn:hover {
    background-color: #ffe3e3;
}

/* =========================================
   ACCESSIBILITY MODES (Applied to Body/HTML)
   ========================================= */


/* =========================================
   ACCESSIBILITY MODES (Applied to Body/HTML)
   ========================================= */

/* Overlay for Filters (Fixes position:fixed issues) */
#acc-filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2147483646;
    /* Below widget (MAX-1) */
    display: none;
}

#acc-filter-overlay.acc-grayscale,
#acc-filter-overlay.acc-high-contrast {
    display: block;
}

/* 1. & 2. Font Size - Handled via inline style on html/body (zoom or font-size %) */

/* 3. Grayscale (Applied to Overlay) */
#acc-filter-overlay.acc-grayscale {
    backdrop-filter: grayscale(100%);
    -webkit-backdrop-filter: grayscale(100%);
}

/* 4. High Contrast (Applied to Overlay) */
#acc-filter-overlay.acc-high-contrast {
    backdrop-filter: contrast(150%) saturate(150%);
    -webkit-backdrop-filter: contrast(150%) saturate(150%);
}

/* 5. Negative Contrast */
.acc-negative-contrast {
    background-color: #000 !important;
    color: #ffeb3b !important;
}

.acc-negative-contrast * {
    background-color: #000 !important;
    color: #ffeb3b !important;
    border-color: #ffeb3b !important;
}

.acc-negative-contrast img,
.acc-negative-contrast video {
    filter: invert(100%) hue-rotate(180deg);
}

/* 6. Light Background */
.acc-light-bg {
    background-color: #ffffff !important;
    color: #000000 !important;
}

.acc-light-bg * {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* 7. Underlined Links */
.acc-links-underline a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
}

/* 8. Readable Font */
.acc-readable-font * {
    font-family: Arial, Verdana, sans-serif !important;
    letter-spacing: 0.05em !important;
    line-height: 1.6 !important;
}

/* Responsive Improvements */
/* Desktop Constraints */
#acc-panel {
    /* Existing base styles but improved max-height */
    /* top: 0 is relative to container at 30% viewport height */
    max-height: 65vh;
    /* 100vh - 30% top = 70vh, minus margin */
    overflow-y: auto;
    overflow-x: hidden;
    /* Custom Scrollbar for panel */
    scrollbar-width: thin;
    scrollbar-color: #0056b3 #f1f1f1;
}

#acc-panel::-webkit-scrollbar {
    width: 6px;
}

#acc-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#acc-panel::-webkit-scrollbar-thumb {
    background: #0056b3;
    border-radius: 3px;
}


/* Mobile & Tablet Responsiveness (< 768px) */
@media (max-width: 768px) {
    /* On mobile, we change strategy to a full-height sidebar */

    #acc-widget-container {
        /* Keep button visible but panel behavior changes */
        top: 120px;
        /* Upper right, below header */
        bottom: auto;
        left: auto;
        right: 0;
    }

    #acc-toggle-btn {
        width: 50px;
        height: 50px;
        border-radius: 8px 0 0 8px;
        /* Revert to flat right edge */
        border: none;
        box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.2);
        /* Shadow to left */
    }

    #acc-toggle-btn svg {
        width: 28px;
        height: 28px;
    }

    /* Break the panel out of the container flow to fill screen */
    #acc-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        right: -100%;
        /* Slide from right */
        left: auto;
        width: 85%;
        max-width: 300px;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border-left: 1px solid #ddd;
        /* Normal left border */
        border-right: none;
        transform: none;
        margin: 0;
        z-index: 2147483648;
        /* Higher than button */
    }

    #acc-panel.active {
        right: 0;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
        /* Left shadow */
    }

    /* Adjust header in panel */
    .acc-panel-header {
        padding: 15px;
        background: #f8f9fa;
        border-bottom: 1px solid #e9ecef;
    }
}

/* Tiny screens */
@media (max-width: 360px) {
    #acc-panel {
        width: 100%;
        max-width: none;
    }
}