/*
Theme Name: Centro Vida
Description: Block theme for the Centro Vida physiotherapy clinic. Page sections are editable ACF blocks.
Author: Centro Vida
Version: 0.1.0
Requires at least: 6.5
Requires PHP: 8.0
Text Domain: centro-vida
*/

/* Design tokens live in theme.json; shared layout helpers for the ACF blocks. */
:root {
	--cv-box: 1344px;
	--cv-gutter: clamp(1rem, 4vw, 3rem);
	--cv-section-space: clamp(3.5rem, 9vw, 9rem);
	--cv-primary: var(--wp--preset--color--verde); /* swapped by body.cv-theme-azul */
	--cv-secondary: var(--wp--preset--color--azul);
	--cv-tertiary: var(--wp--preset--color--amarillo); /* third accent in rotating-colour blocks */
	--cv-quaternary: var(--wp--preset--color--naranja); /* fourth accent when a block has four items */
	--cv-on-primary: var(--wp--preset--color--blanco); /* text on surfaces filled with the primary colour */
	/* Height taken by the fixed header (logo + bar padding); heroes keep their content clear of it. */
	--cv-header-h: calc(clamp(72px, 7.5vw, 110px) * 1.01 + 2 * clamp(0.75rem, 1.8vw, 1.75rem));
	/* Height of the sticky header once scrolled (80px logo + 1rem padding each side). */
	--cv-sticky-h: calc(80px * 1.01 + 2rem);
	--cv-col-gap: clamp(2rem, 4.5vw, 5rem); /* horizontal gutter between text columns */
}

body.cv-theme-azul {
	--cv-primary: var(--wp--preset--color--azul);
	--cv-secondary: var(--wp--preset--color--verde);
}

/* Yellow needs dark text on top of it (white fails contrast). */
body.cv-theme-amarillo {
	--cv-primary: var(--wp--preset--color--amarillo);
	--cv-secondary: var(--wp--preset--color--azul);
	--cv-tertiary: var(--wp--preset--color--verde);
	--cv-on-primary: var(--wp--preset--color--texto);
}

body.cv-theme-amarillo .cv-btn--light {
	color: var(--wp--preset--color--texto);
}

/* In-page links (e.g. the hero button) stop below the sticky header. */
section[id] {
	scroll-margin-top: var(--cv-sticky-h);
}

.cv-box {
	width: min(100% - 2 * var(--cv-gutter), var(--cv-box));
	margin-inline: auto;
}

.cv-title {
	font-family: var(--wp--preset--font-family--lilita-one);
	font-weight: 400;
	font-size: clamp(2.5rem, 5.55vw, 6rem);
	line-height: 1.0625;
	text-wrap: balance;
}

:where(.cv-title) {
	margin: 0;
}

.cv-title--md {
	font-size: clamp(2rem, 3.7vw, 4rem);
	line-height: 1.0625;
}

.cv-script {
	font-family: var(--wp--preset--font-family--pacifico);
	font-weight: 400;
}

.cv-eyebrow-logo {
	display: block;
	height: auto;
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

/* Motion: subtle reveal on scroll. Hidden state only applies once JS has flagged the page. */
@media (prefers-reduced-motion: no-preference) {
	.cv-js [data-cv-reveal] {
		opacity: 0;
		transform: translateY(24px);
		transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
		transition-delay: calc(var(--cv-i, 0) * 120ms);
	}

	.cv-js [data-cv-reveal="zoom"] {
		transform: scale(0.92);
	}

	.cv-js [data-cv-reveal="fade"] {
		transform: none;
	}

	.cv-js [data-cv-reveal].is-visible {
		opacity: 1;
		transform: none;
	}
}

.cv-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.25rem 3rem;
	border: 0;
	border-radius: 16px;
	cursor: pointer;
	background: var(--cv-accent, var(--cv-primary));
	color: var(--cv-on-primary);
	font-family: var(--wp--preset--font-family--lilita-one);
	font-size: 1.125rem;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
}

.cv-btn:focus-visible {
	outline: 3px solid currentcolor;
	outline-offset: 3px;
}

.cv-btn--light {
	background: var(--wp--preset--color--blanco);
	color: var(--cv-primary);
}

@media (prefers-reduced-motion: no-preference) {
	.cv-btn {
		transition: transform 0.2s ease, filter 0.2s ease;
	}

	.cv-btn:hover {
		transform: translateY(-2px);
		filter: brightness(1.06);
	}
}

/* Long-form text (legal pages): wrap core blocks in a Group with the class cv-legal. */
.cv-legal {
	width: min(100% - 2 * var(--cv-gutter), 760px);
	margin-inline: auto;
	padding-block: var(--cv-section-space);
	font-size: var(--wp--preset--font-size--cuerpo-s);
}

.cv-legal h2 {
	margin: 2.5rem 0 0.75rem;
	color: var(--cv-primary);
	font-family: var(--wp--preset--font-family--lilita-one);
	font-size: clamp(1.5rem, 2.2vw, 2rem);
	font-weight: 400;
	line-height: 1.2;
}

.cv-legal > :first-child {
	margin-top: 0;
}

.cv-legal p,
.cv-legal ul {
	margin: 0 0 1rem;
}

.cv-legal ul {
	padding-left: 1.25rem;
}

/*
 * Card grid: three per row, an incomplete last row is centred; exactly four items (class cv-cards-grid--n4)
 * go 2×2 up to 1199px and in one row of four from 1200px. Add cv-cards-grid--n4 from the template.
 */
.cv-cards-grid {
	display: grid;
	gap: 2.5rem var(--cv-col-gap);
}

@media (min-width: 560px) {
	.cv-cards-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 900px) {
	.cv-cards-grid {
		grid-template-columns: repeat(6, 1fr);
	}

	.cv-cards-grid > * {
		grid-column: span 2;
	}

	.cv-cards-grid--c3 > :last-child:nth-child(3n + 1) {
		grid-column: 3 / span 2;
	}

	.cv-cards-grid--c3 > :nth-last-child(2):nth-child(3n + 1) {
		grid-column: 2 / span 2;
	}

	.cv-cards-grid--c3 > :last-child:nth-child(3n + 2) {
		grid-column: 4 / span 2;
	}

	.cv-cards-grid--n4 > * {
		grid-column: span 3;
	}
}

@media (min-width: 1200px) {
	.cv-cards-grid--n4 {
		grid-template-columns: repeat(4, 1fr);
	}

	.cv-cards-grid--n4 > * {
		grid-column: auto;
	}
}
