/**
 * Page: front page (front-page.php + block content edited in the block editor).
 *
 * Blocks are styled by the class names set in the editor (Block › Advanced › Additional CSS class):
 *   Sections: cac-hero, cac-spaces, cac-section (+ cac-section--subtle), cac-section__intro
 *   Pieces:   cac-eyebrow, cac-lead, cac-hero__title, cac-card(__title), cac-chain (ordered list),
 *             cac-profiles, cac-profile + cac-profile--{ciutadania|voluntari|supervivent|professional},
 *             cac-button-arrow (button), cac-carousel (group of video embeds)
 * Groups need a flex or grid layout, or WordPress adds an inner wrapper (classic theme).
 * Selectors start with .cac-home to outrank the layout CSS WordPress generates for those groups.
 */

/* Full-width bands: undo BuddyBoss's content container and padding on this page. */
body.home #content {
	padding-inline: 0;
}

body.home #content > .container {
	max-width: none;
	padding: 0;
}

body.home #content .site-content-grid {
	display: block;
	margin: 0;
}

body.home #main.cac-home {
	padding: 0;
}

.cac-home {
	font-size: var(--cac-font-size-base);
	line-height: var(--cac-line-height-base);
	color: var(--cac-color-text);
}

.cac-home :is(h1, h2, h3, p, ol) {
	margin: 0;
}

.cac-home :is(h1, h2, h3) {
	font-weight: var(--cac-font-weight-bold);
}

/*
 * WordPress's flex layout sets flex-wrap: wrap; on vertical groups inside grids
 * Chrome then miscalculates their height. Our vertical groups never need to wrap.
 */
.cac-home :is(.cac-hero__text, .cac-card, .cac-section, .cac-section__intro, .cac-profile) {
	flex-wrap: nowrap;
}

/* ---------- Sections ---------- */

.cac-home .cac-section {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 2.75rem;
	padding: var(--cac-section-padding) var(--cac-gutter-section);
}

.cac-home .cac-section--subtle {
	background-color: var(--cac-color-bg-subtle);
}

.cac-home .cac-section__intro {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--cac-space-2);
	max-width: 47.5rem;
}

.cac-home .cac-section__title {
	font-size: var(--cac-font-size-3xl);
	line-height: var(--cac-line-height-tight);
	color: var(--cac-color-text-strong);
}

/* ---------- Hero ---------- */

.cac-home .cac-hero {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 21.25rem), 1fr));
	gap: clamp(1.75rem, 4vw, 3.5rem);
	align-items: center;
	padding: clamp(1.75rem, 3.5vw, 2.75rem) var(--cac-gutter-section) clamp(1.5rem, 3vw, 2.25rem);
}

.cac-home .cac-hero__text {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 1.125rem;
}

.cac-home .cac-hero__title {
	font-size: var(--cac-font-size-display);
	line-height: 1.1;
	letter-spacing: -0.01em;
	color: var(--cac-color-text-strong);
	text-wrap: balance;
}

/* Highlight (core "Highlight" format with transparent background): marker underline. */
.cac-home .cac-hero__title mark {
	color: inherit;
	box-shadow: inset 0 -0.28em 0 var(--cac-color-highlight);
}

/* ---------- Spaces (Formació / Comunitat / Recursos) ---------- */

.cac-home .cac-spaces {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.25rem), 1fr));
	gap: var(--cac-space-5);
	padding: 0 var(--cac-gutter-section) clamp(2.5rem, 5vw, 4rem);
}

.cac-home .cac-card {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--cac-space-3);
	padding: var(--cac-space-6) 1.625rem;
	background-color: var(--cac-color-bg);
	border: 1px solid var(--cac-color-border);
	border-top: 4px solid var(--cac-color-brand);
	border-radius: 0 0 var(--cac-radius-md) var(--cac-radius-md);
}

.cac-home .cac-card::before {
	content: "";
	height: 9rem;
	margin-bottom: var(--cac-space-2);
	background: var(--cac-card-image, none) center / contain no-repeat;
}

.cac-home .cac-card:not(:has(a[href*="/cursos/"], a[href*="/forums/"], a[href*="/recursos/"]))::before {
	display: none;
}

.cac-home .cac-card:has(a[href*="/cursos/"]) {
	--cac-card-image: url("../../images/spaces/formacio.svg");
}

.cac-home .cac-card:has(a[href*="/forums/"]) {
	--cac-card-image: url("../../images/spaces/comunitat.svg");
}

.cac-home .cac-card:has(a[href*="/recursos/"]) {
	--cac-card-image: url("../../images/spaces/recursos.svg");
}

.cac-home .cac-card__title {
	font-size: 1.5rem;
	color: var(--cac-color-text-strong);
}

.cac-home .cac-card > p {
	flex: 1;
	line-height: var(--cac-line-height-base);
}

/* ---------- Chain of survival ---------- */

.cac-home .cac-chain {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.75rem), 1fr));
	gap: 2.5rem 0;
	margin: 0;
	padding: var(--cac-space-8) 0 0;
	list-style: none;
	counter-reset: cac-chain;
}

.cac-home .cac-chain > li {
	padding-right: var(--cac-space-6);
	font-size: 1.25rem;
	font-weight: var(--cac-font-weight-bold);
	line-height: 1.3;
	color: var(--cac-color-text-strong);
	border-top: 3px solid var(--cac-color-brand);
	counter-increment: cac-chain;
}

.cac-home .cac-chain > li::before {
	content: counter(cac-chain);
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: content-box;
	width: 4rem;
	height: 4rem;
	margin: -2.125rem 0 0.875rem;
	font-size: 1.625rem;
	color: var(--cac-color-on-brand);
	background-color: var(--cac-color-brand);
	border: 4px solid var(--cac-color-bg-subtle);
	border-radius: 50%;
}

/* ---------- Profiles ---------- */

.cac-home .cac-profiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.75rem), 1fr));
	gap: var(--cac-space-4);
}

.cac-home .cac-profile {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--cac-space-3);
	min-height: 10.625rem;
	padding: var(--cac-space-6);
	background-color: var(--cac-color-bg);
	border: 1px solid var(--cac-color-border);
	border-radius: var(--cac-radius-md);
}

/* Icon: red-outlined circle with the profile pictogram (inline SVG set per profile below). */
.cac-home .cac-profile::before {
	content: "";
	box-sizing: border-box;
	width: 4rem;
	height: 4rem;
	border: 2px solid var(--cac-color-brand);
	border-radius: 50%;
	background:
		var(--cac-profile-icon) center / 2rem no-repeat,
		var(--cac-color-bg);
}

.cac-home .cac-profile__title {
	font-size: 1.1875rem;
	line-height: 1.3;
	color: var(--cac-color-text-strong);
}

.cac-home .cac-profile > p {
	font-size: var(--cac-font-size-md);
	line-height: var(--cac-line-height-base);
}

/* Pictograms from the prototype; volunteer: Lucide "hand-heart" (ISC). */
.cac-home .cac-profile--ciutadania {
	--cac-profile-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d52b1e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6'/%3E%3Ccircle cx='17' cy='9' r='2.5'/%3E%3Cpath d='M15.8 14.1A5 5 0 0 1 21 19'/%3E%3C/svg%3E");
}

.cac-home .cac-profile--professional {
	--cac-profile-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d52b1e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3v6a4 4 0 0 0 8 0V3'/%3E%3Cpath d='M10 13v2a5 5 0 0 0 10 0v-2.5'/%3E%3Ccircle cx='20' cy='10.5' r='2'/%3E%3C/svg%3E");
}

.cac-home .cac-profile--supervivent {
	--cac-profile-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d52b1e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z'/%3E%3Cpath d='M8.5 11.5h2l1-2 1.5 4 1-2h1.5'/%3E%3C/svg%3E");
}

.cac-home .cac-profile--voluntari {
	--cac-profile-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d52b1e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16'/%3E%3Cpath d='m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9'/%3E%3Cpath d='m2 15 6 6'/%3E%3Cpath d='M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z'/%3E%3C/svg%3E");
}
