/* ============================================================
 * AMEFIT HOME MODULES — sekcja 4 boxów na stronie głównej
 * Wczytywane warunkowo (is_front_page) przez wp_enqueue_scripts.
 * ============================================================ */

/* Token akcentu modułów — magenta zgodna z paletą logo (faza 1). */
:root {
	--af-module-accent: var(--af-color-accent, #cf0261);
}

.af-home-modules {
	background: #fafafa;
	padding-block: clamp(4rem, 8vw, 7rem);
	width: 100%;
	position: relative;
}

/* Pełna szerokość vs reguła rodzica która może ograniczać.
 * Zachowujemy normalny flow w obrębie .mcb-section-inner / kontenera BeTheme,
 * ale tutaj używamy własnego inner do max-width 1320px. */
.af-home-modules__inner {
	max-width: 1320px;
	margin: 0 auto;
	padding-inline: clamp(1rem, 4vw, 2.5rem);
}

/* === Section header (eyebrow + H2 + lead) ================== */

.af-home-modules__header {
	max-width: 720px;
	margin-bottom: clamp(2rem, 4vw, 3rem);
}

.af-home-modules .af-home-modules__eyebrow {
	display: inline-block;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--af-module-accent);
	margin-bottom: 1rem;
}

.amefit-modernized .af-home-modules .af-home-modules__title {
	font-size: clamp(2rem, 4vw, 3.25rem);
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--af-color-text, #161922);
	margin: 0 0 1rem;
}

.amefit-modernized .af-home-modules__lead {
	font-size: clamp(1rem, 1.4vw, 1.125rem);
	color: var(--af-color-text-muted, #5f6470);
	line-height: 1.6;
	margin: 0;
}

/* === Grid 3 kolumny × 2 rzędy — proporcje 4:3:3 (2/5 + 3/10 + 3/10) ===
   Layout:
     | KARNETY  | Kadra   | Cennik |
     | (2/5,    | (3/10)  | (3/10) |
     |  span 2) | Zajęcia | Grafik |
   Tablet — Karnety na pełną szerokość, 4 kafle 2×2 poniżej.
   Mobile — wszystkie stacked. */

.af-home-modules__grid {
	display: grid;
	grid-template-columns: 4fr 3fr 3fr;
	grid-auto-rows: 1fr;
	gap: 1.5rem;
}

/* Karnety — kolumna 1, span 2 rzędy */
.af-home-module--karnety {
	grid-column: 1;
	grid-row: 1 / span 2;
}

@media (max-width: 1199px) {
	.af-home-modules__grid {
		grid-template-columns: repeat(2, 1fr);
		grid-auto-rows: auto;
		gap: 1.25rem;
	}
	.af-home-module--karnety {
		grid-column: 1 / -1; /* pełna szerokość na tablecie */
		grid-row: 1;
	}
}

@media (max-width: 599px) {
	.af-home-modules__grid {
		grid-template-columns: 1fr;
		gap: 1rem;
	}
	.af-home-module--karnety {
		grid-column: 1;
		grid-row: auto;
	}
}

/* === Pojedynczy box ======================================== */

.amefit-modernized a.af-home-module,
.af-home-module {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: var(--af-radius-lg, 16px);
	background: #1a1a1a; /* fallback pod wczytywaniem grafiki */
	color: #ffffff;
	text-decoration: none;
	box-shadow:
		0 1px 2px rgba(0, 0, 0, 0.06),
		0 12px 32px -8px rgba(0, 0, 0, 0.18);
	transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
		box-shadow 320ms cubic-bezier(0.16, 1, 0.3, 1);
	contain: layout paint;
	will-change: transform;
	cursor: pointer;
}

/* Karnety — span 2 rzędy, wysokość = 2 × małe + gap, aspect-ratio sterowane przez grid */
.amefit-modernized a.af-home-module--karnety,
.af-home-module--karnety {
	aspect-ratio: auto;
	min-height: 100%;
}

@media (max-width: 1199px) {
	/* Tablet: Karnety pełnej szerokości — 2:1 dla balansu */
	.amefit-modernized a.af-home-module--karnety,
	.af-home-module--karnety {
		aspect-ratio: 2 / 1;
		min-height: 0;
	}
}

@media (max-width: 599px) {
	.amefit-modernized a.af-home-module,
	.af-home-module {
		aspect-ratio: auto;
		height: min(calc(100vw - 2rem), 480px);
	}
	.amefit-modernized a.af-home-module--karnety,
	.af-home-module--karnety {
		aspect-ratio: auto;
		min-height: 0;
		height: min(calc(100vw - 2rem), 320px);
	}
}

/* Override globalnego stylowania linków z fazy 1 — wewnątrz boxa
 * cały tekst jest biały, niezależnie od `.amefit-modernized a` */
.amefit-modernized .af-home-module,
.amefit-modernized .af-home-module:hover,
.amefit-modernized .af-home-module:focus,
.amefit-modernized .af-home-module:focus-visible {
	color: #ffffff;
}

/* === Media (grafika tła) =================================== */

.af-home-module__media {
	position: absolute;
	inset: 0;
	overflow: hidden;
	z-index: 0;
}

.af-home-module__media .af-home-modules__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center center;
	transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Per-moduł object-position — niektóre kompozycje wymagają innego kadru.
 * Box4 (Grafik) — close-up, zostawiamy center (dolna lewa ćwiartka spokojna). */
.af-home-module--karnety .af-home-modules__image  { object-position: center center; }
.af-home-module--kadra .af-home-modules__image    { object-position: center center; }
.af-home-module--cennik .af-home-modules__image   { object-position: center center; }
.af-home-module--zajecia .af-home-modules__image  { object-position: center center; }
.af-home-module--zajęcia .af-home-modules__image  { object-position: center center; }
.af-home-module--grafik .af-home-modules__image   { object-position: center 30%; }

/* === Overlay gradient (czytelność) ========================= */

.af-home-module__overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(
		180deg,
		transparent 0%,
		transparent 35%,
		rgba(0, 0, 0, 0.55) 75%,
		rgba(0, 0, 0, 0.85) 100%
	);
	pointer-events: none;
	transition: opacity 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Cennik — lifestyle still-life, jaśniejszy od reszty — wzmocniony overlay */
.af-home-module--cennik .af-home-module__overlay {
	background: linear-gradient(
		180deg,
		rgba(0, 0, 0, 0.1) 0%,
		rgba(0, 0, 0, 0.25) 35%,
		rgba(0, 0, 0, 0.65) 75%,
		rgba(0, 0, 0, 0.92) 100%
	);
}

/* === Content (eyebrow + tytuł + podtytuł) ================== */

.af-home-module__content {
	position: absolute;
	left: clamp(1.25rem, 2.5vw, 1.75rem);
	right: clamp(4.5rem, 6vw, 5.5rem); /* miejsce na strzałkę po prawej */
	bottom: clamp(1.25rem, 2.5vw, 1.75rem);
	z-index: 1;
	display: flex;
	flex-direction: column;
}

.amefit-modernized .af-home-module .af-home-module__eyebrow {
	display: block;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--af-module-accent);
	margin-bottom: 0.5rem;
}

.amefit-modernized .af-home-module .af-home-module__title {
	font-size: clamp(1.5rem, 2.4vw, 2.25rem);
	font-weight: 800;
	letter-spacing: -0.01em;
	line-height: 1.05;
	text-transform: uppercase;
	color: #ffffff;
	margin: 0 0 0.5rem;
}

.amefit-modernized .af-home-module .af-home-module__subtitle {
	font-size: 0.95rem;
	line-height: 1.45;
	color: rgba(255, 255, 255, 0.88);
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* === CTA strzałka =========================================== */

.af-home-module__cta {
	position: absolute;
	right: clamp(1.25rem, 2.5vw, 1.75rem);
	bottom: clamp(1.25rem, 2.5vw, 1.75rem);
	z-index: 1;
	width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 999px;
	background: var(--af-module-accent);
	color: #ffffff;
	box-shadow: 0 6px 16px -4px rgba(207, 2, 97, 0.5);
	transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
		background-color 220ms cubic-bezier(0.65, 0, 0.35, 1),
		box-shadow 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.af-home-module__cta svg {
	transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* === Hover === */

.af-home-module:hover {
	transform: translateY(-8px);
	box-shadow:
		0 4px 8px rgba(0, 0, 0, 0.08),
		0 24px 48px -12px rgba(0, 0, 0, 0.28);
}

.af-home-module:hover .af-home-modules__image {
	transform: scale(1.06);
}

.af-home-module:hover .af-home-module__overlay {
	background: linear-gradient(
		180deg,
		transparent 0%,
		transparent 30%,
		rgba(0, 0, 0, 0.62) 70%,
		rgba(0, 0, 0, 0.92) 100%
	);
}

.af-home-module:hover .af-home-module__cta svg {
	transform: translateX(4px);
}

.af-home-module:hover .af-home-module__cta {
	box-shadow: 0 12px 24px -4px rgba(207, 2, 97, 0.65);
}

/* === Focus visible (klawiatura) === */

.af-home-module:focus-visible {
	outline: 3px solid var(--af-module-accent);
	outline-offset: 4px;
	transform: translateY(-8px);
	box-shadow:
		0 4px 8px rgba(0, 0, 0, 0.08),
		0 24px 48px -12px rgba(0, 0, 0, 0.28);
}

.af-home-module:focus-visible .af-home-modules__image {
	transform: scale(1.06);
}

/* === Active (touch tap feedback) === */

.af-home-module:active {
	transform: scale(0.98);
	transition-duration: 150ms;
}

/* === Scroll reveal (JS dorzuca .is-revealed) =============== */

.af-home-module {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
		transform 600ms cubic-bezier(0.16, 1, 0.3, 1),
		box-shadow 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.af-home-module.is-revealed {
	opacity: 1;
	transform: translateY(0);
}

/* Stagger 100ms per kolejny box */
.af-home-module[data-af-module-index="0"].is-revealed { transition-delay: 0ms; }
.af-home-module[data-af-module-index="1"].is-revealed { transition-delay: 100ms; }
.af-home-module[data-af-module-index="2"].is-revealed { transition-delay: 200ms; }
.af-home-module[data-af-module-index="3"].is-revealed { transition-delay: 300ms; }

/* === Reduced motion ======================================== */

@media (prefers-reduced-motion: reduce) {
	.af-home-module {
		opacity: 1;
		transform: none;
		transition-duration: 180ms;
	}
	.af-home-module:hover {
		transform: none;
	}
	.af-home-module:hover .af-home-modules__image {
		transform: none;
	}
	.af-home-module:hover .af-home-module__cta svg {
		transform: none;
	}
	.af-home-module:focus-visible {
		transform: none;
	}
}
