/**
 * Magnetiks Consent — styles front.
 * Préfixe .magconsent pour éviter les collisions de thème.
 */

.magconsent,
.magconsent * {
	box-sizing: border-box;
}

.magconsent {
	--mc-accent: var(--magconsent-accent, #e3402c);
	--mc-radius: 14px;
	--mc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-family: var(--mc-font);
	display: none;
}

/* Affichage piloté par le plugin via une classe dédiée — insensible aux
   éventuels resets de thème sur l'attribut [hidden]. !important pour primer
   sur tout CSS de thème agressif. */
.magconsent.magconsent--visible,
.magconsent.magconsent--visible[hidden] {
	display: block !important;
}

.magconsent[hidden] {
	display: none;
}

/* Le conteneur ne couvre tout l'écran QUE lorsque le panneau modal est ouvert.
   En mode bannière, seuls les blocs .magconsent__banner (position:fixed) sont
   présents : aucune couche transparente plein écran ne bloque la page. */
.magconsent.is-panel {
	position: fixed;
	inset: 0;
	z-index: 2147483600;
}

/* Overlay seulement en mode panneau (préférences) */
.magconsent__overlay {
	position: fixed;
	inset: 0;
	background: rgba(8, 9, 10, 0.55);
	backdrop-filter: blur(2px);
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: none;
	display: none;
}

.magconsent.is-panel .magconsent__overlay {
	opacity: 1;
	pointer-events: auto;
	display: block;
}

/* Quand le panneau de préférences est ouvert, la bannière du bas est masquée. */
.magconsent.is-panel .magconsent__banner {
	display: none !important;
}

/* ---------- Conteneurs ---------- */

.magconsent__banner,
.magconsent__panel {
	position: fixed;
	z-index: 2147483647;
	pointer-events: auto;
	background: #111315;
	color: #f4f5f6;
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
	animation: magconsent-rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.magconsent--light .magconsent__banner,
.magconsent--light .magconsent__panel {
	background: #ffffff;
	color: #14181b;
	box-shadow: 0 18px 60px rgba(20, 24, 27, 0.18), 0 2px 8px rgba(20, 24, 27, 0.08);
	border: 1px solid #e8eaec;
}

@keyframes magconsent-rise {
	from { transform: translateY(18px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

/* ---------- Bannière : position bas pleine largeur ---------- */

.magconsent--bottom .magconsent__banner {
	left: 16px;
	right: 16px;
	bottom: 16px;
	border-radius: var(--mc-radius);
	padding: 22px 24px;
	display: grid;
	grid-template-columns: 1fr auto;
	grid-template-areas: "body actions" "credit actions";
	gap: 8px 28px;
	align-items: center;
	max-width: 1180px;
	margin: 0 auto;
}

.magconsent--bottom .magconsent__body { grid-area: body; }
.magconsent--bottom .magconsent__actions { grid-area: actions; }
.magconsent--bottom .magconsent__credit { grid-area: credit; }

/* ---------- Bannière : boîte coin ---------- */

.magconsent--box-left .magconsent__banner,
.magconsent--box-right .magconsent__banner {
	bottom: 16px;
	width: 400px;
	max-width: calc(100vw - 32px);
	border-radius: var(--mc-radius);
	padding: 24px;
}

.magconsent--box-left .magconsent__banner { left: 16px; }
.magconsent--box-right .magconsent__banner { right: 16px; }

.magconsent--box-left .magconsent__actions,
.magconsent--box-right .magconsent__actions {
	margin-top: 18px;
	flex-direction: column;
}

.magconsent--box-left .magconsent__btn,
.magconsent--box-right .magconsent__btn {
	width: 100%;
}

/* ---------- Bannière : centrée (modale) ---------- */

.magconsent--center .magconsent__banner {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 460px;
	max-width: calc(100vw - 32px);
	border-radius: var(--mc-radius);
	padding: 28px;
}

.magconsent--center .magconsent__actions {
	margin-top: 20px;
}

/* ---------- Typo & texte ---------- */

.magconsent__title {
	margin: 0 0 6px;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.3;
}

.magconsent__text {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.6;
	color: inherit;
	opacity: 0.86;
}

.magconsent__link {
	color: var(--mc-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 600;
}

/* ---------- Boutons ---------- */

.magconsent__actions {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
}

.magconsent__btn {
	appearance: none;
	border: 0;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	padding: 11px 18px;
	border-radius: 9px;
	transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
	white-space: nowrap;
}

.magconsent__btn:active { transform: translateY(1px); }

.magconsent__btn--primary {
	/* Couleur dédiée au bouton « Tout accepter » (séparée de l'accent général).
	   Repli sur --mc-accent puis vert « go » par défaut si la variable n'est
	   pas injectée (anciens caches). */
	background: var(--magconsent-accent-accept, #1a7f43);
	color: #fff;
}

.magconsent__btn--primary:hover { filter: brightness(1.07); }

.magconsent__btn--ghost {
	background: transparent;
	color: inherit;
	border: 1px solid rgba(255, 255, 255, 0.22);
}

.magconsent--light .magconsent__btn--ghost {
	border-color: rgba(20, 24, 27, 0.18);
}

.magconsent__btn--ghost:hover {
	border-color: var(--mc-accent);
	color: var(--mc-accent);
}

/* ---------- Crédit marque ---------- */

.magconsent__credit {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 10.5px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	margin-top: 4px;
}

.magconsent__credit span {
	opacity: 0.5;
}

.magconsent__credit .magconsent-brand {
	display: inline-block;
	height: 14px;
	width: auto;
	opacity: 0.92;
}

.magconsent__panel[hidden],
.magconsent__banner[hidden] {
	display: none !important;
}

/* ---------- Panneau de préférences ---------- */

/* Le panneau est borné en haut ET en bas : il ne peut jamais déborder de
   l'écran. Au-delà d'une certaine hauteur de contenu, c'est la zone interne
   qui scrolle, la barre d'actions restant toujours visible. */
.magconsent__panel {
	top: 24px;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	width: 560px;
	max-width: calc(100vw - 32px);
	/* Hauteur pilotée par top/bottom ; on borne aussi pour les très grands écrans. */
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: var(--mc-radius);
	padding: 0;
}

/* Décale le panneau sous la barre d'admin WordPress si présente. */
.admin-bar .magconsent__panel {
	top: 56px;
	max-height: calc(100vh - 80px);
	max-height: calc(100dvh - 80px);
}

@media screen and (max-width: 782px) {
	.admin-bar .magconsent__panel {
		top: 70px;
		max-height: calc(100vh - 94px);
		max-height: calc(100dvh - 94px);
	}
}

/* En-tête fixe en haut. */
.magconsent__panel .magconsent__panel-head,
.magconsent__panel > .magconsent__text {
	flex: 0 0 auto;
	padding-left: 28px;
	padding-right: 28px;
}

.magconsent__panel .magconsent__panel-head {
	padding-top: 26px;
}

/* Zone des catégories : c'est elle qui scrolle. */
.magconsent__panel .magconsent__cats {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	margin: 16px 0 0;
	padding: 0 28px 8px;
}

/* Barre d'actions : toujours visible, ancrée en bas du panneau. */
.magconsent__panel .magconsent__actions {
	flex: 0 0 auto;
	background: #111315;
	margin: 0;
	padding: 16px 28px;
	border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.magconsent--light .magconsent__panel .magconsent__actions {
	background: #ffffff;
	border-top-color: rgba(20, 24, 27, 0.08);
}

.magconsent__panel-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 4px;
}

.magconsent__close {
	background: transparent;
	border: 0;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.6;
	padding: 0 4px;
}

.magconsent__close:hover { opacity: 1; }

.magconsent__cats {
	margin: 16px 0 18px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.magconsent__cat {
	padding: 13px 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.magconsent--light .magconsent__cat {
	border-bottom-color: rgba(20, 24, 27, 0.08);
}

.magconsent__cat:last-child { border-bottom: 0; }

.magconsent__cat-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
}

.magconsent__cat-name {
	font-size: 14px;
	font-weight: 700;
}

.magconsent__cat-desc {
	margin: 7px 0 0;
	font-size: 12.5px;
	line-height: 1.55;
	opacity: 0.72;
}

/* ---------- Switch ---------- */

.magconsent__switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	flex: 0 0 auto;
}

.magconsent__switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.magconsent__slider {
	width: 42px;
	height: 24px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.22);
	position: relative;
	transition: background 0.2s ease;
	flex: 0 0 auto;
}

.magconsent--light .magconsent__slider {
	background: rgba(20, 24, 27, 0.18);
}

.magconsent__slider::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.magconsent__switch input:checked + .magconsent__slider {
	background: var(--mc-accent);
}

.magconsent__switch input:checked + .magconsent__slider::after {
	transform: translateX(18px);
}

.magconsent__switch input:disabled + .magconsent__slider {
	opacity: 0.6;
	cursor: not-allowed;
}

.magconsent__always {
	font-size: 10.5px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.6;
}

/* ---------- Onglet « Gérer le consentement » ---------- */

.magconsent-tab {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 2147483500;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border: 0;
	border-radius: 999px;
	background: #111315;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	font-family: var(--mc-font, sans-serif);
	cursor: pointer;
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.32);
	transition: transform 0.15s ease;
}

.magconsent-tab--light {
	background: #fff;
	color: #14181b;
	border: 1px solid #e8eaec;
}

.magconsent-tab:hover { transform: translateY(-2px); }

.magconsent-tab__icon { font-size: 14px; }

.magconsent-tab[hidden] { display: none; }

/* ---------- Lien Do Not Sell (CPRA) ---------- */

.magconsent-dns {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 2147483500;
	background: transparent;
	border: 1px solid currentColor;
	color: #6b7177;
	font-size: 11px;
	font-family: var(--mc-font, sans-serif);
	padding: 8px 12px;
	border-radius: 8px;
	cursor: pointer;
	opacity: 0.8;
}

.magconsent-dns:hover { opacity: 1; }

/* ---------- Boutons inline (shortcodes) ---------- */

.magconsent-inline-btn {
	appearance: none;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 8px;
	padding: 8px 14px;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	color: inherit;
}

.magconsent-inline-btn:hover {
	color: var(--magconsent-accent, #e3402c);
	border-color: var(--magconsent-accent, #e3402c);
}

/* ---------- Tableau de politique ---------- */

.magconsent-policy-table table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13.5px;
}

.magconsent-policy-table th,
.magconsent-policy-table td {
	border: 1px solid rgba(0, 0, 0, 0.12);
	padding: 9px 11px;
	text-align: left;
	vertical-align: top;
}

.magconsent-policy-table th {
	background: rgba(0, 0, 0, 0.04);
	font-weight: 700;
}

.magconsent-policy-table code {
	font-size: 12px;
	word-break: break-word;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
	.magconsent--bottom .magconsent__banner {
		grid-template-columns: 1fr;
		grid-template-areas: "body" "actions" "credit";
		padding: 18px;
	}

	.magconsent--bottom .magconsent__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.magconsent--bottom .magconsent__btn { width: 100%; }

	.magconsent__panel { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
	.magconsent__banner,
	.magconsent__panel { animation: none; }
}
