/**
 * PDNews Enquete IA — Estilos do Leitor (Ambiente 1: Frontend Público)
 * Direção Estética: Editorial Cívico & Jornalismo de Dados (@frontend-design)
 * Padrões Web: Container Queries (@container), accent-color + fallback, <dialog> nativo (@modern-web-guidance)
 */

:root {
    color-scheme: light dark;
    --pd-navy: hsl(218, 52%, 14%);
    --pd-slate: hsl(216, 26%, 26%);
    --pd-accent: hsl(214, 88%, 42%);
    --pd-accent-hover: hsl(214, 88%, 34%);
    --pd-accent-soft: hsla(214, 88%, 42%, 0.08);
    --pd-crimson: hsl(350, 82%, 45%);
    --pd-emerald: hsl(158, 76%, 32%);
    --pd-emerald-soft: hsla(158, 76%, 32%, 0.12);
    --pd-surface: hsl(210, 35%, 99%);
    --pd-surface-alt: hsl(214, 30%, 95%);
    --pd-border: hsl(214, 24%, 86%);
    --pd-text: hsl(218, 45%, 12%);
    --pd-muted: hsl(215, 16%, 42%);
    --pd-track: hsl(214, 25%, 91%);
    --pd-radius: 14px;
    --pd-transition: 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --pd-navy: hsl(215, 42%, 11%);
        --pd-slate: hsl(214, 24%, 78%);
        --pd-accent: hsl(210, 92%, 62%);
        --pd-accent-hover: hsl(210, 92%, 70%);
        --pd-accent-soft: hsla(210, 92%, 62%, 0.14);
        --pd-crimson: hsl(350, 85%, 60%);
        --pd-emerald: hsl(156, 72%, 48%);
        --pd-emerald-soft: hsla(156, 72%, 48%, 0.16);
        --pd-surface: hsl(220, 32%, 13%);
        --pd-surface-alt: hsl(220, 28%, 17%);
        --pd-border: hsl(218, 22%, 25%);
        --pd-text: hsl(210, 30%, 96%);
        --pd-muted: hsl(215, 18%, 68%);
        --pd-track: hsl(218, 24%, 22%);
    }
}

/* ─── Container Query Root (modern-web-guidance: size-aware-styling) ─── */
.pdnews-poll-container {
    container-type: inline-size;
    margin: 2.25rem 0;
    width: 100%;
    box-sizing: border-box;
}

.pdnews-poll-container *,
.pdnews-poll-container *::before,
.pdnews-poll-container *::after {
    box-sizing: border-box;
}

.pdnews-poll-card {
    accent-color: var(--pd-accent);
    background: var(--pd-surface);
    color: var(--pd-text);
    border: 1px solid var(--pd-border);
    border-top: 4px solid var(--pd-accent);
    border-radius: var(--pd-radius);
    padding: clamp(1.25rem, 3vw, 1.85rem);
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 14px 34px -16px rgba(11, 23, 42, 0.12);
    position: relative;
    overflow: hidden;
}

.pdnews-tabular-num {
    font-variant-numeric: tabular-nums;
}

/* ─── Header Editorial Limpo (@revivium Regra 4) ─── */
.pdnews-poll-header {
    padding-bottom: 1.1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--pd-border);
}

.pdnews-poll-header__meta {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.pdnews-poll-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--pd-accent);
}

.pdnews-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pd-crimson);
    box-shadow: 0 0 0 3px hsla(350, 82%, 45%, 0.2);
    animation: pdnewsPulse 2.2s infinite ease-in-out;
}

@keyframes pdnewsPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.22); opacity: 0.75; }
}

.pdnews-poll-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--pd-muted);
    background: var(--pd-surface-alt);
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    width: fit-content;
}

.pdnews-poll-counter strong {
    font-family: "Space Grotesk", sans-serif;
    color: var(--pd-text);
    font-weight: 700;
}

.pdnews-poll-title {
    font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif !important;
    font-size: clamp(1.15rem, 2.4vw, 1.4rem) !important;
    font-weight: 700 !important;
    line-height: 1.28 !important;
    margin: 0 !important;
    color: var(--pd-text) !important;
}

/* ─── Feedback de Status ─── */
.pdnews-poll-feedback {
    padding: 0.75rem 1rem;
    border-radius: 9px;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 1.1rem;
}

.pdnews-poll-feedback.is-success {
    background: var(--pd-emerald-soft);
    color: var(--pd-emerald);
    border: 1px solid var(--pd-emerald);
}

.pdnews-poll-feedback.is-error {
    background: hsla(350, 82%, 45%, 0.1);
    color: var(--pd-crimson);
    border: 1px solid var(--pd-crimson);
}

/* ─── Perguntas e Opções de Votação ─── */
.pdnews-question-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 1.35rem 0;
}

.pdnews-question-legend {
    font-size: clamp(1rem, 2vw, 1.12rem);
    font-weight: 700;
    line-height: 1.45;
    color: var(--pd-text);
    margin-bottom: 0.9rem;
    padding: 0;
    display: block;
    width: 100%;
}

.pdnews-question-num {
    font-family: "Space Grotesk", sans-serif;
    color: var(--pd-accent);
    margin-right: 0.35rem;
}

.pdnews-options-grid {
    display: grid;
    gap: 0.65rem;
}

.pdnews-option-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--pd-border);
    border-radius: 10px;
    background: var(--pd-surface);
    cursor: pointer;
    transition: border-color var(--pd-transition), background-color var(--pd-transition), transform var(--pd-transition);
    position: relative;
}

.pdnews-option-label:hover {
    border-color: var(--pd-accent);
    background: var(--pd-accent-soft);
    transform: translateY(-1px);
}

.pdnews-option-label:has(input:checked) {
    border-color: var(--pd-accent);
    background: var(--pd-accent-soft);
    box-shadow: 0 0 0 1px var(--pd-accent);
}

.pdnews-option-label:has(input:focus-visible) {
    outline: 3px solid var(--pd-accent);
    outline-offset: 2px;
}

.pdnews-option-radio {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}

.pdnews-option-text {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--pd-text);
}

/* Fallback para navegadores sem suporte a accent-color (modern-web-guidance: brand-consistent-forms) */
@supports not (accent-color: var(--pd-accent)) {
    .pdnews-poll-card input[type="radio"].visually-hidden {
        position: absolute !important;
        clip-path: inset(50%) !important;
        overflow: hidden !important;
        width: 1px !important;
        height: 1px !important;
        margin: -1px !important;
        padding: 0 !important;
        border: 0 !important;
        white-space: nowrap !important;
    }

    .pdnews-option-label {
        padding-left: 2.5rem;
    }

    .pdnews-option-radio + .pdnews-option-text::before {
        content: "";
        position: absolute;
        left: 0.9rem;
        top: 50%;
        transform: translateY(-50%);
        width: 1.15rem;
        height: 1.15rem;
        border: 2px solid var(--pd-muted);
        border-radius: 50%;
        background: var(--pd-surface);
        box-sizing: border-box;
    }

    .pdnews-option-radio:checked + .pdnews-option-text::before {
        border-color: var(--pd-accent);
        background: var(--pd-accent);
        box-shadow: inset 0 0 0 3px var(--pd-surface);
    }
}

/* ─── Botões de Ação (Votar & Ver Respostas) ─── */
.pdnews-poll-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1.15rem;
}

.pdnews-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.78rem 1.35rem;
    border-radius: 9px;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid transparent;
    text-decoration: none;
    transition: background-color var(--pd-transition), color var(--pd-transition), transform var(--pd-transition), border-color var(--pd-transition);
}

.pdnews-btn:active {
    transform: scale(0.99);
}

.pdnews-btn--vote {
    background: var(--pd-accent);
    color: #fff;
}

.pdnews-btn--vote:hover,
.pdnews-btn--vote:focus-visible {
    background: var(--pd-accent-hover);
    color: #fff;
}

.pdnews-btn--secondary {
    background: var(--pd-surface-alt);
    color: var(--pd-text);
    border-color: var(--pd-border);
}

.pdnews-btn--secondary:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

.pdnews-btn--ghost {
    background: transparent;
    color: var(--pd-muted);
    border-color: var(--pd-border);
}

.pdnews-btn--ghost:hover {
    color: var(--pd-text);
    background: var(--pd-surface-alt);
}

/* ─── Painel de Resultados e Barras de Progresso ─── */
.pdnews-result-group {
    margin-bottom: 1.35rem;
}

.pdnews-result-question-title {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    margin: 0 0 0.85rem 0 !important;
    color: var(--pd-text) !important;
    line-height: 1.4 !important;
}

.pdnews-result-bars {
    display: grid;
    gap: 0.75rem;
}

.pdnews-result-item {
    padding: 0.75rem 0.95rem;
    border-radius: 10px;
    border: 1px solid var(--pd-border);
    background: var(--pd-surface);
}

.pdnews-result-item.is-leading {
    border-color: var(--pd-accent);
}

.pdnews-result-item.is-user-choice {
    background: var(--pd-accent-soft);
    border-color: var(--pd-accent);
}

.pdnews-result-item__top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
}

.pdnews-result-item__label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--pd-text);
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.pdnews-user-vote-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: var(--pd-emerald);
    color: #fff;
}

.pdnews-result-item__stats {
    white-space: nowrap;
    font-family: "Space Grotesk", sans-serif;
}

.pdnews-result-pct {
    font-size: 0.98rem;
    color: var(--pd-text);
}

.pdnews-result-count {
    font-size: 0.78rem;
    color: var(--pd-muted);
    margin-left: 0.25rem;
}

.pdnews-result-track {
    width: 100%;
    height: 9px;
    background: var(--pd-track);
    border-radius: 999px;
    overflow: hidden;
}

.pdnews-result-fill {
    height: 100%;
    width: 0;
    background: var(--pd-slate);
    border-radius: 999px;
    transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.pdnews-result-item.is-leading .pdnews-result-fill {
    background: var(--pd-accent);
}

.pdnews-result-item.is-user-choice .pdnews-result-fill {
    background: var(--pd-emerald);
}

.pdnews-voted-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--pd-emerald);
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    background: var(--pd-emerald-soft);
}

/* ─── Footer Institucional & Modal Nativo <dialog> (@revivium Regra 4) ─── */
.pdnews-poll-footer {
    margin-top: 1.35rem;
    padding-top: 0.9rem;
    border-top: 1px dashed var(--pd-border);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.76rem;
    color: var(--pd-muted);
}

.pdnews-poll-footer__link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--pd-accent);
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.pdnews-lgpd-dialog {
    max-width: 520px;
    width: calc(100% - 2rem);
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    padding: 0;
    background: var(--pd-surface);
    color: var(--pd-text);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
}

.pdnews-lgpd-dialog::backdrop {
    background: rgba(10, 18, 32, 0.55);
    backdrop-filter: blur(3px);
}

.pdnews-lgpd-dialog__inner {
    padding: 1.5rem;
}

.pdnews-lgpd-dialog__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--pd-border);
}

.pdnews-lgpd-dialog__header h4 {
    margin: 0 !important;
    font-size: 1.05rem !important;
    font-weight: 700 !important;
}

.pdnews-lgpd-dialog__close {
    background: var(--pd-surface-alt);
    border: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--pd-text);
    font-weight: 700;
}

.pdnews-lgpd-dialog__body p {
    font-size: 0.88rem;
    line-height: 1.55;
    margin: 0 0 0.85rem 0;
    color: var(--pd-text);
}

.pdnews-lgpd-dialog__footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* ─── Adaptação por Container Queries (modern-web-guidance: size-aware-styling) ─── */
@media (min-width: 600px) {
    .pdnews-poll-header__meta {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .pdnews-poll-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

@supports (container-type: inline-size) {
    @media (min-width: 600px) {
        .pdnews-poll-header__meta {
            flex-direction: column;
        }
        .pdnews-poll-actions {
            flex-direction: column;
        }
    }

    @container (min-width: 460px) {
        .pdnews-poll-header__meta {
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
        }
        .pdnews-poll-actions {
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .pdnews-pulse-dot,
    .pdnews-result-fill,
    .pdnews-option-label,
    .pdnews-btn {
        animation: none !important;
        transition: none !important;
    }
}
