/**
 * Shop by Category — homepage gradient cards (fixed 255×255).
 * Desktop (lg+): 5-column centered rows (max 10). Mobile/tablet: 3 rows × 2 (max 6).
 */

.shop-by-category {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	padding-block-end: 48px;
}

.shop-by-category .home-page-section__inner {
	width: 100%;
	max-width: min(100%, 1200px);
	margin-inline: auto;
	padding-block-end: 0;
}

.shop-by-category__categories {
	--category-card-width: 255px;
	--category-card-height: 255px;
	--category-card-gap: 24px;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: min(100%, 1371px);
	margin-inline: auto;
	padding: 48px var(--onoff-gutter) 0;
	box-sizing: border-box;
}

.category-grid-rows {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--category-card-gap);
	width: 100%;
}

/* Large screens — 5-column layout (1120px+) */
.category-grid-rows--desktop {
	display: flex;
}

.category-grid-rows--desktop .category-grid__row--count-5 {
	max-width: calc(5 * var(--category-card-width) + 4 * var(--category-card-gap));
}

.category-grid-rows--mobile {
	display: none;
}

.category-grid__row {
	display: flex;
	flex-wrap: nowrap;
	justify-content: center;
	align-items: flex-start;
	gap: var(--category-card-gap);
	width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

.category-card {
	flex: 0 0 var(--category-card-width);
	width: var(--category-card-width);
	height: var(--category-card-height);
	margin: 0;
	padding: 0;
}

.category-card__link {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: var(--category-card-width);
	height: var(--category-card-height);
	padding: 0;
	border-radius: 24px;
	text-decoration: none;
	text-align: start;
	overflow: hidden;
	isolation: isolate;
	transition: box-shadow 0.22s ease;
	--category-card-overlay-height: 50%;
}

.category-card__bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	background-image: var(--category-card-bg-image);
	background-repeat: no-repeat;
	background-position: center center;
	background-size: cover;
	border-radius: inherit;
	transform-origin: center center;
	transition: transform 0.22s ease;
	pointer-events: none;
}

.category-card__link::after {
	content: '';
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	z-index: 1;
	height: var(--category-card-overlay-height);
	background: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0) 100%);
	border: none;
	border-radius: 0 0 24px 24px;
	pointer-events: none;
}

.category-card__link--has-image {
	background: transparent;
}

.category-card__link:hover .category-card__bg,
.category-card__link:focus-visible .category-card__bg {
	transform: scale(1.1);
}

.category-card__link:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(242, 251, 4, 0.45);
}

.category-card--palette-0 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); }
.category-card--palette-1 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%); }
.category-card--palette-2 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #fff7ed 0%, #ffedd4 100%); }
.category-card--palette-3 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #ecfeff 0%, #cefafe 100%); }
.category-card--palette-4 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%); }
.category-card--palette-5 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); }
.category-card--palette-6 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #fefce8 0%, #fef9c2 100%); }
.category-card--palette-7 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #fef2f2 0%, #ffe2e2 100%); }
.category-card--palette-8 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); }
.category-card--palette-9 .category-card__link:not(.category-card__link--has-image) { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); }

.category-card__figure {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	z-index: 2;
	box-sizing: border-box;
	width: 100%;
	height: var(--category-card-overlay-height);
	margin: 0;
	padding: 0;
}

.category-card__name {
	position: absolute;
	inset-inline: 32px;
	top: 50%;
	width: auto;
	margin: 0;
	padding: 0;
	font-family: var(--onoff-font-family);
	font-weight: 700;
	color: #fff;
	text-align: start;
}

.category-card__name--short {
	font-size: 20px;
	line-height: 28px;
}

.category-card__name--long {
	font-size: 14px;
	line-height: 20px;
}

.category-grid-embed__actions {
	display: flex;
	justify-content: center;
	width: 100%;
	margin-block-start: 24px;
}

.shop-by-category__show-all {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 224.51px;
	width: min(100%, 224.51px);
	height: 59.2px;
	padding: 0 28px;
	border: 1.6px solid #262415;
	border-radius: 999999px;
	background: #fff;
	color: #262415;
	font-family: var(--onoff-font-family, 'Cairo', sans-serif);
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.shop-by-category__show-all:hover,
.shop-by-category__show-all:focus-visible {
	background: #262415;
	color: #fff;
	outline: none;
	box-shadow: 0 0 0 3px rgba(242, 251, 4, 0.45);
}

/* Tablet / mobile — 3 rows × 2 cards (max 6) */
@media (max-width: 1119px) {
	.category-grid-rows--desktop {
		display: none;
	}

	.category-grid-rows--mobile {
		display: flex;
	}

	.category-grid-rows--mobile .category-grid__row {
		flex-wrap: wrap;
		justify-content: center;
		max-width: calc(2 * var(--category-card-width) + var(--category-card-gap));
	}
}

@media (max-width: 533px) {
	.category-grid__row {
		flex-wrap: wrap;
		justify-content: center;
	}
}

@media (max-width: 599px) {
	.shop-by-category__show-all {
		min-width: 0;
		width: min(100%, 224.51px);
		height: auto;
		min-height: 52px;
		padding: 12px 24px;
	}
}

/* Mobile — smaller cards; homepage category grid fixed at 2 columns */
@media (max-width: 899px) {
	.shop-by-category__categories,
	.categories-page__grid {
		--category-card-width: 171px;
		--category-card-height: 171px;
		--category-card-gap: 16px;
	}

	.category-card__link {
		border-radius: 16px;
	}

	.category-card__link::after {
		border-radius: 0 0 16px 16px;
	}

	.category-card__name {
		inset-inline: 21px;
	}

	.category-card__name--short {
		font-size: 13px;
		line-height: 19px;
	}

	.category-card__name--long {
		font-size: 10px;
		line-height: 14px;
	}

	body.home .shop-by-category .category-grid-rows--mobile {
		display: grid;
		grid-template-columns: repeat(2, var(--category-card-width));
		justify-content: center;
		gap: var(--category-card-gap);
		width: 100%;
	}

	body.home .shop-by-category .category-grid-rows--mobile .category-grid__row {
		display: contents;
	}
}

/* Categories page — same cards as homepage */
.categories-page__grid {
	--category-card-width: 255px;
	--category-card-height: 255px;
	--category-card-gap: 24px;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: min(100%, 1088px);
	margin-inline: auto;
	padding: 48px var(--onoff-gutter) 2.5rem;
	box-sizing: border-box;
}
