/* Shared electoral-history-style map hover cards (#mapTip, #govMapTip, #ehMapTip) */
#mapTip,
#govMapTip,
#ehMapTip {
    position: fixed;
    pointer-events: none;
    z-index: 60;
    min-width: 280px;
    width: max-content;
    max-width: min(560px, calc(100vw - 24px));
    background: #0c0f14;
    border: 1px solid rgba(51, 65, 85, 0.65);
    padding: 0.7rem 0.75rem;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    font-size: 0.875rem;
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    gap: calc(0.55rem + 5px);
    border-radius: 0;
    box-sizing: border-box;
}

/* Hub map tips: fixed widths by content class (set in shared.js). Base bar width = 280px. */
#mapTip.eh-map-tip--bars,
#govMapTip.eh-map-tip--bars {
    min-width: 280px;
    width: 280px;
    max-width: min(280px, calc(100vw - 24px));
}

#mapTip.eh-map-tip--primary,
#govMapTip.eh-map-tip--primary,
#mapTip.eh-map-tip--primary-dual,
#govMapTip.eh-map-tip--primary-dual {
    min-width: 230px;
    width: 230px;
    max-width: min(230px, calc(100vw - 24px));
    gap: 0.55rem;
}

#mapTip.eh-map-tip--no-election,
#govMapTip.eh-map-tip--no-election {
    min-width: 160px;
    width: 160px;
    max-width: min(160px, calc(100vw - 24px));
}

#mapTip.eh-map-tip--no-polls,
#govMapTip.eh-map-tip--no-polls {
    min-width: 190px;
    width: 190px;
    max-width: min(190px, calc(100vw - 24px));
}

#mapTip.eh-map-tip--no-polls .eh-tip-body--sub,
#govMapTip.eh-map-tip--no-polls .eh-tip-body--sub {
    margin-top: -3px;
}

#mapTip.eh-map-tip--no-election .eh-tip-body--sub,
#govMapTip.eh-map-tip--no-election .eh-tip-body--sub {
    margin-top: -3px;
}

.eh-tip-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0;
    transform: translateY(3px);
}

.eh-tip-title {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    transform: translateY(-3px);
}

.eh-tip-kicker {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
    line-height: 1.25;
    margin: 0;
}

.eh-tip-state-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    line-height: 1;
    min-height: 1.1875rem;
}

.eh-tip-state-line .eh-tip-state {
    flex: 0 1 auto;
    font-size: 1.1875rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
}

.eh-tip-ev-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.eh-tip-ev-sep {
    color: #64748b;
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1;
    user-select: none;
    display: flex;
    align-items: center;
}

.eh-tip-state-line .eh-tip-ev-sep {
    font-size: 1.1875rem;
}

.eh-tip-ev {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.15;
    letter-spacing: 0.01em;
}

.eh-tip-state-line .eh-tip-ev {
    font-size: 1.1875rem;
    line-height: 1;
    display: flex;
    align-items: center;
}

.eh-tip-chip {
    flex-shrink: 0;
    transform: scale(1.12);
    transform-origin: right top;
    margin-top: 0;
    align-self: flex-start;
}

.eh-tip-body {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 0;
    width: 100%;
    min-width: 0;
}

.eh-tip-sub,
.eh-tip-sub-line {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.35;
    margin: 0;
}

.eh-tip-body--primary {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: -2px;
    width: 100%;
}

.eh-tip-primary-line {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
    margin: 0;
    white-space: nowrap;
}

.eh-tip-primary-line--dem .eh-tip-primary-tag {
    color: #1181ff;
    font-weight: 500;
}

.eh-tip-primary-line--rep .eh-tip-primary-tag {
    color: #f93637;
    font-weight: 500;
}

.eh-tip-primary-detail {
    color: #ffffff;
    font-weight: 600;
}

.eh-tip-bars {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 0;
    width: max-content;
    min-width: 260px;
    max-width: min(520px, calc(100vw - 48px));
}

.eh-tip-bar-row {
    width: max-content;
    min-width: 100%;
}

.eh-tip-bar-track {
    display: inline-flex;
    align-items: center;
    width: 100%;
    min-width: 100%;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    vertical-align: top;
    background:
        linear-gradient(var(--track-tint, transparent), var(--track-tint, transparent)),
        rgba(15, 23, 42, 0.5);
}

.eh-tip-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 6px;
    z-index: 0;
}

/* Flip winner bar in map tooltips: same inset ring as flip margin chips */
.eh-tip-bar-fill.eh-tip-bar-fill--flip {
    box-shadow: inset 0 0 0 1px #ffffff;
}

.eh-tip-bar-labels {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-height: 1.875rem;
    padding: 0 0.6rem;
    box-sizing: border-box;
    pointer-events: none;
}

.eh-tip-bar-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    white-space: nowrap;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.eh-tip-bar-pct {
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex: 0 0 auto;
    margin-left: auto;
}

#ehMapTip.eh-map-tip--dc {
    align-items: stretch;
}

#ehMapTip.eh-map-tip--dc .eh-tip-head,
#ehMapTip.eh-map-tip--dc .eh-tip-bars {
    width: 100%;
    align-self: stretch;
    box-sizing: border-box;
}

#ehMapTip.eh-map-tip--dc .eh-tip-state-line {
    flex-wrap: nowrap;
    gap: 0.35rem;
}

#ehMapTip.eh-map-tip--dc .eh-tip-state-line .eh-tip-state {
    display: inline-block;
    transform: scaleX(0.75);
    transform-origin: left center;
    margin-right: calc(-5.25ch);
}

#ehMapTip.eh-map-tip--dc .eh-tip-ev-group {
    margin-left: 25px;
}

html[data-pollsmax-theme="light"] #mapTip,
html[data-pollsmax-theme="light"] #govMapTip,
html[data-pollsmax-theme="light"] #ehMapTip {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12) !important;
}

html[data-pollsmax-theme="light"] .eh-tip-kicker,
html[data-pollsmax-theme="light"] .eh-tip-sub {
    color: #64748b !important;
}

html[data-pollsmax-theme="light"] .eh-tip-state-line .eh-tip-state {
    color: #0f172a !important;
}

html[data-pollsmax-theme="light"] .eh-tip-bar-track {
    background:
        linear-gradient(var(--track-tint, transparent), var(--track-tint, transparent)),
        rgba(241, 245, 249, 0.9) !important;
}

html[data-pollsmax-theme="light"] .eh-tip-bar-name,
html[data-pollsmax-theme="light"] .eh-tip-bar-pct {
    color: #ffffff !important;
}

/*
 * Main home (index): ~80% visual size of hub tips. No CSS zoom — zoom breaks position:fixed placement.
 */
body.pollsmax-home-page #mapTip,
body.pollsmax-home-page #govMapTip {
    font-size: 0.7rem;
    padding: 0.56rem 0.6rem;
    gap: calc((0.55rem + 5px) * 0.8);
    max-width: min(448px, calc(100vw - 24px));
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

body.pollsmax-home-page #mapTip.eh-map-tip--bars,
body.pollsmax-home-page #govMapTip.eh-map-tip--bars {
    min-width: 224px;
    width: 224px;
    max-width: min(224px, calc(100vw - 24px));
}

body.pollsmax-home-page #mapTip.eh-map-tip--primary,
body.pollsmax-home-page #govMapTip.eh-map-tip--primary,
body.pollsmax-home-page #mapTip.eh-map-tip--primary-dual,
body.pollsmax-home-page #govMapTip.eh-map-tip--primary-dual {
    min-width: 185px;
    width: 185px;
    max-width: min(185px, calc(100vw - 24px));
    gap: calc(0.55rem * 0.8);
}

body.pollsmax-home-page #mapTip.eh-map-tip--no-election,
body.pollsmax-home-page #govMapTip.eh-map-tip--no-election {
    min-width: 128px;
    width: 128px;
    max-width: min(128px, calc(100vw - 24px));
}

body.pollsmax-home-page #mapTip.eh-map-tip--no-polls,
body.pollsmax-home-page #govMapTip.eh-map-tip--no-polls {
    min-width: 158px;
    width: 158px;
    max-width: min(158px, calc(100vw - 24px));
}

body.pollsmax-home-page #mapTip .eh-tip-head,
body.pollsmax-home-page #govMapTip .eh-tip-head {
    gap: 0.6rem;
    transform: translateY(2.4px);
}

body.pollsmax-home-page #mapTip .eh-tip-title,
body.pollsmax-home-page #govMapTip .eh-tip-title {
    gap: 0.16rem;
    transform: translateY(-2.4px);
}

body.pollsmax-home-page #mapTip .eh-tip-kicker,
body.pollsmax-home-page #govMapTip .eh-tip-kicker,
body.senate-hub-page #mapTip .eh-tip-kicker,
body.gov-hub-page #govMapTip .eh-tip-kicker {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Home + hub: race eyebrow above state name (DOM state→kicker, reversed stack) */
body.pollsmax-home-page #mapTip .eh-tip-title--home,
body.pollsmax-home-page #govMapTip .eh-tip-title--home,
body.senate-hub-page #mapTip .eh-tip-title--home,
body.gov-hub-page #govMapTip .eh-tip-title--home {
    flex-direction: column-reverse;
    align-items: flex-start;
}

body.senate-hub-page #mapTip .eh-tip-kicker,
body.gov-hub-page #govMapTip .eh-tip-kicker {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.pollsmax-home-page #mapTip .eh-tip-state-line,
body.pollsmax-home-page #govMapTip .eh-tip-state-line {
    gap: 0.28rem;
    min-height: 0.95rem;
}

body.pollsmax-home-page #mapTip .eh-tip-state,
body.pollsmax-home-page #govMapTip .eh-tip-state {
    font-size: 0.95rem;
}

body.pollsmax-home-page #mapTip .eh-tip-chip,
body.pollsmax-home-page #govMapTip .eh-tip-chip {
    transform: scale(0.896);
    transform-origin: right top;
}

body.pollsmax-home-page #mapTip .eh-tip-body,
body.pollsmax-home-page #govMapTip .eh-tip-body,
body.pollsmax-home-page #mapTip .eh-tip-bars,
body.pollsmax-home-page #govMapTip .eh-tip-bars {
    gap: 0.44rem;
}

body.pollsmax-home-page #mapTip .eh-tip-sub,
body.pollsmax-home-page #govMapTip .eh-tip-sub,
body.pollsmax-home-page #mapTip .eh-tip-sub-line,
body.pollsmax-home-page #govMapTip .eh-tip-sub-line,
body.pollsmax-home-page #mapTip .eh-tip-primary-line,
body.pollsmax-home-page #govMapTip .eh-tip-primary-line {
    font-size: 0.65rem;
}

body.pollsmax-home-page #mapTip .eh-tip-body--primary,
body.pollsmax-home-page #govMapTip .eh-tip-body--primary {
    gap: 0.2rem;
    margin-top: -1.6px;
}

body.pollsmax-home-page #mapTip .eh-tip-bar-track,
body.pollsmax-home-page #govMapTip .eh-tip-bar-track {
    border-radius: 4.8px;
}

body.pollsmax-home-page #mapTip .eh-tip-bar-fill,
body.pollsmax-home-page #govMapTip .eh-tip-bar-fill {
    border-radius: 4.8px;
}

body.pollsmax-home-page #mapTip .eh-tip-bar-labels,
body.pollsmax-home-page #govMapTip .eh-tip-bar-labels {
    min-height: 1.5rem;
    height: 100%;
    padding: 0 0.48rem;
    gap: 0.8rem;
    align-self: stretch;
    align-items: center;
}

body.pollsmax-home-page #mapTip .eh-tip-bar-name,
body.pollsmax-home-page #govMapTip .eh-tip-bar-name,
body.pollsmax-home-page #mapTip .eh-tip-bar-pct,
body.pollsmax-home-page #govMapTip .eh-tip-bar-pct {
    font-size: 0.8rem;
}

/* Home tips (~80% scale): 2nd-place+ label text sits optically high in the bar */
body.pollsmax-home-page #mapTip.eh-map-tip--bars .eh-tip-bar-row:not(:first-child) .eh-tip-bar-labels,
body.pollsmax-home-page #govMapTip.eh-map-tip--bars .eh-tip-bar-row:not(:first-child) .eh-tip-bar-labels {
    transform: translateY(1px);
}

/* Senate / governor hub + main home: bars span header width (end at chip), not max-content overflow */
body.senate-hub-page #mapTip.eh-map-tip--bars .eh-tip-bars,
body.gov-hub-page #govMapTip.eh-map-tip--bars .eh-tip-bars,
body.pollsmax-home-page #mapTip.eh-map-tip--bars .eh-tip-bars,
body.pollsmax-home-page #govMapTip.eh-map-tip--bars .eh-tip-bars {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

body.senate-hub-page #mapTip.eh-map-tip--bars .eh-tip-bar-row,
body.gov-hub-page #govMapTip.eh-map-tip--bars .eh-tip-bar-row,
body.pollsmax-home-page #mapTip.eh-map-tip--bars .eh-tip-bar-row,
body.pollsmax-home-page #govMapTip.eh-map-tip--bars .eh-tip-bar-row {
    width: 100%;
    min-width: 0;
}

/* Senate / governor hub map tips only */
body.senate-hub-page #mapTip.eh-map-tip--primary .eh-tip-body--primary,
body.senate-hub-page #mapTip.eh-map-tip--primary-dual .eh-tip-body--primary,
body.gov-hub-page #govMapTip.eh-map-tip--primary .eh-tip-body--primary,
body.gov-hub-page #govMapTip.eh-map-tip--primary-dual .eh-tip-body--primary {
    margin-top: -2px;
}

body.senate-hub-page #mapTip.eh-map-tip--no-polls .eh-tip-body--sub,
body.gov-hub-page #govMapTip.eh-map-tip--no-polls .eh-tip-body--sub {
    margin-top: -5px;
}

body.senate-hub-page #mapTip.eh-map-tip--no-election .eh-tip-body--sub,
body.gov-hub-page #govMapTip.eh-map-tip--no-election .eh-tip-body--sub {
    margin-top: -9px;
    margin-bottom: -3px;
}

body.pollsmax-home-page #mapTip.eh-map-tip--no-election .eh-tip-body--sub,
body.pollsmax-home-page #govMapTip.eh-map-tip--no-election .eh-tip-body--sub {
    margin-top: -7.2px;
    margin-bottom: -2.4px;
}

/* Map hover bars only (not state-page poll chart stages): keep 6px corners; center names + % in the bar */
#mapTip .eh-tip-bar-track,
#govMapTip .eh-tip-bar-track,
#ehMapTip .eh-tip-bar-track {
    display: flex;
    align-items: stretch;
    border-radius: 6px;
    vertical-align: middle;
}

#mapTip .eh-tip-bar-fill,
#govMapTip .eh-tip-bar-fill,
#ehMapTip .eh-tip-bar-fill {
    border-radius: 6px;
}

#mapTip .eh-tip-bar-labels,
#govMapTip .eh-tip-bar-labels,
#ehMapTip .eh-tip-bar-labels {
    display: flex;
    align-items: center;
    align-self: stretch;
    min-height: 1.875rem;
    height: 100%;
    box-sizing: border-box;
}

#mapTip .eh-tip-bar-name,
#govMapTip .eh-tip-bar-name,
#ehMapTip .eh-tip-bar-name,
#mapTip .eh-tip-bar-pct,
#govMapTip .eh-tip-bar-pct,
#ehMapTip .eh-tip-bar-pct {
    display: flex;
    align-items: center;
    line-height: 1;
}
