/* =========================================================================
   Page Demande d'estimation — questionnaire pas à pas
   page-demande-estimation.php, template-parts/sections/form-estimation.php,
   assets/js/estimation-wizard.js. Jetons et blocs communs : estimation.css
   ========================================================================= */

/* ── Mise en page : présentation à gauche, questionnaire à droite ── */

.estim-demande {
	padding: calc( var( --header-height ) + clamp( 2rem, 4vw, 3.5rem ) ) 0 clamp( 4rem, 8vw, 7rem );
	background: var( --color-white );
}

.estim-back {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: clamp( 2rem, 4vw, 3rem );
	font-size: 0.85rem;
	color: var( --color-text-muted );
	text-decoration: none;
	transition: color var( --transition );
}

.estim-back svg {
	width: 16px;
	height: 16px;
	transition: transform var( --transition );
}

.estim-back:hover {
	color: var( --color-accent-dark );
}

.estim-back:hover svg {
	transform: translateX( -3px );
}

.estim-demande-grid {
	display: grid;
	grid-template-columns: minmax( 0, 4fr ) minmax( 0, 8fr );
	gap: 2.5rem clamp( 2.5rem, 5vw, 6rem );
	align-items: start;
}

.estim-aside {
	display: flex;
	flex-direction: column;
	gap: 2.5rem;
}

/* Reste à l'écran seulement si la fenêtre est assez haute pour l'afficher en entier */
@media ( min-width: 1025px ) and ( min-height: 980px ) {
	.estim-aside {
		position: sticky;
		top: var( --estim-sticky-top );
	}
}

.estim-aside h1 {
	margin-bottom: 1.25rem;
	font-size: clamp( 2.6rem, 4.6vw, 4.25rem );
	font-weight: 500;
	line-height: 0.98;
	letter-spacing: -0.02em;
}

.estim-aside h1 em {
	display: block;
	font-style: italic;
	font-weight: 400;
	color: var( --color-accent-dark );
}

.estim-aside-prose {
	margin-top: 1.25rem;
	font-size: 0.95rem;
	color: var( --color-text-muted );
}

.estim-aside-prose > :last-child {
	margin-bottom: 0;
}

/* « Et ensuite ? » : les étapes en liste compacte */
.estim-next-title {
	margin-bottom: 0.5rem;
	font-family: var( --font-body );
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var( --color-primary );
}

.estim-steps--compact {
	grid-template-columns: minmax( 0, 1fr );
	gap: 0;
	margin: 0;
}

.estim-steps--compact .estim-step {
	display: grid;
	grid-template-columns: 2.25rem minmax( 0, 1fr );
	column-gap: 0.75rem;
	padding: 1rem 0;
	border-top: 1px solid var( --color-border );
}

.estim-steps--compact .estim-step-num {
	grid-row: span 2;
	margin: 0;
	padding-top: 0.4rem;
}

.estim-steps--compact .estim-step-title {
	margin-bottom: 0.25rem;
	font-size: 1.2rem;
}

.estim-steps--compact .estim-step p {
	font-size: 0.88rem;
	line-height: 1.6;
}

.estim-aside-head p {
	max-width: 34ch;
	margin: 0;
	line-height: 1.7;
	color: var( --color-text-muted );
}

/* Carte du questionnaire pas à pas */
.estim-form-card {
	min-height: 560px;
	padding: clamp( 1.5rem, 3.5vw, 3.25rem );
	background: var( --color-cream-soft );
	border-radius: 20px;
	scroll-margin-top: calc( var( --header-height ) + 1.5rem );
}

.estim-form {
	display: flex;
	flex-direction: column;
	min-height: calc( 560px - 2 * clamp( 1.5rem, 3.5vw, 3.25rem ) );
}

.estim-wiz-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 32px;
	margin-bottom: 0.9rem;
}

.estim-wiz-back {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.25rem 0;
	font-family: var( --font-body );
	font-size: 0.85rem;
	color: var( --color-text-muted );
	background: none;
	border: 0;
	cursor: pointer;
	transition: color var( --transition );
}

.estim-wiz-back svg {
	width: 16px;
	height: 16px;
}

.estim-wiz-back:hover {
	color: var( --color-accent-dark );
}

.estim-wiz-count {
	margin-left: auto;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var( --color-accent-dark );
}

.estim-wiz-bar {
	height: 3px;
	margin-bottom: clamp( 2rem, 4vw, 3rem );
	overflow: hidden;
	background: rgba( 0, 0, 0, 0.08 );
	border-radius: 3px;
}

.estim-wiz-bar span {
	display: block;
	height: 100%;
	background: var( --color-accent );
	border-radius: inherit;
	transition: width 0.5s var( --ease-out-expo );
}

/* Un écran = une question */
.estim-q,
.estim-cond {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.estim-q {
	animation: estim-q-in 0.45s var( --ease-out-expo );
}

.estim-q:focus {
	outline: none;
}

.is-back .estim-q {
	animation-name: estim-q-back;
}

@keyframes estim-q-in {
	from { opacity: 0; transform: translateX( 24px ); }
	to   { opacity: 1; transform: none; }
}

@keyframes estim-q-back {
	from { opacity: 0; transform: translateX( -24px ); }
	to   { opacity: 1; transform: none; }
}

@media ( prefers-reduced-motion: reduce ) {
	.estim-q { animation: none; }
	.estim-wiz-bar span { transition: none; }
}

.estim-q-title {
	display: block;
	width: 100%;
	margin: 0 0 0.6rem;
	padding: 0;
	font-family: var( --font-heading );
	font-size: clamp( 1.85rem, 3vw, 2.6rem );
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: -0.01em;
	color: var( --color-primary );
}

.estim-q-title em {
	font-style: italic;
	font-weight: 400;
	color: var( --color-accent-dark );
}

.estim-q-hint {
	margin: 0 0 1.75rem;
	font-size: 0.92rem;
	line-height: 1.6;
	color: var( --color-text-muted );
}

.estim-q-title + .estim-q-body,
.estim-q-title + .estim-choices {
	margin-top: 1.75rem;
}

.estim-row {
	display: grid;
	gap: 1.1rem 1.25rem;
	margin-bottom: 1.5rem;
}

.estim-row--2 { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }

.estim-field {
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin-bottom: 1.5rem;
}

.estim-row .estim-field {
	margin-bottom: 0;
}

.estim-form label,
.estim-label {
	margin: 0 0 0.5rem;
	font-size: 0.82rem;
	font-weight: 500;
	color: var( --color-primary-soft );
}

.estim-req {
	color: var( --color-accent-dark );
}

.estim-opt {
	font-weight: 400;
	color: var( --color-text-light );
}

.estim-opt::before {
	content: "· ";
}

/* Champs */
.estim-form input[type="text"],
.estim-form input[type="email"],
.estim-form input[type="tel"],
.estim-form input[type="number"],
.estim-form select,
.estim-form textarea {
	width: 100%;
	height: 52px;
	padding: 0 1rem;
	font-family: var( --font-body );
	font-size: 0.95rem;
	color: var( --color-primary );
	background-color: var( --color-white );
	border: 1px solid var( --estim-line );
	border-radius: 10px;
	transition: border-color var( --transition ), box-shadow var( --transition );
}

.estim-form textarea {
	height: auto;
	min-height: 120px;
	padding: 0.9rem 1rem;
	line-height: 1.6;
	resize: vertical;
}

.estim-form select {
	padding-right: 2.75rem;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 1rem center;
	background-size: 16px;
	cursor: pointer;
}

.estim-form input[type="number"] {
	-moz-appearance: textfield;
}

.estim-form input[type="number"]::-webkit-inner-spin-button,
.estim-form input[type="number"]::-webkit-outer-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.estim-form ::placeholder {
	color: var( --color-text-light );
}

.estim-form input:hover,
.estim-form select:hover,
.estim-form textarea:hover {
	border-color: rgba( 0, 0, 0, 0.28 );
}

.estim-form input:focus,
.estim-form select:focus,
.estim-form textarea:focus {
	border-color: var( --color-accent );
	box-shadow: 0 0 0 3px rgba( 4, 173, 186, 0.15 );
	outline: none;
}

/* Unité dans le champ (m²) */
.estim-unit {
	position: relative;
}

.estim-unit input[type="number"] {
	padding-right: 3rem;
}

.estim-unit::after {
	content: attr( data-unit );
	position: absolute;
	top: 50%;
	right: 1rem;
	transform: translateY( -50% );
	font-size: 0.85rem;
	color: var( --color-text-muted );
	pointer-events: none;
}

/* Choix (boutons radio / cases à cocher en pastilles) */
.estim-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.estim-form .estim-choice,
.estim-form .estim-dpe {
	position: relative;
	margin: 0;
	cursor: pointer;
}

.estim-choice input,
.estim-dpe input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.estim-choice span {
	display: inline-flex;
	align-items: center;
	min-height: 46px;
	padding: 0 1.15rem;
	font-size: 0.9rem;
	color: var( --color-primary-soft );
	background: var( --color-white );
	border: 1px solid var( --estim-line );
	border-radius: var( --radius-pill );
	transition: background var( --transition ), border-color var( --transition ), color var( --transition );
}

.estim-choice--type span {
	min-height: 56px;
	padding: 0 1.4rem;
	font-family: var( --font-heading );
	font-size: 1.25rem;
	font-weight: 500;
	border-radius: 12px;
}

.estim-choice--sm span {
	min-height: 42px;
	padding: 0 1rem;
	font-size: 0.86rem;
}

.estim-choice:hover span {
	border-color: var( --color-primary );
}

.estim-choice input:checked + span {
	color: var( --color-white );
	background: var( --color-primary );
	border-color: var( --color-primary );
}

.estim-choice input:focus-visible + span,
.estim-dpe input:focus-visible + span {
	outline: 2px solid var( --color-accent );
	outline-offset: 2px;
}

/* DPE : lettres aux couleurs de l'étiquette énergie */
.estim-dpe--a { --dpe-tone: var( --dpe-a ); }
.estim-dpe--b { --dpe-tone: var( --dpe-b ); }
.estim-dpe--c { --dpe-tone: var( --dpe-c ); }
.estim-dpe--d { --dpe-tone: var( --dpe-d ); }
.estim-dpe--e { --dpe-tone: var( --dpe-e ); }
.estim-dpe--f { --dpe-tone: var( --dpe-f ); }
.estim-dpe--g { --dpe-tone: var( --dpe-g ); }

.estim-dpe span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	font-size: 0.95rem;
	font-weight: 700;
	color: var( --color-primary-soft );
	background: var( --color-white );
	border: 1px solid var( --estim-line );
	border-radius: 10px;
	box-shadow: inset 0 -4px 0 var( --dpe-tone );
	transition: background var( --transition ), color var( --transition );
}

.estim-dpe:hover span {
	border-color: var( --dpe-tone );
}

.estim-dpe input:checked + span {
	color: var( --color-white );
	background: var( --dpe-tone );
	border-color: var( --dpe-tone );
	box-shadow: none;
}

.estim-dpe--c input:checked + span,
.estim-dpe--d input:checked + span,
.estim-dpe--e input:checked + span {
	color: var( --color-primary );
}

/* Raccourcis de communes */
.estim-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 0.75rem;
}

.estim-chip {
	padding: 0.4rem 0.85rem;
	font-family: var( --font-body );
	font-size: 0.8rem;
	color: var( --color-text-muted );
	background: transparent;
	border: 1px solid var( --estim-line );
	border-radius: var( --radius-pill );
	cursor: pointer;
	transition: border-color var( --transition ), color var( --transition ), background var( --transition );
}

.estim-chip:hover {
	color: var( --color-primary );
	border-color: var( --color-primary );
}

.estim-chip.is-on {
	color: var( --color-white );
	background: var( --color-primary );
	border-color: var( --color-primary );
}

/* Champ numérique avec boutons − / + */
.estim-stepper {
	display: flex;
	max-width: 220px;
}

.estim-form .estim-stepper input[type="number"] {
	text-align: center;
	border-radius: 0;
}

.estim-stepper button {
	flex-shrink: 0;
	width: 52px;
	font-size: 1.25rem;
	color: var( --color-primary );
	background: var( --color-white );
	border: 1px solid var( --estim-line );
	cursor: pointer;
	transition: background var( --transition );
}

.estim-stepper button:first-child {
	border-right: 0;
	border-radius: 10px 0 0 10px;
}

.estim-stepper button:last-child {
	border-left: 0;
	border-radius: 0 10px 10px 0;
}

.estim-stepper button:hover {
	background: var( --color-cream );
}

/* Récapitulatif */
.estim-recap {
	margin: 0 0 1.75rem;
	border-top: 1px solid var( --estim-line );
}

.estim-recap-row {
	display: grid;
	grid-template-columns: 11rem minmax( 0, 1fr );
	gap: 0.25rem 1.25rem;
	padding: 0.8rem 0;
	border-bottom: 1px solid var( --estim-line );
	font-size: 0.92rem;
	line-height: 1.5;
}

.estim-recap-row dt {
	color: var( --color-text-muted );
}

.estim-recap-row dd {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	margin: 0;
	color: var( --color-primary );
}

.estim-recap-row dd span {
	overflow-wrap: anywhere;
}

.estim-recap-edit {
	flex-shrink: 0;
	padding: 0;
	font-family: var( --font-body );
	font-size: 0.8rem;
	color: var( --color-accent-dark );
	text-decoration: underline;
	text-underline-offset: 3px;
	background: none;
	border: 0;
	cursor: pointer;
}

.estim-form .estim-rgpd {
	display: flex;
	align-items: flex-start;
	gap: 0.7rem;
	max-width: 36rem;
	margin: 0;
	font-size: 0.82rem;
	font-weight: 400;
	line-height: 1.55;
	color: var( --color-text-muted );
	cursor: pointer;
}

.estim-rgpd input {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin-top: 1px;
	accent-color: var( --color-accent );
}

.estim-error {
	margin: 1.5rem 0 0;
	padding: 0.9rem 1.15rem;
	font-size: 0.88rem;
	line-height: 1.5;
	color: #991b1b;
	background: rgba( 220, 38, 38, 0.06 );
	border-left: 3px solid #dc2626;
	border-radius: var( --radius-sm );
}

/* Boutons : toujours en bas de la carte */
.estim-wiz-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem 1.25rem;
	margin-top: auto;
	padding-top: clamp( 2rem, 4vw, 2.75rem );
}

.estim-wiz-foot .btn[disabled] {
	opacity: 0.6;
	cursor: wait;
}

.estim-wiz-enter {
	font-size: 0.8rem;
	color: var( --color-text-light );
}

.estim-wiz-enter kbd {
	padding: 0.1rem 0.45rem;
	font-family: var( --font-body );
	font-size: 0.75rem;
	color: var( --color-primary-soft );
	background: var( --color-white );
	border: 1px solid var( --estim-line );
	border-radius: 4px;
}

@media ( hover: none ) {
	.estim-wiz-enter { display: none; }
}

/* Confirmation après envoi */
.estim-sent {
	padding: clamp( 0.5rem, 2vw, 1.5rem ) 0;
}

.estim-sent-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin-bottom: 1.5rem;
	color: var( --color-white );
	background: var( --color-accent );
	border-radius: 50%;
}

.estim-sent-icon svg {
	width: 24px;
	height: 24px;
}

.estim-sent h2 {
	margin-bottom: 0.75rem;
	font-size: clamp( 1.8rem, 3vw, 2.4rem );
}

.estim-sent p {
	max-width: 44ch;
	margin: 0;
	line-height: 1.7;
	color: var( --color-text-muted );
}

.estim-sent-again {
	margin-top: 1.5rem;
	padding: 0;
	font-family: var( --font-body );
	font-size: 0.9rem;
	color: var( --color-accent-dark );
	text-decoration: underline;
	text-underline-offset: 3px;
	background: none;
	border: 0;
	cursor: pointer;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media ( max-width: 1024px ) {
	.estim-demande-grid {
		grid-template-columns: minmax( 0, 1fr );
	}

	/* Sur une colonne : présentation, questionnaire, déroulé, puis contact */
	.estim-aside {
		display: contents;
	}

	.estim-aside-head { order: 1; }
	.estim-form-card  { order: 2; }
	.estim-next       { order: 3; }
	.estim-aside > .estim-contact { order: 4; }
}

@media ( max-width: 760px ) {
	/* En-tête compact : la première question reste visible sans défiler */
	.estim-demande {
		padding-top: calc( var( --header-height ) + 0.5rem );
	}

	.estim-back {
		margin-bottom: 1.25rem;
	}

	.estim-demande-grid {
		gap: 1.75rem;
	}

	.estim-aside-head .estim-eyebrow {
		display: none;
	}

	.estim-aside h1 {
		margin-bottom: 0.75rem;
		font-size: 2.4rem;
	}

	.estim-aside h1 em {
		display: inline;
	}

	.estim-aside-head p {
		font-size: 0.92rem;
	}

	.estim-steps--compact {
		gap: 0;
	}

	.estim-form-card,
	.estim-form {
		min-height: 0;
	}

	.estim-wiz-foot .btn {
		width: 100%;
	}

	.estim-recap-row {
		grid-template-columns: minmax( 0, 1fr );
	}
}

@media ( max-width: 560px ) {
	.estim-row--2 {
		grid-template-columns: minmax( 0, 1fr );
	}

	.estim-choices--types {
		display: grid;
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	}

	.estim-choices--types span {
		justify-content: center;
		width: 100%;
	}

	.estim-choices--dpe {
		gap: 0.4rem;
	}

	.estim-dpe span {
		width: 36px;
		height: 40px;
		border-radius: 8px;
	}

	.estim-choice--type span {
		min-height: 50px;
		padding: 0 1.1rem;
		font-size: 1.15rem;
	}
}
