/* Public results + shared tokens (brand palette from logo) */
:root {
    --brand-teal: #0b7d7f;
    --brand-green: #39b54a;
    --brand-mint: #7ef3d3;
    --brand-orange: #f7931e;
    --brand-yellow: #ffc107;
    --brand-deep: #053a3b;
    --card-bg: #ffffff;
    --card-radius: 20px;
    --text-muted: #9ca3af;
    --text-dark: #111827;
    --track: #e5e7eb;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body.app-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Noto Sans", system-ui, sans-serif;
    color: var(--text-dark);
    background:
        linear-gradient(
            168deg,
            var(--brand-deep) 0%,
            var(--brand-teal) 22%,
            #0a5c52 42%,
            var(--brand-teal) 58%,
            #0d4a4c 78%,
            #1a3830 100%
        );
    overflow-x: hidden;
}

/* Dhivehi (Thaana) copy — MV Faseyha */
.loading-msg,
.area-dv,
.title-dv,
.subtitle-dv,
.name-dv,
.ballot-footnote,
.foot-link,
.foot-btn {
    font-family: var(--font-dhivehi);
}

@media (prefers-reduced-motion: reduce) {
    .bg-anim,
    .bg-anim::before,
    .bg-anim::after {
        animation: none !important;
    }

    .bar-fill--animate,
    .poll-row__fill--animate {
        transition: none !important;
    }

    .stats-dash,
    .stats-dash__live,
    .stats-metric__value--anim {
        animation: none !important;
        transition: none !important;
    }
}

.bg-anim {
    position: fixed;
    inset: -40%;
    z-index: 0;
    background:
        radial-gradient(ellipse 75% 55% at 18% 28%, rgba(126, 243, 211, 0.4), transparent 58%),
        radial-gradient(ellipse 65% 50% at 82% 18%, rgba(57, 181, 74, 0.32), transparent 52%),
        radial-gradient(ellipse 55% 65% at 48% 82%, rgba(11, 125, 127, 0.42), transparent 55%);
    filter: blur(0px);
    animation: drift 22s ease-in-out infinite alternate;
    pointer-events: none;
}

.bg-anim--2 {
    opacity: 0.9;
    mix-blend-mode: screen;
    animation-duration: 28s;
    animation-delay: -6s;
    background:
        radial-gradient(ellipse 58% 48% at 72% 68%, rgba(255, 193, 7, 0.26), transparent 52%),
        radial-gradient(ellipse 52% 58% at 12% 58%, rgba(247, 147, 30, 0.22), transparent 50%),
        radial-gradient(ellipse 45% 45% at 55% 35%, rgba(126, 243, 211, 0.16), transparent 48%);
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
    100% {
        transform: translate(4%, -3%) scale(1.08) rotate(4deg);
    }
}

.bg-noise {
    position: fixed;
    inset: 0;
    z-index: 1;
    opacity: 0.04;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.main-wrap {
    position: relative;
    z-index: 2;
    max-width: 1320px;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Brand logo — centered, responsive */
.site-brand {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 1rem 0.25rem;
    margin: 0 0 0.5rem;
}

.site-brand__logo {
    display: block;
    width: clamp(5.5rem, 20vw, 10.5rem);
    height: auto;
    max-width: min(280px, 88vw);
    aspect-ratio: 1;
    object-fit: contain;
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.35));
}

@media (min-width: 640px) {
    .site-brand__logo {
        width: clamp(6.5rem, 16vw, 11rem);
    }
}

.location-hub {
    width: 100%;
    max-width: 100%;
    margin-bottom: 1.25rem;
    padding: 0.35rem 0;
    position: sticky;
    top: 0;
    z-index: 5;
    background: linear-gradient(180deg, rgba(12, 25, 41, 0.92) 0%, rgba(12, 25, 41, 0.75) 100%);
    backdrop-filter: blur(8px);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.location-pills {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.35rem 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.location-pill {
    flex: 0 0 auto;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #f3f4f6;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.location-pill:hover {
    background: rgba(255, 255, 255, 0.14);
}

.location-pill--active {
    background: #fff;
    color: #0f172a;
    border-color: #fff;
}

/* ——— Stats dashboard bar (LTR / Inter) ——— */
.stats-dash {
    width: 100%;
    max-width: 1200px;
    margin-bottom: 1.35rem;
    font-family: "Inter", "Noto Sans", system-ui, sans-serif;
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.stats-dash.stats-dash--visible {
    opacity: 1;
    transform: translateY(0);
}

.stats-dash.stats-dash--total {
    margin-bottom: 0.65rem;
}

.stats-dash.stats-dash--total .stats-dash__inner {
    border-radius: 16px;
    border-color: rgba(99, 102, 241, 0.14);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 18px 48px rgba(0, 0, 0, 0.14),
        0 0 0 1px rgba(99, 102, 241, 0.06);
}

.stats-dash__kicker {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #6366f1;
    margin-bottom: 0.2rem;
}

.stats-dash__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0;
    background: #fafafa;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.8) inset,
        0 18px 48px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.stats-dash__status {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 1.1rem 1.35rem;
    min-width: 10rem;
    flex: 0 0 auto;
}

.stats-dash__live {
    width: 10px;
    height: 10px;
    margin-top: 0.35rem;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
        transform: scale(1.05);
    }
}

.stats-dash__label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 0.25rem;
}

.stats-dash__time {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stats-dash__divider {
    width: 1px;
    background: linear-gradient(180deg, transparent, #e5e7eb 12%, #e5e7eb 88%, transparent);
    flex-shrink: 0;
    align-self: stretch;
    min-height: 4.5rem;
}

.stats-dash__metrics {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
    justify-content: space-around;
    gap: 0.75rem 1rem;
    padding: 1rem 1.1rem;
    list-style: none;
    margin: 0;
}

.stats-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 5.5rem;
    flex: 1 1 auto;
    max-width: 8.5rem;
}

.stats-metric__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-bottom: 0.35rem;
    color: #9ca3af;
}

.stats-metric__icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stats-metric__label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #9ca3af;
    letter-spacing: 0.02em;
    margin-bottom: 0.2rem;
    line-height: 1.25;
}

.stats-metric__value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stats-metric__value--muted {
    color: #9ca3af;
    font-weight: 600;
}

.stats-metric__value--anim {
    animation: statValueIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: calc(0.04s * var(--mi, 0));
}

@keyframes statValueIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 720px) {
    .stats-dash__inner {
        flex-direction: column;
    }

    .stats-dash__divider {
        width: 100%;
        height: 1px;
        min-height: 0;
        background: linear-gradient(90deg, transparent, #e5e7eb 15%, #e5e7eb 85%, transparent);
    }

    .stats-dash__metrics {
        justify-content: center;
    }
}

.cards-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 1.5rem;
    align-items: start;
}

.cards-grid.cards-grid--three {
    grid-template-columns: 1fr;
    max-width: 1200px;
}

@media (min-width: 900px) {
    .cards-grid.cards-grid--three {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: stretch;
    }
}

.result-box-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.slot-label-chip {
    align-self: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(243, 244, 246, 0.85);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.cards-grid--three .card-shell {
    max-width: none;
    margin: 0;
    height: 100%;
}

.card-shell {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem 1.25rem 1.75rem;
}

.card-shell--poll {
    border-radius: 26px;
    box-shadow:
        0 8px 32px rgba(15, 23, 42, 0.08),
        0 32px 64px rgba(15, 23, 42, 0.06);
    padding: 1.35rem 1.2rem 1.5rem;
}

.result-header__divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0 12%, #e2e8f0 88%, transparent);
    margin: 0 0 1rem;
}

.loading-msg,
.error-msg {
    text-align: center;
    margin: 2rem 0;
    font-family: "Noto Sans Thaana", "Noto Sans", sans-serif;
}

.error-msg {
    color: #b91c1c;
}

/* Header */
.result-header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.box-pill {
    display: inline-block;
    background: #f3f4f6;
    color: #374151;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    padding: 0.35rem 1.1rem;
    border-radius: 999px;
    font-family: "Noto Sans", sans-serif;
}

.area-dv {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
    color: #4b5563;
}

.title-dv {
    margin: 0.65rem 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.5;
    color: #1f2937;
    direction: rtl;
}

.subtitle-dv {
    margin: 0.35rem 0 0;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.45;
    color: #4b5563;
    direction: rtl;
}

.title-en {
    margin: 0.35rem 0 0;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #6b7280;
}

.ballot-mini-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem 0.5rem;
    margin: 0.85rem 0 0;
    padding: 0.65rem 0.5rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.ballot-mini-metric {
    flex: 1 1 4.5rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.2rem;
}

.ballot-mini-metric__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.ballot-mini-metric__icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ballot-mini-metric__label {
    font-family: "Noto Sans", system-ui, sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    line-height: 1.2;
}

.ballot-mini-metric__value {
    font-family: "Noto Sans", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.ballot-mini-metric__value--muted {
    color: #94a3b8;
    font-weight: 600;
}

.ballot-meta,
.ballot-updated {
    margin: 0.4rem 0 0;
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 500;
}

.ballot-footnote {
    margin: 1rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
    font-size: 0.82rem;
    font-weight: 500;
    color: #6b7280;
    text-align: center;
    line-height: 1.45;
}

/* Rows */
.candidate-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.65rem 0.75rem;
    align-items: center;
    padding: 0.85rem 0;
    border-top: 1px solid #f3f4f6;
}

.candidate-row:first-of-type {
    border-top: none;
    padding-top: 0.25rem;
}

.stats {
    display: flex;
    gap: 1rem;
    min-width: 5.5rem;
}

.stat-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    font-family: "Noto Sans", sans-serif;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    font-family: "Noto Sans", sans-serif;
}

.mid {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bar-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    direction: rtl;
    text-align: right;
}

.party-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.party-code {
    font-weight: 700;
    font-size: 0.8rem;
    font-family: "Noto Sans", sans-serif;
    letter-spacing: 0.02em;
}

.party-logo-inline {
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 50%;
    flex-shrink: 0;
    vertical-align: middle;
}

.name-dv {
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    line-height: 1.35;
}

.bar-track {
    height: 6px;
    background: var(--track);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    min-width: 0;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-fill--animate {
    transition: width 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.avatar-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #d1d5db, #9ca3af);
}

/* Fennana Nufenna — Yes (green) / No (red) split cards */
.candidate-row--poll {
    display: block;
    padding: 0;
    margin: 0 0 0.75rem;
    border: none;
}

.candidate-row--poll:last-of-type {
    margin-bottom: 0;
}

.poll-row {
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.poll-row--yes {
    border-color: #86efac;
    box-shadow: 0 2px 12px rgba(34, 197, 94, 0.08);
}

.poll-row--no {
    border-color: #e8e8e8;
}

.poll-row__split {
    display: flex;
    align-items: stretch;
    min-height: 4.35rem;
}

.poll-row__band {
    flex: 0 0 40%;
    max-width: 44%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0.9rem 0.65rem;
}

.poll-row--yes .poll-row__band {
    background: #dcfce7;
}

.poll-row--no .poll-row__band {
    background: #ffe4e6;
}

.poll-row__glyph-ring {
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.08);
}

.poll-row__glyph {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
    font-family: "Noto Sans", system-ui, sans-serif;
}

.poll-row--yes .poll-row__glyph {
    color: #16a34a;
}

.poll-row--no .poll-row__glyph {
    color: #dc2626;
}

.poll-row__label-dv {
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
    min-width: 0;
}

.candidate-row--poll-yes .poll-row__label-dv {
    color: #14532d;
}

.candidate-row--poll-no .poll-row__label-dv {
    color: #9f1239;
}

.poll-row__data {
    flex: 1;
    min-width: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.85rem 1rem 0.85rem 0.35rem;
}

.poll-row__data-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.38rem;
}

.poll-row__pct-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.poll-row__pct {
    font-family: "Noto Sans", system-ui, sans-serif;
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.poll-row--yes .poll-row__pct {
    color: #16a34a;
}

.poll-row--no .poll-row__pct {
    color: #dc2626;
}

.poll-row__votes {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    font-family: "Noto Sans", system-ui, sans-serif;
}

.poll-row__winner-mark {
    display: flex;
    align-items: center;
}

.poll-row__winner-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
}

.poll-row__winner-dot--yes {
    background: linear-gradient(160deg, #4ade80, #16a34a);
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.45);
}

.poll-row__winner-dot--no {
    background: linear-gradient(160deg, #f87171, #dc2626);
    box-shadow: 0 2px 10px rgba(220, 38, 38, 0.4);
}

.poll-card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid #f1f5f9;
    font-size: 0.78rem;
    color: #64748b;
    font-family: "Noto Sans", system-ui, sans-serif;
}

.poll-card-footer__total strong {
    color: #0f172a;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.site-foot {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.foot-link,
.foot-btn {
    font-family: "Noto Sans Thaana", "Noto Sans", sans-serif;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
}

.foot-link:hover,
.foot-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 420px) {
    .candidate-row:not(.candidate-row--poll) {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .candidate-row:not(.candidate-row--poll) .stats {
        justify-content: flex-start;
    }

    .candidate-row:not(.candidate-row--poll) .bar-label {
        justify-content: flex-start;
    }

    .candidate-row:not(.candidate-row--poll) .avatar-wrap {
        justify-self: end;
    }

    .poll-row__band {
        flex: 0 0 38%;
        padding: 0.75rem 0.45rem;
        gap: 0.45rem;
    }

    .poll-row__glyph-ring {
        width: 2.1rem;
        height: 2.1rem;
    }

    .poll-row__label-dv {
        font-size: 0.92rem;
    }

    .poll-row__data {
        padding: 0.75rem 0.65rem 0.75rem 0.25rem;
    }

    .poll-row__pct {
        font-size: 1.45rem;
    }
}
