/*
 * Calculateur de taux d'endettement (template-taux-endettement.php).
 * Le parcours reprend les styles du budget en ligne (budget-stepper.css, classes .bs-*, chargée avant).
 * Ici : en-tête de page, champs, jauge et résultat propres au calculateur.
 */

.te-page {
	color: var(--bs-ink);
	/* Même décalage que .container-main-content, sous l'en-tête fixe du site. */
	margin-top: 70px;
}
.te-page [hidden] { display: none !important; }

/* ---------- En-tête de page : aligné sur le bloc du calculateur (760 px) ---------- */

.te-hero { background: linear-gradient(135deg, #EAF3F8 0%, #EAF3F8 60%, #E5F1DC 100%); padding: 28px 0 88px; }
.te-hero__texte { max-width: 760px; margin: 0 auto; }
.te-fil, .te-fil a { margin: 0 0 8px; font-size: 14px; color: var(--bs-muted); }
.te-fil a { text-decoration: underline; text-underline-offset: 3px; }
.te-page h1 {
	margin: 0;
	font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
	font-size: clamp(30px, 4.4vw, 42px);
	font-weight: 800;
	line-height: 1.12;
	letter-spacing: -.02em;
	text-transform: none;
	text-wrap: balance;
	color: var(--bs-navy);
}
.te-chapo { max-width: 60ch; margin: 10px 0 0; font-size: 17px; line-height: 1.55; color: var(--bs-muted); }

/* Le calculateur remonte sur le dégradé de l'en-tête. */
.te-outil { padding: 0 0 40px; }
.te-outil .bs-app { margin-top: -64px; position: relative; }
.te-confidentialite { max-width: 760px; margin: 14px auto 0; font-size: 13px; color: var(--bs-muted); text-align: center; }

/* ---------- Champs ---------- */

/* Une ligne par montant : libellé (et aide) à gauche, champ à droite ; empilés sur mobile. */
.te-champs { margin-bottom: 8px; border-top: 1px solid var(--bs-line); }
.te-champ {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 240px;
	grid-template-areas: "label box" "aide box" "erreur erreur";
	column-gap: 20px;
	align-items: center;
	padding: 14px 0;
	border-bottom: 1px solid var(--bs-line);
}
.te-champ__label { grid-area: label; align-self: end; margin: 0; font-size: 16px; font-weight: 700; color: var(--bs-ink); }
.te-champ__aide { grid-area: aide; align-self: start; margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--bs-muted); }
.te-champ .bs-field__box { grid-area: box; }
.te-champ .te-erreur { grid-area: erreur; text-align: right; }
.te-champ:not(:has(.te-champ__aide)) .te-champ__label { grid-row: 1 / 3; align-self: center; }
.te-app .bs-field__box input[data-groupe] { text-align: right; }
.te-app .bs-field__box span { white-space: nowrap; font-size: 14px; }
.te-champ.is-invalid .bs-field__box { border-color: var(--bs-red); }
.te-erreur { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--bs-red); }
.te-alerte {
	margin: 12px 0 4px;
	padding: 12px 14px;
	border-radius: 12px;
	background: #FDECEA;
	font-size: 15px;
	font-weight: 600;
	color: #8E2A1F;
}

/* Taux en direct dans la barre du bas : vert (sain), jaune foncé (à surveiller), rouge (élevé). */
.bs-balance.te-is-mid .bs-balance__value { color: #8A5A00; }

/* ---------- Résultat ---------- */

.te-resultat__taux {
	margin: 4px 0 18px;
	font-size: clamp(48px, 10vw, 68px);
	font-weight: 800;
	line-height: 1;
	letter-spacing: -.03em;
	font-variant-numeric: tabular-nums;
	color: var(--bs-navy);
}
.te-resultat[data-niveau="sain"] .te-resultat__taux,
.te-resultat[data-niveau="sain"] .te-resultat__verdict { color: var(--bs-green-ink); }
.te-resultat[data-niveau="surveiller"] .te-resultat__taux,
.te-resultat[data-niveau="surveiller"] .te-resultat__verdict { color: #8A5A00; }
.te-resultat[data-niveau="eleve"] .te-resultat__taux,
.te-resultat[data-niveau="eleve"] .te-resultat__verdict { color: var(--bs-red); }

.te-jauge__barre {
	position: relative;
	height: 12px;
	border-radius: 999px;
	background: linear-gradient(to right, var(--bs-green) 0 50%, var(--bs-yellow) 50% 66.67%, var(--bs-red) 66.67% 100%);
}
.te-jauge__repere {
	position: absolute;
	top: 50%;
	left: 0;
	width: 24px;
	height: 24px;
	border: 4px solid var(--bs-ink);
	border-radius: 50%;
	background: #fff;
	transform: translate(-50%, -50%);
	transition: left .5s ease;
}
.te-jauge__zones {
	display: grid;
	grid-template-columns: 50% 16.67% 33.33%;
	margin-top: 8px;
	font-size: 12px;
	line-height: 1.3;
	color: var(--bs-muted);
}
.te-jauge__zone--surveiller { text-align: center; }
.te-jauge__zone--eleve { text-align: right; }

.te-resultat__verdict { margin: 22px 0 4px; font-size: 20px; font-weight: 800; }
.te-resultat__texte { margin: 0; font-size: 16px; line-height: 1.5; }

/* Rapport PDF : formulaire, envoi par courriel, puis téléchargement (même bloc .bs-send que le budget). */
.te-rapport { margin-top: 16px; }
.te-rapport__pdf { width: 100%; margin-top: 12px; background: #fff; }
.te-rapport__pdf[hidden], .te-rapport .bs-btn[hidden] { display: none; }
.te-rapport .bs-field.is-invalid .bs-field__box { border-color: var(--bs-red); }
.te-rapport__message { margin: 0 0 14px !important; padding: 10px 12px; border-radius: 10px; background: #E9F4DC; font-size: 15px !important; font-weight: 600; color: #2F5409 !important; }
.te-rapport__message.is-erreur { background: #FDECEA; color: #8E2A1F !important; }
.te-rapport .bs-btn[disabled] { opacity: .65; cursor: progress; }
/* « .bs-send p » du budget l'emporterait sur la couleur rouge du message de consentement. */
.te-rapport .bs-consent__error { margin: -8px 0 14px 32px; font-size: 13px; font-weight: 600; color: var(--bs-red); }
.te-piege { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.te-suite__actions { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.te-suite--eleve { background: #FDF3F2; }
.te-tel { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; }

/* ---------- Textes explicatifs (champs ACF, mis en page par le gabarit) ---------- */

.te-contenu { padding: 32px 0 56px; border-top: 1px solid var(--bs-line); background: var(--bs-wash); }
.te-doc { max-width: 1040px; margin: 0 auto; }

/* Sommaire : bloc en tête sur mobile, colonne collante à gauche sur grand écran. */
.te-sommaire {
	margin: 0 0 24px;
	padding: 18px 20px;
	border: 1px solid var(--bs-line);
	border-radius: var(--bs-radius);
	background: #fff;
}
.te-sommaire__titre {
	margin: 0 0 8px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--bs-muted);
}
.te-sommaire ol { margin: 0; padding: 0; list-style: none; counter-reset: te-som; }
.te-sommaire li { counter-increment: te-som; }
.te-sommaire a {
	display: flex;
	gap: 10px;
	align-items: baseline;
	min-height: 44px;
	padding: 10px 0;
	border-bottom: 1px solid var(--bs-line);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--bs-navy);
	text-decoration: none;
}
.te-sommaire li:last-child a { border-bottom: 0; }
.te-sommaire a::before { content: counter(te-som); flex: none; width: 22px; font-weight: 800; color: var(--bs-green-ink); }
.te-sommaire a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Colonne de lecture. */
.te-prose {
	max-width: 720px;
	padding: 8px 28px 28px;
	border: 1px solid var(--bs-line);
	border-radius: 24px;
	background: #fff;
	font-family: "Plus Jakarta Sans", system-ui, sans-serif;
	font-size: 17px;
	line-height: 1.7;
	color: var(--bs-ink);
}
.te-surtitre {
	margin: 20px 0 0;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--bs-green-ink);
}
.te-section { padding: 8px 0 20px; scroll-margin-top: 96px; }
.te-section + .te-section { border-top: 1px solid var(--bs-line); }
.te-prose h2 {
	margin: 18px 0 12px;
	font-family: inherit !important;
	font-size: clamp(22px, 3.2vw, 28px);
	font-weight: 800;
	line-height: 1.2;
	letter-spacing: -.01em;
	text-transform: none;
	color: var(--bs-navy);
}
.te-prose h3 { margin: 18px 0 8px; font-family: inherit !important; font-size: 18px; font-weight: 700; text-transform: none; color: var(--bs-navy); }
.te-prose p { margin: 0 0 14px; }
.te-prose a { color: var(--bs-navy); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.te-prose a:hover { text-decoration-thickness: 2px; }
.te-prose strong, .te-prose b { font-weight: 700; }
.te-prose ul, .te-prose ol { margin: 0 0 16px; padding: 0; list-style: none; }
.te-prose li { position: relative; margin: 0 0 8px; padding-left: 28px; }
.te-prose ul > li::before {
	content: "";
	position: absolute;
	left: 4px;
	top: .62em;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--bs-green);
}
.te-prose ol { counter-reset: te-li; }
.te-prose ol > li { counter-increment: te-li; }
.te-prose ol > li::before { content: counter(te-li) "."; position: absolute; left: 0; font-weight: 800; color: var(--bs-green-ink); }
.te-prose li p { margin: 0; }

/* Accordéons : même marqueur « + » que les lignes du budget. */
.te-accordeons { margin: 8px 0 16px; border-top: 1px solid var(--bs-line); }
.te-accordeon { border-bottom: 1px solid var(--bs-line); }
.te-accordeon summary {
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 60px;
	padding: 12px 2px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--bs-ink);
	cursor: pointer;
	list-style: none;
}
.te-accordeon summary::-webkit-details-marker { display: none; }
.te-accordeon summary > span:first-child { flex: 1; }
.te-accordeon summary:hover > span:first-child { color: var(--bs-navy); }
.te-accordeon summary:focus-visible { outline: 3px solid var(--bs-yellow); outline-offset: 2px; }
.te-accordeon[open] .bs-item__mark::after { transform: scaleY(0); }
.te-accordeon__corps { padding: 0 2px 14px; font-size: 16px; }

@media (min-width: 1100px) {
	.te-doc { display: grid; grid-template-columns: 260px minmax(0, 720px); gap: 40px; justify-content: center; }
	.te-sommaire { position: sticky; top: 96px; align-self: start; margin: 0; }
	.te-prose { padding: 12px 40px 36px; }
}

/* ---------- Mobile (mêmes paliers que budget-stepper.css) ---------- */

@media (max-width: 640px) {
	.te-hero { padding-bottom: 24px; }
	.te-outil .bs-app { margin-top: 0; }
	.te-champs { border-top: 0; }
	.te-champ {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "label" "aide" "box" "erreur";
		padding: 0 0 16px;
		border-bottom: 0;
	}
	.te-champ:not(:has(.te-champ__aide)) .te-champ__label { grid-row: auto; }
	.te-champ__label { margin-bottom: 6px; }
	.te-champ__aide { margin: -4px 0 8px; }
	.te-champ .te-erreur { text-align: left; }
	/* La zone « à surveiller » (17 % de la barre) est trop étroite pour son libellé. */
	.te-jauge__zones { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
	.te-suite__actions .bs-btn { width: 100%; }
	.te-contenu { padding-top: 24px; }
	.te-prose { margin: 0 -15px; padding: 4px 16px 20px; border-left: 0; border-right: 0; border-radius: 0; font-size: 16px; }
}

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