/*
 * Components shared by the front page and the inner pages: the work grid and the closing call to action.
 * Logical properties only, so one file serves RTL and LTR.
 */

/* Soft-form tokens (tile corner radius, edge slope, section cut radius) */
:root {
	--ayh-tr: 0.875rem; /* tile corner radius */
	--ayh-tsk: 0.4245; /* edge slope: tan(23deg), 0 gives a plain rounded rectangle */
	--ayh-sr: 1.5rem; /* section cut corner radius */
}

.ayh-cta .ayh-lead {
	color: inherit;
}

.ayh-cta .wp-block-button__link {
	background-color: var(--wp--preset--color--brass-light);
	color: var(--wp--preset--color--ink);
}

/* ==========================================================================
 * Work: six projects as slanted-mask tiles with the title over the image.
 * Hidden while no portfolio item is published.
 * ========================================================================== */

.ayh-work {
	--ayh-skew: -23deg;
	--ayh-dx: 2.25rem;
	--ayh-dir: 1;
	padding-block: clamp(3rem, 7vw, 6rem) clamp(4rem, 9vw, 8rem);
}

.ayh-work:dir(rtl) {
	--ayh-dir: -1;
}

.ayh-work:not(:has(.wp-block-post)) {
	display: none;
}

.ayh-work__inner {
	display: grid;
	gap: 2.5rem;
}

.ayh-work__head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1rem 2rem;
}

.ayh-work__intro > * {
	margin-block: 0;
}

.ayh-work__intro h2 {
	position: relative;
	padding-block-start: 1.5rem;
	font-size: var(--wp--preset--font-size--xx-large);
	line-height: 1.5;
}

.ayh-work__intro h2::before {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0.5rem;
	inline-size: 3rem;
	block-size: 2px;
	background: var(--wp--preset--color--brass);
	transform: skewX(var(--ayh-skew-el));
}

.ayh-work__intro .ayh-lead {
	margin-block-start: 0.5rem;
}

.ayh-work__all {
	margin: 0;
	font-weight: 700;
}

.ayh-work__all a::after {
	content: "\2190";
	margin-inline-start: 0.5rem;
}

.ayh-work__all a:dir(ltr)::after {
	content: "\2192";
}

.ayh-work__list {
	display: grid;
	gap: 1.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: ayh-work;
}

.ayh-work__list > .wp-block-post {
	counter-increment: ayh-work;
	position: relative;
	isolation: isolate;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	margin: 0;
	background: var(--wp--preset--color--ink);
}

.ayh-work__list > .wp-block-post > * {
	margin: 0;
}

/* The image fills the tile */
.ayh-work .ayh-work__image {
	position: absolute;
	inset: 0;
	z-index: -2;
	margin: 0;
}

.ayh-work .ayh-work__image img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	aspect-ratio: auto;
	object-fit: cover;
	transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Ink fade so the title always reads */
.ayh-work__list > .wp-block-post::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(to top, color-mix(in srgb, var(--wp--preset--color--ink) 92%, transparent) 0%, color-mix(in srgb, var(--wp--preset--color--ink) 55%, transparent) 38%, transparent 70%);
	transition: opacity 0.4s ease;
}

/* Slanted brass wipe on hover */
.ayh-work__list > .wp-block-post::after {
	content: "";
	position: absolute;
	inset: -10% -30%;
	z-index: -1;
	background: color-mix(in srgb, var(--wp--preset--color--brass) 78%, transparent);
	mix-blend-mode: multiply;
	transform: translateX(calc(var(--ayh-dir) * -120%)) skewX(var(--ayh-skew-el));
	transition: transform 0.6s cubic-bezier(0.65, 0, 0.35, 1);
	pointer-events: none;
}

.ayh-work__list > .wp-block-post:hover::after,
.ayh-work__list > .wp-block-post:focus-within::after {
	transform: translateX(0) skewX(var(--ayh-skew-el));
}

.ayh-work__list > .wp-block-post:hover .ayh-work__image img,
.ayh-work__list > .wp-block-post:focus-within .ayh-work__image img {
	transform: scale(1.06);
}

/* Title bar: outlined number, slanted tick, title */
.ayh-work .ayh-work__title {
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	padding: 1.25rem calc(var(--ayh-d) + 0.5rem) 1.5rem calc(var(--ayh-d) * 0.4 + 0.5rem);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.6;
	color: var(--wp--preset--color--ivory);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	max-block-size: 7.5em;
}

.ayh-work .ayh-work__title::before {
	content: "۰" counter(ayh-work, persian);
	display: block;
	margin-block-end: 0.25rem;
	font-family: var(--wp--preset--font-family--peyda);
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0;
	color: var(--wp--preset--color--brass-light);
}

.ayh-work .ayh-work__title a,
.ayh-work .ayh-work__title a:hover,
.ayh-work .ayh-work__title a:focus-visible {
	color: inherit;
	text-decoration: none;
}

/* The whole tile is the click target */
.ayh-work .ayh-work__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.ayh-work .ayh-work__title a:focus-visible {
	outline: none;
}

html[data-input="keyboard"] .ayh-work__list > .wp-block-post:has(a:focus-visible) {
	outline: 3px solid var(--wp--preset--color--brass);
	outline-offset: -6px;
}

/* The stepped rhythm: wide, narrow / narrow, wide, with the second tile of each pair dropped.
 * --ayh-d (the lean) is 0.105 x the tile's height, as a share of its width, so every tile leans the same. */
@media (min-width: 40rem) {
	.ayh-work__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 1.75rem;
	}

	.ayh-work__list > .wp-block-post:nth-child(1) {
		grid-column: 1 / -1;
		aspect-ratio: 16 / 8;
		--ayh-d: 5.3%;
	}

	.ayh-work .ayh-work__list > .wp-block-post:nth-child(1) .ayh-work__title {
		font-size: var(--wp--preset--font-size--large);
	}
}

@media (min-width: 64rem) {
	.ayh-work__list {
		grid-template-columns: repeat(12, minmax(0, 1fr));
		gap: 1.75rem;
		align-items: start;
	}

	.ayh-work__list > .wp-block-post:nth-child(1) {
		grid-column: 1 / span 7;
		aspect-ratio: 7 / 5;
		--ayh-d: 7.5%;
	}

	.ayh-work__list > .wp-block-post:nth-child(2) {
		grid-column: 8 / span 5;
		margin-block-start: 5rem;
		aspect-ratio: 1 / 1;
		--ayh-d: 10.5%;
	}

	.ayh-work__list > .wp-block-post:nth-child(3) {
		grid-column: 1 / span 5;
		aspect-ratio: 1 / 1;
		--ayh-d: 10.5%;
		margin-block-start: -1rem;
	}

	.ayh-work__list > .wp-block-post:nth-child(4) {
		grid-column: 6 / span 7;
		aspect-ratio: 7 / 5;
		--ayh-d: 7.5%;
		margin-block-start: 4rem;
	}

	.ayh-work__list > .wp-block-post:nth-child(5) {
		grid-column: 1 / span 6;
		aspect-ratio: 6 / 4.5;
		margin-block-start: -1rem;
	}

	.ayh-work__list > .wp-block-post:nth-child(6) {
		grid-column: 7 / span 6;
		aspect-ratio: 6 / 4.5;
		margin-block-start: 3.5rem;
	}
}
@media (prefers-reduced-motion: reduce) {
	.ayh-work .ayh-work__image img,
	.ayh-work__list > .wp-block-post::after {
		transition: none;
	}
}

/* ==========================================================================
 * CTA: dark closing set piece. The logo mark returns, large and cropped.
 * ========================================================================== */

.ayh-cta {
	--ayh-skew: -23deg;
	--ayh-cut: 4.5rem;
	--ayh-cut-dx: calc(var(--ayh-cut) * 0.4245);
	position: relative;
	isolation: isolate;
	overflow: clip;
	margin-inline: -1.25rem;
	padding: calc(var(--ayh-cut) + 4rem) 1.25rem 6rem;
	/* One long step at the top edge */
	clip-path: polygon(0 var(--ayh-cut), 45% var(--ayh-cut), calc(45% + var(--ayh-cut-dx)) 0, 100% 0, 100% 100%, 0 100%);
}

.ayh-cta__glow {
	position: absolute;
	z-index: -2;
	inset-inline-end: -10%;
	inset-block-start: 5%;
	inline-size: min(60rem, 110vw);
	aspect-ratio: 1;
	background: radial-gradient(circle, color-mix(in srgb, var(--wp--preset--color--brass-light) 24%, transparent) 0%, transparent 62%);
	pointer-events: none;
}

.ayh-cta__mark {
	position: absolute;
	z-index: -1;
	inset-inline-end: -6%;
	inset-block-end: -18%;
	block-size: min(120%, 58rem);
	inline-size: auto;
	aspect-ratio: 1;
	pointer-events: none;
}

.ayh-cta__bar--ink {
	fill: var(--wp--preset--color--ivory);
	fill-opacity: 0.07;
}

.ayh-cta__bar--brass {
	fill: var(--wp--preset--color--brass);
	fill-opacity: 0.55;
}

.ayh-cta__inner {
	display: grid;
	gap: 1.5rem;
	justify-items: start;
}

.ayh-cta__inner > * {
	margin-block: 0;
}

.ayh-cta__title {
	position: relative;
	padding-block-start: 1.75rem;
	max-inline-size: 20ch;
	line-height: 1.25;
}

.ayh-cta__title::before {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0.5rem;
	inline-size: 4rem;
	block-size: 2px;
	background: var(--wp--preset--color--brass-light);
	transform: skewX(var(--ayh-skew-el));
}

.ayh-cta .ayh-cta__lead {
	max-inline-size: 30rem;
	color: color-mix(in srgb, var(--wp--preset--color--ivory) 82%, transparent);
}

.ayh-cta .ayh-btn-slant {
	--ayh-cta-bg: var(--wp--preset--color--brass-light);
	--ayh-cta-fg: var(--wp--preset--color--ink);
	--ayh-cta-bg-hover: var(--wp--preset--color--ivory);
	margin-block-start: 1rem;
}

.ayh-cta .ayh-btn-slant .wp-block-button__link {
	min-block-size: 3.5rem;
	padding-inline: 2.5rem;
	font-size: var(--wp--preset--font-size--medium);
	background: none;
	color: var(--ayh-cta-fg);
}

@media (min-width: 64rem) {
	.ayh-cta {
		--ayh-cut: 6rem;
		padding-block-end: 8rem;
	}
}

@media (max-width: 47.9375rem) {
	.ayh-cta {
		--ayh-cut: 3rem;
	}

	.ayh-cta__mark {
		opacity: 0.6;
	}
}

/* Soft corners */
.ayh-work__intro h2::before,
.ayh-cta__title::before {
	border-radius: 999px;
}

/* Full-tile hover wipe: a gentle corner radius, not a pill (it is a big rectangle, not a bar).
 * .ayh-service::before needs none of its own: it is wider than its parent and clipped by the
 * parent's own rounded overflow:hidden (see .ayh-service above). */
.ayh-work__list > .wp-block-post::after {
	border-radius: 0.875rem;
}

@supports (clip-path: shape(from 0 0, line to 10px 0, close)) {
	.ayh-cta {
		--ayh-rk: calc(var(--ayh-sr) * 0.4245);
		clip-path: shape(
			from 0 var(--ayh-cut),
			line to calc(45% - var(--ayh-sr)) var(--ayh-cut),
			curve to calc(45% + var(--ayh-rk)) calc(var(--ayh-cut) - var(--ayh-sr)) with 45% var(--ayh-cut),
			line to calc(45% + var(--ayh-cut-dx) - var(--ayh-rk)) var(--ayh-sr),
			curve to calc(45% + var(--ayh-cut-dx) + var(--ayh-sr)) 0 with calc(45% + var(--ayh-cut-dx)) 0,
			line to 100% 0,
			line to 100% 100%,
			line to 0 100%,
			close
		);
	}
}

/* Section links ("all work", "all articles", "see products"): no underline */
.ayh-more a,
.ayh-more a:hover,
.ayh-more a:focus-visible {
	text-decoration: none;
}

/* True-angle work tiles (see home.css for the other tiles that share this recipe) */
.ayh-work__list > .wp-block-post {
	--ayh-d: 6.6%;
	--ayh-tsk: 0.105; /* a quarter of the logo lean: subtle */
	--ayh-rk: calc(var(--ayh-tr) * var(--ayh-tsk));
	clip-path: polygon(var(--ayh-d) 0, 100% 0, calc(100% - var(--ayh-d)) 100%, 0 100%);
	clip-path: shape(
		from calc(var(--ayh-d) + var(--ayh-tr)) 0,
		line to calc(100% - var(--ayh-tr)) 0,
		curve to calc(100% - var(--ayh-rk)) var(--ayh-tr) with 100% 0,
		line to calc(100% - var(--ayh-d) + var(--ayh-rk)) calc(100% - var(--ayh-tr)),
		curve to calc(100% - var(--ayh-d) - var(--ayh-tr)) 100% with calc(100% - var(--ayh-d)) 100%,
		line to var(--ayh-tr) 100%,
		curve to var(--ayh-rk) calc(100% - var(--ayh-tr)) with 0 100%,
		line to calc(var(--ayh-d) - var(--ayh-rk)) var(--ayh-tr),
		curve to calc(var(--ayh-d) + var(--ayh-tr)) 0 with var(--ayh-d) 0,
		close
	);
}

.ayh-work__list > .wp-block-post {
	--ayh-d: 8%; /* 4:3 */
	--ayh-tr: 1rem;
}
