/**
 * ARH - Rauhes Barrierefreiheit
 * Frontend CSS
 * (c) 2026 Rauhes.de
 */

/* ===== Toggle Button ===== */
#rhs-a11y-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #50af30;
    border: 2px solid #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}
#rhs-a11y-toggle:hover { transform: scale(1.1); box-shadow: 0 6px 16px rgba(0,0,0,0.4); }
#rhs-a11y-toggle:focus { outline: 3px solid #fff; outline-offset: 2px; }
#rhs-a11y-toggle svg { width: 30px; height: 30px; fill: #000; }

/* ===== Active Count Badge ===== */
#rhs-a11y-badge {
    display: none;
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ff6d00;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    padding: 0 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
#rhs-a11y-badge.rhs-a11y-badge-visible { display: block; }

/* ===== Panel ===== */
#rhs-a11y-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999998;
    width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 0;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#rhs-a11y-panel.rhs-a11y-panel--open {
    display: block;
    animation: rhs-a11y-fadein 0.25s ease;
}
@keyframes rhs-a11y-fadein {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Panel Header ===== */
#rhs-a11y-panel-header {
    background: #50af30;
    color: #000;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 20px;
    font-weight: 600;
    border-radius: 16px 16px 0 0;
}
#rhs-a11y-panel-header span { display: flex; align-items: center; gap: 8px; }
#rhs-a11y-panel-header svg { width: 30px; height: 30px; fill: #000; }
#rhs-a11y-panel-close {
    background: none; border: 1px solid #000; color: #000; cursor: pointer;
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: bold; padding: 0; line-height: 1;
    transition: background 0.15s ease;
}
#rhs-a11y-panel-close:hover { background: rgba(255,255,255,0.2); }
#rhs-a11y-panel-close:focus { outline: 2px solid #fff; outline-offset: 1px; }

/* ===== Panel isolation from WP theme ===== */
#rhs-a11y-panel,
#rhs-a11y-panel *,
#rhs-a11y-panel *::before,
#rhs-a11y-panel *::after {
    box-sizing: border-box !important;
    direction: ltr !important;
    unicode-bidi: normal !important;
}

/* ===== Panel Body - 3-column grid ===== */
#rhs-a11y-panel-body {
    padding: 12px !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
    text-align: left !important;
    list-style: none !important;
    margin: 0 !important;
    float: none !important;
    justify-content: stretch !important;
    justify-items: stretch !important;
    align-content: start !important;
}
/* Hide any non-button elements injected by WP theme/plugins */
#rhs-a11y-panel-body > *:not(button) {
    display: none !important;
}

/* ===== Explicit grid positions (nuclear option against WP theme overrides) ===== */
#rhs-a11y-btn-tts        { grid-column: 1 !important; grid-row: 1 !important; }
#rhs-a11y-btn-contrast   { grid-column: 2 !important; grid-row: 1 !important; }
#rhs-a11y-btn-links      { grid-column: 3 !important; grid-row: 1 !important; }
#rhs-a11y-btn-fontsize   { grid-column: 1 !important; grid-row: 2 !important; }
#rhs-a11y-btn-spacing    { grid-column: 2 !important; grid-row: 2 !important; }
#rhs-a11y-btn-animations { grid-column: 3 !important; grid-row: 2 !important; }
#rhs-a11y-btn-images     { grid-column: 1 !important; grid-row: 3 !important; }
#rhs-a11y-btn-dyslexia   { grid-column: 2 !important; grid-row: 3 !important; }
#rhs-a11y-btn-cursor     { grid-column: 3 !important; grid-row: 3 !important; }
#rhs-a11y-btn-lineheight { grid-column: 1 !important; grid-row: 4 !important; }
#rhs-a11y-btn-align      { grid-column: 2 !important; grid-row: 4 !important; }
#rhs-a11y-btn-saturation { grid-column: 3 !important; grid-row: 4 !important; }
#rhs-a11y-reset-btn      { grid-column: 1 / -1 !important; grid-row: 5 !important; }

/* ===== Feature Button ===== */
#rhs-a11y-panel-body .rhs-a11y-feature-btn {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 16px 8px 12px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 12px !important;
    background: #fff !important;
    cursor: pointer !important;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #333 !important;
    text-align: center !important;
    min-height: 100px !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    float: none !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    box-sizing: border-box !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
#rhs-a11y-panel-body .rhs-a11y-feature-btn:hover { border-color: #4caf50 !important; background: #f5fdf5 !important; }
#rhs-a11y-panel-body .rhs-a11y-feature-btn:focus { outline: 3px solid #4caf50 !important; outline-offset: 1px !important; }
#rhs-a11y-panel-body .rhs-a11y-feature-btn.rhs-a11y-active {
    border-color: #2e7d32 !important; background: #e8f5e9 !important; box-shadow: 0 0 0 1px #2e7d32 !important;
}

/* ===== Checkmark on active buttons ===== */
.rhs-a11y-feature-btn .rhs-a11y-check {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    align-items: center;
    justify-content: center;
}
.rhs-a11y-feature-btn .rhs-a11y-check svg {
    width: 12px;
    height: 12px;
    fill: #fff;
}
.rhs-a11y-feature-btn.rhs-a11y-active .rhs-a11y-check {
    display: flex;
}
.rhs-a11y-feature-btn svg { width: 36px; height: 36px; fill: #333; flex-shrink: 0; }
.rhs-a11y-feature-btn.rhs-a11y-active svg { fill: #2e7d32; }

/* ===== Mode Indicator Bars ===== */
.rhs-a11y-indicators { display: flex; gap: 4px; margin-top: 2px; }
.rhs-a11y-indicators span {
    width: 14px; height: 3px; border-radius: 2px; background: #ccc;
    transition: background 0.2s ease;
}
.rhs-a11y-indicators span.rhs-a11y-ind-on { background: #2e7d32; }

/* ===== Contrast Modes ===== */
html.rhs-a11y-contrast-dark { filter: invert(1) hue-rotate(180deg); }
html.rhs-a11y-contrast-dark img,
html.rhs-a11y-contrast-dark video,
html.rhs-a11y-contrast-dark picture,
html.rhs-a11y-contrast-dark svg:not(#rhs-a11y-toggle svg):not(#rhs-a11y-panel svg):not(.rhs-a11y-feature-btn svg),
html.rhs-a11y-contrast-dark [style*="background-image"],
html.rhs-a11y-contrast-dark canvas { filter: invert(1) hue-rotate(180deg); }

html.rhs-a11y-contrast-invert { filter: invert(1); }
html.rhs-a11y-contrast-invert img,
html.rhs-a11y-contrast-invert video,
html.rhs-a11y-contrast-invert picture,
html.rhs-a11y-contrast-invert svg:not(#rhs-a11y-toggle svg):not(#rhs-a11y-panel svg):not(.rhs-a11y-feature-btn svg),
html.rhs-a11y-contrast-invert [style*="background-image"],
html.rhs-a11y-contrast-invert canvas { filter: invert(1); }

html.rhs-a11y-contrast-light { filter: contrast(1.5) brightness(1.1); }

/* ===== Highlight Links ===== */
html.rhs-a11y-highlight-links a {
    outline: 2px solid #ff0 !important;
    background-color: rgba(255,255,0,0.15) !important;
    text-decoration: underline !important;
}

/* ===== Large Text (4 levels) - applied via JS ===== */

/* ===== Text Spacing (3 levels) ===== */
html.rhs-a11y-spacing-1 body { letter-spacing: 0.05em !important; word-spacing: 0.1em !important; line-height: 1.6 !important; }
html.rhs-a11y-spacing-2 body { letter-spacing: 0.1em !important; word-spacing: 0.2em !important; line-height: 1.8 !important; }
html.rhs-a11y-spacing-3 body { letter-spacing: 0.15em !important; word-spacing: 0.35em !important; line-height: 2.0 !important; }

/* ===== Stop Animations ===== */
html.rhs-a11y-no-animations *,
html.rhs-a11y-no-animations *::before,
html.rhs-a11y-no-animations *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* ===== Hide Images ===== */
html.rhs-a11y-hide-images img,
html.rhs-a11y-hide-images picture,
html.rhs-a11y-hide-images svg:not(#rhs-a11y-toggle svg):not(#rhs-a11y-panel svg):not(.rhs-a11y-feature-btn svg),
html.rhs-a11y-hide-images video,
html.rhs-a11y-hide-images [style*="background-image"] {
    opacity: 0.05 !important;
}

/* ===== Dyslexia Friendly ===== */
html.rhs-a11y-dyslexia-1 body { font-family: 'OpenDyslexic', 'Comic Sans MS', cursive, sans-serif !important; font-size: 200% !important; }
html.rhs-a11y-dyslexia-2 body { font-family: Verdana, Geneva, sans-serif !important; letter-spacing: 0.03em !important; word-spacing: 0.08em !important; }

/* ===== Large Cursor ===== */
html.rhs-a11y-cursor-big,
html.rhs-a11y-cursor-big * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 32 32'%3E%3Cpath d='M4 0l20 16-9 1 6 12-4 2-6-12-7 7z' fill='black' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 4 0, auto !important;
}

/* ===== Reading Mask ===== */
#rhs-a11y-reading-mask {
    display: none;
    position: fixed;
    left: 0; top: 0; width: 100%; height: 100%;
    z-index: 999990;
    pointer-events: none;
}
#rhs-a11y-reading-mask.rhs-a11y-visible { display: block; }
#rhs-a11y-mask-top, #rhs-a11y-mask-bottom {
    position: absolute; left: 0; width: 100%;
    background: rgba(0,0,0,0.6);
    transition: top 0.05s linear, height 0.05s linear;
}
#rhs-a11y-mask-top { top: 0; }
#rhs-a11y-mask-bottom { bottom: 0; }

/* ===== Reading Guide ===== */
#rhs-a11y-reading-guide {
    display: none;
    position: fixed;
    left: 0; width: 100%; height: 3px;
    background: #ff0000;
    z-index: 999990;
    pointer-events: none;
    transition: top 0.05s linear;
}
#rhs-a11y-reading-guide.rhs-a11y-visible { display: block; }

/* ===== Line Height (3 levels) ===== */
html.rhs-a11y-lineheight-1 body * { line-height: 1.5 !important; }
html.rhs-a11y-lineheight-2 body * { line-height: 1.75 !important; }
html.rhs-a11y-lineheight-3 body * { line-height: 2 !important; }

/* ===== Text Alignment (4 modes) ===== */
html.rhs-a11y-align-left body * { text-align: left !important; }
html.rhs-a11y-align-right body * { text-align: right !important; }
html.rhs-a11y-align-center body * { text-align: center !important; }
html.rhs-a11y-align-justify body * { text-align: justify !important; }

/* ===== Saturation (3 modes) ===== */
html.rhs-a11y-saturation-low { filter: saturate(0.5); }
html.rhs-a11y-saturation-high { filter: saturate(2); }
html.rhs-a11y-saturation-none { filter: saturate(0); }

/* ===== Reset Button ===== */
#rhs-a11y-reset-btn {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: #50af30;
    color: #000;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s ease;
    margin-top: 4px;
}
#rhs-a11y-reset-btn:hover { background: #50af30; }
#rhs-a11y-reset-btn:focus { outline: 3px solid #2e7d32; outline-offset: 1px; }
#rhs-a11y-reset-btn svg { width: 24px; height: 24px; fill: #000; }

/* ===== Vorlesen active highlight ===== */
.rhs-a11y-tts-highlight {
    background-color: rgba(76,175,80,0.25) !important;
    outline: 2px solid #4caf50 !important;
}
html.rhs-a11y-tts-active [data-rhs-tts-target] { cursor: pointer !important; }
