/* =============================================================
   DU Global – Accessibility Widget  (UserWay-equivalent)
   ============================================================= */

/* ── Toggle Button ─────────────────────────────────────────── */
.a11y-toggle {
    position: fixed;
    left: 0;
    bottom: 24px;
    z-index: 99998;
    width: 50px;
    height: 50px;
    border-radius: 0 10px 10px 0;
    background: #c8102e;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 3px 14px rgba(0,0,0,.28);
    transition: background .2s, width .22s;
    padding: 0;
    outline: none;
    overflow: visible;
}
.a11y-toggle:hover { background: #a10d24; width: 56px; }
.a11y-toggle:focus-visible { outline: 3px solid #ffd700; outline-offset: 2px; }
.a11y-toggle svg { width: 26px; height: 26px; fill: #fff; flex-shrink: 0; }

/* ── Tooltip ─────────────────────────────────────────────── */
.a11y-tooltip {
    position: absolute;
    left: calc(100% + 10px);
    bottom: 50%;
    transform: translateY(50%);
    background: #222;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-family: Arial, sans-serif;
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.a11y-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #222;
}
.a11y-toggle:hover .a11y-tooltip { opacity: 1; }

/* ── Overlay ────────────────────────────────────────────────── */
.a11y-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 99990;
}
.a11y-overlay.open { display: block; }

/* ── Panel ─────────────────────────────────────────────────── */
.a11y-panel {
    position: fixed;
    top: 0;
    left: -360px;
    width: 345px;
    height: 100vh;
    background: #f5f5f5;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    transition: left .32s cubic-bezier(.4,0,.2,1);
    font-family: inherit;
    font-size: 13px;
    overflow: hidden;
}
.a11y-panel.open { left: 0; }

/* ── Panel Header ───────────────────────────────────────────── */
.a11y-head {
    background: #c8102e;
    color: #fff;
    padding: 14px 16px 12px;
    flex-shrink: 0;
}
.a11y-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.a11y-head-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .01em;
}
.a11y-head-title svg { width: 22px; height: 22px; fill: #fff; }
.a11y-close-btn {
    background: rgba(255,255,255,.18);
    border: none;
    color: #fff;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background .2s;
    flex-shrink: 0;
}
.a11y-close-btn:hover { background: rgba(255,255,255,.35); }

/* ── Panel Body ─────────────────────────────────────────────── */
.a11y-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
    scroll-behavior: smooth;
}
.a11y-body::-webkit-scrollbar { width: 5px; }
.a11y-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ── Section ────────────────────────────────────────────────── */
.a11y-section { margin-bottom: 16px; }
.a11y-section-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #999;
    margin-bottom: 8px;
    padding-left: 2px;
}

/* ── Profile Cards ──────────────────────────────────────────── */
.a11y-profiles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.a11y-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: #fff;
    border: 1.5px solid #e4e4e4;
    border-radius: 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #444;
    text-align: center;
    line-height: 1.25;
    transition: all .18s;
}
.a11y-profile svg { width: 28px; height: 28px; fill: #888; transition: fill .18s; }
.a11y-profile:hover { background: #fff1f1; border-color: #c8102e; color: #c8102e; }
.a11y-profile:hover svg { fill: #c8102e; }
.a11y-profile.active { background: #c8102e; border-color: #c8102e; color: #fff; }
.a11y-profile.active svg { fill: #fff; }
.a11y-profile-full { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 10px; }

/* ── Feature Buttons (2-column grid) ────────────────────────── */
.a11y-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}
.a11y-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 6px;
    background: #fff;
    border: 1.5px solid #e4e4e4;
    border-radius: 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #444;
    text-align: center;
    line-height: 1.25;
    transition: all .18s;
}
.a11y-btn svg { width: 22px; height: 22px; fill: #888; transition: fill .18s; }
.a11y-btn:hover { background: #fff1f1; border-color: #c8102e; color: #c8102e; }
.a11y-btn:hover svg { fill: #c8102e; }
.a11y-btn.active { background: #c8102e; border-color: #c8102e; color: #fff; }
.a11y-btn.active svg { fill: #fff; }
.a11y-btn-full { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 8px; }

/* ── Stepper Controls (font/line-height/letter-spacing) ─────── */
.a11y-stepper {
    background: #fff;
    border: 1.5px solid #e4e4e4;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}
.a11y-stepper-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.a11y-stepper-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.a11y-step-btn {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1.5px solid #e0e0e0;
    background: #f8f8f8;
    color: #333;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    line-height: 1;
}
.a11y-step-btn:hover { background: #fff1f1; border-color: #c8102e; color: #c8102e; }
.a11y-step-value {
    min-width: 48px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #333;
    background: #f3f3f3;
    border-radius: 6px;
    padding: 4px 6px;
}

/* ── Text Align Row ─────────────────────────────────────────── */
.a11y-align-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 7px;
}

/* ── Color Filter Buttons ───────────────────────────────────── */
.a11y-color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 7px;
}
.a11y-color-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px;
    background: #fff;
    border: 1.5px solid #e4e4e4;
    border-radius: 10px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    color: #444;
    text-align: center;
    line-height: 1.2;
    transition: all .18s;
}
.a11y-color-btn .a11y-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #eee;
    flex-shrink: 0;
}
.a11y-color-btn:hover { border-color: #c8102e; background: #fff1f1; color: #c8102e; }
.a11y-color-btn.active { border-color: #c8102e; background: #c8102e; color: #fff; }
.a11y-color-btn.active .a11y-color-swatch { border-color: #fff; }

/* ── Panel Footer (fixed at bottom, always visible) ─────────── */
.a11y-footer {
    flex-shrink: 0;
    padding: 10px 12px;
    background: #f5f5f5;
    border-top: 1px solid #e4e4e4;
}

/* ── Reset Button ───────────────────────────────────────────── */
.a11y-reset {
    display: block;
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    text-align: center;
    transition: all .15s;
}
.a11y-reset:hover { background: #fff1f1; border-color: #c8102e; color: #c8102e; }

/* ── Divider ────────────────────────────────────────────────── */
.a11y-divider {
    height: 1px;
    background: #e4e4e4;
    margin: 4px 0 14px;
}

/* =============================================================
   ACTIVE FEATURE OVERRIDES ON <body>
   ============================================================= */

/* Color filters — applied to .wrapper so position:fixed elements (toggle, panel)
   are NOT inside the filtered context and remain fixed on scroll */
body.a11y-dark    .wrapper { filter: invert(1) hue-rotate(180deg); }
body.a11y-dark    .wrapper img,
body.a11y-dark    .wrapper video,
body.a11y-dark    .wrapper svg  { filter: invert(1) hue-rotate(180deg); }
body.a11y-light   .wrapper { filter: brightness(1.08) contrast(1.25); }
body.a11y-mono    .wrapper { filter: grayscale(1); }
body.a11y-contrast .wrapper { filter: contrast(2.5); }
body.a11y-hi-sat  .wrapper { filter: saturate(3); }
body.a11y-lo-sat  .wrapper { filter: saturate(.3); }
body.a11y-invert  .wrapper { filter: invert(1) hue-rotate(180deg); }
body.a11y-invert  .wrapper img,
body.a11y-invert  .wrapper video { filter: invert(1) hue-rotate(180deg); }

/* Readable / dyslexia font */
body.a11y-readable *:not(.a11y-panel):not(.a11y-panel *) {
    font-family: Arial, Helvetica, sans-serif !important;
    letter-spacing: .04em;
    word-spacing: .1em;
}

/* Highlight titles */
body.a11y-titles h1,
body.a11y-titles h2,
body.a11y-titles h3,
body.a11y-titles h4,
body.a11y-titles h5,
body.a11y-titles h6 {
    text-decoration: underline !important;
    text-decoration-color: #c8102e !important;
    text-underline-offset: 4px !important;
}

/* Highlight links */
body.a11y-links a {
    outline: 2px solid #c8102e !important;
    outline-offset: 2px !important;
    text-decoration: underline !important;
}

/* Text alignment */
body.a11y-align-left   *:not(.a11y-panel):not(.a11y-panel *) { text-align: left   !important; }
body.a11y-align-center *:not(.a11y-panel):not(.a11y-panel *) { text-align: center !important; }
body.a11y-align-right  *:not(.a11y-panel):not(.a11y-panel *) { text-align: right  !important; }

/* Pause animations */
body.a11y-pause *:not(.a11y-panel):not(.a11y-panel *) {
    animation: none !important;
    transition: none !important;
}

/* Hide images */
body.a11y-hide-img img { visibility: hidden !important; }

/* Highlight hover */
body.a11y-hover-highlight *:not(.a11y-panel):not(.a11y-panel *):hover {
    outline: 3px solid #c8102e !important;
    outline-offset: 2px !important;
}

/* Focus indicator */
body.a11y-focus-ring *:focus {
    outline: 3px solid #c8102e !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 5px rgba(200,16,46,.2) !important;
}

/* Big cursors */
body.a11y-cursor-black,
body.a11y-cursor-black * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='2.5' d='M7 2l24 16-9 2.5 5 10-4 2-5-10-11 7z'/%3E%3C/svg%3E") 5 2, auto !important;
}
body.a11y-cursor-white,
body.a11y-cursor-white * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath fill='%23fff' stroke='%23000' stroke-width='2.5' d='M7 2l24 16-9 2.5 5 10-4 2-5-10-11 7z'/%3E%3C/svg%3E") 5 2, auto !important;
}

/* ── Reading Guide ──────────────────────────────────────────── */
#a11y-reading-guide {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(200,16,46,.1);
    border-top: 2px solid rgba(200,16,46,.6);
    border-bottom: 2px solid rgba(200,16,46,.6);
    pointer-events: none;
    z-index: 99995;
}
body.a11y-guide #a11y-reading-guide { display: block; }

/* ── Reading Mask ───────────────────────────────────────────── */
#a11y-mask-top, #a11y-mask-bot {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    background: rgba(0,0,0,.72);
    pointer-events: none;
    z-index: 99994;
}
body.a11y-mask #a11y-mask-top { display: block; top: 0; }
body.a11y-mask #a11y-mask-bot { display: block; bottom: 0; }

/* ── Text Magnifier ─────────────────────────────────────────── */
#a11y-magnifier {
    display: none;
    position: fixed;
    background: #fff;
    border: 2px solid #c8102e;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 22px !important;
    font-weight: 500;
    color: #111;
    max-width: 300px;
    white-space: normal;
    word-break: break-word;
    box-shadow: 0 6px 24px rgba(0,0,0,.18);
    pointer-events: none;
    z-index: 99993;
    line-height: 1.4;
}
body.a11y-magnifier #a11y-magnifier { display: block; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .a11y-panel { width: 100vw; left: -100vw; }
    .a11y-toggle { bottom: 16px; }
    .a11y-tooltip { display: none; }
}
