/* Widget flutuante — estilos críticos (botão + painel) */

html {
    --a11y-font-scale: 1;
}

html.a11y-font-scaled {
    font-size: calc(100% * var(--a11y-font-scale));
}

.a11y-widget {
    position: fixed;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    z-index: 1200;
}

.a11y-widget-trigger,
.a11y-widget-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-background);
    color: var(--color-dark);
    box-shadow: 0 8px 24px rgba(26, 31, 38, 0.14);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.a11y-widget-trigger:hover,
.a11y-widget-btn:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
    background: var(--color-bg-alt);
}

.a11y-widget-trigger img,
.a11y-widget-btn img {
    display: block;
    width: 22px;
    height: 22px;
    pointer-events: none;
}

.a11y-contrast-icon {
    object-fit: contain;
}

.a11y-widget-trigger {
    position: relative;
    z-index: 2;
    width: 56px;
    height: 56px;
    background: var(--color-dark);
    color: #ffffff;
    border-color: var(--color-dark);
}

.a11y-widget-trigger img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

.a11y-widget.is-open .a11y-widget-trigger {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.a11y-widget-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.65rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    pointer-events: none;
}

.a11y-widget.is-open .a11y-widget-panel {
    pointer-events: auto;
}

.a11y-widget-panel[hidden] {
    display: none;
}

.a11y-widget.is-open .a11y-widget-panel {
    display: flex;
    animation: a11yPanelIn 0.28s ease;
}

.a11y-widget.is-open .a11y-widget-btn,
.a11y-widget.is-open .a11y-widget-panel a.a11y-widget-btn {
    animation: a11yBtnIn 0.32s ease backwards;
}

.a11y-widget.is-open .a11y-widget-panel > *:nth-child(1) { animation-delay: 0.18s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(2) { animation-delay: 0.16s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(3) { animation-delay: 0.14s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(4) { animation-delay: 0.12s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(5) { animation-delay: 0.10s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(6) { animation-delay: 0.08s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(7) { animation-delay: 0.06s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(8) { animation-delay: 0.04s; }
.a11y-widget.is-open .a11y-widget-panel > *:nth-child(9) { animation-delay: 0.02s; }

.a11y-widget-btn[aria-pressed="true"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff;
}

.a11y-widget-btn[aria-pressed="true"] img {
    filter: brightness(0) invert(1);
}

@keyframes a11yPanelIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes a11yBtnIn {
    from { opacity: 0; transform: translateY(10px) scale(0.85); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Evita flash do banner antes do CSS adiado carregar */
.cookie-banner[hidden] {
    display: none !important;
}

@media (max-width: 767px) {
    .a11y-widget {
        right: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    .a11y-widget-trigger,
    .a11y-widget-btn {
        width: 48px;
        height: 48px;
    }

    .a11y-widget-trigger {
        width: 52px;
        height: 52px;
    }
}
