/* =========================
   TOOL WRAPPER
========================= */

.accessibility-toolbar {
    position: fixed;
    left: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 2147483647;

    display: flex;
    align-items: center;

    isolation: isolate;
}

/* =========================
   TOGGLE BUTTON (ALWAYS SAFE)
========================= */

.accessibility-toggle {
    width: 60px;
    height: 60px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;

    background: #288ce6 !important;
    color: #fff !important;

    border: none !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);

    position: relative;
    z-index: 2147483647;

    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

    /* prevent theme interference */
    filter: none !important;
}

/* FORCE ICON VISIBILITY */
.accessibility-toggle {
    -webkit-text-fill-color: #fff !important;
}

/* =========================
   PANEL (BASE STYLE)
========================= */

.accessibility-panel {
    position: fixed;
    left: 90px;
    bottom: calc(90px + env(safe-area-inset-bottom));

    width: 320px;
    max-height: 70vh;          /* IMPORTANT */
    overflow: hidden;          /* container clean */

    background: #fff;
    color: #111;

    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);

    display: none;

    z-index: 2147483647;
}

.accessibility-panel.active {
    display: block;
}

.accessibility-panel * {
    color: inherit;
}

/* =========================
   HEADER + CONTENT
========================= */

.accessibility-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px;
    border-bottom: 1px solid #eee;
}

.accessibility-content {
    padding: 12px;

    max-height: calc(70vh - 60px); /* header space */
    overflow-y: auto;

    -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
}

.accessibility-group {
    margin-bottom: 15px;
}

.accessibility-btn {
    width: 100%;
    margin-top: 6px;
    padding: 8px;

    border: 1px solid #ddd;
    background: #f8f9fa;

    cursor: pointer;
}

/* =========================
   OVERLAYS
========================= */

#reading-guide-line {
    position: fixed;
    left: 0;
    width: 100%;
    height: 3px;
    background: red;

    display: none;

    z-index: 2147483646;
    pointer-events: none;
}

#reading-mask-overlay {
    position: fixed;
    inset: 0;

    display: none;

    background: rgba(0,0,0,0.5);

    z-index: 2147483645;
    pointer-events: none;
}

/* =========================
   THEMES (FIXED - NO UI BREAKING)
========================= */

/* IMPORTANT: we ONLY style main content, NOT UI */

body.high-contrast main,
body.high-contrast section,
body.high-contrast div.content {
    background: #000 !important;
    color: #fff !important;
}

body.high-contrast a {
    color: yellow !important;
}

/* PANEL SAFE OVERRIDE */
body.high-contrast .accessibility-panel {
    background: #111 !important;
    color: #fff !important;
    border: 1px solid #fff !important;
}

body.high-contrast .accessibility-btn {
    background: #000 !important;
    color: #fff !important;
    border: 1px solid #fff !important;
}

/* =========================
   LIGHT MODE (SAFE)
========================= */

body.light-mode main,
body.light-mode section,
body.light-mode div.content {
    background: #fff !important;
    /*color: #111 !important;*/
}

/*body.light-mode .offer-area {*/
/*    background-color: #17548F !important;*/
/*}*/

body.light-mode {
    /*background: #fff;*/
    color: #111;
}

/*body.light-mode .offer-area,*/
/*body.light-mode .offer-area p,*/
/*body.light-mode .offer-area h1,*/
/*body.light-mode .offer-area h2 {*/
/*    color: #fff !important;*/
/*}*/

body.light-mode p,
body.light-mode span,
body.light-mode li,
body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4,
body.light-mode h5,
body.light-mode h6 {
    color: #111 !important;
}


body.light-mode a {
    color: #0d6efd !important;
}

/* PANEL */
body.light-mode .accessibility-panel {
    background: #fff !important;
    color: #111 !important;
}

/* =========================
   DYSLEXIA MODE
========================= */

body.dyslexia {
    font-family: Arial, Helvetica, sans-serif !important;

    line-height: 2 !important;
    letter-spacing: 0.9px !important;
    word-spacing: 3px !important;
}

/* =========================
   EXTRA FEATURES
========================= */

body.text-spacing {
    line-height: 1.9 !important;
    letter-spacing: 0.6px !important;
    word-spacing: 2px !important;
}

body.highlight-links a {
    background: yellow !important;
    color: black !important;
}

body.keyboard-focus *:focus {
    outline: 3px solid #ff9800 !important;
    outline-offset: 2px;
}


.accessibility-content::-webkit-scrollbar {
    width: 6px;
}

.accessibility-content::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
}

.accessibility-content::-webkit-scrollbar-track {
    background: transparent;
}


@media (max-width: 768px) {

    .accessibility-panel {
        left: 10px;
        right: 10px;
        bottom: calc(80px + env(safe-area-inset-bottom));

        width: auto;
        max-height: 75vh;
    }

    .accessibility-toggle {
        width: 55px;
        height: 55px;
        font-size: 20px;
    }
}
