/* =========================================================
   FILE PURPOSE: Global shared styling only

   What this file does:
   - Defines design tokens
   - Defines base/reset styles
   - Defines shared reusable UI primitives
   - Defines shared layout-shell/header/footer/modal styles

   IMPORTANT:
   - Page-specific layouts should live inline in their views
   - Do not add home/election/candidate/race-specific styling here
========================================================= */

/* =========================
   Design Tokens
========================= */

:root {
    --bg-top: #0b1220;
    --bg-bottom: #0f172a;

    --panel: rgba(15, 23, 42, 0.92);
    --panel-strong: rgba(30, 41, 59, 0.94);

    --border: rgba(148, 163, 184, 0.16);
    --border-strong: rgba(148, 163, 184, 0.26);

    --text: #e5e7eb;
    --text-strong: #f8fafc;
    --text-muted: #cbd5e1;
    --text-soft: #94a3b8;

    --accent: #93c5fd;
    --accent-strong: #60a5fa;

    --success: #86efac;
    --danger: #fca5a5;

    --shadow: 0 18px 44px rgba(0, 0, 0, 0.26);

    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --content-width: 1200px;
}

/* =========================
   Base
========================= */

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

html {
    background: var(--bg-bottom);
}

body.site-body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
    background:
            radial-gradient(circle at top, rgba(37, 99, 235, 0.14), transparent 34%),
            linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition:
            color 0.15s ease,
            border-color 0.15s ease,
            background-color 0.15s ease,
            opacity 0.15s ease,
            box-shadow 0.15s ease,
            transform 0.15s ease;
}

a:hover {
    color: #bfdbfe;
}

h1,
h2,
h3,
h4,
h5 {
    margin: 0;
    color: var(--text-strong);
    letter-spacing: -0.02em;
}

p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.65;
}

/* =========================
   Shared Layout / UI
========================= */

.site-main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 28px 24px 56px;
}

.card {
    background: linear-gradient(180deg, var(--panel-strong), var(--panel));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.page-section {
    display: grid;
    gap: 24px;
    padding: 24px 0;
}

.section-header {
    display: grid;
    gap: 8px;
}

.section-header h2 {
    font-size: 1.35rem;
    line-height: 1.15;
}

.section-copy {
    max-width: 760px;
    color: var(--text-muted);
}

.section-heading {
    margin-bottom: 14px;
}

.section-heading h2 {
    font-size: 1.2rem;
    line-height: 1.2;
}

.section-heading p {
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 0.95rem;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.empty-state {
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.62);
    border: 1px dashed rgba(148, 163, 184, 0.22);
    color: var(--text-muted);
}

/* =========================
   Shared Buttons / Badges
========================= */

.button-link,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition:
            background-color 0.15s ease,
            border-color 0.15s ease,
            color 0.15s ease,
            transform 0.15s ease,
            opacity 0.15s ease;
}

.button {
    min-height: 44px;
    padding: 0.8rem 1.1rem;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.button:hover,
.button-link:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #eff6ff;
    border: 1px solid rgba(147, 197, 253, 0.35);
}

.button-primary:hover {
    color: #ffffff;
}

.button-secondary,
.button-link {
    background: rgba(15, 23, 42, 0.75);
    color: #dbeafe;
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.button-secondary:hover,
.button-link:hover {
    color: #ffffff;
    border-color: rgba(147, 197, 253, 0.45);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* =========================
   Shared Stats
========================= */

.stat {
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    gap: 8px;
}

.stat--green {
    background:
            radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 40%),
            linear-gradient(180deg, rgba(34, 197, 94, 0.08), rgba(15, 23, 42, 0.9));
    border-color: rgba(34, 197, 94, 0.35);
}

.stat--red {
    background:
            radial-gradient(circle at top right, rgba(239, 68, 68, 0.12), transparent 40%),
            linear-gradient(180deg, rgba(239, 68, 68, 0.08), rgba(15, 23, 42, 0.9));
    border-color: rgba(239, 68, 68, 0.35);
}

.stat__label {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.stat__value {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-strong);
}

.stat--green .stat__value {
    color: var(--success);
}

.stat--red .stat__value {
    color: var(--danger);
}

/* =========================
   Header
========================= */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    max-width: var(--content-width);
    margin: 0 auto;
    min-height: 78px;
    padding: 12px 24px 14px;
    display: grid;
    gap: 12px;
}

.site-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-logo {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 0;
}

.site-logo img {
    height: 52px;
    width: auto;
}

.site-header__branding {
    min-width: 0;
}

.site-header__tagline {
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
}

.site-header__share {
    position: relative;
    flex: 0 0 auto;
}

.site-header__share-toggle {
    appearance: none;
    -webkit-appearance: none;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.56);
    color: #dbeafe;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.site-header__share-toggle:hover {
    background: rgba(30, 41, 59, 0.82);
    border-color: rgba(96, 165, 250, 0.24);
    color: #ffffff;
}

.site-header__share-toggle i {
    color: var(--accent-strong);
}

.site-header__share-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    padding: 8px;
    display: grid;
    gap: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.site-header__share-menu[hidden] {
    display: none !important;
}

.site-header__share-item {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #dbeafe;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.site-header__share-item:hover {
    background: rgba(30, 41, 59, 0.82);
    color: #ffffff;
}

.site-header__share-item i {
    width: 18px;
    text-align: center;
    color: var(--accent-strong);
    font-size: 0.95rem;
}

/* =========================
   Source Modal + Source Button
========================= */

.source-button {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 999px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    background: rgba(37, 99, 235, 0.15);
    color: #93c5fd;
    cursor: pointer;
    transition:
            background-color 0.15s ease,
            border-color 0.15s ease,
            transform 0.12s ease;
}

.source-button:hover {
    background: rgba(37, 99, 235, 0.3);
    border-color: rgba(147, 197, 253, 0.6);
    transform: translateY(-1px);
}

.source-button span {
    display: none;
}

.source-button:focus-visible {
    outline: 2px solid rgba(147, 197, 253, 0.8);
    outline-offset: 2px;
}

.source-modal {
    position: fixed;
    inset: 0;
    z-index: 140;
}

.source-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(3px);
}

.source-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(560px, calc(100vw - 32px));
    margin: min(10vh, 72px) auto 24px;
    padding: 22px;
}

.source-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.source-modal__close {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.source-modal__close:hover {
    background: rgba(30, 41, 59, 0.86);
    border-color: rgba(147, 197, 253, 0.4);
}

.source-modal__body {
    margin-top: 18px;
    display: grid;
    gap: 14px;
}

.source-modal__title {
    color: var(--text-strong);
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.4;
}

.source-modal__meta {
    color: var(--text-soft);
    font-size: 0.93rem;
    line-height: 1.5;
}

.source-modal__body .button.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.source-modal-open {
    overflow: hidden;
}

/* =========================
   Cookie Consent
========================= */

.cookie-banner {
    position: fixed;
    left: 24px;
    right: 24px;
    bottom: 24px;
    z-index: 120;
}

.cookie-banner__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.97);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(10px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
}

.cookie-banner__content {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.cookie-banner__title {
    font-size: 1.05rem;
    line-height: 1.2;
}

.cookie-banner__text {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.cookie-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.cookie-modal {
    position: fixed;
    inset: 0;
    z-index: 130;
}

.cookie-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(3px);
}

.cookie-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(680px, calc(100vw - 32px));
    margin: min(8vh, 64px) auto 24px;
    padding: 22px;
}

.cookie-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.cookie-modal__close {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.cookie-modal__close:hover {
    background: rgba(30, 41, 59, 0.86);
    border-color: rgba(147, 197, 253, 0.4);
}

.cookie-modal__body {
    margin-top: 18px;
    display: grid;
    gap: 18px;
}

.cookie-modal__copy {
    color: var(--text-muted);
}

.cookie-settings {
    display: grid;
    gap: 14px;
}

.cookie-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.cookie-setting__text {
    min-width: 0;
}

.cookie-setting__text h3 {
    font-size: 1rem;
    line-height: 1.25;
}

.cookie-setting__text p {
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 0.93rem;
    line-height: 1.5;
}

.cookie-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    cursor: pointer;
}

.cookie-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cookie-toggle__slider {
    position: relative;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.28);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.cookie-toggle__slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    transition: transform 0.15s ease;
}

.cookie-toggle input:checked + .cookie-toggle__slider {
    background: rgba(37, 99, 235, 0.78);
    border-color: rgba(96, 165, 250, 0.78);
}

.cookie-toggle input:checked + .cookie-toggle__slider::after {
    transform: translateX(20px);
}

.cookie-toggle input:disabled + .cookie-toggle__slider {
    background: rgba(34, 197, 94, 0.22);
    border-color: rgba(34, 197, 94, 0.38);
}

.cookie-toggle__label {
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.cookie-modal__footer {
    margin-top: 22px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.cookie-settings-link {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 110;
    appearance: none;
    -webkit-appearance: none;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.82);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.cookie-settings-link:hover {
    color: #ffffff;
    border-color: rgba(147, 197, 253, 0.42);
    background: rgba(30, 41, 59, 0.92);
}

.scroll-top-button {
    position: fixed;
    right: 18px;
    bottom: 64px;
    z-index: 109;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.92);
    color: #dbeafe;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.28);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.scroll-top-button.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-top-button:hover,
.scroll-top-button:focus-visible {
    background: rgba(37, 99, 235, 0.22);
    border-color: rgba(147, 197, 253, 0.45);
    color: #ffffff;
}

.cookie-modal-open {
    overflow: hidden;
}

/* =========================
   Footer
========================= */

.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 44px;
}

.site-footer__inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 18px 24px 28px;
    color: var(--text-soft);
    font-size: 0.9rem;
}

/* =========================
   Responsive
========================= */

@media (max-width: 991px) {
    .site-header__inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    .site-header__top {
        gap: 12px;
    }

    .site-header__share-menu {
        right: 0;
        left: auto;
    }

    .cookie-banner {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .scroll-top-button {
        right: 16px;
        bottom: 62px;
    }

    .cookie-banner__inner {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .cookie-banner__actions {
        justify-content: flex-start;
    }
}

@media (max-width: 767px) {
    .site-main,
    .site-header__inner,
    .site-footer__inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    .site-logo img {
        height: 44px;
    }

    .button,
    .button-link {
        width: 100%;
    }

    .site-header__share-menu {
        width: min(260px, calc(100vw - 32px));
    }

    .source-modal__dialog {
        width: calc(100vw - 20px);
        margin: 10px auto;
        padding: 18px;
    }

    .source-modal__body .button {
        width: 100%;
    }

    .cookie-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .scroll-top-button {
        right: 12px;
        bottom: 58px;
    }

    .cookie-banner__inner {
        padding: 16px;
        gap: 14px;
    }

    .cookie-banner__title {
        font-size: 1rem;
    }

    .cookie-banner__text {
        font-size: 0.9rem;
    }

    .cookie-banner__actions,
    .cookie-modal__footer {
        display: grid;
        grid-template-columns: 1fr;
    }

    .cookie-modal__dialog {
        width: calc(100vw - 20px);
        margin: 10px auto;
        padding: 18px;
    }

    .cookie-setting {
        flex-direction: column;
        align-items: stretch;
    }

    .cookie-toggle {
        justify-content: space-between;
        width: 100%;
    }

    .cookie-settings-link {
        right: 12px;
        bottom: 12px;
        font-size: 0.78rem;
    }
}
