/*
 * Product category tiles in shop loops (woocommerce/content-product_cat.php): an image tile with the name,
 * product count and an arrow over a dark gradient; the whole tile is one link. Logical properties for RTL.
 */

/* The column shell of product cards (border, shadow, room for the buy button) does not apply. */
.row-items .jude-cat-col,
.row-items [class*="col-"].jude-cat-col {
	padding: 0;
	border: 0;
	border-radius: 18px;
	background: transparent;
	box-shadow: none;
}

.jude-cat-card.item-product {
	position: relative;
	aspect-ratio: var(--jude-cat-ratio, 4 / 5);
	height: auto;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border-radius: var(--jude-cat-radius, 18px);
	background: #1f1f24;
	isolation: isolate;
	box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .45);
	transition: box-shadow .35s ease, transform .35s ease;
}

.jude-cat-card.item-product:hover {
	box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
	transform: translateY(-3px);
}

/* Image (or placeholder) fills the tile. */
.jude-cat-card .jude-cat-thumb {
	position: absolute;
	inset: 0;
	z-index: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
}

/* !important: style.css forces "height: auto !important" and a square ratio on every .item-thumb img. */
.jude-cat-card .jude-cat-thumb img:not(.jude-cat-icon) {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	aspect-ratio: auto;
	margin: 0;
	object-fit: cover;
	border-radius: 0;
	transition: transform .7s cubic-bezier(.2, .7, .2, 1);
}

.jude-cat-card:hover .jude-cat-thumb img:not(.jude-cat-icon) {
	transform: scale(1.07);
}

/* Dark gradient for the text. */
.jude-cat-card .jude-cat-thumb::after {
	content: "";
	position: absolute;
	inset: 0;
	/* --jude-cat-overlay: 0-1, from the Customizer (default .72). */
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, calc(var(--jude-cat-overlay, .72) * .25)) 58%, rgba(0, 0, 0, var(--jude-cat-overlay, .72)) 100%);
	pointer-events: none;
}

/* No category image: colour gradient with the icon or the first letter. */
.jude-cat-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding-block-end: 22%;
	background:
		radial-gradient(circle at 25% 20%, hsla(var(--jude-cat-hue, 250), 85%, 75%, .55), transparent 55%),
		linear-gradient(140deg, hsl(var(--jude-cat-hue, 250), 55%, 52%), hsl(calc(var(--jude-cat-hue, 250) + 35), 60%, 32%));
}

.jude-cat-initial {
	color: rgba(255, 255, 255, .9);
	font-size: clamp(56px, 9vw, 104px);
	font-weight: 800;
	line-height: 1;
	text-shadow: 0 8px 30px rgba(0, 0, 0, .25);
	transition: transform .6s ease;
}

.jude-cat-icon {
	width: 42%;
	max-width: 120px;
	height: auto;
	filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .25));
	transition: transform .6s ease;
}

.jude-cat-card:hover .jude-cat-initial,
.jude-cat-card:hover .jude-cat-icon {
	transform: scale(1.08);
}

/* Name, count and arrow at the bottom; the link stretches over the whole tile. */
.jude-cat-card .item-content {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	margin: 0;
	padding: 18px;
	padding-inline-end: 66px;
	border: 0;
	background: transparent;
	text-align: start;
	color: #fff;
}

.jude-cat-card .jude-cat-title {
	margin: 0;
	padding: 0;
	color: #fff;
	font-size: 19px;
	font-weight: 800;
	line-height: 1.25;
	text-align: start;
	text-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}

.jude-cat-card .jude-cat-link,
.jude-cat-card .jude-cat-link:hover,
.jude-cat-card .jude-cat-link:visited {
	color: #fff;
	text-decoration: none;
}

.jude-cat-card .jude-cat-link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	border-radius: var(--jude-cat-radius, 18px);
}

.jude-cat-card .jude-cat-link:focus-visible {
	outline: none;
}

.jude-cat-card .jude-cat-link:focus-visible::after {
	box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px rgba(0, 0, 0, .35);
}

.jude-cat-count {
	margin-block-start: 5px;
	color: rgba(255, 255, 255, .82);
	font-size: 13px;
	font-weight: 500;
}

.jude-cat-arrow {
	position: absolute;
	inset-inline-end: 16px;
	bottom: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 1px solid rgba(255, 255, 255, .35);
	border-radius: 50%;
	background: rgba(255, 255, 255, .14);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #fff;
	font-size: 14px;
	transition: background-color .3s ease, color .3s ease, transform .3s ease;
}

[dir="rtl"] .jude-cat-arrow i {
	transform: scaleX(-1);
}

.jude-cat-card:hover .jude-cat-arrow {
	background: #fff;
	color: #111;
	transform: translateX(4px);
}

[dir="rtl"] .jude-cat-card:hover .jude-cat-arrow {
	transform: translateX(-4px);
}

/* Phones: two tiles per row. */
@media (max-width: 575px) {
	.jude-cat-card .item-content {
		padding: 12px;
		padding-inline-end: 50px;
	}

	.jude-cat-card .jude-cat-title {
		font-size: 15px;
	}

	.jude-cat-count {
		font-size: 12px;
	}

	.jude-cat-arrow {
		inset-inline-end: 10px;
		bottom: 12px;
		width: 32px;
		height: 32px;
		font-size: 12px;
	}
}

/* Narrow tiles (three per row on phones, the swipe slider): the arrow is decorative (the whole tile is
   a link), so it gives its space to the name. Browsers without container queries keep the rules above. */
.jude-cat-col {
	container-type: inline-size;
}

@container (max-width: 150px) {
	.jude-cat-card .item-content {
		padding: 10px;
	}

	.jude-cat-card .jude-cat-title {
		font-size: 13px;
	}

	.jude-cat-card .jude-cat-arrow {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jude-cat-card.item-product,
	.jude-cat-card .jude-cat-thumb img,
	.jude-cat-initial,
	.jude-cat-icon,
	.jude-cat-arrow {
		transition: none;
	}
}

/* ------------------------------------------------------------------
 * Separate sections (Customizer > WooCommerce > Shop categories): categories section with its title,
 * then a title above the products. Variables come from the section's style attribute.
 * ------------------------------------------------------------------ */

.jude-shop-cats {
	margin-block-end: 40px;
}

.jude-shop-head {
	margin-block: 4px 18px;
	text-align: start;
}

.jude-shop-head--center {
	text-align: center;
}

.jude-shop-head__title {
	position: relative;
	display: inline-block;
	margin: 0;
	padding-block-end: 10px;
	font-size: 24px;
	font-weight: 800;
	line-height: 1.3;
}

.jude-shop-head__title::after {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	bottom: 0;
	width: 48px;
	height: 3px;
	border-radius: 3px;
	background: var(--jude-accent, #453ec1);
}

.jude-shop-head--center .jude-shop-head__title::after {
	inset-inline-start: 50%;
	transform: translateX(-50%);
}

[dir="rtl"] .jude-shop-head--center .jude-shop-head__title::after {
	transform: translateX(50%);
}

.jude-shop-head__subtitle {
	margin: 8px 0 0;
	color: #6b6b75;
	font-size: 15px;
}

.jude-shop-products-head {
	margin-block-start: 0;
}

/* Grid of tiles: columns from the Customizer; the bootstrap column classes of the template are neutralised. */
.jude-cat-grid {
	display: grid;
	grid-template-columns: repeat(var(--jude-cat-cols, 3), minmax(0, 1fr));
	gap: 20px;
}

.jude-cat-grid > .jude-cat-col {
	flex: none;
	width: auto;
	max-width: none;
	margin: 0;
	padding: 0;
}

@media (max-width: 991px) {
	.jude-cat-grid {
		grid-template-columns: repeat(min(var(--jude-cat-cols, 3), 3), minmax(0, 1fr));
		gap: 14px;
	}
}

@media (max-width: 575px) {
	.jude-cat-grid {
		grid-template-columns: repeat(var(--jude-cat-cols-m, 2), minmax(0, 1fr));
		gap: 10px;
	}

	.jude-shop-head__title {
		font-size: 20px;
	}

	/* Swipe sideways instead of a grid. */
	.jude-shop-cats--slider .jude-cat-grid {
		grid-template-columns: none;
		grid-auto-flow: column;
		grid-auto-columns: calc((100% - 10px * (var(--jude-cat-cols-m, 2) - 1)) / var(--jude-cat-cols-m, 2) * .86);
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
		padding-block-end: 4px;
	}

	.jude-shop-cats--slider .jude-cat-grid::-webkit-scrollbar {
		display: none;
	}

	.jude-shop-cats--slider .jude-cat-col {
		scroll-snap-align: start;
	}
}

/* Name in the centre of the tile. */
.jude-shop-cats--text-center .jude-cat-card .item-content {
	align-items: center;
	justify-content: center;
	padding-inline-end: 18px;
	text-align: center;
}

.jude-shop-cats--text-center .jude-cat-card .jude-cat-title {
	text-align: center;
}

.jude-shop-cats--text-center .jude-cat-card .jude-cat-thumb::after {
	background: rgba(0, 0, 0, calc(var(--jude-cat-overlay, .72) * .6));
}

.jude-shop-cats--text-center .jude-cat-arrow,
.jude-shop-cats--no-arrow .jude-cat-arrow {
	display: none;
}

.jude-shop-cats--no-arrow .jude-cat-card .item-content {
	padding-inline-end: 18px;
}

.jude-shop-cats--text-center .jude-cat-placeholder {
	padding-block-end: 0;
}

/* Name in the centre: the placeholder letter / icon becomes a faint watermark behind it. */
.jude-shop-cats--text-center .jude-cat-initial {
	opacity: .22;
	font-size: clamp(90px, 14vw, 160px);
}

.jude-shop-cats--text-center .jude-cat-icon {
	opacity: .3;
}
