/* =============================================================
   Digelite – Frontend Barrierefreiheits-Panel
   WCAG 2.2 AA: 1.4.4 · 1.4.3 · 1.4.12 · 2.3.3 · 3.1.5 · 2.4.11 · 2.5.8
   Panel öffnet links neben der .bf-fixed-nav-Pill (right-side).
   ============================================================= */

/* -------------------------------------------------------
   A) BENUTZEREINSTELLUNGEN – data-Attribute auf <html>
------------------------------------------------------- */

/* Schriftgröße (WCAG 1.4.4) */
html[data-bf-size="large"] { font-size: 112% !important; }
html[data-bf-size="xl"]    { font-size: 125% !important; }

/* Hoher Kontrast (WCAG 1.4.3 / 1.4.6) */
html[data-bf-contrast] body {
    background-color: #ffffff !important;
    color: #000000 !important;
}
html[data-bf-contrast] :is(p, li, h1, h2, h3, h4, h5, h6) {
    color: #000000 !important;
}
html[data-bf-contrast] a {
    color: #0000cc !important;
    text-decoration: underline !important;
}
html[data-bf-contrast] a:visited {
    color: #440088 !important;
}
html[data-bf-contrast] :is(input, select, textarea) {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #000000 !important;
}

/* Animationen pausieren (WCAG 2.3.3) */
html[data-bf-anim-off] *,
html[data-bf-anim-off] *::before,
html[data-bf-anim-off] *::after {
    animation-duration:        0.001ms !important;
    animation-iteration-count: 1       !important;
    transition-duration:       0.001ms !important;
    scroll-behavior:           auto    !important;
}
/* Panel-Animation vom eigenen anim-off ausschließen – sonst öffnet es ohne Bewegung */
html[data-bf-anim-off] .dbf-panel {
    transition: transform 0.2s ease, opacity 0.2s ease !important;
}

/* Zeilenabstand (WCAG 1.4.12) */
html[data-bf-spacing] :is(p, li, dt, dd, td, th) {
    line-height:    1.8    !important;
    letter-spacing: 0.12em !important;
    word-spacing:   0.16em !important;
}
html[data-bf-spacing] p {
    margin-bottom: 2em !important;
}

/* Lesehilfe-Schrift (WCAG 3.1.5) */
html[data-bf-font] :is(body, p, li, a, button, input, select, textarea, label, td, th) {
    font-family:    Verdana, Arial, 'Liberation Sans', sans-serif !important;
    letter-spacing: 0.05em !important;
}

/* Links hervorheben (WCAG 1.4.1) */
html[data-bf-links] a {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
    font-weight: 600 !important;
    outline-offset: 2px;
}

/* Leselineal */
#dbf-ruler {
    position: fixed;
    left: 0;
    width: 100%;
    height: 36px;
    background: rgba(255, 220, 0, 0.30);
    border-top: 2px solid rgba(200, 160, 0, 0.50);
    border-bottom: 2px solid rgba(200, 160, 0, 0.50);
    pointer-events: none;
    z-index: 999990;
    display: none;
}

/* Panel und Trigger von Kontrast-Overrides ausnehmen */
html[data-bf-contrast] .dbf-panel,
html[data-bf-contrast] .dbf-panel-header,
html[data-bf-contrast] .dbf-panel-footer,
html[data-bf-contrast] .dbf-panel-body {
    background-color: #ffffff !important;
}
html[data-bf-contrast] .dbf-panel :is(p, li, h1, h2, h3, span, div) {
    color: inherit !important;
    background-color: transparent !important;
}
/* Strukturelle Panel-Divs explizit schützen (höhere Spezifität als die div-Regel oben) */
html[data-bf-contrast] .dbf-panel .dbf-panel-header,
html[data-bf-contrast] .dbf-panel .dbf-panel-footer,
html[data-bf-contrast] .dbf-panel .dbf-panel-body {
    background-color: #ffffff !important;
}
html[data-bf-contrast] .dbf-panel-title { color: #111111 !important; }
html[data-bf-contrast] .dbf-row-name    { color: #111111 !important; }
html[data-bf-contrast] .dbf-row-desc    { color: #767676 !important; }
html[data-bf-contrast] .dbf-close       { color: #555555 !important; }
html[data-bf-contrast] .dbf-fallback-trigger {
    color: #ffffff !important;
    background-color: var(--dbf-color, #1a56db) !important;
}


/* -------------------------------------------------------
   B) PANEL – positioniert neben der bf-fixed-nav
   Trigger: #mdp-readabler-trigger-button (48px, right: 5px)
   → Panel right: 5 + 48 + 12 = 65px
------------------------------------------------------- */

.dbf-panel {
    position: fixed;
    right: 65px;
    top: 50%;
    z-index: 999998; /* knapp unter bf-fixed-nav (999999) */
    width: 348px;
    max-width: calc(100vw - 80px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.14),
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1rem;
    color: #1a1a1a;
    /* Eintritt-Animation: von rechts gleiten */
    transform: translateY(-50%) translateX(14px);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    pointer-events: none;
}
.dbf-panel.dbf-panel--open {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
    .dbf-panel { transition: none; }
}
.dbf-panel[hidden] { display: none; }


/* ── Panel-Kopfzeile ── */
.dbf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: 1px solid #ebebeb;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
    border-radius: 16px 16px 0 0;
}
.dbf-panel-title {
    margin: 0;
    font-size: 1.125em;
    font-weight: 700;
    color: #111111;
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.dbf-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #555555;
    font-size: 1.25em;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.dbf-close:hover   { background: #f2f2f2; }
.dbf-close:focus-visible {
    outline: 3px solid var(--dbf-color, #1a56db);
    outline-offset: 2px;
}


/* ── Zeilen ── */
.dbf-panel-body { padding: 6px 0; }

.dbf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px;
}
.dbf-row + .dbf-row { border-top: 1px solid #f3f3f3; }

.dbf-row-info {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}
.dbf-row-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #f0f4ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125em;
    font-weight: 700;
    color: var(--dbf-color, #1a56db);
    flex-shrink: 0;
    user-select: none;
}
.dbf-row-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.dbf-row-name {
    font-weight: 600;
    font-size: 0.9375em;
    color: #111111;
    line-height: 1.3;
}
.dbf-row-desc {
    font-size: 0.9375em;
    color: #999999;
    line-height: 1.3;
    font-weight: 400;
}


/* ── Schriftgröße – segmentierte Steuerung ── */
.dbf-row:has(.dbf-size-group) {
    flex-wrap: wrap;
    row-gap: 10px;
}
.dbf-size-group {
    display: flex;
    width: 100%;
    border: 1.5px solid #d1d5db;
    border-radius: 9px;
    overflow: hidden;
}
.dbf-size-btn {
    flex: 1;
    padding: 10px 6px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9375em;
    font-weight: 500;
    cursor: pointer;
    color: #4b5563;
    line-height: 1;
    transition: background 0.1s;
    text-align: center;
}
.dbf-size-btn + .dbf-size-btn { border-left: 1.5px solid #d1d5db; }
.dbf-size-btn:hover { background: #f3f4f6; }
.dbf-size-btn[aria-pressed="true"] {
    background: var(--dbf-color, #1a56db);
    color: #ffffff;
}
.dbf-size-btn:focus-visible {
    outline: 3px solid var(--dbf-color, #1a56db);
    outline-offset: -1px;
    z-index: 1;
    position: relative;
}


/* ── Toggle-Switch (role="switch") ── */
.dbf-switch {
    -webkit-appearance: none;
    appearance: none;
    width: 48px;
    height: 28px;
    background: #d1d5db;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
    padding: 0;
}
.dbf-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s;
}
.dbf-switch[aria-checked="true"] { background: var(--dbf-color, #1a56db); }
.dbf-switch[aria-checked="true"]::after { transform: translateX(20px); }
.dbf-switch:focus-visible {
    outline: 3px solid var(--dbf-color, #1a56db);
    outline-offset: 2px;
}
.dbf-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}


/* ── Fußzeile ── */
.dbf-panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid #ebebeb;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    border-radius: 0 0 16px 16px;
}
.dbf-reset-btn {
    padding: 8px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    font-size: 0.9375em;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.dbf-reset-btn:hover { background: #f9fafb; border-color: #9ca3af; }
.dbf-reset-btn:focus-visible {
    outline: 3px solid var(--dbf-color, #1a56db);
    outline-offset: 2px;
}
.dbf-powered {
    font-size: 0.875em;
    color: #cccccc;
    user-select: none;
    letter-spacing: 0.01em;
}


/* ── Fallback-Trigger (nur wenn kein #mdp-readabler-trigger-button) ── */
.dbf-fallback-trigger {
    position: fixed;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999999;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 15%;
    background: var(--dbf-color, #1a56db) !important;
    color: #ffffff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
}
.dbf-fallback-trigger:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--dbf-color, #1a56db);
}
.dbf-fallback-trigger svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}


/* ── Mobil: Panel von unten, über allen Nav-Icons ── */
@media (max-width: 600px) {
    .dbf-panel {
        right: 0 !important;
        left: 0 !important;
        top: auto;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(20px);
        transition: transform 0.22s ease, opacity 0.22s ease;
    }
    /* Panel im offenen Zustand über die bf-fixed-nav (999999) heben */
    .dbf-panel.dbf-panel--open {
        transform: translateY(0);
        z-index: 1000001 !important;
    }
    .dbf-panel-header { border-radius: 20px 20px 0 0; }
    .dbf-panel-footer { border-radius: 0; }

    /* Nav-Pill auf Mobile ausblenden wenn Panel offen ist */
    html:has(.dbf-panel--open) .bf-fixed-nav {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s;
    }
}

/* ── Dropdown-Toggle (Sprache + Profile) ── */
.dbf-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    gap: 8px;
}
.dbf-section-toggle:focus-visible {
    outline: 3px solid var(--dbf-color, #1a56db);
    outline-offset: 3px;
    border-radius: 4px;
}
.dbf-chevron {
    display: block;
    color: #555555;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.dbf-section-toggle[aria-expanded="true"] .dbf-chevron {
    transform: rotate(180deg);
}
.dbf-section-body[hidden] { display: none; }
.dbf-section-body { padding-top: 10px; }

/* ── Barrierefreiheitsprofile ── */
.dbf-profile-section {
    padding: 14px 20px 12px;
    border-bottom: 2px solid #f0f0f0;
}
.dbf-profile-title {
    font-size: 1em;
    font-weight: 700;
    color: #222222;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
}
.dbf-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    padding-bottom: 4px;
}
.dbf-profile-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 9px;
    background: #ffffff;
    font-family: inherit;
    font-size: 0.9375em;
    font-weight: 500;
    color: #333333;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1.3;
    min-width: 0;
}
.dbf-profile-btn:hover {
    background: #f5f7ff;
    border-color: #c5ccde;
    color: #111111;
}
.dbf-profile-btn--active {
    background: var(--dbf-color, #1a56db);
    border-color: var(--dbf-color, #1a56db);
    color: #ffffff !important;
    font-weight: 600;
}
.dbf-profile-btn--active:hover {
    background: var(--dbf-color, #1a56db);
    border-color: var(--dbf-color, #1a56db);
}
.dbf-profile-btn:focus-visible {
    outline: 3px solid var(--dbf-color, #1a56db);
    outline-offset: 2px;
}
/* Profil-Icon mit SVG */
.dbf-profile-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #f0f4ff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dbf-color, #1a56db);
    flex-shrink: 0;
    user-select: none;
}
.dbf-profile-btn--active .dbf-profile-icon {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}
.dbf-profile-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
/* Kontrast-Override: Profile-Buttons isolieren */
html[data-bf-contrast] .dbf-profile-btn {
    color: #333333 !important;
    background: #ffffff !important;
    border-color: #333333 !important;
}
html[data-bf-contrast] .dbf-profile-btn--active {
    background: var(--dbf-color, #1a56db) !important;
    border-color: var(--dbf-color, #1a56db) !important;
    color: #ffffff !important;
}
html[data-bf-contrast] .dbf-profile-icon {
    background: #f0f4ff !important;
    color: var(--dbf-color, #1a56db) !important;
}
html[data-bf-contrast] .dbf-profile-btn--active .dbf-profile-icon {
    background: rgba(255,255,255,0.22) !important;
    color: #ffffff !important;
}

/* ─── TranslatePress Sprachumschalter im Panel-Footer ─── */

/* Footer-Wrapper – nimmt den Platz des Branding-Texts ein */
.dbf-footer-lang {
    display: flex;
    align-items: center;
    position: relative;
}

/* TP rendert seinen eigenen Stil – nur Schriftgröße anpassen */
.dbf-footer-lang .trp-language-switcher-container,
.dbf-footer-lang .trp-ls-shortcode-container {
    font-size: 0.875em;
    font-family: inherit;
}

/* Dropdown-Liste nach oben öffnen statt nach unten */
.dbf-footer-lang li ul,
.dbf-footer-lang .trp-current-language ul,
.dbf-footer-lang .trp-language-item-list {
    position: absolute !important;
    bottom: calc(100% + 6px) !important;
    top: auto !important;
    right: 0 !important;
    left: auto !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 10px !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.14) !important;
    min-width: 130px !important;
    z-index: 999999 !important;
    list-style: none !important;
    padding: 4px 0 !important;
    margin: 0 !important;
}


/* ── Aktiver Zustand des ♿-Buttons ── */
#mdp-readabler-trigger-button[aria-expanded="true"] {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
}
/* Tooltip ausblenden wenn Panel geöffnet ist */
#mdp-readabler-trigger-button[aria-expanded="true"] .bf-tooltip {
    opacity: 0 !important;
    pointer-events: none !important;
}
