/**
 * Accessibility toolbar + back-to-top for resume.berezawp.com
 * Ported from the prismaticflowers.com widget 2026-07-30 and re-themed.
 *
 * PORTED, NOT PASTED. Four defects in the source were fixed on the way over
 * (memory: feedback_porting_a_component_means_testing_it_not_pasting_it):
 *   1. 29 inline onclick handlers -> data attributes + one delegated listener,
 *      so a stricter CSP later cannot silently disarm every control.
 *   2. `font-size: calc(1em * S)` on every element compounded once per nesting
 *      level (17.5px became 560px on one site). Scaling happens ONCE at :root here.
 *   3. alert() on reset -> an aria-live status region.
 *   4. Floating furniture: ADA sits bottom-LEFT, back-to-top bottom-RIGHT, and
 *      nothing else on this site is pinned, so they cannot overlap each other.
 */

:root {
    --dbada-primary: #2563eb;
    --dbada-primary-dark: #1d4ed8;
    --dbada-accent: #0ea5e9;
    --dbada-dark: #0f172a;
    --dbada-text: #334155;
    --dbada-border: #e2e8f0;
    --dbada-white: #ffffff;
    --dbada-shadow: 0 10px 15px -3px rgba(0,0,0,.15), 0 4px 6px -2px rgba(0,0,0,.08);
}

/* ---------- launcher ---------- */
.dbada-button {
    position: fixed;
    bottom: 24px;
    left: 20px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--dbada-primary), var(--dbada-accent));
    color: #fff;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
    z-index: 99998;
    box-shadow: var(--dbada-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
}
.dbada-button:hover { transform: scale(1.08); }
.dbada-button:focus-visible { outline: 3px solid var(--dbada-dark); outline-offset: 3px; }

/* ---------- panel ---------- */
.dbada-panel {
    position: fixed;
    bottom: 90px;
    left: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: min(76vh, 640px);
    background: var(--dbada-white);
    border: 1px solid var(--dbada-border);
    border-radius: 14px;
    box-shadow: var(--dbada-shadow);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
}
.dbada-panel.dbada-open { display: flex; }

.dbada-header {
    background: linear-gradient(135deg, var(--dbada-primary), var(--dbada-accent));
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}
.dbada-header h2 { margin: 0; font-size: 1.05rem; color: #fff; }
.dbada-close {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.dbada-close:hover { background: rgba(255,255,255,.35); }

.dbada-tabs { display: flex; border-bottom: 1px solid var(--dbada-border); flex: 0 0 auto; }
.dbada-tab {
    flex: 1;
    padding: 11px 4px;
    background: #f8fafc;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
    color: var(--dbada-text);
}
.dbada-tab[aria-selected="true"] {
    background: var(--dbada-white);
    border-bottom-color: var(--dbada-primary);
    color: var(--dbada-primary);
}

.dbada-content { padding: 16px 18px 20px; overflow-y: auto; flex: 1 1 auto; }
.dbada-pane { display: none; }
.dbada-pane.dbada-active { display: block; }

.dbada-section-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    margin: 4px 0 10px;
    font-weight: 700;
}

.dbada-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dbada-opt {
    padding: 11px 9px;
    border: 2px solid var(--dbada-border);
    border-radius: 9px;
    background: var(--dbada-white);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    color: var(--dbada-text);
    text-align: center;
    line-height: 1.3;
}
.dbada-opt:hover { border-color: var(--dbada-primary); }
.dbada-opt[aria-pressed="true"] {
    border-color: var(--dbada-primary);
    background: #eff6ff;
    color: var(--dbada-primary-dark);
}
.dbada-opt:focus-visible { outline: 3px solid var(--dbada-primary); outline-offset: 2px; }

.dbada-slider-row { margin: 14px 0; }
.dbada-slider-label {
    display: flex;
    justify-content: space-between;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--dbada-text);
}
.dbada-slider-row input[type="range"] { width: 100%; accent-color: var(--dbada-primary); }

.dbada-actions { display: flex; gap: 9px; margin-top: 18px; }
.dbada-act {
    flex: 1;
    padding: 10px;
    border-radius: 9px;
    border: 2px solid var(--dbada-border);
    background: var(--dbada-white);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    color: var(--dbada-text);
}
.dbada-act:hover { border-color: var(--dbada-primary); color: var(--dbada-primary); }

/* Replaces the source widget's alert(). Announces without stealing focus. */
.dbada-status {
    margin-top: 12px;
    font-size: .8rem;
    color: var(--dbada-primary-dark);
    min-height: 1.2em;
}

/* ---------- applied accessibility features ---------- */
/* Scaling is applied ONCE here. Never re-multiply per element.
 *
 * Scaling :root alone was NOT enough on this site and shipped as a dead control
 * until a click test caught it: style.css sets `body { font-size: 16px }` (14px
 * under 480px), and that px declaration overrides the inherited root size, so
 * every <p> stayed at 14.0px while the slider moved. Headings use rem and would
 * have scaled, which is exactly why a spot check on an <h1> would have passed.
 *
 * So body is re-declared here against a CONSTANT base times the scale. The
 * multiplier still lands exactly once, so nothing compounds through nesting.
 * The breakpoint below mirrors style.css:604 - keep them in step. */
html.dbada-scaled { font-size: calc(100% * var(--dbada-font-scale, 1)); }
html.dbada-scaled body { font-size: calc(16px * var(--dbada-font-scale, 1)); }
@media (max-width: 480px) {
    html.dbada-scaled body { font-size: calc(14px * var(--dbada-font-scale, 1)); }
}
body.dbada-linespace  * { line-height: var(--dbada-line-height, 1.5) !important; }
body.dbada-letterspace * { letter-spacing: var(--dbada-letter-space, 0em) !important; }

body.dbada-grayscale { filter: grayscale(100%); }
body.dbada-contrast  { filter: contrast(1.55); }
body.dbada-invert    { filter: invert(1) hue-rotate(180deg); }
body.dbada-invert img, body.dbada-invert video { filter: invert(1) hue-rotate(180deg); }

body.dbada-links a {
    text-decoration: underline !important;
    text-underline-offset: 3px;
    outline: 2px solid #f59e0b !important;
    outline-offset: 1px;
}
body.dbada-titles h1, body.dbada-titles h2, body.dbada-titles h3,
body.dbada-titles h4, body.dbada-titles h5, body.dbada-titles h6 {
    outline: 2px dashed var(--dbada-primary) !important;
    outline-offset: 3px;
}
body.dbada-noimg img { visibility: hidden !important; }
body.dbada-nomotion *,
body.dbada-nomotion *::before,
body.dbada-nomotion *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}
body.dbada-readable * {
    font-family: Verdana, Geneva, Arial, sans-serif !important;
}
body.dbada-bigcursor { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M6 2 L6 38 L15 30 L21 44 L28 41 L22 27 L34 27 Z' fill='%230f172a' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 6 2, auto; }

#dbada-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--dbada-primary);
    z-index: 99997;
    pointer-events: none;
    display: none;
}
body.dbada-guide #dbada-guide { display: block; }

/* Never let the widget restyle itself into unreadability. */
.dbada-panel, .dbada-panel *, .dbada-button, .dbada-backtotop {
    filter: none !important;
    letter-spacing: normal !important;
}

/* ---------- back to top ---------- */
.dbada-backtotop {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--dbada-dark);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 99996;
    box-shadow: var(--dbada-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.dbada-backtotop.dbada-show { opacity: 1; visibility: visible; transform: translateY(0); }
.dbada-backtotop:hover { background: var(--dbada-primary); }
.dbada-backtotop:focus-visible { outline: 3px solid var(--dbada-primary); outline-offset: 3px; }

@media (max-width: 480px) {
    .dbada-button   { width: 48px; height: 48px; font-size: 22px; bottom: 18px; left: 14px; }
    .dbada-backtotop{ width: 44px; height: 44px; bottom: 18px; right: 14px; }
    .dbada-panel    { bottom: 76px; left: 14px; }
    .dbada-grid     { grid-template-columns: 1fr; }
}
