/*
 * Section « scan 3D de bâtiment » de l'accueil : fond bleu nuit, planche du chantier épinglée
 * à gauche (construite par scan.js à partir des images des étapes), quatre étapes qui défilent
 * à droite, reliées par un rail. À chaque étape, un balayage laser transforme la planche.
 * Sous 900 px : pas de planche, chaque étape montre sa propre image.
 */

.cp-main > .cp-scan-part { margin-block: 0; }

.cp-scan {
	--cp-scan-orange: var(--wp--preset--color--orange, #FF9900);
	--cp-scan-text-2: #C9CBE0;
	--cp-scan-text-3: #9A9EBD;
	--cp-scan-line: rgba(255, 255, 255, .14);
	--cp-scan-sweep: 1100ms;
	--cp-scan-ease: cubic-bezier(.2, .7, .2, 1);
	position: relative;
	margin: 0 !important;
	padding-block: clamp(72px, 9vw, 128px);
	background: var(--wp--preset--color--navy, #000033);
	color: #fff;
	overflow: clip;
}
.cp-scan,
.cp-scan * { box-sizing: border-box; }
.cp-scan > *,
.cp-scan__grid > *,
.cp-scan__stage > *,
.cp-scan__content > *,
.cp-steps > *,
.cp-step > * { margin-block: 0 !important; }
/* Trame de fond : grille de relevé très discrète. */
.cp-scan::before {
	content: "";
	position: absolute;
	inset: 0;
	background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
	background-size: 48px 48px;
	-webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
	mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
	pointer-events: none;
}
.cp-scan__grid { position: relative; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 88px); }

/* ---------- Planche épinglée ---------- */
.cp-scan__stage {
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--cp-bar-h, 76px) + 5vh);
	align-self: start;
	display: flex;
	flex-direction: column;
}
.cp-plate-frame { position: relative; order: -1; }
.cp-plate { position: relative; aspect-ratio: 1080 / 700; max-width: 100%; overflow: hidden; border-radius: 8px; background: #fff; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6); }
.cp-plate__img { position: absolute; inset: 0; margin: 0; visibility: hidden; }
.cp-plate__img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cp-plate__img.is-on,
.cp-plate__img.is-off { visibility: visible; }
.cp-plate__img.is-on { z-index: 2; }
.cp-plate__img.is-off { z-index: 1; }
.cp-plate__img.is-in { clip-path: inset(0 100% 0 0); animation: cp-scan-reveal var(--cp-scan-sweep) var(--cp-scan-ease) forwards; }
@keyframes cp-scan-reveal { to { clip-path: inset(0 0 0 0); } }
.cp-plate__laser {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	z-index: 3;
	width: 2px;
	background: var(--cp-scan-orange);
	box-shadow: 0 0 12px 2px rgba(255, 153, 0, .85), 0 0 36px 8px rgba(255, 153, 0, .3);
	opacity: 0;
	pointer-events: none;
}
.cp-plate__laser::before { content: ""; position: absolute; top: 0; bottom: 0; right: 2px; width: 120px; background: linear-gradient(90deg, rgba(255, 153, 0, 0), rgba(255, 153, 0, .18)); }
.cp-plate__laser.is-run { animation: cp-scan-sweep var(--cp-scan-sweep) var(--cp-scan-ease) forwards; }
@keyframes cp-scan-sweep { 0% { opacity: 1; transform: translateX(0); } 90% { opacity: 1; } 100% { opacity: 0; transform: translateX(var(--w, 700px)); } }
/* Repères de coupe aux angles, comme sur une planche imprimée. */
.cp-plate__marks { position: absolute; inset: -12px; pointer-events: none; }
.cp-plate__marks i { position: absolute; width: 18px; height: 18px; border: 0 solid rgba(255, 255, 255, .5); }
.cp-plate__marks i:nth-child(1) { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.cp-plate__marks i:nth-child(2) { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.cp-plate__marks i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.cp-plate__marks i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }
.cp-scan__place { margin-top: 22px !important; color: var(--cp-scan-text-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.cp-scan__place strong { color: #fff; font-weight: 600; }
.cp-scan__count { float: right; margin-left: 16px; color: var(--cp-scan-orange); font-weight: 700; white-space: nowrap; }

/* ---------- Texte et étapes ---------- */
.cp-scan .cp-scan__title { margin-bottom: 20px !important; color: #fff; font-size: clamp(32px, 3.3vw, 48px); line-height: 1.1; font-weight: 700; letter-spacing: -.01em; }
.cp-scan__intro { color: var(--cp-scan-text-2); font-size: 18px; }
.cp-steps { position: relative; margin-top: clamp(48px, 6vw, 80px) !important; padding-left: 44px; counter-reset: cp-step; }
/* Rail : trait fin, rempli en orange au fil du défilement (--p posé par scan.js). */
.cp-steps::before,
.cp-steps::after { content: ""; position: absolute; left: 11px; top: 14px; bottom: 14px; width: 2px; border-radius: 2px; }
.cp-steps::before { background: var(--cp-scan-line); }
.cp-steps::after { background: var(--cp-scan-orange); transform-origin: top; transform: scaleY(var(--p, 0)); }
/* Chaque étape passe au-dessus de la ligne de progression : sinon la ligne orange traverse la pastille et coupe le chiffre. */
.cp-step { position: relative; z-index: 1; min-height: 46vh; padding-bottom: 32px; counter-increment: cp-step; transition: opacity .5s ease; }
.cp-step:last-child { min-height: 0; padding-bottom: 0; }
.cp-scan.is-ready .cp-step { opacity: .38; }
.cp-scan.is-ready .cp-step.is-on { opacity: 1; }
.cp-step::before {
	content: counter(cp-step);
	position: absolute;
	left: -44px;
	top: 4px;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border: 2px solid var(--cp-scan-line);
	border-radius: 50%;
	background: var(--wp--preset--color--navy, #000033);
	color: var(--cp-scan-text-3);
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	transition: border-color .4s, background .4s, color .4s;
}
.cp-step.is-on::before,
.cp-step.is-done::before { border-color: var(--cp-scan-orange); }
.cp-step.is-on::before { background: var(--cp-scan-orange); color: var(--wp--preset--color--navy, #000033); }
.cp-scan .cp-step__title { margin-bottom: 12px !important; color: #fff; font-size: 24px; line-height: 1.2; font-weight: 700; }
.cp-step__text { color: var(--cp-scan-text-2); font-size: 17px; }
/* Sur grand écran, l'image de l'étape est montrée par la planche. */
.cp-step__img { display: none; }
.cp-step__img figcaption { display: none; } /* lue par scan.js pour la ligne de lieu sous la planche */

.cp-scan__actions { margin-top: 40px !important; }
.cp-scan__cta .wp-block-button__link { display: inline-flex; align-items: center; gap: 12px; padding: 15px 26px; }
.cp-scan__cta .wp-block-button__link::after {
	content: "";
	width: 16px;
	height: 16px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform .2s;
}
.cp-scan__cta .wp-block-button__link:hover::after { transform: translateX(3px); }
.cp-scan a:focus-visible { outline: 2px solid var(--cp-scan-orange); outline-offset: 3px; }

/* ---------- Éditeur : étapes en liste simple, images visibles ---------- */
.editor-styles-wrapper .cp-scan__grid { grid-template-columns: minmax(0, 1fr); }
.editor-styles-wrapper .cp-scan__stage { position: static; }
.editor-styles-wrapper .cp-step { min-height: 0; }
.editor-styles-wrapper .cp-step__img { display: block; max-width: 420px; margin-bottom: 14px !important; }

/* ---------- Mobile et tablette : chaque étape montre son image ---------- */
@media (max-width: 900px) {
	.cp-scan__grid { grid-template-columns: minmax(0, 1fr); }
	.cp-scan__stage { display: none; }
	.cp-scan.is-ready .cp-step { opacity: 1; }
	.cp-step { min-height: 0; padding-bottom: 44px; }
	.cp-step__img { position: relative; display: block; margin-bottom: 18px !important; aspect-ratio: 1080 / 700; max-width: 100%; overflow: hidden; border-radius: 8px; background: #fff; }
	.cp-step__img img { display: block; width: 100%; height: 100%; object-fit: cover; }
	.cp-step__img::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: var(--cp-scan-orange); box-shadow: 0 0 12px 2px rgba(255, 153, 0, .8); opacity: 0; }
	.cp-scan.is-ready .cp-step:not(.is-seen) .cp-step__img img { clip-path: inset(0 100% 0 0); }
	.cp-step.is-seen .cp-step__img img { animation: cp-scan-reveal var(--cp-scan-sweep) var(--cp-scan-ease) both; }
	.cp-step.is-seen .cp-step__img::after { animation: cp-scan-sweep-m var(--cp-scan-sweep) var(--cp-scan-ease) both; }
	@keyframes cp-scan-sweep-m { 0% { opacity: 1; left: 0; } 90% { opacity: 1; } 100% { opacity: 0; left: 100%; } }
}
@media (prefers-reduced-motion: reduce) {
	.cp-plate__img.is-in,
	.cp-step.is-seen .cp-step__img img { animation: none; clip-path: none; }
	.cp-scan.is-ready .cp-step:not(.is-seen) .cp-step__img img { clip-path: none; }
	.cp-plate__laser,
	.cp-step__img::after { display: none; }
	.cp-step { transition: none; }
}
