/* ============================================================================
   Écran d'analyse du scan de carte grise (resources/js/scan-carte-grise.js)
   La photo reste visible, une ligne de lecture la parcourt, trois étapes
   réelles : préparation, envoi, lecture. Même écran pour les messages
   (photo floue ou sombre avant envoi, envoi en échec).
   ========================================================================== */

.scap {
	--scap-fg: #1a2226;
	--scap-muted: #5f6b70;
	--scap-line: #dde1e4;
	--scap-accent: #8b1538;
	--scap-accent-dark: #6f1029;
	--scap-accent-soft: #f7e8ed;
	--scap-ok: #2e7d52;
	--scap-ok-soft: #e8f5ee;
	--scap-warn: #a14a07;
	--scap-warn-soft: #fef3c7;
	position: fixed;
	inset: 0;
	z-index: 20000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(10, 14, 16, 0.6);
	color: var(--scap-fg);
	font-family: inherit;
}

.scap[hidden] {
	display: none;
}

html.scap-ouvert {
	overflow: hidden;
}

.scap__carte {
	width: 100%;
	max-width: 420px;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	background: #fff;
	border-radius: 18px;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
}

.scap__titre {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	outline: none;
}

.scap__photo {
	position: relative;
	aspect-ratio: 1.55;
	border-radius: 12px;
	overflow: hidden;
	background: linear-gradient(160deg, #e9e3d3, #d9d0b9);
}

.scap__photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.scap__ligne {
	display: none;
	position: absolute;
	left: 0;
	right: 0;
	top: 40%;
	height: 2px;
	background: var(--scap-accent);
	box-shadow: 0 0 14px 4px rgba(139, 21, 56, 0.55);
}

.scap[data-etat="analyse"] .scap__ligne {
	display: block;
}

@media (prefers-reduced-motion: no-preference) {
	.scap[data-etat="analyse"] .scap__ligne {
		animation: scap-balayage 2.2s ease-in-out infinite alternate;
	}
}

@keyframes scap-balayage {
	from { top: 6%; }
	to { top: 92%; }
}

/* ---------- Étapes ---------- */

.scap__analyse,
.scap__message {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.scap[data-etat="analyse"] .scap__message,
.scap[data-etat="message"] .scap__analyse {
	display: none;
}

.scap__etapes {
	list-style: none;
	margin: 0;
	padding: 12px 14px;
	border: 1px solid var(--scap-line);
	border-radius: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.scap__etapes li {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	font-weight: 600;
}

.scap__etapes li i {
	flex: none;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-style: normal;
	font-size: 11px;
	font-weight: 800;
}

.scap__etapes li[data-statut="todo"] {
	color: #9aa3a8;
}

.scap__etapes li[data-statut="todo"] i {
	border: 2px solid var(--scap-line);
}

.scap__etapes li[data-statut="run"] i {
	border: 2px solid var(--scap-accent);
	border-right-color: transparent;
}

@media (prefers-reduced-motion: no-preference) {
	.scap__etapes li[data-statut="run"] i {
		animation: scap-rotation 0.9s linear infinite;
	}
}

@keyframes scap-rotation {
	to { transform: rotate(360deg); }
}

.scap__etapes li[data-statut="done"] i {
	background: var(--scap-ok-soft);
	color: var(--scap-ok);
}

.scap__etapes li[data-statut="done"] i::before {
	content: "✓";
}

.scap__pct {
	font-weight: 700;
	color: var(--scap-muted);
	margin-left: 4px;
}

.scap__note {
	margin: 0;
	font-size: 12.5px;
	color: var(--scap-muted);
	text-align: center;
}

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

.scap__msg-titre {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: var(--scap-warn);
}

.scap__msg-texte {
	margin: 0;
	font-size: 14px;
	line-height: 1.45;
	padding: 10px 12px;
	border-radius: 10px;
	background: var(--scap-warn-soft);
	color: #5b3a07;
}

.scap__actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.scap__btn {
	min-height: 46px;
	padding: 0 16px;
	border-radius: 12px;
	border: 1.5px solid var(--scap-accent);
	background: var(--scap-accent);
	color: #fff;
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
}

.scap__btn:hover {
	background: var(--scap-accent-dark);
	border-color: var(--scap-accent-dark);
}

.scap__btn--ghost {
	background: transparent;
	color: var(--scap-accent);
}

.scap__btn--ghost:hover {
	background: var(--scap-accent-soft);
	border-color: var(--scap-accent);
}

.scap__btn:focus-visible {
	outline: 2px solid var(--scap-accent);
	outline-offset: 2px;
}

.scap__btn[hidden] {
	display: none;
}

/* Téléphone : la carte occupe la largeur, la photo reste en haut. */
@media (max-width: 480px) {
	.scap {
		padding: 12px;
		align-items: flex-end;
		padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
	}

	.scap__carte {
		border-radius: 18px;
		padding: 18px 16px;
	}
}
