/* TPMP Consultation — styles publics. Mobile d'abord, aucune ressource externe. */

.tpmp {
	--tpmp-texte: #1a1a1a;
	--tpmp-attenue: #545454;
	--tpmp-fond: #ffffff;
	--tpmp-fond-doux: #f4f5f4;
	--tpmp-bordure: #767676;
	--tpmp-bordure-douce: #d0d0d0;
	--tpmp-piste: #e4e4e4;
	--tpmp-barre: #2f4858;
	--tpmp-accent: #1d4e89;
	--tpmp-focus: #0a58ca;
	--tpmp-rayon: 6px;
	color: var(--tpmp-texte);
	line-height: 1.5;
	margin-block: 1.5rem;
}

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

.tpmp :focus-visible {
	outline: 3px solid var(--tpmp-focus);
	outline-offset: 2px;
}

.tpmp .tpmp-h,
.tpmp .tpmp-q-title,
.tpmp .tpmp-jauge-title {
	margin: 0 0 0.25rem;
	line-height: 1.3;
}

.tpmp .tpmp-q-title {
	font-size: 1rem;
	margin-top: 1.25rem;
}

.tpmp .tpmp-count {
	margin: 0 0 0.75rem;
	color: var(--tpmp-attenue);
	font-size: 0.95em;
}

.tpmp .tpmp-seuil {
	margin: 0.5rem 0 0;
	padding: 0.75rem 1rem;
	background: var(--tpmp-fond-doux);
	border: 1px dashed var(--tpmp-bordure);
	border-radius: var(--tpmp-rayon);
	color: var(--tpmp-texte);
}

.tpmp .tpmp-mention,
.tpmp .tpmp-hint {
	font-size: 0.875em;
	color: var(--tpmp-attenue);
	margin: 1rem 0 0;
}

/* ---------- Messages ---------- */

.tpmp .tpmp-message {
	margin: 0 0 1.25rem;
	padding: 0.875rem 1rem;
	border: 1px solid;
	border-left-width: 6px;
	border-radius: var(--tpmp-rayon);
	background: var(--tpmp-fond);
	font-weight: 600;
}

.tpmp .tpmp-message p {
	margin: 0;
}

.tpmp .tpmp-message--succes {
	border-color: #1e7b34;
	background: #edf7ef;
}

.tpmp .tpmp-message--info {
	border-color: #1d4e89;
	background: #eef3fa;
}

.tpmp .tpmp-message--erreur {
	border-color: #b3261e;
	background: #fcefee;
}

.tpmp .tpmp-admin-hint {
	font-size: 0.875em;
	color: var(--tpmp-attenue);
}

/* ---------- Formulaire ---------- */

.tpmp-form {
	display: grid;
	gap: 1.25rem;
}

.tpmp-form .tpmp-required-note {
	margin: 0;
	font-size: 0.9em;
	color: var(--tpmp-attenue);
}

.tpmp-form .tpmp-label {
	display: block;
	font-weight: 700;
	margin-bottom: 0.5rem;
	padding: 0;
}

.tpmp-form .tpmp-num {
	color: var(--tpmp-accent);
}

.tpmp-form select {
	width: 100%;
	max-width: 32rem;
	min-height: 2.75rem;
	padding: 0.5rem 0.75rem;
	font: inherit;
	color: var(--tpmp-texte);
	background: var(--tpmp-fond);
	border: 1px solid var(--tpmp-bordure);
	border-radius: var(--tpmp-rayon);
}

.tpmp-form .tpmp-question {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.tpmp-form .tpmp-options {
	display: grid;
	gap: 0.5rem;
}

.tpmp-form .tpmp-option {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	min-height: 2.75rem;
	padding: 0.625rem 0.875rem;
	background: var(--tpmp-fond);
	border: 1px solid var(--tpmp-bordure-douce);
	border-radius: var(--tpmp-rayon);
	cursor: pointer;
}

.tpmp-form .tpmp-option:hover {
	border-color: var(--tpmp-bordure);
}

.tpmp-form .tpmp-option:has(input:checked) {
	border-color: var(--tpmp-accent);
	box-shadow: inset 0 0 0 1px var(--tpmp-accent);
	background: #eef3fa;
}

.tpmp-form .tpmp-option input {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.15rem 0 0;
	accent-color: var(--tpmp-accent);
}

.tpmp-form .tpmp-option label {
	flex: 1;
	cursor: pointer;
}

/* Toute la carte est cliquable. */
.tpmp-form .tpmp-option label::after {
	content: "";
	position: absolute;
	inset: 0;
}

.tpmp-form .tpmp-hp {
	position: absolute !important;
	left: -10000px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.tpmp-form .tpmp-submit {
	justify-self: start;
	min-height: 2.75rem;
	padding: 0.625rem 1.75rem;
	font: inherit;
	font-weight: 700;
	color: #ffffff;
	background: var(--tpmp-accent);
	border: 2px solid var(--tpmp-accent);
	border-radius: var(--tpmp-rayon);
	cursor: pointer;
}

.tpmp-form .tpmp-submit:hover {
	background: #163c69;
}

.tpmp-form .tpmp-submit:disabled {
	opacity: 0.7;
	cursor: wait;
}

/* ---------- Mention RGPD ---------- */

.tpmp .tpmp-rgpd {
	margin-top: 1.75rem;
	padding: 1rem 1.25rem;
	background: var(--tpmp-fond-doux);
	border-radius: var(--tpmp-rayon);
	font-size: 0.875em;
}

.tpmp .tpmp-rgpd-title {
	margin: 0 0 0.5rem;
}

.tpmp .tpmp-rgpd ul {
	margin: 0;
	padding-left: 1.25rem;
}

.tpmp .tpmp-rgpd li + li {
	margin-top: 0.35rem;
}

/* ---------- Barres (résultats) ---------- */

.tpmp .tpmp-bars {
	list-style: none;
	margin: 0.5rem 0 0;
	padding: 0;
	display: grid;
	gap: 0.75rem;
}

.tpmp .tpmp-bar {
	display: grid;
	grid-template-columns: 1fr auto;
	column-gap: 1rem;
	row-gap: 0.3rem;
	margin: 0;
}

.tpmp .tpmp-bar-value {
	font-weight: 700;
	white-space: nowrap;
	text-align: right;
}

.tpmp .tpmp-bar-count {
	font-weight: 400;
	color: var(--tpmp-attenue);
}

.tpmp .tpmp-bar-track {
	grid-column: 1 / -1;
	display: block;
	height: 0.875rem;
	background: var(--tpmp-piste);
	border-radius: 999px;
	overflow: hidden;
}

.tpmp .tpmp-bar-fill {
	display: block;
	height: 100%;
	background: var(--tpmp-barre);
	border-radius: 999px;
}

/* ---------- Couleurs des trois modes ---------- */

.tpmp .tpmp-fill-pap {
	background: var(--tpmp-pap);
	color: var(--tpmp-pap-texte);
}

.tpmp .tpmp-fill-pav {
	background: var(--tpmp-pav);
	color: var(--tpmp-pav-texte);
}

.tpmp .tpmp-fill-mixte {
	background: var(--tpmp-mixte);
	color: var(--tpmp-mixte-texte);
}

/* ---------- Jauges ---------- */

.tpmp-jauges .tpmp-jauges-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.25rem;
}

.tpmp-jauges .tpmp-jauge {
	margin: 0;
	padding: 1rem 1.25rem 1.25rem;
	background: var(--tpmp-fond);
	border: 1px solid var(--tpmp-bordure-douce);
	border-radius: calc(var(--tpmp-rayon) * 1.5);
}

.tpmp-jauges .tpmp-jauge-title {
	font-size: 1.1rem;
}

.tpmp .tpmp-gauge {
	display: flex;
	width: 100%;
	height: 2.75rem;
	background: var(--tpmp-piste);
	border-radius: var(--tpmp-rayon);
	overflow: hidden;
}

.tpmp .tpmp-seg {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	font-weight: 700;
	font-size: 0.95rem;
}

.tpmp .tpmp-seg + .tpmp-seg {
	border-left: 2px solid #ffffff;
}

.tpmp .tpmp-legend {
	list-style: none;
	margin: 0.75rem 0 0;
	padding: 0;
	display: grid;
	gap: 0.35rem;
	font-size: 0.95em;
}

.tpmp .tpmp-legend li {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.25rem 0.5rem;
	margin: 0;
}

.tpmp .tpmp-swatch {
	flex: none;
	display: inline-block;
	width: 1rem;
	height: 1rem;
	border-radius: 3px;
	outline: 1px solid rgba(0, 0, 0, 0.35);
}

/* ---------- Animation au défilement ---------- */

.tpmp .tpmp-anim {
	width: var(--w, 0%);
	transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Posée par le script avant l'entrée dans la zone visible. */
.tpmp .tpmp-anim.tpmp-pending {
	width: 0 !important;
	transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.tpmp .tpmp-anim {
		transition: none;
	}

	.tpmp .tpmp-anim.tpmp-pending {
		width: var(--w, 0%) !important;
	}
}

/* ---------- Résultats détaillés ---------- */

.tpmp-resultats .tpmp-section + .tpmp-section {
	margin-top: 2.5rem;
}

.tpmp-resultats .tpmp-group {
	margin-top: 1.5rem;
	padding-top: 1rem;
	border-top: 1px solid var(--tpmp-bordure-douce);
}

.tpmp-resultats .tpmp-commune {
	margin: 0.5rem 0 0;
	border: 1px solid var(--tpmp-bordure-douce);
	border-radius: var(--tpmp-rayon);
	background: var(--tpmp-fond);
}

.tpmp-resultats .tpmp-commune summary {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.25rem 1rem;
	min-height: 2.75rem;
	padding: 0.625rem 1rem;
	cursor: pointer;
	font-weight: 600;
	list-style: none;
}

.tpmp-resultats .tpmp-commune summary::before {
	content: "▸";
	color: var(--tpmp-accent);
	margin-right: 0.5rem;
}

.tpmp-resultats .tpmp-commune[open] summary::before {
	content: "▾";
}

.tpmp-resultats .tpmp-commune summary::-webkit-details-marker {
	display: none;
}

.tpmp-resultats .tpmp-commune-nom {
	flex: 1;
}

.tpmp-resultats .tpmp-commune-n {
	font-weight: 400;
	color: var(--tpmp-attenue);
}

.tpmp-resultats .tpmp-commune-body {
	padding: 0 1rem 1rem;
}

.tpmp .tpmp-apres-vote {
	margin-top: 1rem;
}

/* ---------- Écrans plus larges : jauges sur deux colonnes ---------- */

@media (min-width: 48em) {
	.tpmp-jauges .tpmp-jauges-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (forced-colors: active) {
	.tpmp .tpmp-seg,
	.tpmp .tpmp-bar-fill,
	.tpmp .tpmp-swatch {
		forced-color-adjust: none;
	}
}
