/**
 * Notices WooCommerce dans la charte KidShow : succès, information, erreur, avertissement.
 * Couvre les gabarits du thème (woocommerce/notices/*.php, classe .ks-notice) et les notices
 * produites ailleurs (extensions, blocs WooCommerce) via les classes natives.
 * Sélecteurs « :root body … » : passent devant woocommerce-general (bordure violette, icône
 * en police WooCommerce) et le style générique de catalog.css.
 * Le message de points SUMO de la fiche produit (.summary) garde son style de pastille.
 */
:root {
	--ks-n-ink: #2a2230;
	--ks-n-ink-soft: #5d5463;
	--ks-n-orange: #ff8000;
	--ks-n-orange-dark: #e56f00;
	--ks-n-purple: #a2257c;
	--ks-n-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

	/* Icônes blanches (cercle de couleur dessiné en CSS) */
	--ks-n-icon-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
	--ks-n-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 11v7'/%3E%3Ccircle cx='12' cy='6.5' r='.6' fill='%23fff'/%3E%3C/svg%3E");
	--ks-n-icon-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 5v8.5'/%3E%3Ccircle cx='12' cy='18.5' r='.6' fill='%23fff'/%3E%3C/svg%3E");
	--ks-n-icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232a2230' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 5v8.5'/%3E%3Ccircle cx='12' cy='18.5' r='.6' fill='%232a2230'/%3E%3C/svg%3E");
}

/* Socle commun */
:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *),
:root body .wc-block-components-notice-banner {
	--ks-n-bg: #f6ecfb;
	--ks-n-line: #e8d3f2;
	--ks-n-accent: var(--ks-n-purple);
	--ks-n-icon: var(--ks-n-icon-info);
	position: relative;
	display: block;
	width: auto;
	min-height: 3.5rem;
	margin: 0 0 1.25rem;
	padding: 1rem 1.25rem 1rem 3.875rem;
	overflow-wrap: anywhere;
	list-style: none;
	border: 1.5px solid var(--ks-n-line);
	border-radius: 16px;
	background: var(--ks-n-bg);
	box-shadow: 0 12px 24px -20px rgba(42, 34, 48, 0.45);
	font-size: 0.9375rem;
	line-height: 1.5;
	color: var(--ks-n-ink);
	animation: ks-notice-in 0.35s var(--ks-n-ease);
}

/* Pastille d'icône */
:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *)::before {
	content: "";
	position: absolute;
	top: 0.8125rem;
	left: 1rem;
	width: 2rem;
	height: 2rem;
	margin: 0;
	border-radius: 999px;
	background: var(--ks-n-accent) var(--ks-n-icon) center / 1.125rem no-repeat;
	box-shadow: 0 6px 12px -6px var(--ks-n-accent);
	font-family: inherit;
	color: transparent;
}

:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *)::after {
	content: none;
}

/* États */
:root body .woocommerce-message:not(.summary *),
:root body .wc-block-components-notice-banner.is-success {
	--ks-n-bg: #e8f7f3;
	--ks-n-line: #bfe8df;
	--ks-n-accent: #20b2a6;
	--ks-n-icon: var(--ks-n-icon-success);
}

:root body .woocommerce-error:not(.summary *),
:root body .wc-block-components-notice-banner.is-error {
	--ks-n-bg: #fff0f4;
	--ks-n-line: #ffcfdc;
	--ks-n-accent: #e0336b;
	--ks-n-icon: var(--ks-n-icon-error);
}

:root body .wc-block-components-notice-banner.is-warning,
:root body .woocommerce-info.is-warning:not(.summary *) {
	--ks-n-bg: #fff8dc;
	--ks-n-line: #ffe7a0;
	--ks-n-accent: #ffc93c;
	--ks-n-icon: var(--ks-n-icon-warning);
}

/* Liens dans le texte */
:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) a:not(.button),
:root body .wc-block-components-notice-banner a:not(.button) {
	font-weight: 700;
	color: var(--ks-n-purple);
	text-decoration: underline;
	text-decoration-thickness: 1.5px;
	text-underline-offset: 3px;
}

:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) a:not(.button):hover {
	color: var(--ks-n-orange-dark);
}

:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) strong {
	font-weight: 700;
}

/* Boutons d'action (« Voir le panier », « Annuler »…), y compris hors gabarits du thème */
:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) .button {
	float: right;
	display: inline-flex;
	align-items: center;
	min-height: 2.25rem;
	margin: -0.125rem 0 0 1rem;
	padding: 0.4375rem 1.125rem;
	border: 1.5px solid var(--ks-n-line);
	border-radius: 999px;
	background: #fff;
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.2;
	color: var(--ks-n-ink);
	white-space: nowrap;
	text-decoration: none;
	transition:
		background-color 0.15s,
		border-color 0.15s,
		color 0.15s;
}

:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) .button:hover,
:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) .button:focus-visible {
	border-color: var(--ks-n-orange);
	color: var(--ks-n-orange-dark);
}

/* Succès : l'action (souvent « Voir le panier ») est le bouton principal, en orange. */
:root body .woocommerce-message:not(.summary *) .button {
	border-color: var(--ks-n-orange);
	background: var(--ks-n-orange);
	box-shadow: 0 8px 18px -10px rgba(255, 128, 0, 0.8);
	color: #fff;
}

:root body .woocommerce-message:not(.summary *) .button:hover,
:root body .woocommerce-message:not(.summary *) .button:focus-visible {
	border-color: var(--ks-n-orange-dark);
	background: var(--ks-n-orange-dark);
	color: #fff;
}

/* Gabarits du thème : texte, actions et fermeture alignés */
/* Même spécificité que le socle commun (déclaré après lui) */
:root body .ks-notice:not(ul, .summary *) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.625rem 1rem;
	padding-right: 3.25rem;
}

.ks-notice__text {
	flex: 1 1 16rem;
	min-width: 0;
	padding: 0.3125rem 0;
}

.ks-notice__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

:root body .ks-notice .ks-notice__actions .button {
	float: none;
	margin: 0;
}

.ks-notice__close {
	position: absolute;
	top: 0.875rem;
	right: 0.75rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.875rem;
	height: 1.875rem;
	border-radius: 999px;
	color: var(--ks-n-ink-soft);
	opacity: 0.7;
	transition:
		background-color 0.15s,
		opacity 0.15s;
}

.ks-notice__close svg {
	fill: none;
	stroke: currentColor;
	stroke-width: 2.4;
	stroke-linecap: round;
}

.ks-notice__close:hover,
.ks-notice__close:focus-visible {
	background: rgba(255, 255, 255, 0.85);
	opacity: 1;
}

/* Erreurs : liste (plusieurs champs à corriger) */
:root body ul.woocommerce-error:not(.summary *) li {
	margin: 0;
	padding: 0.3125rem 0;
	list-style: none;
}

:root body ul.woocommerce-error.is-multiple:not(.summary *) li:not(.ks-notice__title) {
	position: relative;
	/* woocommerce-general force « padding-left: 0 !important » sur ces li. */
	padding-left: 1rem !important;
}

:root body ul.woocommerce-error.is-multiple:not(.summary *) li:not(.ks-notice__title)::before {
	content: "";
	position: absolute;
	top: 0.875rem;
	left: 0.125rem;
	width: 0.375rem;
	height: 0.375rem;
	border-radius: 999px;
	background: #e0336b;
}

.ks-notice__title {
	font-weight: 700;
}

/* Bascules de la page de commande (« Vous avez un code promo ? ») : discrètes, sans fermeture */
:root body :is(.woocommerce-form-coupon-toggle, .woocommerce-form-login-toggle) .woocommerce-info {
	border-style: dashed;
	background: #fff;
	box-shadow: none;
}

:is(.woocommerce-form-coupon-toggle, .woocommerce-form-login-toggle) .ks-notice__close {
	display: none;
}

:root body :is(.woocommerce-form-coupon-toggle, .woocommerce-form-login-toggle) .ks-notice:not(ul) {
	padding-right: 1.25rem;
}

/* Espacements : pas de marge en double dans la mise en page en flex du panier et de la commande */
:root body .woocommerce-notices-wrapper > :last-child {
	margin-bottom: 0;
}

:root body .ks-woo-page .woocommerce > :is(.woocommerce-message, .woocommerce-info, .woocommerce-error),
:root body .ks-woo-page .woocommerce > .woocommerce-notices-wrapper {
	margin-bottom: 0;
}

:root body .ks-woo-page .woocommerce > .woocommerce-notices-wrapper:empty {
	display: none;
}

/* Erreurs en ligne sous un champ (code promo du panier, champs de la commande) */
:root body :is(.coupon-error-notice, .checkout-inline-error-message) {
	position: relative;
	margin: 0.5rem 0 0;
	padding-left: 1.5rem;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.4;
	color: #c4204f;
}

:root body :is(.coupon-error-notice, .checkout-inline-error-message)::before {
	content: "";
	position: absolute;
	top: 0.0625rem;
	left: 0;
	width: 1.0625rem;
	height: 1.0625rem;
	border-radius: 999px;
	background: #e0336b var(--ks-n-icon-error) center / 0.75rem no-repeat;
}

:root body :is(.has-error, .woocommerce-invalid) :is(input.input-text, select, textarea),
:root body input#coupon_code[aria-invalid="true"] {
	border-color: #e0336b;
	box-shadow: 0 0 0 3px rgba(224, 51, 107, 0.12);
}

/* Blocs WooCommerce : leur icône SVG reprend la couleur d'accent */
:root body .wc-block-components-notice-banner {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding-left: 1rem;
}

:root body .wc-block-components-notice-banner > svg {
	flex: none;
	padding: 0.25rem;
	border-radius: 999px;
	background: var(--ks-n-accent);
	fill: #fff;
}

/* Bandeau « boutique de démonstration » de WooCommerce */
:root body .woocommerce-store-notice,
:root body p.demo_store {
	background: var(--ks-n-purple);
	font-size: 0.875rem;
	font-weight: 600;
}

/*
 * Toast « Ajouté au panier » (ajout AJAX, assets/js/cart-toast.js).
 * Ordinateur : en bas au centre. Mobile et tablette : en haut au centre, pour ne recouvrir
 * ni la barre de navigation du bas, ni la barre d'achat de la fiche produit, ni le tchat.
 * Au-dessus du tiroir du mini-panier (z-index 60), qui s'ouvre en même temps.
 */
.ks-toast {
	position: fixed;
	bottom: calc(1.5rem + env(safe-area-inset-bottom));
	left: 50%;
	z-index: 80;
	display: flex;
	align-items: center;
	gap: 0.875rem;
	width: min(25rem, calc(100vw - 2rem));
	padding: 0.625rem 3rem 0.625rem 0.625rem;
	overflow: hidden;
	border: 1.5px solid #eee4d8;
	border-radius: 18px;
	background: #fff;
	box-shadow:
		0 24px 48px -20px rgba(42, 34, 48, 0.5),
		0 2px 6px rgba(42, 34, 48, 0.06);
	color: var(--ks-n-ink);
	opacity: 0;
	visibility: hidden;
	transform: translate(-50%, 1rem) scale(0.98);
	transition:
		opacity 0.22s ease,
		transform 0.32s var(--ks-n-ease),
		visibility 0s linear 0.32s;
}

.ks-toast.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translate(-50%, 0) scale(1);
	transition:
		opacity 0.22s ease,
		transform 0.32s var(--ks-n-ease),
		visibility 0s;
}

.ks-toast__media {
	position: relative;
	flex: none;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 12px;
	background: #fff8f0;
}

#page ~ .ks-toast .ks-toast__media img,
.ks-toast__media img {
	width: 100%;
	height: 100%;
	padding: 0.25rem;
	border-radius: 12px;
	object-fit: contain;
	mix-blend-mode: multiply;
}

/* Coche de confirmation sur la vignette */
.ks-toast__media::after {
	content: "";
	position: absolute;
	right: -0.375rem;
	bottom: -0.375rem;
	width: 1.375rem;
	height: 1.375rem;
	border: 2px solid #fff;
	border-radius: 999px;
	background: #20b2a6 var(--ks-n-icon-success) center / 0.75rem no-repeat;
}

.ks-toast__body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ks-toast__title {
	font-size: 0.8125rem;
	font-weight: 700;
	color: #12877d;
}

.ks-toast__name {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.35;
}

.ks-toast__close {
	position: absolute;
	top: 50%;
	right: 0.625rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.875rem;
	height: 1.875rem;
	border-radius: 999px;
	color: var(--ks-n-ink-soft);
	transform: translateY(-50%);
}

.ks-toast__close:hover,
.ks-toast__close:focus-visible {
	background: #fff8f0;
	color: var(--ks-n-ink);
}

/* Barre de temps restant (fermeture automatique après 4 s, en pause au survol) */
.ks-toast__timer {
	position: absolute;
	bottom: 0;
	left: 0;
	height: 3px;
	width: 100%;
	background: #20b2a6;
	transform-origin: left;
	transform: scaleX(0);
}

.ks-toast.is-visible .ks-toast__timer {
	animation: ks-toast-timer var(--ks-toast-duration, 4s) linear forwards;
}

.ks-toast.is-paused .ks-toast__timer {
	animation-play-state: paused;
}

/* Variante erreur (ajout refusé, erreur serveur ou réseau) */
.ks-toast.is-error {
	border-color: #ffcfdc;
}

.ks-toast.is-error .ks-toast__media::after {
	background-color: #e0336b;
	background-image: var(--ks-n-icon-error);
}

.ks-toast.is-error .ks-toast__title {
	color: #c4204f;
}

.ks-toast.is-error .ks-toast__name {
	font-weight: 500;
	-webkit-line-clamp: 3;
}

.ks-toast.is-error .ks-toast__timer {
	background: #e0336b;
}

/* Sans photo (erreur générique) : pastille seule */
.ks-toast__media:empty {
	width: 2.25rem;
	height: 2.25rem;
	background: none;
}

.ks-toast__media:empty::after {
	inset: 0;
	width: auto;
	height: auto;
	border: 0;
	background-size: 1rem;
}

@keyframes ks-toast-timer {
	from {
		transform: scaleX(1);
	}
}

@media (width < 64rem) {
	.ks-toast {
		top: calc(0.75rem + env(safe-area-inset-top));
		bottom: auto;
		transform: translate(-50%, -1rem) scale(0.98);
	}

	/* Barre d'administration WordPress (visible pour les comptes connectés) */
	body.admin-bar .ks-toast {
		top: calc(46px + 0.75rem);
	}
}

@media (width < 64rem) and (width >= 48.875rem) {
	body.admin-bar .ks-toast {
		top: calc(32px + 0.75rem);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ks-toast,
	.ks-toast.is-visible {
		transform: translate(-50%, 0);
		transition: opacity 0.15s;
	}

	.ks-toast.is-visible .ks-toast__timer {
		animation: none;
	}
}

@keyframes ks-notice-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
}

@media (width < 40rem) {
	:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *) {
		padding-left: 3.5rem;
		font-size: 0.875rem;
	}

	:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error):not(.summary *)::before {
		left: 0.875rem;
		width: 1.75rem;
		height: 1.75rem;
	}

	/* Le bouton d'action passe sous le texte, sur toute la largeur. */
	.ks-notice__actions,
	.ks-notice__actions .button {
		flex: 1 1 100%;
		justify-content: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	:root body :is(.woocommerce-message, .woocommerce-info, .woocommerce-error),
	:root body .wc-block-components-notice-banner {
		animation: none;
	}
}
