/* CA YIMBY Election Results
 * Fonts and text color come from the theme. Brand color is detected from the theme
 * (or set in Settings → Election Results) and exposed as --cayr-primary.
 */

.cayr {
	font-family: inherit;
	color: inherit;
	line-height: 1.45;
	font-variant-numeric: tabular-nums;
	max-width: 1200px;
	margin: 1.5rem auto 3rem;
	padding-left: clamp(1.25rem, 5vw, 3rem);
	padding-right: clamp(1.25rem, 5vw, 3rem);
}
.cayr *,
.cayr *::before,
.cayr *::after { box-sizing: border-box; }

.cayr-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Status line + refresh */
.cayr-status {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .75rem 1.5rem;
	font-size: .875em;
	margin-bottom: 1.25rem;
}
.cayr-status-text { opacity: var(--cayr-muted-opacity, .78); color: var(--cayr-muted, inherit); }

.cayr-btn {
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	padding: .55em 1.1em;
	border: 2px solid var(--cayr-primary, currentColor);
	background: transparent;
	color: inherit;
	border-radius: var(--cayr-radius, 0);
	cursor: pointer;
}
.cayr-btn:hover { background: var(--cayr-primary, currentColor); color: var(--cayr-on-primary, #fff); }
.cayr-btn:disabled { opacity: .55; cursor: progress; }

/* Section filter */
.cayr-tabs {
	display: flex;
	gap: 0 1.5rem;
	overflow-x: auto;
	border-bottom: 1px solid rgba(128, 128, 128, .35);
	margin-bottom: .5rem;
	scrollbar-width: thin;
}
.cayr-tab {
	font: inherit;
	font-weight: 600;
	white-space: nowrap;
	background: none;
	border: 0;
	border-bottom: 4px solid transparent;
	padding: .6rem 0 .5rem;
	margin-bottom: -1px;
	color: inherit;
	opacity: .7;
	cursor: pointer;
}
.cayr-tab:hover { opacity: 1; }
.cayr-tab[aria-pressed="true"] {
	opacity: 1;
	border-bottom-color: var(--cayr-primary, currentColor);
}

/* Groups and contests */
.cayr-group { margin-top: 2.25rem; }
.cayr .cayr-group-title {
	font-family: var(--cayr-heading-font, inherit);
	color: var(--cayr-group-color, #003D50);
	font-size: 1.6em;
	line-height: 1.15;
	margin: 0 0 1.25rem;
}

.cayr-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
	gap: 2.25rem 2.5rem;
}
.cayr-grid-props { grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }

.cayr-race {
	border-top: 3px solid var(--cayr-heading-color, currentColor);
	padding-top: .8rem;
	min-width: 0;
}
.cayr-race.is-updated { animation: cayr-updated 2.4s ease-out 1; }
@keyframes cayr-updated {
	from { box-shadow: inset 0 3px 0 0 var(--cayr-primary, currentColor), 0 -3px 0 0 var(--cayr-primary, currentColor); }
	to   { box-shadow: none; }
}

.cayr .cayr-race-title {
	font-family: var(--cayr-heading-font, inherit);
	color: var(--cayr-contest-color, #028B9D);
	font-size: 1.25em;
	line-height: 1.2;
	margin: 0 0 .9rem;
}

/* Candidate rows */
.cayr-cands { list-style: none; margin: 0; padding: 0; }
.cayr-cand { margin: 0 0 .85rem; padding: 0; }
.cayr-cand::marker { content: none; }
.cayr-cand-line {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: .75rem;
}
.cayr-name { min-width: 0; overflow-wrap: anywhere; }
.cayr-cand.is-leading .cayr-name,
.cayr-cand.is-leading .cayr-pct { font-weight: 700; }
.cayr-pct { white-space: nowrap; }
.cayr-party {
	font-size: .8em;
	text-decoration: none;
	border: 0;
	opacity: .7;
	cursor: help;
}
.cayr-inc { font-size: .8em; opacity: .7; }

.cayr-track {
	height: .55rem;
	margin: .3rem 0 .2rem;
	background: rgba(128, 128, 128, .18);
	border-radius: var(--cayr-radius, 0);
	overflow: hidden;
}
.cayr-fill {
	display: block;
	height: 100%;
	background: rgba(128, 128, 128, .6);
	transition: width .6s ease;
}
.cayr-cand.is-leading .cayr-fill { background: var(--cayr-primary, currentColor); }

.cayr-votes {
	font-size: .8125em;
	opacity: var(--cayr-muted-opacity, .78);
	color: var(--cayr-muted, inherit);
}

.cayr-tag {
	display: inline-block;
	margin-left: .5em;
	padding: .1em .5em;
	font-size: .9em;
	font-weight: 700;
	line-height: 1.4;
	background: var(--cayr-primary, currentColor);
	color: var(--cayr-on-primary, #fff);
	border-radius: var(--cayr-radius, 0);
	vertical-align: baseline;
}

/* Propositions: one bar, Yes from the left, No from the right, midpoint marked */
.cayr-measure-name {
	font-size: .9375em;
	margin: -.35rem 0 .9rem;
	opacity: var(--cayr-muted-opacity, .78);
	color: var(--cayr-muted, inherit);
}
.cayr-split {
	position: relative;
	display: flex;
	justify-content: space-between;
	height: 2rem;
	background: rgba(128, 128, 128, .18);
	border-radius: var(--cayr-radius, 0);
}
.cayr-split-yes,
.cayr-split-no { display: block; height: 100%; transition: width .6s ease; }
.cayr-split-yes { background: var(--cayr-yes, var(--cayr-primary, currentColor)); }
.cayr-split-no  { background: var(--cayr-no, rgba(128, 128, 128, .6)); }
.cayr-split-mid {
	position: absolute;
	left: calc(50% - 1px);
	top: -.3rem;
	bottom: -.3rem;
	width: 2px;
	background: currentColor;
}
.cayr-split-legend {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin-top: .55rem;
}
.cayr-side { display: flex; flex-direction: column; gap: .1rem; }
.cayr-side-no { text-align: right; align-items: flex-end; }
.cayr-side-head { font-size: 1.05em; }
.cayr-side.is-leading .cayr-pct { font-weight: 700; }
.cayr-side .cayr-tag { margin-left: 0; margin-top: .3rem; font-size: .85em; align-self: flex-start; }
.cayr-side-no .cayr-tag { align-self: flex-end; }
.cayr-name .cayr-tag { font-size: .75em; }

/* Notes under each contest */
.cayr-meta {
	display: flex;
	flex-direction: column;
	gap: .15rem;
	margin: .9rem 0 0;
	font-size: .8125em;
	opacity: var(--cayr-muted-opacity, .78);
	color: var(--cayr-muted, inherit);
}
.cayr-meta a { color: inherit; text-decoration: underline; text-underline-offset: .15em; }
.cayr-warn { font-weight: 700; opacity: 1; }
.cayr-empty { margin: 0; font-size: .9375em; opacity: .85; }
.cayr-loading { opacity: .7; }

/* Keyboard focus */
.cayr button:focus-visible,
.cayr a:focus-visible {
	outline: 3px solid var(--cayr-primary, currentColor);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.cayr-race.is-updated { animation: none; }
	.cayr-fill, .cayr-split-yes, .cayr-split-no { transition: none; }
}

/* Phones and small tablets only (720px wide or less). Desktop styles above are unchanged.
 * Everything stacks in one column and nothing can be wider than the screen. */
@media (max-width: 720px) {
	.cayr {
		box-sizing: border-box;
		width: auto !important;
		max-width: 100% !important;
		min-width: 0;
		margin-left: 0;
		margin-right: 0;
		padding-left: 1rem;
		padding-right: 1rem;
		overflow-wrap: anywhere;
		-webkit-text-size-adjust: 100%;
		text-size-adjust: 100%;
	}
	.cayr-status {
		flex-direction: column;
		align-items: flex-start;
		gap: .6rem;
	}
	.cayr-tabs {
		flex-wrap: wrap;
		overflow-x: visible;
		gap: .1rem 1.25rem;
	}
	.cayr-tab { white-space: normal; text-align: left; }
	.cayr-group { margin-top: 2rem; }
	.cayr-grid,
	.cayr-grid-props {
		display: flex;
		flex-direction: column;
		gap: 2rem;
	}
	.cayr-race { width: 100%; max-width: 100%; }
	.cayr-cand-line,
	.cayr-split-legend,
	.cayr-side { min-width: 0; }
	.cayr-split-legend { flex-wrap: wrap; }
}
