/* ==========================================================================
   Homepage — "Multicerame en chiffres" (template-parts/home-original.php).
   Each figure is drawn as a tile on a black wall, and the drawing IS the figure:
     90 %  → a gold glaze rises to 90 % of the tile (satisfaction),
     500   → a network of points lights up from the centre (points of sale),
     10    → ten tiles appear one by one (formats),
     70 %  → 70 % of the tile's edge is traced (rectification).
   Then the two distinctions as gold seals. Original figures, texts and icons only.
   Motion: transform / opacity / stroke only, started once in view; none with reduced motion.
   ========================================================================== */

.kf {
	--kf-gold: #c99a3f;
	--kf-gold-soft: #e3c27a;
	--kf-line: rgba(255, 255, 255, 0.14);
	--kf-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--kf-head: "Red Hat Display", var(--o-heading, sans-serif);
	position: relative;
	overflow: hidden;
	padding: clamp(56px, 7vw, 104px) max(20px, (100% - 1240px) / 2);
	color: #fff;
	background: #000;
	isolation: isolate;
}
/* Faint joints of a tiled wall. */
.kf::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -2;
	background:
		linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 120px 120px,
		linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 120px 120px;
	mask-image: radial-gradient(80% 70% at 50% 40%, #000, transparent 80%);
}

/* Floating tiles set on their point, drifting slowly behind the content. */
.kf__float {
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
}
.kf__float i {
	position: absolute;
	width: 46px;
	height: 46px;
	border: 1px solid rgba(227, 194, 122, 0.22);
	transform: rotate(45deg);
	animation: kf-drift 18s ease-in-out infinite alternate;
	will-change: transform;
}
.kf__float i:nth-child(1) {
	top: 12%;
	left: 4%;
}
.kf__float i:nth-child(2) {
	top: 64%;
	left: 46%;
	width: 26px;
	height: 26px;
	animation-duration: 22s;
	animation-delay: -6s;
}
.kf__float i:nth-child(3) {
	top: 18%;
	right: 6%;
	width: 70px;
	height: 70px;
	border-color: rgba(227, 194, 122, 0.12);
	animation-duration: 26s;
	animation-delay: -12s;
}
.kf__float i:nth-child(4) {
	bottom: 8%;
	left: 22%;
	width: 18px;
	height: 18px;
	background: rgba(227, 194, 122, 0.12);
	animation-duration: 16s;
	animation-delay: -3s;
}
@keyframes kf-drift {
	from {
		transform: translate3d(0, 0, 0) rotate(45deg);
	}
	to {
		transform: translate3d(24px, -30px, 0) rotate(90deg);
	}
}

/* ------------------------------------------------------------ The four tiles */
.kf__tiles {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: clamp(14px, 1.8vw, 24px);
	margin: 0;
	padding: 0;
	list-style: none;
	perspective: 900px;
}
.kf-tile {
	--mx: 50%;
	--my: 30%;
	--rx: 0deg;
	--ry: 0deg;
	position: relative;
	display: flex;
	flex-direction: column;
	padding: clamp(18px, 2vw, 26px);
	overflow: hidden;
	border: 1px solid var(--kf-line);
	border-radius: 4px;
	background:
		radial-gradient(260px circle at var(--mx) var(--my), rgba(227, 194, 122, 0.12), transparent 60%),
		linear-gradient(160deg, #111 0%, #070707 100%);
	transform: rotateX(var(--rx)) rotateY(var(--ry));
	transition: transform 0.6s var(--kf-ease), border-color 0.4s;
	transform-style: preserve-3d;
}
.kf-tile:hover {
	border-color: rgba(227, 194, 122, 0.5);
}
.kf-tile__art {
	width: min(100%, 210px);
	aspect-ratio: 1;
	margin: 0 auto clamp(14px, 2vw, 22px);
}
.kf-tile__art svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}
.kf-frame {
	fill: none;
	stroke: rgba(255, 255, 255, 0.22);
	stroke-width: 0.8;
}
.kf-tile__figure {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	margin: auto 0 0;
	font-family: var(--kf-head);
	font-size: clamp(2.6rem, 1.6rem + 2.6vw, 4.2rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.03em;
	color: #fff;
	font-variant-numeric: tabular-nums;
}
.kf-tile__plus,
.kf-tile__unit {
	margin-top: 0.12em;
	font-size: 0.42em;
	font-weight: 600;
	color: var(--kf-gold-soft);
}
.kf-tile__plus {
	margin-right: 0.08em;
}
.kf-tile__unit {
	margin-left: 0.06em;
}
.kf-tile__label {
	position: relative;
	margin: 14px 0 0;
	padding-top: 14px;
	font-size: 15px;
	line-height: 1.4;
	text-align: center;
	color: rgba(255, 255, 255, 0.75);
}
.kf-tile__label::before {
	content: "";
	position: absolute;
	top: 0;
	left: 50%;
	width: 36px;
	height: 1.5px;
	background: var(--kf-gold);
	transform: translateX(-50%) scaleX(var(--kf-rule, 1));
	transition: transform 0.9s 0.5s var(--kf-ease), width 0.4s var(--kf-ease);
}
.kf-tile:hover .kf-tile__label::before {
	width: 64px;
}

/* 90 % — the glaze rises to the figure; its surface ripples. */
.kf-glaze {
	transform: translateY(calc(94px - 88px * var(--v) * var(--kf-p, 1)));
	transition: transform 2s var(--kf-ease);
}
.kf-wave {
	fill: var(--kf-gold);
	opacity: 0.88;
	animation: kf-wave 6s linear infinite;
}
@keyframes kf-wave {
	to {
		transform: translateX(100px);
	}
}

/* 500 — the network of points lights up from the centre. */
.kf-dots-faint {
	opacity: 0.16;
}
#kf-dots circle {
	fill: var(--kf-gold-soft);
}
.kf-net-mask {
	transform-box: fill-box;
	transform-origin: center;
	transform: scale(var(--kf-p, 1));
	transition: transform 2.2s var(--kf-ease);
}

/* 10 — ten tiles appear one after the other. */
.kf-cell {
	fill: rgba(227, 194, 122, 0.85);
	stroke: none;
	opacity: var(--kf-p, 1);
	transform-box: fill-box;
	transform-origin: center bottom;
	transform: scaleY(var(--kf-p, 1));
	transition: opacity 0.5s var(--kf-ease), transform 0.7s var(--kf-ease), fill 0.3s;
	transition-delay: calc(var(--n) * 110ms);
}
.kf-tile--formats:hover .kf-cell:nth-child(odd) {
	fill: #fff;
}

/* 70 % — 70 % of the tile's edge is traced (rectified). */
.kf-edge-base {
	fill: none;
	stroke: rgba(255, 255, 255, 0.16);
	stroke-width: 1.4;
	stroke-dasharray: 2 2;
}
.kf-edge {
	fill: rgba(227, 194, 122, 0.06);
	stroke: var(--kf-gold-soft);
	stroke-width: 2.2;
	stroke-linecap: square;
	stroke-dasharray: 100;
	stroke-dashoffset: calc(100 - 70 * var(--kf-p, 1));
	transition: stroke-dashoffset 2s var(--kf-ease);
}

/* ------------------------------------------------------------ Distinctions */
.kf__awards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(14px, 1.8vw, 24px);
	margin: clamp(28px, 4vw, 48px) 0 0;
	padding: 0;
	list-style: none;
}
.kf-award {
	display: flex;
	align-items: center;
	gap: clamp(16px, 2vw, 28px);
	padding: clamp(18px, 2vw, 26px) clamp(20px, 2.4vw, 32px);
	border-top: 1px solid var(--kf-line);
	transition: transform 0.6s var(--kf-ease);
}
.kf-award p {
	margin: 0;
	font-family: var(--kf-head);
	font-size: clamp(1.1rem, 0.9rem + 0.6vw, 1.45rem);
	font-weight: 600;
	line-height: 1.3;
	color: #fff;
	text-wrap: balance;
}
.kf-award__seal {
	position: relative;
	display: grid;
	flex: none;
	place-items: center;
	width: 86px;
	height: 86px;
}
.kf-award__seal img {
	position: relative;
	width: 42px;
	height: 42px;
	object-fit: contain;
	transition: transform 0.6s var(--kf-ease);
}
.kf-award__ring {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	fill: rgba(227, 194, 122, 0.06);
	stroke: var(--kf-gold);
	stroke-width: 1.2;
	stroke-dasharray: 2 4.2;
	animation: kf-spin 30s linear infinite;
}
@keyframes kf-spin {
	to {
		transform: rotate(360deg);
	}
}
.kf-award:hover .kf-award__seal img {
	transform: scale(1.12) rotate(-6deg);
}
.kf-award:hover {
	transform: translateX(6px);
}

/* ------------------------------------------------------------ Entrance (assets/js/kf.js) */
.kf-js .kf-tile {
	--kf-p: 0;
	--kf-rule: 0;
	opacity: 0;
	translate: 0 26px;
	transition: transform 0.6s var(--kf-ease), border-color 0.4s, opacity 0.9s var(--kf-ease), translate 1s var(--kf-ease);
	transition-delay: 0s, 0s, calc(var(--i) * 110ms), calc(var(--i) * 110ms);
}
.kf-js .kf-tile.is-in {
	--kf-p: 1;
	--kf-rule: 1;
	opacity: 1;
	translate: none;
}
.kf-js .kf-award {
	opacity: 0;
	translate: 0 20px;
	transition: transform 0.6s var(--kf-ease), opacity 0.9s var(--kf-ease), translate 1s var(--kf-ease);
}
.kf-js .kf-award + .kf-award {
	transition-delay: 0s, 0.12s, 0.12s;
}
.kf-js .kf-award.is-in {
	opacity: 1;
	translate: none;
}

/* ------------------------------------------------------------ Responsive */
@media (max-width: 1023px) {
	.kf__tiles {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
@media (max-width: 599px) {
	.kf {
		padding-inline: 16px;
	}
	/* Phones: each tile becomes a row — drawing on the left, figure and label on the right. */
	.kf__tiles {
		grid-template-columns: minmax(0, 1fr);
		gap: 12px;
	}
	.kf-tile {
		display: grid;
		grid-template-columns: 96px minmax(0, 1fr);
		grid-template-rows: auto auto;
		align-items: center;
		column-gap: 18px;
		padding: 16px;
	}
	.kf-tile__art {
		grid-row: 1 / span 2;
		width: 96px;
		margin: 0;
	}
	.kf-tile__figure {
		justify-content: flex-start;
		margin: 0;
		font-size: 2.6rem;
	}
	.kf-tile__label {
		margin-top: 8px;
		padding-top: 10px;
		font-size: 14px;
		text-align: left;
	}
	.kf-tile__label::before {
		left: 0;
		transform: scaleX(var(--kf-rule, 1));
		transform-origin: left;
	}
	.kf__awards {
		grid-template-columns: minmax(0, 1fr);
	}
	.kf-award {
		padding-inline: 4px;
	}
	.kf-award__seal {
		width: 70px;
		height: 70px;
	}
	.kf__float i:nth-child(3) {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.kf *,
	.kf *::before {
		animation: none !important;
		transition: none !important;
	}
	.kf-js .kf-tile,
	.kf-js .kf-award {
		--kf-p: 1;
		--kf-rule: 1;
		opacity: 1;
		translate: none;
	}
}
