/*
 * Alexa : bandeau cookies et feuille « Installer l'app » (modules Cookies et PWA du plugin Skyward Ecomm).
 * Chargée après swe-cookies.css et swe-pwa.css (voir alx_enqueue_consent_pwa dans inc/assets.php).
 * Gabarit de la feuille : skyward-ecomm/pwa/install-banner.php.
 */

/* ------------------------------------------------------------------ Cookies : carte */

.swe-ck {
	--alx-ck-gap: 20px;
	--alx-ck-lift: 0px; /* hauteur d'une barre d'achat fixe à éviter (mobile) */
	left: var(--alx-ck-gap);
	right: auto;
	bottom: var(--alx-ck-gap);
	width: min(400px, calc(100vw - 2 * var(--alx-ck-gap)));
	padding: 0;
	font-family: var(--alx-font);
	font-size: var(--alx-fs-s);
	line-height: 1.5;
	color: var(--alx-ink);
}

.swe-ck__inner {
	max-width: none;
	max-height: calc(100vh - 2 * var(--alx-ck-gap));
	margin: 0;
	padding: 22px;
	border: 1px solid var(--alx-line);
	border-radius: var(--alx-radius-l);
	box-shadow: 0 18px 40px -12px rgba(17, 17, 17, 0.22), 0 2px 6px rgba(17, 17, 17, 0.06);
}

.swe-ck__title {
	display: block;
	margin: 0 0 6px;
	font-size: var(--alx-fs-m);
	font-weight: 600;
	line-height: 1.3;
	color: var(--alx-ink);
}

.swe-ck__text,
.swe-ck__msg {
	color: var(--alx-text-soft);
	font-size: var(--alx-fs-s);
}

.swe-ck__msg {
	display: inline;
	overflow: visible;
}

.swe-ck__policy {
	color: var(--alx-ink);
	font-size: var(--alx-fs-s);
	white-space: normal;
}

.swe-ck__policy-long {
	display: inline;
}

.swe-ck__policy-short {
	display: none;
}

/* Refuser et accepter : mêmes dimensions, même poids (CNIL). Personnaliser : lien dessous. */
.swe-ck__actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-top: 16px;
}

button.swe-ck__btn {
	min-width: 0;
	min-height: 44px;
	padding: 0 12px;
	border-color: var(--alx-ink);
	background: var(--alx-ink);
	font-family: var(--alx-font);
	font-size: var(--alx-fs-s);
	font-weight: 600;
}

button.swe-ck__btn:hover,
button.swe-ck__btn:focus {
	border-color: var(--alx-ink);
	background: var(--alx-ink);
}

button.swe-ck__btn--ghost,
button.swe-ck__btn--ghost:hover,
button.swe-ck__btn--ghost:focus {
	grid-column: 1 / -1;
	min-height: 36px;
	padding: 0;
	border-color: transparent;
	background: transparent;
	color: var(--alx-ink);
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 3px;
}

button.swe-ck__btn[data-swe-ck="save"] {
	grid-column: 1 / -1;
}

/* Panneau Personnaliser : lignes aérées, case à droite, à l'intérieur de la carte. */
.swe-ck__prefs {
	margin-top: 14px;
}

.swe-ck__cat {
	padding: 12px 0;
}

.swe-ck__cat:last-child {
	border-bottom: 0;
}

.swe-ck__cat-name {
	font-size: var(--alx-fs-s);
	font-weight: 600;
}

.swe-ck__cat-desc {
	font-size: var(--alx-fs-xs);
	line-height: 1.5;
	color: var(--alx-text-soft);
}

.swe-ck__cat-head input {
	accent-color: var(--alx-ink);
}

.swe-ck button:focus-visible,
.swe-ck a:focus-visible,
.swe-ck input:focus-visible {
	outline: 2px solid var(--alx-ink);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ Cookies : feuille mobile */

@media (max-width: 767px) {
	.swe-ck {
		--alx-ck-gap: 10px;
		left: var(--alx-ck-gap);
		right: var(--alx-ck-gap);
		width: auto;
		/* Au-dessus de la barre d'onglets, et d'une barre d'achat fixe si la page en a une. */
		bottom: calc(max(var(--swe-bottom-offset, 0px), env(safe-area-inset-bottom, 0px)) + var(--alx-ck-lift) + var(--alx-ck-gap));
	}

	body:has(.alx-buybar) .swe-ck {
		--alx-ck-lift: 68px;
	}

	body:has(.alx-cart__sbar) .swe-ck {
		--alx-ck-lift: 76px;
	}

	.swe-ck__inner {
		max-height: calc(100dvh - var(--swe-bottom-offset, 0px) - var(--alx-ck-lift) - 3 * var(--alx-ck-gap));
		padding: 16px;
	}

	.swe-ck__title {
		display: block;
		margin-bottom: 4px;
		font-size: var(--alx-fs-m);
	}

	.swe-ck__msg {
		font-size: var(--alx-fs-xs);
		line-height: 1.5;
	}

	.swe-ck__policy {
		font-size: var(--alx-fs-xs);
	}

	.swe-ck__policy-long {
		display: none;
	}

	.swe-ck__policy-short {
		display: inline;
	}

	.swe-ck__actions {
		margin-top: 12px;
	}
}

/* Les cookies passent d'abord : tant que le bandeau est là, la feuille d'installation reste cachée. */
body:has(.swe-ck:not([hidden])) .swe-pwa-banner.alx-install {
	display: none;
}

/* ------------------------------------------------------------------ PWA : feuille d'installation */

.swe-pwa-banner.alx-install {
	inset: 0;
	z-index: 99980;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: stretch;
	gap: 0;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	font-family: var(--alx-font);
	color: var(--alx-ink);
	transition: opacity 0.25s ease;
	transform: none;
}

.swe-pwa-banner.alx-install[hidden] {
	display: none;
}

.alx-install__scrim {
	position: absolute;
	inset: 0;
	background: rgba(17, 17, 17, 0.45);
}

.alx-install__sheet {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 520px;
	margin: 0 auto;
	padding: 10px 20px calc(18px + env(safe-area-inset-bottom, 0px));
	border-radius: 20px 20px 0 0;
	background: var(--alx-white);
	box-shadow: 0 -12px 40px rgba(17, 17, 17, 0.18);
	transform: translateY(32px);
	transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

.alx-install.is-visible .alx-install__sheet {
	transform: none;
}

.alx-install__grab {
	display: block;
	width: 40px;
	height: 4px;
	margin: 0 auto 16px;
	border-radius: var(--alx-radius-pill);
	background: var(--alx-line);
}

.alx-install__head {
	display: flex;
	align-items: center;
	gap: 14px;
}

.alx-install__icon {
	flex: none;
	width: 60px;
	height: 60px;
	border-radius: 14px;
	object-fit: cover;
	box-shadow: 0 0 0 1px var(--alx-line);
}

.alx-install__heading {
	min-width: 0;
}

.alx-install .alx-install__title {
	margin: 0;
	font-family: var(--alx-font);
	font-size: var(--alx-fs-l);
	font-weight: 700;
	line-height: 1.25;
	color: var(--alx-ink);
}

.alx-install__lead {
	margin: 3px 0 0;
	font-size: var(--alx-fs-s);
	line-height: 1.4;
	color: var(--alx-text-soft);
}

.alx-install__perks {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 20px 0 0;
	padding: 16px;
	list-style: none;
	border-radius: var(--alx-radius-m);
	background: var(--alx-soft);
}

.alx-install__perks[hidden],
.alx-install__steps[hidden] {
	display: none;
}

.alx-install__perks li {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	padding: 0;
	font-size: var(--alx-fs-s);
	line-height: 1.4;
	color: var(--alx-ink);
}

.alx-install__perks li::before {
	content: none;
}

.alx-install__perks svg {
	flex: none;
	color: var(--alx-ink);
}

/* iPhone : deux étapes illustrées. */
.alx-install__steps {
	margin-top: 18px;
}

.alx-install__steps-lead {
	margin: 0 0 12px;
	font-size: var(--alx-fs-s);
	line-height: 1.45;
	color: var(--alx-text-soft);
}

.alx-install__steps ol {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.alx-install__steps li {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	padding: 12px;
	border-radius: var(--alx-radius-m);
	background: var(--alx-soft);
}

.alx-install__num {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--alx-ink);
	color: #fff;
	font-size: var(--alx-fs-xs);
	font-weight: 700;
}

.alx-install__step-text {
	flex: 1 1 auto;
	min-width: 0;
	font-size: var(--alx-fs-s);
	line-height: 1.4;
	color: var(--alx-ink);
}

/* Reproduit le bouton de Safari pour qu'on le reconnaisse. */
.alx-install__chip {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 44px;
	height: 44px;
	padding: 0 10px;
	border: 1px solid var(--alx-line);
	border-radius: 10px;
	background: var(--alx-white);
	color: var(--alx-blue);
	font-size: var(--alx-fs-xs);
	font-weight: 600;
	white-space: nowrap;
}

.alx-install__chip--wide {
	color: var(--alx-ink);
}

.alx-install__chip--wide span {
	display: none;
}

.alx-install__actions {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 20px;
}

button.alx-install__btn {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-width: 0;
	min-height: 50px;
	margin: 0;
	padding: 0 20px;
	border: 1px solid transparent;
	border-radius: var(--alx-radius-pill);
	box-shadow: none;
	font-family: var(--alx-font);
	font-size: var(--alx-fs-m);
	font-weight: 600;
	letter-spacing: normal;
	line-height: 1.2;
	text-transform: none;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

button.alx-install__btn[hidden] {
	display: none;
}

button.alx-install__btn--primary,
button.alx-install__btn--primary:hover,
button.alx-install__btn--primary:focus {
	background: var(--alx-ink);
	border-color: var(--alx-ink);
	color: #fff;
}

button.alx-install__btn--ghost,
button.alx-install__btn--ghost:hover,
button.alx-install__btn--ghost:focus {
	min-height: 44px;
	background: transparent;
	color: var(--alx-text-soft);
	font-weight: 500;
}

button.alx-install__btn:active {
	opacity: 0.8;
}

button.alx-install__btn:focus-visible {
	outline: 2px solid var(--alx-ink);
	outline-offset: 2px;
}

@media (max-width: 360px) {
	.alx-install__sheet {
		padding-right: 16px;
		padding-left: 16px;
	}

	.alx-install__icon {
		width: 52px;
		height: 52px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.swe-pwa-banner.alx-install,
	.alx-install__sheet {
		transition: none;
	}
}

/* ------------------------------------------------------------------ Mode installé (display standalone) */

@media (display-mode: standalone) {
	/* La zone sous la barre d'onglets (indicateur d'accueil) prend le blanc de la barre, pas le gris de page. */
	html {
		background: var(--alx-white);
	}

	/* Pas de rebond de défilement qui découvre le fond, pas de sélection de texte accidentelle sur les commandes. */
	body {
		overscroll-behavior-y: none;
		-webkit-tap-highlight-color: transparent;
	}

	.swe-app-tabbar,
	.alx-buybar,
	button,
	a {
		-webkit-touch-callout: none;
	}
}

/* Le choix cookies passe toujours avant l'invite d'installation. */
body:has([data-swe-ck-banner]:not([hidden])) .alx-install {
	display: none !important;
}
