/* Accessibility Widget Full Styles */
:root {
    --acc-primary: #0044cc; /* Royal Blue like image */
    --acc-bg: #f0f2f5; /* Light gray background */
    --acc-card-bg: #ffffff;
    --acc-text: #333333;
    --acc-text-secondary: #666666;
    --acc-border: #e0e0e0;
    --acc-active: #000000;
    --acc-panel-width: 380px;
}

/* Floating Trigger Button */
#acc-trigger {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 100000;
    width: 60px;
    height: 60px;
    background-color: var(--acc-primary);
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background-color 0.3s;
}

#acc-trigger:hover {
    transform: scale(1.1);
    background-color: #003399;
}

#acc-trigger svg {
    width: 35px;
    height: 35px;
    fill: #fff;
}

/* Main Panel */
#acc-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--acc-panel-width);
    background-color: var(--acc-bg);
    z-index: 100001;
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    overflow: hidden;
}

#acc-panel.active {
    transform: translateX(0);
}

/* Panel Header */
.acc-header {
    background-color: var(--acc-primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.acc-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.acc-header-actions {
    display: flex;
    gap: 10px;
}

.acc-header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.2s;
}

.acc-header-btn:hover {
    background: rgba(255,255,255,0.4);
}

.acc-header-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Scrollable Content Area */
.acc-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Google Translate Section */
.acc-translate-container {
    background: var(--acc-card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.acc-translate-container .goog-te-gadget-simple {
    background-color: #f8f9fa !important;
    border: 1px solid #ddd !important;
    padding: 8px !important;
    border-radius: 6px !important;
    width: 100% !important;
    box-sizing: border-box;
}

/* Section Headings */
.acc-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--acc-text-secondary);
    margin-bottom: 10px;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Font Size Control */
.acc-font-control {
    background: var(--acc-card-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.acc-font-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-weight: 700;
    color: var(--acc-text);
}

.acc-font-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.acc-font-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0f2f5;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--acc-text);
    transition: background 0.2s;
}

.acc-font-btn:hover {
    background: #e4e6e9;
}

.acc-font-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--acc-text);
}

/* Grid Layout for Buttons */
.acc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.acc-btn {
    background: var(--acc-card-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 15px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    height: 100px;
}

.acc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.acc-btn.active {
    border-color: var(--acc-active);
    background-color: #fff;
    box-shadow: inset 0 0 0 1px var(--acc-active);
}

.acc-btn svg {
    width: 32px;
    height: 32px;
    fill: var(--acc-text);
    transition: fill 0.2s;
}

.acc-btn.active svg {
    fill: var(--acc-active);
}

.acc-btn span {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--acc-text);
}

/* Footer */
.acc-footer {
    padding: 20px;
    background: var(--acc-bg);
    border-top: 1px solid var(--acc-border);
}

.acc-reset-btn {
    width: 100%;
    padding: 12px;
    background: var(--acc-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Reading Guide Line */
#acc-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: rgba(255, 255, 0, 0.5);
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    z-index: 999999;
    pointer-events: none;
    display: none;
    transform: translateZ(0);
}

/* --- Accessibility Modes CSS Implementation --- */

/* 1. Font Size handled via JS on 'html' tag */

/* 2. Highlight Title */
/* Moved to specific scope or high specificity to override dark mode */
body.acc-highlight-title h1, 
body.acc-highlight-title h2, 
body.acc-highlight-title h3, 
body.acc-highlight-title h4, 
body.acc-highlight-title h5, 
body.acc-highlight-title h6 {
    border: 3px solid var(--acc-primary) !important;
    padding: 5px !important;
    border-radius: 4px !important;
    background-color: rgba(0, 68, 204, 0.05) !important;
    /* Ensure visibility in dark mode */
    color: inherit !important; 
}
/* In dark mode, make background lighter for visibility or rely on border */
body.acc-dark-contrast.acc-highlight-title h1,
body.acc-dark-contrast.acc-highlight-title h2,
body.acc-dark-contrast.acc-highlight-title h3,
body.acc-dark-contrast.acc-highlight-title h4,
body.acc-dark-contrast.acc-highlight-title h5,
body.acc-dark-contrast.acc-highlight-title h6 {
    background-color: #333 !important;
    border-color: #4da6ff !important;
}

/* 3. Highlight Links */
body.acc-highlight-links a {
    background-color: #ffff00 !important;
    color: #000000 !important;
    text-decoration: underline !important;
    font-weight: bold !important;
}

/* 4. Dyslexia Font */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/opendyslexic@2.1.0-beta1/opendyslexic/OpenDyslexic-Regular.otf');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
body.acc-dyslexia-font * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif !important;
}

/* 5. Letter Spacing */
body.acc-letter-spacing-1 * { letter-spacing: 0.1em !important; }
body.acc-letter-spacing-2 * { letter-spacing: 0.2em !important; }
body.acc-letter-spacing-3 * { letter-spacing: 0.3em !important; }

/* 6. Line Height */
body.acc-line-height-1 * { line-height: 1.5 !important; }
body.acc-line-height-2 * { line-height: 1.8 !important; }
body.acc-line-height-3 * { line-height: 2.2 !important; }

/* 7. Font Weight */
body.acc-font-weight * { font-weight: 700 !important; }

/* 8. Color Adjustments */
body.acc-dark-contrast {
    background-color: #000 !important;
    color: #fff !important;
}
body.acc-dark-contrast * {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}
body.acc-dark-contrast img { opacity: 0.8; }

body.acc-light-contrast {
    background-color: #fff !important;
    color: #000 !important;
}
body.acc-light-contrast * {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}

body.acc-high-contrast {
    /* Filter handled by JS */
}

body.acc-high-saturation {
    /* Filter handled by JS */
}

body.acc-low-saturation {
    /* Filter handled by JS */
}

body.acc-monochrome {
    /* Filter handled by JS */
}

/* 9. Tools */
/* Reading guide handled by JS element */

body.acc-stop-animations * {
    animation: none !important;
    transition: none !important;
    transform: none !important;
}

body.acc-big-cursor, body.acc-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="black" stroke="white" stroke-width="2"><path d="M7 2l12 11.2-5.8.5 3.3 7.3-2.2.9-3.2-7.4-4.4 4.6z"/></svg>') 0 0, auto !important;
}

/* Hide Google Translate Bar Frame */
.goog-te-banner-frame.skiptranslate {
    display: none !important;
} 
body {
    top: 0px !important; 
}

/* Responsive adjustment on mobile (< 768px) to prevent bottom app bar overlap */
@media (max-width: 767.98px) {
    #acc-trigger {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
        left: 14px !important;
        width: 44px !important;
        height: 44px !important;
        border: 2px solid #ffffff !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
        z-index: 1000 !important;
    }
    #acc-trigger svg {
        width: 22px !important;
        height: 22px !important;
    }
    #acc-panel {
        width: 100vw !important;
        max-width: 100vw !important;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
}
