/*
 * Apuração das Eleições 2026.
 *
 * Folha própria, servida como arquivo estático e carregada só nas páginas com
 * apuração: a funcionalidade sobe sem rebuild do bundle do site e sai do ar
 * sem deixar CSS para trás. Tudo fica sob .elx para não vazar no portal.
 */

.elx {
    --elx-primary: #035083;
    --elx-primary-strong: #023a60;
    --elx-primary-soft: #e8f0f6;
    --elx-bar: #6f9bbd;
    --elx-live: #d81b1b;
    --elx-live-soft: #fdecec;
    --elx-elected: #146c34;
    --elx-elected-soft: #def5e5;
    --elx-runoff: #8a4b06;
    --elx-runoff-soft: #fdf0d5;
    --elx-ink: #0f172a;
    --elx-text: #1e293b;
    --elx-muted: #5b6678;
    --elx-line: #e2e8f0;
    --elx-track: #edf1f5;
    --elx-surface: #ffffff;
    --elx-radius: 12px;
    --elx-gutter: 16px;

    color: var(--elx-text);
    font-family: Roboto, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    text-align: left;
    -webkit-font-smoothing: antialiased;
}

.elx *,
.elx *::before,
.elx *::after {
    box-sizing: border-box;
}

.elx [hidden] {
    display: none !important;
}

.elx a {
    color: inherit;
    text-decoration: none;
}

.elx :focus-visible {
    outline: 3px solid var(--elx-primary);
    outline-offset: 2px;
    border-radius: 6px;
}

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

.elx-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Cabeçalho de seção ---------- */

.elx-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 0 var(--elx-gutter) 12px;
    border-bottom: 1px solid var(--elx-line);
    margin-bottom: 16px;
}

.elx-head__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--elx-primary);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.elx-head__title a:hover {
    color: var(--elx-primary-strong);
}

.elx-head__kicker {
    display: block;
    margin-bottom: 2px;
    color: var(--elx-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.elx-head__actions {
    display: flex;
    flex: 1 1 100%;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.elx-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 4px;
    color: var(--elx-primary);
    font-size: 15px;
    font-weight: 600;
}

.elx-link:hover {
    color: var(--elx-primary-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.elx-link svg {
    width: 16px;
    height: 16px;
    flex: none;
}

.elx-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 40px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--elx-line);
    border-radius: 999px;
    background: var(--elx-surface);
    color: var(--elx-primary);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.elx-refresh:hover {
    border-color: var(--elx-primary);
}

.elx-refresh:disabled {
    cursor: progress;
}

.elx-refresh svg {
    width: 16px;
    height: 16px;
}

[aria-busy="true"] .elx-refresh svg {
    animation: elx-spin 0.9s linear infinite;
}

.elx-alert {
    margin: 0 var(--elx-gutter) 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--elx-runoff-soft);
    color: var(--elx-runoff);
    font-size: 14px;
}

.elx-source {
    margin: 12px var(--elx-gutter) 0;
    color: var(--elx-muted);
    font-size: 13px;
}

/* ---------- Selo de status da apuração ---------- */

.elx-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
}

.elx-status--counting {
    background: var(--elx-live-soft);
    color: var(--elx-live);
}

.elx-status--counting::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: elx-pulse 1.8s ease-out infinite;
}

.elx-status--finished {
    background: var(--elx-elected-soft);
    color: var(--elx-elected);
}

.elx-status--pending {
    background: var(--elx-track);
    color: var(--elx-muted);
}

/* ---------- Destaques (home e resumo) ---------- */

.elx-races {
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 2px var(--elx-gutter) 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--elx-gutter);
    scrollbar-width: none;
    list-style: none;
}

.elx-races::-webkit-scrollbar {
    display: none;
}

.elx-races > li {
    display: flex;
    flex: 0 0 86%;
    max-width: 380px;
    scroll-snap-align: start;
}

.elx-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 16px;
    border: 1px solid var(--elx-line);
    border-radius: var(--elx-radius);
    background: var(--elx-surface);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 4px 16px rgb(15 23 42 / 0.05);
}

.elx-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.elx-card__title {
    margin: 0;
    color: var(--elx-ink);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.elx-card__title a:hover {
    color: var(--elx-primary);
}

.elx-card__region {
    margin: 2px 0 0;
    color: var(--elx-muted);
    font-size: 13px;
}

.elx-card__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--elx-line);
}

.elx-card__foot .elx-link {
    min-height: 36px;
    padding: 0;
    font-size: 14px;
}

.elx-updated {
    color: var(--elx-muted);
    font-size: 12px;
}

/* ---------- Progresso das seções apuradas ---------- */

.elx-progress {
    margin: 14px 0 6px;
}

.elx-progress__label {
    margin: 0 0 6px;
    color: var(--elx-muted);
    font-size: 13px;
}

.elx-progress__label strong {
    color: var(--elx-ink);
    font-size: 15px;
    font-weight: 700;
}

.elx-progress__track {
    height: 6px;
    border-radius: 999px;
    background: var(--elx-track);
    overflow: hidden;
}

.elx-progress__track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--elx-primary);
    transition: width 0.6s ease;
}

/* ---------- Lista de candidatos ---------- */

.elx-list {
    margin: 4px 0 12px;
    padding: 0;
    list-style: none;
}

.elx-cand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--elx-line);
}

.elx-cand:last-child {
    border-bottom: 0;
}

.elx-cand__photo {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--elx-primary-soft);
    overflow: hidden;
}

.elx-cand__photo img,
.elx-cand__initials {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.elx-cand__photo img {
    object-fit: cover;
    object-position: center 18%;
}

.elx-cand__initials {
    display: grid;
    place-items: center;
    color: var(--elx-primary);
    font-size: 15px;
    font-weight: 700;
}

.elx-cand__body {
    min-width: 0;
}

.elx-cand__name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 8px;
    margin: 0;
    color: var(--elx-ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
}

.elx-cand__meta {
    display: block;
    margin: 2px 0 0;
    color: var(--elx-muted);
    font-size: 13px;
    line-height: 1.3;
}

.elx-card .elx-cand__meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.elx-cand__numbers {
    text-align: right;
    white-space: nowrap;
}

.elx-cand__pct {
    display: block;
    color: var(--elx-ink);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
}

.elx-cand__votes {
    display: block;
    color: var(--elx-muted);
    font-size: 12px;
}

.elx-bar {
    grid-column: 2 / -1;
    height: 6px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--elx-track);
    overflow: hidden;
}

.elx-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--elx-bar);
    transition: width 0.6s ease;
}

.elx-cand.is-leader .elx-bar > span {
    background: var(--elx-primary);
}

.elx-cand.is-elected .elx-bar > span {
    background: var(--elx-elected);
}

.elx-cand.is-out .elx-cand__name,
.elx-cand.is-out .elx-cand__pct {
    color: var(--elx-muted);
}

.elx-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.5;
    text-transform: uppercase;
    white-space: nowrap;
}

.elx-badge--elected {
    background: var(--elx-elected-soft);
    color: var(--elx-elected);
}

.elx-badge--runoff {
    background: var(--elx-runoff-soft);
    color: var(--elx-runoff);
}

.elx-badge--neutral {
    background: var(--elx-track);
    color: var(--elx-muted);
}

/* Separa quem ocupa as vagas do restante (senado com 2 vagas) */
.elx-cand.is-cutoff {
    border-bottom: 2px dashed var(--elx-line);
}

.elx-note {
    margin: 8px 0 0;
    color: var(--elx-muted);
    font-size: 13px;
    line-height: 1.45;
}

/* ---------- Carregando ---------- */

.elx-skeleton {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--elx-track) 0, #f6f8fa 40%, var(--elx-track) 80%) var(--elx-track);
    background-size: 400px 100%;
    animation: elx-shimmer 1.3s linear infinite;
}

.elx-skeleton--title {
    width: 55%;
    height: 20px;
}

.elx-skeleton--line {
    width: 100%;
    height: 12px;
    margin-top: 14px;
}

.elx-skeleton--row {
    width: 100%;
    height: 44px;
    margin-top: 14px;
}

/* ---------- Página da apuração ---------- */

.elx-page {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

.elx-page--wide {
    max-width: none;
}

.elx-page__intro {
    padding: 0 var(--elx-gutter);
    margin-bottom: 16px;
}

.elx-page__title {
    margin: 0;
    color: var(--elx-primary);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.elx-page__lead {
    margin: 8px 0 0;
    color: var(--elx-muted);
    font-size: 16px;
    line-height: 1.5;
}

.elx-tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 16px;
    padding: 2px var(--elx-gutter) 6px;
    overflow-x: auto;
    scrollbar-width: none;
    list-style: none;
}

.elx-tabs::-webkit-scrollbar {
    display: none;
}

/* Esmaece a borda direita no celular para indicar que há mais cargos ao lado */
@media (max-width: 767px) {
    .elx-tabs {
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
    }
}

.elx-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--elx-line);
    border-radius: 999px;
    background: var(--elx-surface);
    color: var(--elx-text);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.elx-tabs a:hover {
    border-color: var(--elx-primary);
    color: var(--elx-primary);
}

.elx-tabs a[aria-current="page"] {
    border-color: var(--elx-primary);
    background: var(--elx-primary);
    color: #fff;
}

.elx-panel {
    margin: 0 var(--elx-gutter);
    padding: 16px;
    border: 1px solid var(--elx-line);
    border-radius: var(--elx-radius);
    background: var(--elx-surface);
}

.elx-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 0 var(--elx-gutter) 16px;
}

.elx-field {
    display: flex;
    flex: 1 1 220px;
    flex-direction: column;
    gap: 6px;
}

.elx-field label {
    color: var(--elx-muted);
    font-size: 13px;
    font-weight: 600;
}

.elx-field__row {
    display: flex;
    gap: 8px;
}

.elx-input,
.elx-select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background-color: var(--elx-surface);
    color: var(--elx-ink);
    font: inherit;
    font-size: 16px;
}

.elx-input:focus,
.elx-select:focus {
    border-color: var(--elx-primary);
    box-shadow: 0 0 0 3px rgb(3 80 131 / 0.18);
    outline: none;
}

.elx-button {
    flex: none;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    background: var(--elx-primary);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.elx-button:hover {
    background: var(--elx-primary-strong);
}

.elx-summary-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
}

.elx-summary-bar .elx-progress {
    flex: 1 1 100%;
    margin: 4px 0 0;
}

.elx-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin: 16px 0 0;
    border: 1px solid var(--elx-line);
    border-radius: 10px;
    background: var(--elx-line);
    overflow: hidden;
}

.elx-stats > div {
    padding: 12px;
    background: var(--elx-surface);
}

.elx-stats dt {
    color: var(--elx-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.elx-stats dd {
    margin: 4px 0 0;
    color: var(--elx-ink);
    font-size: 18px;
    font-weight: 700;
}

.elx-stats dd small {
    display: block;
    color: var(--elx-muted);
    font-size: 12px;
    font-weight: 400;
}

.elx-seats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.elx-seats li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 10px;
    border: 1px solid var(--elx-line);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.elx-seats strong {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--elx-primary);
    color: #fff;
    font-size: 12px;
}

.elx-section-title {
    margin: 20px 0 4px;
    color: var(--elx-ink);
    font-size: 16px;
    font-weight: 700;
}

.elx-empty {
    margin: 16px 0;
    color: var(--elx-muted);
    text-align: center;
}

.elx-share {
    display: flex;
    justify-content: flex-start;
    margin-top: 12px;
}

/* ---------- Telas maiores ---------- */

@media (min-width: 768px) {
    .elx {
        --elx-gutter: 0px;
    }

    .elx-head__title {
        font-size: 32px;
    }

    .elx-head__actions {
        flex: none;
    }

    .elx-races {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
        overflow: visible;
    }

    .elx-races > li {
        max-width: none;
    }

    .elx-page__title {
        font-size: 36px;
    }

    .elx-panel {
        padding: 24px;
    }

    .elx-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .elx-list--full .elx-cand {
        grid-template-columns: 52px minmax(0, 1fr) auto;
    }

    .elx-list--full .elx-cand__photo {
        width: 52px;
        height: 52px;
    }
}

@media (min-width: 1024px) {
    .elx-stats {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* ---------- Movimento ---------- */

@keyframes elx-pulse {
    0% { box-shadow: 0 0 0 0 rgb(216 27 27 / 0.55); }
    70% { box-shadow: 0 0 0 6px rgb(216 27 27 / 0); }
    100% { box-shadow: 0 0 0 0 rgb(216 27 27 / 0); }
}

@keyframes elx-shimmer {
    from { background-position: -200px 0; }
    to { background-position: 200px 0; }
}

@keyframes elx-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .elx *,
    .elx *::before,
    .elx *::after {
        animation: none !important;
        transition: none !important;
    }
}
