/*
 * Categories-first homepage.
 *
 * Only the pieces this arrangement introduces: the category band that opens the
 * page and the card design inside it. Everything below the categories is the
 * shared section stack and keeps theme.css styling untouched.
 *
 * Colours are the theme's own tokens throughout -- this is a change of
 * placement, not of palette.
 */

.ken-cat-section {
	padding: 3rem 0 2.5rem;
	background: linear-gradient(180deg, #fdfcfa 0%, var(--brand-gold-light) 100%);
}

.ken-cat-intro {
	max-width: 46rem;
	margin: -0.75rem auto 2rem;
	text-align: center;
	color: var(--brand-text-muted);
}

/* ---------------------------------------------------------------------------
 * Grid
 * Two up on a phone so the cards stay large enough to read, four up from the
 * desktop breakpoint -- the eight categories then land as the two rows of four
 * the design shows.
 * ------------------------------------------------------------------------- */

.ken-cat-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ken-cat-cell {
	display: flex;
	min-width: 0;
}

/*
 * Phones get the same eight categories as a two-at-a-time swipeable track.
 * Expressed on the grid itself -- auto-flow column with a fixed auto-column
 * width -- rather than by switching to flex, so the desktop rules above stay
 * the single description of this component.
 */
@media (max-width: 767.98px) {
	.ken-cat-grid {
		grid-auto-flow: column;
		grid-template-columns: none;
		grid-auto-columns: calc(50% - 0.5rem);
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		margin-right: -0.75rem;
		margin-left: -0.75rem;
		padding: 0 0.75rem 0.25rem;
	}

	.ken-cat-grid::-webkit-scrollbar {
		display: none;
	}

	.ken-cat-cell {
		scroll-snap-align: start;
	}
}

@media (min-width: 768px) {
	.ken-cat-grid {
		gap: 1.25rem;
	}
}

@media (min-width: 992px) {
	.ken-cat-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* ---------------------------------------------------------------------------
 * Card
 * ------------------------------------------------------------------------- */

.ken-cat-card {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	border: 1px solid rgba(182, 137, 62, 0.28);
	border-radius: 12px;
	background: #ffffff;
	color: inherit;
	text-decoration: none;
	transition: var(--transition-smooth);
}

.ken-cat-card:hover,
.ken-cat-card:focus-visible {
	border-color: var(--brand-gold);
	box-shadow: 0 12px 28px rgba(18, 18, 18, 0.08);
	transform: translateY(-3px);
	color: inherit;
}

/* The first category the administrator ordered carries the design's badge. */
.ken-cat-card.is-lead {
	border-color: rgba(182, 137, 62, 0.55);
}

.ken-cat-card__media {
	position: relative;
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: linear-gradient(160deg, #f7f2e8 0%, #ffffff 100%);
}

/* aspect-ratio is not universal; the padding fallback only applies where it
 * is unsupported, so the two never both take effect. */
@supports not (aspect-ratio: 4 / 3) {
	.ken-cat-card__media {
		height: 0;
		padding-bottom: 75%;
	}
}

.ken-cat-card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: var(--transition-smooth);
}

/* Categories with no thumbnail reuse the numbered .research-cardN artwork,
 * which theme.css already declares as a background image. */
.ken-cat-card__image--fallback {
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
}

.ken-cat-card:hover .ken-cat-card__image {
	transform: scale(1.04);
}

.ken-cat-card__badge {
	position: absolute;
	top: 0.625rem;
	right: 0.625rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--brand-gold);
	color: #ffffff;
	font-size: 0.8125rem;
	box-shadow: 0 2px 8px rgba(18, 18, 18, 0.18);
}

.ken-cat-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: center;
	gap: 0.25rem;
	padding: 0.875rem 0.75rem 1rem;
	text-align: center;
	border-top: 1px solid var(--brand-border);
}

.ken-cat-card__name {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--brand-dark);
}

.ken-cat-card__sub {
	font-size: 0.8125rem;
	line-height: 1.35;
	color: var(--brand-text-muted);
}

.ken-cat-card__rule {
	width: 34px;
	height: 1px;
	margin: 0.5rem 0 0.375rem;
	background: var(--brand-gold);
	opacity: 0.55;
}

/* Pushed to the bottom so the CTA lines up across cards whose names and
 * subtitles wrap to different heights. */
.ken-cat-card__cta {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-top: auto;
	padding-top: 0.25rem;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--brand-gold);
}

.ken-cat-card__cta i {
	transition: var(--transition-smooth);
}

.ken-cat-card:hover .ken-cat-card__cta i {
	transform: translateX(3px);
}

@media (min-width: 992px) {
	.ken-cat-card__body {
		padding: 1rem 1rem 1.125rem;
	}

	.ken-cat-card__name {
		font-size: 1.0625rem;
	}
}

/* ---------------------------------------------------------------------------
 * "Shop all peptides"
 * Ruled either side, as the design has it.
 * ------------------------------------------------------------------------- */

.ken-cat-all {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin: 2rem 0 0;
}

.ken-cat-all::before,
.ken-cat-all::after {
	content: "";
	width: 3rem;
	height: 1px;
	background: var(--brand-gold);
	opacity: 0.4;
}

.ken-cat-all a {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.9375rem;
	font-weight: 600;
	color: var(--brand-gold);
	text-decoration: none;
}

.ken-cat-all a:hover {
	color: var(--brand-gold-hover);
}

@media (prefers-reduced-motion: reduce) {
	.ken-cat-card,
	.ken-cat-card__image,
	.ken-cat-card__cta i {
		transition: none;
	}

	.ken-cat-card:hover {
		transform: none;
	}

	.ken-cat-card:hover .ken-cat-card__image {
		transform: none;
	}
}
