/**
 * Phase 9 visual effects. Each one is switched on by a body class from
 * Settings › Promotiques Site › Design & Motion (includes/design.php). Colours come from the
 * design tokens (Elementor Global Colors). All motion stops for prefers-reduced-motion.
 */

/* --- 1. Page heroes: 3D perspective grid (body.pq-hero-3d) ------------------
   The flat crosshair grid of interior heroes and title bands is tilted into a floor that
   recedes towards the horizon and slides slowly towards the viewer. The slide is a transform
   (GPU-composited, no repaint): one grid cell per loop, so the loop is seamless. The layer
   extends one cell below the band (clipped) so no gap shows. */
.pq-hero-3d :is(.pq-page-hero, .pq-project-hero).pq-grid-bg::after,
.pq-hero-3d .entry-hero .entry-hero-container-inner::after {
	inset: auto -45% calc(-1 * var(--pq-grid-size, 64px) - 2px);
	height: 160%;
	background-position: 0 0;
	transform: perspective(640px) rotateX(64deg);
	transform-origin: 50% 100%;
	-webkit-mask-image: linear-gradient(to top, #000 0%, rgb(0 0 0 / 0.6) 35%, transparent 80%);
	mask-image: linear-gradient(to top, #000 0%, rgb(0 0 0 / 0.6) 35%, transparent 80%);
	animation: pq-grid-drift 6s linear infinite;
	will-change: transform;
}

@keyframes pq-grid-drift {
	from {
		transform: perspective(640px) rotateX(64deg) translateY(calc(-1 * var(--pq-grid-size, 64px)));
	}

	to {
		transform: perspective(640px) rotateX(64deg) translateY(0);
	}
}

/* --- 2. Page heroes: animated brand mark (body.pq-hero-mark, desktop) -------
   The reticle from the logo, tilted in 3D and turning slowly. Decorative only (a pseudo-element,
   invisible to assistive technology). */
@media (min-width: 1025px) {
	.pq-hero-mark .pq-page-hero > .e-con-inner::after,
	.pq-hero-mark .pq-project-hero > .pq-wrap::after,
	.pq-hero-mark .entry-hero .entry-hero-container-inner::before {
		content: "";
		position: absolute;
		z-index: -1;
		top: 50%;
		right: max(2%, calc((100% - var(--pq-container, 1240px)) / 2));
		width: min(30vw, 400px);
		aspect-ratio: 1;
		background:
			radial-gradient(circle, var(--pq-red) 0 9%, transparent 9.5%),
			linear-gradient(160deg, rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.35));
		-webkit-mask: var(--pq-mark) center / contain no-repeat;
		mask: var(--pq-mark) center / contain no-repeat;
		opacity: var(--pq-mark-opacity, 0.22);
		pointer-events: none;
		transform: translateY(-50%) perspective(1000px) rotateX(58deg) rotateY(-16deg);
		animation: pq-mark-spin var(--pq-mark-speed, 60s) linear infinite;
	}

	/* Title bands are shorter: smaller mark. */
	.pq-hero-mark .entry-hero .entry-hero-container-inner::before {
		width: min(22vw, 280px);
	}
}

body {
	--pq-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23000'%3E%3Ccircle cx='100' cy='100' r='94' stroke-width='2.5' stroke-dasharray='3 9'/%3E%3Ccircle cx='100' cy='100' r='70' stroke-width='15'/%3E%3Ccircle cx='100' cy='100' r='40' stroke-width='2.5'/%3E%3Cpath d='M100 2v50M100 148v50M2 100h50M148 100h50' stroke-width='5'/%3E%3C/g%3E%3Cpath d='M100 72l12 30-12-6-12 6z'/%3E%3C/svg%3E");
}

@keyframes pq-mark-spin {
	from {
		transform: translateY(-50%) perspective(1000px) rotateX(58deg) rotateY(-16deg) rotateZ(0deg);
	}

	to {
		transform: translateY(-50%) perspective(1000px) rotateX(58deg) rotateY(-16deg) rotateZ(360deg);
	}
}

/* --- 3. Card spotlight (body.pq-spotlight; position set by a tiny script) ---- */
.pq-spotlight :is(.pq-card--hover, .pq-project-card, .pq-post-card, .loop-entry.type-post) {
	background-image: radial-gradient(380px circle at var(--pq-mx, 50%) var(--pq-my, -400px), color-mix(in srgb, var(--pq-red) 9%, transparent), transparent 65%);
}

.pq-spotlight .pq-dark .pq-card--hover {
	background-image: radial-gradient(380px circle at var(--pq-mx, 50%) var(--pq-my, -400px), color-mix(in srgb, var(--pq-red) 16%, transparent), transparent 65%);
}

/* --- 4. Reading progress on articles (body.pq-reading-progress) ------------- */
@supports (animation-timeline: scroll()) {
	.pq-reading-progress.single-post::before {
		content: "";
		position: fixed;
		z-index: 10000;
		top: 0;
		left: 0;
		width: 100%;
		height: 3px;
		background: var(--pq-red);
		transform: scaleX(0);
		transform-origin: 0 50%;
		pointer-events: none;
		animation: pq-progress linear both;
		animation-timeline: scroll(root block);
	}

	.admin-bar.pq-reading-progress.single-post::before {
		top: var(--wp-admin--admin-bar--height, 32px);
	}
}

@keyframes pq-progress {
	to {
		transform: scaleX(1);
	}
}

/* --- 5. Images: one corner style for content images (--pq-img-radius) ------- */
.elementor-widget-image img,
.single-content :is(.wp-block-image, figure) img,
.post-thumbnail img,
.pq-project-body img,
.pq-project-image__img {
	border-radius: var(--pq-img-radius, 18px);
}

/* --- 6. Pressed state for buttons and pill links (always on, tiny) ---------- */
.elementor-button:active,
.button:active,
.pq-project-filter a:active,
.pq-project-pages a:active {
	transform: translateY(0) scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
	.pq-hero-3d :is(.pq-page-hero, .pq-project-hero).pq-grid-bg::after,
	.pq-hero-3d .entry-hero .entry-hero-container-inner::after,
	.pq-hero-mark .pq-page-hero > .e-con-inner::after,
	.pq-hero-mark .pq-project-hero > .pq-wrap::after,
	.pq-hero-mark .entry-hero .entry-hero-container-inner::before {
		animation: none;
	}
}
