/*
 * Categories Section — homepage [log_categories] card grid.
 * Mirrors .cat-card in website_reference/homepage_6.html: each card is a
 * transparent shell whose ring pseudo-element paints an animated conic gold
 * sweep, revealed on hover behind an inset white face.
 *
 * @package log-core
 */

/* Global .wrap utility for all homepage sections */
.wrap {
	max-width: var(--max-width, 1340px);
	margin: 0 auto;
	padding: 0 40px;
}

/*
 * Section shell — this was missing entirely, so #categories rendered with no
 * vertical padding or background, butted flush against Stats Bar above and
 * Trending below. Matches the reference's
 * "bg-surface-container-low py-section-gap-md border-y" section.
 */
.hp-cats {
	padding: 80px 0;
	background: var(--surface);
	border-top: 1px solid var(--line);
	border-bottom: 1px solid var(--line);
}

@media (max-width: 767px) {
	.hp-cats {
		padding: 60px 0;
	}
}

.head-row {
	display: flex;
	justify-content: space-between;
	/* !important removed — it was beating log-responsive.css's mobile
	   "align-items: flex-start" override (both !important, this file
	   loads later), right-aligning Categories/Health Library headings
	   on mobile instead of left-aligning them like every other section. */
	align-items: flex-end;
	gap: 20px;
	flex-wrap: wrap;
}

/* ── Card grid ── */
.cat-grid {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 24px;
}

.cat-card {
	position: relative;
	min-height: 130px;
	display: block;
	text-decoration: none;
}

/* Ring: rotating conic gradient, masked to a 2px edge by the ::after face. */
.cat-card-ring {
	position: absolute;
	inset: -2px;
	border-radius: 12px;
	overflow: hidden;
	pointer-events: none;
	z-index: 0;
}

.cat-card-ring::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 280%;
	height: 280%;
	background: conic-gradient(from 0deg,
			var(--gold-500) 0deg,
			var(--gold-400) 80deg,
			var(--gold-600) 150deg,
			transparent 200deg,
			transparent 360deg);
	transform: translate(-50%, -50%) rotate(0deg);
	animation: none;
}

.cat-card:hover .cat-card-ring::before,
.cat-card:focus-visible .cat-card-ring::before {
	animation: log-cat-sweep 2.2s linear infinite;
}

.cat-card-ring::after {
	content: '';
	position: absolute;
	inset: 2px;
	border-radius: 10px;
	background: #fff;
	transition: background .3s ease;
}

.cat-card-inner {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	min-height: 130px;
	padding: 24px 32px;
	border-radius: 10px;
	text-align: center;
	transition: background .3s ease;
}

.cat-card:hover .cat-card-inner,
.cat-card:focus-visible .cat-card-inner {
	background: rgba(212, 175, 55, .06);
}

/* Named .cat-card-icon, not .cat-icon — see the comment in
   inc/shortcodes-log-part-3.php on why that name is avoided here. */
.cat-card-icon {
	width: 34px;
	height: 34px;
	margin-bottom: 12px;
	color: var(--ink-900);
	stroke: currentColor;
	fill: none;
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform .3s var(--ease), color .3s var(--ease);
}

.cat-card:hover .cat-card-icon,
.cat-card:focus-visible .cat-card-icon {
	/* Reference hovers to text-primary-container (#D4AF37 = --gold-500). */
	color: var(--gold-500);
	transform: scale(1.1);
}

.cat-name {
	font-weight: 700;
	font-size: 15px;
	line-height: 1.3;
	color: var(--ink-900);
}

@keyframes log-cat-sweep {
	from {
		transform: translate(-50%, -50%) rotate(0deg);
	}

	to {
		transform: translate(-50%, -50%) rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {

	.cat-card:hover .cat-card-ring::before,
	.cat-card:focus-visible .cat-card-ring::before {
		animation: none;
	}
}

/* ── Responsive: 5 → 3 → 2 columns, matching the reference grid. ── */
@media (max-width: 1023px) {
	.cat-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 767px) {
	.cat-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 16px;
	}

	.cat-card-inner {
		padding: 16px 12px;
	}

	.cat-name {
		font-size: 14px;
	}

	/* Odd card count leaves a lone card on the last row — let it span. */
	.cat-card:last-child:nth-child(odd) {
		grid-column: span 2;
	}
}
