/*
 * NetRhyme WP Theme: effects. Loaded after base.css, on every page and in the editor.
 *
 * 1. Section styles "tinted abstract", "dark abstract", "tinted gradient", "dark gradient"
 *    (chosen per section, like "tinted" and "dark"; base.css gives them the same colours).
 * 2. Motion: sections come into view with a short movement (Appearance, Design options).
 * 3. Glint: a thin line of light travels along card borders (Appearance, Design options).
 *
 * Which drawing the abstract styles show, on which side and how large, is set under
 * Appearance, Design options and arrives as one inline rule (inc/design.php), for example
 *   :root { --wprk-motif: var(--wprk-motif-pyramids); --wprk-motif-glow: 1; --wprk-motif-size: 40rem; }
 * Visitors who ask their device for reduced motion get the drawings and nothing that moves.
 */

@property --wprk-glint-turn {
	inherits: false;
	initial-value: 0deg;
	syntax: "<angle>";
}

/* ---------- 1a. Abstract sections ---------- */

/* The drawings (made by _kit/extras/motifs/gen.py). Only their shape is used, as a mask. */
:root {
	--wprk-motif-pyramids: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 380' width='640' height='380'%3E%3Cg fill='%23000' stroke='%23000' stroke-linejoin='round'%3E%3Cpolygon points='414.0,103.2 196.4,313.6 478.0,512.0 478.0,147.2' fill-opacity='0.42'/%3E%3Cpolygon points='478.0,147.2 478.0,512.0 748.4,325.6 540.4,105.6' fill-opacity='0.16'/%3E%3Cpolygon points='478.0,40.0 414.0,103.2 478.0,147.2' fill-opacity='0.62'/%3E%3Cpolygon points='478.0,40.0 478.0,147.2 540.4,105.6' fill-opacity='0.3'/%3E%3Cpath d='M478.0,40.0 L196.4,313.6 L478.0,512.0 L748.4,325.6 Z M478.0,40.0 L478.0,512.0 M414.0,103.2 L478.0,147.2 L540.4,105.6' fill='none' stroke-width='1.3' stroke-opacity='0.85'/%3E%3Cpath d='M40.0 380 L214 150.0 L388.0 380' fill='none' stroke-width='1.5' stroke-opacity='0.95'/%3E%3Cpath d='M66.1 380 L214 184.5 L361.9 380' fill='none' stroke-width='1.1' stroke-opacity='0.83'/%3E%3Cpath d='M92.2 380 L214 219.0 L335.8 380' fill='none' stroke-width='1.1' stroke-opacity='0.70'/%3E%3Cpath d='M118.3 380 L214 253.5 L309.7 380' fill='none' stroke-width='1.1' stroke-opacity='0.58'/%3E%3Cpath d='M144.4 380 L214 288.0 L283.6 380' fill='none' stroke-width='1.1' stroke-opacity='0.46'/%3E%3Cpath d='M170.5 380 L214 322.5 L257.5 380' fill='none' stroke-width='1.1' stroke-opacity='0.33'/%3E%3C/g%3E%3C/svg%3E");
	--wprk-motif-arcs: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 380' width='640' height='380'%3E%3Cg fill='%23000' stroke='%23000' stroke-linejoin='round'%3E%3Ccircle cx='640' cy='380' r='70' fill='none' stroke-width='1.5' stroke-opacity='1.00'/%3E%3Ccircle cx='640' cy='380' r='128' fill='none' stroke-width='1.5' stroke-opacity='0.92'/%3E%3Ccircle cx='640' cy='380' r='186' fill='none' stroke-width='1.5' stroke-opacity='0.84'/%3E%3Ccircle cx='640' cy='380' r='244' fill='none' stroke-width='1.5' stroke-opacity='0.76'/%3E%3Ccircle cx='640' cy='380' r='302' fill='none' stroke-width='1.5' stroke-opacity='0.68'/%3E%3Ccircle cx='640' cy='380' r='360' fill='none' stroke-width='1.5' stroke-opacity='0.60'/%3E%3Ccircle cx='640' cy='380' r='418' fill='none' stroke-width='1.5' stroke-opacity='0.52'/%3E%3Ccircle cx='640' cy='380' r='476' fill='none' stroke-width='1.5' stroke-opacity='0.44'/%3E%3Ccircle cx='640' cy='380' r='534' fill='none' stroke-width='1.5' stroke-opacity='0.36'/%3E%3Ccircle cx='640' cy='380' r='592' fill='none' stroke-width='1.5' stroke-opacity='0.28'/%3E%3C/g%3E%3C/svg%3E");
	--wprk-motif-dots: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 380' width='640' height='380'%3E%3Cg fill='%23000' stroke='%23000' stroke-linejoin='round'%3E%3Cdefs%3E%3Cpattern id='p' width='18' height='18' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3C/pattern%3E%3CradialGradient id='g' cx='1' cy='1' r='1'%3E%3Cstop offset='0' stop-color='%23fff'/%3E%3Cstop offset='0.55' stop-color='%23fff' stop-opacity='0.55'/%3E%3Cstop offset='1' stop-color='%23fff' stop-opacity='0'/%3E%3C/radialGradient%3E%3Cmask id='m'%3E%3Crect width='640' height='380' fill='url(%23g)'/%3E%3C/mask%3E%3C/defs%3E%3Crect width='640' height='380' fill='url(%23p)' mask='url(%23m)'/%3E%3C/g%3E%3C/svg%3E");
}

.is-style-wprk-tinted-abstract {
	--wprk-motif-glow-color: color-mix(in srgb, var(--wp--preset--color--base) calc(var(--wprk-motif-glow, 0) * 88%), transparent);
}

.is-style-wprk-dark-abstract {
	--wprk-motif-glow-color: color-mix(in srgb, var(--wp--preset--color--primary) calc(var(--wprk-motif-glow, 0) * 24%), transparent);
}

/* A soft patch of light in the corner of the drawing: white on tinted, warm on dark. */
:is(.is-style-wprk-tinted-abstract, .is-style-wprk-dark-abstract):not(.wp-block-cover) {
	background-image: radial-gradient(ellipse 62rem 30rem at var(--wprk-motif-x, 100%) 100%, var(--wprk-motif-glow-color), transparent 72%);
	isolation: isolate;
	position: relative;
}

/* The drawing, in the heading colour of the section, behind the content. */
:is(.is-style-wprk-tinted-abstract, .is-style-wprk-dark-abstract):not(.wp-block-cover)::before {
	background-color: var(--wprk-heading);
	content: "";
	inset: 0;
	-webkit-mask-image: var(--wprk-motif, linear-gradient(transparent, transparent));
	mask-image: var(--wprk-motif, linear-gradient(transparent, transparent));
	-webkit-mask-position: right bottom;
	mask-position: right bottom;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-size: min(var(--wprk-motif-size, 40rem), 92%) auto;
	mask-size: min(var(--wprk-motif-size, 40rem), 92%) auto;
	opacity: 0.2;
	pointer-events: none;
	position: absolute;
	transform: scaleX(var(--wprk-motif-flip, 1));
	z-index: -1;
}

/* One section on the other side: Advanced, Additional CSS class "wprk-motif-left" or "wprk-motif-right". */
.wprk-motif-left {
	--wprk-motif-flip: -1;
	--wprk-motif-x: 0%;
}

.wprk-motif-right {
	--wprk-motif-flip: 1;
	--wprk-motif-x: 100%;
}

/* ---------- 1b. Gradient sections ---------- */

/* White into tinted, with a breath of the brand colour, drifting slowly. */
.is-style-wprk-tinted-gradient {
	background-image: linear-gradient(
		120deg,
		var(--wp--preset--color--base) 0%,
		var(--wp--preset--color--light) 26%,
		color-mix(in srgb, var(--wp--preset--color--primary) 7%, var(--wp--preset--color--light)) 50%,
		var(--wp--preset--color--light) 74%,
		var(--wp--preset--color--base) 100%
	);
	background-size: 250% 250%;
}

/* The dark colour with a deep glow of the brand colour moving through it. */
.is-style-wprk-dark-gradient {
	background-image: linear-gradient(
		120deg,
		var(--wp--preset--color--dark) 0%,
		color-mix(in srgb, var(--wp--preset--color--primary) 34%, var(--wp--preset--color--dark)) 32%,
		var(--wp--preset--color--dark) 58%,
		color-mix(in srgb, var(--wp--preset--color--base) 9%, var(--wp--preset--color--dark)) 80%,
		var(--wp--preset--color--dark) 100%
	);
	background-size: 250% 250%;
}

@keyframes wprk-gradient-drift {
	from {
		background-position: 0% 50%;
	}

	to {
		background-position: 100% 50%;
	}
}

@media (prefers-reduced-motion: no-preference) {
	:is(.is-style-wprk-tinted-gradient, .is-style-wprk-dark-gradient) {
		animation: wprk-gradient-drift 14s ease-in-out infinite alternate;
	}
}

/* ---------- 2. Motion ---------- */

@keyframes wprk-rise {
	from {
		opacity: 0;
		translate: 0 1.25rem;
	}

	to {
		opacity: 1;
		translate: 0 0;
	}
}

@media (prefers-reduced-motion: no-preference) {
	/*
	 * The first section arrives with the page. Pure CSS: nothing waits for a
	 * script, so nothing flickers. Its parts follow each other closely.
	 */
	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section:first-child:not(.wp-block-cover) > *,
	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section.wp-block-cover:first-child > .wp-block-cover__inner-container > * > *,
	body.wprk-motion .wprk-main > .wprk-titlebar .wprk-titlebar__inner > * {
		animation: wprk-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
	}

	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section:first-child:not(.wp-block-cover) > :nth-child(2),
	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section.wp-block-cover:first-child > .wp-block-cover__inner-container > * > :nth-child(2),
	body.wprk-motion .wprk-main > .wprk-titlebar .wprk-titlebar__inner > :nth-child(2) {
		animation-delay: 0.09s;
	}

	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section:first-child:not(.wp-block-cover) > :nth-child(3),
	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section.wp-block-cover:first-child > .wp-block-cover__inner-container > * > :nth-child(3),
	body.wprk-motion .wprk-main > .wprk-titlebar .wprk-titlebar__inner > :nth-child(3) {
		animation-delay: 0.18s;
	}

	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section:first-child:not(.wp-block-cover) > :nth-child(n + 4),
	body.wprk-motion .wprk-main .wp-block-post-content > .wprk-section.wp-block-cover:first-child > .wp-block-cover__inner-container > * > :nth-child(n + 4) {
		animation-delay: 0.27s;
	}

	/*
	 * Everything further down waits below the fold and rises as it is scrolled
	 * into view. effects.js gives the two classes and takes them away again.
	 */
	.wprk-reveal {
		opacity: 0;
		translate: 0 1.5rem;
	}

	.wprk-reveal.is-in {
		opacity: 1;
		transition: opacity 0.7s ease var(--wprk-reveal-delay, 0ms), translate 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) var(--wprk-reveal-delay, 0ms);
		translate: 0 0;
	}
}

@media print {
	.wprk-reveal {
		opacity: 1 !important;
		translate: none !important;
	}
}

/* ---------- 3. Glint ---------- */

@keyframes wprk-glint-turn {
	to {
		--wprk-glint-turn: 360deg;
	}
}

/* One pass around the border: fades in, goes round once, fades out. */
@keyframes wprk-glint-pass {
	0% {
		--wprk-glint-turn: 0deg;
		opacity: 0;
	}

	12%,
	86% {
		opacity: 1;
	}

	100% {
		--wprk-glint-turn: 360deg;
		opacity: 0;
	}
}

@keyframes wprk-glint-slide {
	from {
		background-position: -14rem 0;
	}

	to {
		background-position: calc(100% + 14rem) 0;
	}
}

@media (prefers-reduced-motion: no-preference) {
	body.wprk-glint .wprk-card {
		position: relative;
	}

	/*
	 * A ring exactly on the border of a card, one pixel wide, transparent except
	 * for a short line of light. It goes round once when the card comes into view
	 * (effects.js adds is-lit) and keeps going while the card is hovered.
	 */
	body.wprk-glint .wprk-card::after {
		background: conic-gradient(from var(--wprk-glint-turn), transparent 0 86%, color-mix(in srgb, var(--wprk-link) 45%, transparent) 95%, var(--wprk-link) 99%, transparent 100%);
		border-radius: inherit;
		content: "";
		inset: -1px;
		-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
		-webkit-mask-composite: xor;
		mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
		opacity: 0;
		padding: 1px;
		pointer-events: none;
		position: absolute;
		transition: opacity 0.3s ease;
	}

	body.wprk-glint .wprk-card.is-lit::after {
		animation: wprk-glint-pass 2.1s linear var(--wprk-glint-delay, 0ms) 1 both;
	}

	body.wprk-glint .wprk-card:is(:hover, :focus-within)::after {
		animation: wprk-glint-turn 2.8s linear infinite;
		opacity: 1;
	}

	/* A light that runs along the line above the last row of the footer. */
	body.wprk-glint .wprk-footer__bottom {
		position: relative;
	}

	body.wprk-glint .wprk-footer__bottom::before {
		animation: wprk-glint-slide 9s linear infinite;
		background: linear-gradient(90deg, transparent, var(--wprk-link), transparent) no-repeat;
		background-size: 14rem 100%;
		content: "";
		height: 1px;
		inset-inline: 0;
		opacity: 0.7;
		pointer-events: none;
		position: absolute;
		top: -1px;
	}

	/* A sheen crosses a button when the pointer comes over it. */
	body.wprk-glint .wp-block-button:not(.is-style-wprk-text) > .wp-block-button__link {
		overflow: hidden;
		position: relative;
	}

	body.wprk-glint .wp-block-button:not(.is-style-wprk-text) > .wp-block-button__link::before {
		background: linear-gradient(105deg, transparent 35%, color-mix(in srgb, currentColor 28%, transparent) 50%, transparent 65%);
		content: "";
		inset: 0;
		pointer-events: none;
		position: absolute;
		translate: -110% 0;
	}

	body.wprk-glint .wp-block-button:not(.is-style-wprk-text) > .wp-block-button__link:hover::before {
		transition: translate 0.7s ease;
		translate: 110% 0;
	}
}
