/**
 * Floating "Avis Google" badge + reviews modal.
 *
 * Namespaced under .asg so it never collides with the theme or a plugin.
 */

.asg {
	--asg-blue: #006dff;
	--asg-gold: #fcbf02;
	--asg-ink: #111111;
	--asg-line: rgba(17, 17, 17, .1);
	--asg-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.9 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l7.1-1.01z'/%3E%3C/svg%3E") no-repeat center / contain;

	position: fixed;
	bottom: max(20px, env(safe-area-inset-bottom));
	/* position:fixed + z-index crée un contexte d'empilement : c'est CETTE valeur
	   qui décide de tout le bloc (badge + modale) face au reste de la page.
	   Doit rester au-dessus de la bulle du simulateur (.asw-wrap, z-index 9999). */
	z-index: 10000;
	font-family: var(--font, "Inter", system-ui, sans-serif);
	line-height: 1.4;
}

.asg--bottom-left  { left: max(20px, env(safe-area-inset-left)); }
.asg--bottom-right { right: max(20px, env(safe-area-inset-right)); }

/* ---------- Stars ---------- */

.asg-stars {
	display: inline-flex;
	gap: 2px;
	font-size: 15px;
	vertical-align: middle;
}

.asg-stars--sm { font-size: 12px; }

.asg-star {
	position: relative;
	display: inline-block;
	width: 1em;
	height: 1em;
	background: rgba(17, 17, 17, .18);
	-webkit-mask: var(--asg-star);
	mask: var(--asg-star);
}

.asg-star__on {
	position: absolute;
	inset: 0 auto 0 0;
	display: block;
	background: var(--asg-gold);
}

/* ---------- Avatars ---------- */

.asg-avatar {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid #fff;
	background: #e8ecf3;
	flex: none;
}

.asg-avatar--initials {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
}

.asg-avatar--lg {
	width: 40px;
	height: 40px;
	border-width: 0;
	font-size: 16px;
}

.asg-g {
	width: 20px;
	height: 20px;
	flex: none;
}

/* ---------- Floating badge (carte compacte, 2 lignes) ---------- */

.asg-badge {
	display: flex;
	flex-direction: column;
	gap: 9px;
	margin: 0;
	padding: 14px 18px;
	border: 1px solid rgba(17, 17, 17, .07);   /* garde sa forme sur fond blanc */
	border-radius: 24px;
	background: #fff;
	box-shadow: 0 2px 8px rgba(17, 17, 17, .06), 0 12px 32px rgba(17, 17, 17, .16);
	cursor: pointer;
	font: inherit;
	color: var(--asg-ink);
	text-align: left;
	/* L'entree utilise `translate`, distincte de `transform`, pour que le survol
	   ci-dessous reste libre : une animation en fill-forwards sur `transform`
	   l'aurait ecrase et la carte ne se serait jamais soulevee. */
	opacity: 0;
	translate: 0 14px;
	animation: asg-in .45s cubic-bezier(.2, .8, .3, 1) .8s forwards;
	transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

@keyframes asg-in {
	to { opacity: 1; translate: 0 0; }
}

.asg-badge:hover {
	transform: translateY(-3px);
	border-color: rgba(17, 17, 17, .12);
	box-shadow: 0 4px 12px rgba(17, 17, 17, .08), 0 18px 42px rgba(17, 17, 17, .22);
}

.asg-badge:active { transform: translateY(-1px); }

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

.asg-badge__row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.asg-badge .asg-g {
	width: 22px;
	height: 22px;
}

.asg-badge__score {
	font-size: 20px;
	font-weight: 800;
	line-height: 1;
	letter-spacing: -.02em;
}

.asg-badge .asg-stars { font-size: 14px; }

.asg-badge__link {
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	color: var(--asg-blue);
	white-space: nowrap;
}

.asg-badge:hover .asg-badge__link { text-decoration: underline; }

.asg-badge__thumbs {
	display: flex;
	flex: none;
}

.asg-badge__thumbs > * + * { margin-left: -9px; }

/* ---------- Modal ---------- */

.asg-modal {
	position: fixed;
	inset: 0;
	/* Résolu dans le contexte d'empilement de .asg ; sert seulement à passer
	   au-dessus du badge, l'arbitrage global se fait sur .asg. */
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.asg-modal[hidden] { display: none; }

.asg-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 30, 53, .55);
	animation: asg-fade .2s ease forwards;
}

@keyframes asg-fade { from { opacity: 0; } to { opacity: 1; } }

.asg-modal__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(480px, 100%);
	max-height: min(640px, 100%);
	padding: 28px 8px 8px;
	border-radius: 24px;
	background: #fff;
	box-shadow: 0 24px 60px rgba(17, 17, 17, .28);
	animation: asg-pop .25s cubic-bezier(.2, .8, .3, 1) forwards;
}

@keyframes asg-pop {
	from { opacity: 0; transform: translateY(12px) scale(.98); }
	to   { opacity: 1; transform: none; }
}

.asg-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(17, 17, 17, .05);
	color: var(--asg-ink);
	cursor: pointer;
}

.asg-modal__close:hover { background: rgba(17, 17, 17, .1); }
.asg-modal__close svg { width: 16px; height: 16px; }

.asg-modal__head {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 4px 24px 20px;
	border-bottom: 1px solid var(--asg-line);
	text-align: center;
}

.asg-modal__head .asg-g { width: 28px; height: 28px; }

.asg-modal__title {
	margin: 4px 0 0;
	font-size: 18px;
	font-weight: 700;
	color: var(--asg-ink);
}

.asg-modal__rating {
	display: flex;
	align-items: center;
	gap: 8px;
}

.asg-modal__score {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -.02em;
}

.asg-modal__count {
	margin: 0;
	font-size: 13px;
	color: rgba(17, 17, 17, .6);
}

.asg-modal__count a { color: inherit; }

.asg-modal__cta {
	margin-top: 10px;
	padding: 9px 24px;
	border-radius: 999px;
	background: var(--asg-blue);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
}

.asg-modal__cta:hover { background: #005ada; color: #fff; }

/* ---------- Review list ---------- */

.asg-list {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	margin: 0;
	padding: 8px 20px 20px;
	list-style: none;
	-webkit-overflow-scrolling: touch;
}

.asg-review {
	padding: 16px 0;
	border-bottom: 1px solid var(--asg-line);
}

.asg-review:last-child { border-bottom: 0; }

.asg-review__head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 8px;
}

.asg-review__meta {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.asg-review__name {
	font-size: 14px;
	font-weight: 700;
	color: var(--asg-ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.asg-review__date {
	font-size: 12px;
	color: rgba(17, 17, 17, .55);
}

.asg-review__text {
	margin: 8px 0 0;
	font-size: 14px;
	color: var(--asg-ink);
	white-space: pre-line;
}

.asg-review__text.is-clamped {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.asg-more {
	margin-top: 4px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--asg-blue);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.asg-review__role {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	color: rgba(17, 17, 17, .55);
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
	.asg { bottom: max(14px, env(safe-area-inset-bottom)); }
	.asg--bottom-left  { left: max(14px, env(safe-area-inset-left)); }
	.asg--bottom-right { right: max(14px, env(safe-area-inset-right)); }

	.asg-badge { gap: 7px; padding: 11px 15px; border-radius: 20px; }
	.asg-badge__row { gap: 8px; }
	.asg-badge__score { font-size: 18px; }
	.asg-badge .asg-g { width: 19px; height: 19px; }
	.asg-badge .asg-stars { font-size: 12px; }
	.asg-badge__link { font-size: 12px; }

	/* Deux vignettes suffisent : la preuve sociale reste, l'encombrement baisse. */
	.asg-avatar { width: 22px; height: 22px; }
	.asg-badge__thumbs > *:nth-child(n+3) { display: none; }

	.asg-modal { padding: 0; align-items: flex-end; }

	.asg-modal__panel {
		width: 100%;
		max-height: 88vh;
		border-radius: 24px 24px 0 0;
	}

	/* Option Customizer « Masquer le badge sur mobile » (avisg_hide_mobile). */
	.asg--hide-mobile { display: none; }
}

/* ---------- Cohabitation avec le sticky « Simulez votre prix » (.asw-*) ----------

   Les deux composants flottent en bas de page. Le sticky garde le coin bas-droit,
   le badge passe donc toujours à gauche. Le badge, lui, ne perd rien sur mobile :
   c'est le sticky qui se réduit à sa pastille sous 600px (inc/simulateur.php), ce
   qui laisse la place à la carte complète. La classe vient de
   artisites_simu_sticky_body_class() et le JS du sticky la retire quand le
   visiteur ferme le bouton — le badge retrouve alors le côté choisi au Customizer. */

@media (max-width: 900px) {
	body.has-asw-sticky .asg {
		right: auto;
		left: max(20px, env(safe-area-inset-left));
	}
}

@media (prefers-reduced-motion: reduce) {
	.asg-badge,
	.asg-modal__panel,
	.asg-modal__overlay {
		animation: none;
		opacity: 1;
		translate: none;
		transform: none;
		transition: none;
	}
}
