/* Design tokens (colors, fonts), body/container, and other generic pieces
   now live in ../../shared/base.css — loaded before this file in index.html.
   Only election-tracker-specific styles remain here. */

/* ── Header ── */
header {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-bright);
}

.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.last-update {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
}

.last-update span {
    color: var(--text-label);
}

.refresh-btn {
    background: var(--bg-elevated);
    color: var(--text-label);
    border: 1px solid var(--border-bright);
    padding: 7px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Mulish', sans-serif;
    font-weight: 600;
    transition: all 0.15s;
}

.refresh-btn:hover {
    border-color: var(--blue);
    color: var(--text-bright);
    background: var(--blue-dim);
}

.certification-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(240, 180, 41, 0.07);
    border: 1px solid rgba(240, 180, 41, 0.2);
    border-left: 3px solid var(--gold);
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 12.5px;
    color: rgba(240, 180, 41, 0.8);
    line-height: 1.5;
}

/* ── Race Cards ── */
.race {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 18px 20px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.race:hover {
    border-color: var(--border-bright);
}

.race:last-child {
    margin-bottom: 0;
}

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
    gap: 12px;
}

.race-title-section { flex: 1; }

.race-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 20px;
    color: var(--text-bright);
    letter-spacing: 0.2px;
}

/* ── Ballot Count Status ── */
.ballot-count-status {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.ballot-count-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.ballot-count-pct {
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    font-size: 26px;
    color: var(--gold);
    letter-spacing: -1px;
    line-height: 1;
}

.ballot-count-labels {
    flex: 1;
    min-width: 0;
}

.ballot-count-title {
    font-size: 12px;
    color: var(--text-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ballot-count-sub {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ballot-count-footer {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 7px;
    font-style: italic;
}

.ballot-progress {
    height: 4px;
    background: var(--border-bright);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.ballot-progress-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.6s ease;
}

/* ── Status Badges ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    font-family: 'Cormorant Garamond', serif;
}

.status-badge.early-count {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(230, 57, 70, 0.2);
}

.status-badge.counting {
    background: var(--blue-dim);
    color: #60a5fa;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.status-badge.late-count {
    background: rgba(16, 185, 129, 0.1);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ── Candidates ── */
.candidate {
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.candidate:last-of-type {
    border-bottom: none;
}

.candidate.hidden { display: none; }

.candidate-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.candidate.compact-candidate .candidate-info {
    margin-bottom: 0;
}

.candidate-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    font-family: 'Fira Code', monospace;
    flex-shrink: 0;
}

.candidate-rank.rank-1 {
    background: var(--gold-dim);
    color: var(--gold);
    border: 1px solid rgba(240, 180, 41, 0.3);
}

.candidate-rank.rank-2 {
    background: rgba(106, 127, 152, 0.1);
    color: var(--silver);
    border: 1px solid rgba(106, 127, 152, 0.25);
}

.candidate-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.candidate.top-candidate .candidate-name {
    color: var(--text-bright);
    font-size: 15px;
}

.party {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: 'Cormorant Garamond', serif;
}

.incumbent {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: 'Cormorant Garamond', serif;
    background: rgba(16, 185, 129, 0.1);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.party.Dem { background: rgba(143, 180, 212, 0.15); color: #8fb4d4; border: 1px solid rgba(143, 180, 212, 0.3); }
.party.Rep { background: rgba(194, 116, 122, 0.15); color: #c2747a; border: 1px solid rgba(194, 116, 122, 0.3); }
.party.NPP, .party.Grn, .party.Lib, .party.AI, .party.P-F {
    background: rgba(154, 138, 139, 0.15);
    color: #9a8a8b;
    border: 1px solid rgba(154, 138, 139, 0.25);
}

.votes {
    text-align: right;
    flex-shrink: 0;
    min-width: 130px;
}

.vote-count {
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-bright);
    letter-spacing: -0.5px;
}

.vote-percent {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-label);
    font-weight: 500;
}

.progress-bar {
    height: 4px;
    background: var(--border-bright);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #5a3035;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.progress-fill.leading { background: var(--accent); }

/* ── Show all / collapsed ── */
.show-all-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-bright);
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Mulish', sans-serif;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.15s;
}

.show-all-btn:hover {
    color: var(--text-bright);
    border-color: var(--blue);
    background: var(--blue-dim);
}

.collapsed-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
}

/* ── Top Two Note ── */
.top-two-note {
    background: var(--gold-dim);
    border: 1px solid rgba(240, 180, 41, 0.2);
    border-left: 3px solid var(--gold);
    padding: 9px 12px;
    border-radius: 4px;
    font-size: 12.5px;
    color: rgba(240, 180, 41, 0.85);
    margin-top: 12px;
}

.top-two-note strong { color: var(--gold); }

#error-container { margin-bottom: 8px; }

/* ── Link-only races ── */
.race-link-only-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.link-button.ballotpedia {
    border-color: rgba(37, 99, 235, 0.3);
    color: #60a5fa;
}

/* ── Local races grid ── */
.race-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.race-link-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 14px;
    transition: all 0.15s;
}

.race-link-card:hover {
    border-color: var(--border-bright);
    background: var(--bg-elevated);
}

.race-link-card h4 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.race-link-card .links {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.race-link-card a {
    font-size: 12px;
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.race-link-card a:hover { color: #93c5fd; }

.race-link-card .separator {
    color: var(--text-muted);
    font-size: 11px;
}

.local-races-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px 20px;
}

.local-race-list {
    list-style: none;
    margin-bottom: 16px;
}

.local-race-list li {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-family: 'Cormorant Garamond', serif;
}

.local-race-list li:last-child {
    border-bottom: none;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    .container { padding: 16px 12px 40px; }

    .race { padding: 14px 14px; }

    .race-header { flex-wrap: wrap; }

    .show-all-btn { font-size: 11px; padding: 4px 10px; }

    .votes { min-width: 100px; }

    .vote-count { font-size: 14px; }

    .vote-percent { font-size: 12px; }

    .ballot-count-pct { font-size: 22px; }

    .ballot-count-sub { white-space: normal; }

    .ballot-count-inner { gap: 8px; }

    .status-badge { font-size: 9px; padding: 3px 6px; }
}
