/**
 * AP Content Layout Styles
 *
 * Flexible content sections with multiple layout options.
 * Animations are handled by BB's native animation system (fl-animation classes).
 */

/* ===========================================
   BASE SECTION STYLES
   =========================================== */

.ap-content-layout {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: calc(100vh - 115px);
	overflow: hidden;
}

.ap-content-layout__background {
	position: absolute;
	inset: 0;
	z-index: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

.ap-content-layout__overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
}

.ap-content-layout__container {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4rem;
	align-items: center;
	width: 100%;
	max-width: 1400px;
	margin: 0 auto;
	padding: 3rem 4rem;
	border-radius: 12px;
	box-sizing: border-box;
}

/* ===========================================
   TWO-COLUMN LAYOUT VARIATIONS
   =========================================== */

.ap-content-layout--layout-two-col-image-left .ap-content-layout__image {
	order: 1;
}

.ap-content-layout--layout-two-col-image-left .ap-content-layout__content {
	order: 2;
}

.ap-content-layout--layout-two-col-image-right .ap-content-layout__image {
	order: 2;
}

.ap-content-layout--layout-two-col-image-right .ap-content-layout__content {
	order: 1;
}

/* ===========================================
   STACKED LAYOUT
   =========================================== */

.ap-content-layout--layout-stacked .ap-content-layout__container {
	grid-template-columns: 1fr;
	text-align: center;
	max-width: 1200px;
}

.ap-content-layout--layout-stacked .ap-content-layout__heading {
	grid-column: 1;
}

.ap-content-layout--layout-stacked .ap-content-layout__image {
	grid-column: 1;
	margin: 0 auto;
}

.ap-content-layout--layout-stacked .ap-content-layout__content {
	grid-column: 1;
	align-items: center;
}

/* ===========================================
   THREE-COLUMN LAYOUTS (shared)
   =========================================== */

.ap-content-layout--layout-three-col .ap-content-layout__container,
.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__container {
	grid-template-columns: 1fr;
	text-align: center;
}

.ap-content-layout--layout-three-col .ap-content-layout__container {
	max-width: 1200px;
}

.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__container {
	max-width: 1400px;
}

.ap-content-layout--layout-three-col .ap-content-layout__heading,
.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__heading {
	grid-column: 1;
	margin-bottom: 1rem;
}

.ap-content-layout__three-col-row {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 4rem;
	align-items: start;
	width: 100%;
}

.ap-content-layout--layout-three-col .ap-content-layout__image {
	max-width: 400px;
}

.ap-content-layout--layout-three-col .ap-content-layout__content--left,
.ap-content-layout--layout-three-col .ap-content-layout__content--right {
	text-align: left;
}

.ap-content-layout--layout-three-col .ap-content-layout__buttons,
.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__buttons {
	justify-content: center;
	margin-top: 2rem;
}

/* Image | Text | Image specific overrides */
.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__three-col-row {
	grid-template-columns: 1fr 2.5fr 1fr;
	align-items: center;
}

.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__image {
	width: 100%;
}

.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__content--center {
	text-align: center;
	padding: 3rem 4rem;
	border-radius: 12px;
}

.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__content--center .ap-content-layout__heading {
	margin-bottom: 1rem;
}

/* ===========================================
   IMAGE AND CONTENT COMMON STYLES
   =========================================== */

.ap-content-layout__image {
	width: 100%;
}

.ap-content-layout__image img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 8px;
}

.ap-content-layout__content {
	display: flex;
	flex-direction: column;
	gap: 2.5rem;
}

.ap-content-layout__heading {
	margin: 0;
	font-weight: 700;
	font-size: clamp(2rem, 5vw, 48px);
	line-height: 1.2;
}

.ap-content-layout__text {
	margin: 0;
	font-size: clamp(1rem, 3vw, 24px);
	line-height: 1.6;
}

.ap-content-layout__text p:first-child {
	margin-top: 0;
}

.ap-content-layout__text p:last-child {
	margin-bottom: 0;
}

/* ===========================================
   TEXT COLOUR VARIATIONS
   =========================================== */

.ap-content-layout--text-light,
.ap-content-layout--text-light .ap-content-layout__heading {
	color: #ffffff;
}

.ap-content-layout--text-dark,
.ap-content-layout--text-dark .ap-content-layout__heading {
	color: #1a1f4b;
}

/* ===========================================
   BUTTONS
   =========================================== */

.ap-content-layout__buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	margin-top: 0.5rem;
}

/* ===========================================
   RESPONSIVE - TABLET LANDSCAPE (1024px)
   =========================================== */

@media (max-width: 1024px) {
	.ap-content-layout__three-col-row {
		gap: 2rem;
	}

	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__three-col-row {
		grid-template-columns: 1fr 2fr 1fr;
	}
}

/* ===========================================
   RESPONSIVE - TABLET PORTRAIT (820px)
   =========================================== */

@media (max-width: 820px) {
	/* Allow section to grow beyond viewport on tablet/mobile */
	.ap-content-layout {
		height: auto;
		min-height: calc(100vh - 115px);
		overflow: visible;
	}

	.ap-content-layout__container {
		grid-template-columns: 1fr;
		gap: 3rem;
	}

	/* Hide decorative elements in all layouts */
	.ap-content-layout .ap-decorative-element {
		display: none;
	}

	/* All three-col rows stack to single column */
	.ap-content-layout__three-col-row,
	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__three-col-row {
		grid-template-columns: 1fr;
		text-align: center;
	}

	/* Two-column layouts: image first, content second */
	.ap-content-layout--layout-two-col-image-left .ap-content-layout__image,
	.ap-content-layout--layout-two-col-image-right .ap-content-layout__image {
		order: 1;
	}

	.ap-content-layout--layout-two-col-image-left .ap-content-layout__content,
	.ap-content-layout--layout-two-col-image-right .ap-content-layout__content {
		order: 2;
	}

	/* Three-column layouts: shared image styling */
	.ap-content-layout--layout-three-col .ap-content-layout__image,
	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__image {
		max-width: 70%;
		margin: 0 auto;
	}

	/* Text | Image | Text: stack order */
	.ap-content-layout--layout-three-col .ap-content-layout__image {
		order: 1;
	}

	.ap-content-layout--layout-three-col .ap-content-layout__content--left {
		order: 2;
	}

	.ap-content-layout--layout-three-col .ap-content-layout__content--right {
		order: 3;
	}

	.ap-content-layout--layout-three-col .ap-content-layout__content--left,
	.ap-content-layout--layout-three-col .ap-content-layout__content--right {
		text-align: center;
	}

	/* Image | Text | Image: stack order */
	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__image--left {
		order: 1;
	}

	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__content--center {
		order: 2;
		padding: 2rem;
	}

	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__image--right {
		order: 3;
	}
}

/* ===========================================
   RESPONSIVE - PHONE (480px)
   =========================================== */

@media (max-width: 480px) {
	.ap-content-layout__container {
		padding: 3rem 2rem;
		gap: 2rem;
	}

	.ap-content-layout__three-col-row {
		gap: 1.5rem;
	}

	/* Images larger on phone for better visibility */
	.ap-content-layout--layout-three-col .ap-content-layout__image,
	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__image {
		max-width: 80%;
	}

	.ap-content-layout--layout-three-col-image-text-image .ap-content-layout__content--center {
		padding: 1.5rem;
	}
}

/* ===========================================
   STICKY SCROLL-LOCK MODE
   Uses JS-controlled fixed positioning since CSS sticky
   doesn't work with BB's per-module container structure.

   Key architecture:
   - Section height = scroll zone (viewport × multiplier)
   - Inner wrapper = viewport height with centering
   - When stuck: section fixed at 100vh, placeholder shows at scroll zone height
   =========================================== */

.ap-content-layout--sticky {
	height: calc(100vh * var(--scroll-multiplier, 1.5));
	display: block;
	overflow: visible;
}

.ap-content-layout__sticky-content {
	height: 100vh;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	will-change: opacity;
}

.ap-content-layout--sticky.is-stuck {
	position: fixed;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	height: 100vh;
	isolation: isolate;
}

.ap-content-layout__sticky-placeholder {
	display: none;
}

.ap-content-layout--sticky.is-stuck + .ap-content-layout__sticky-placeholder {
	display: block;
	height: calc(100vh * var(--scroll-multiplier, 1.5));
}

/* ===========================================
   REDUCED MOTION PREFERENCE
   =========================================== */

@media (prefers-reduced-motion: reduce) {
	.ap-content-layout .fl-animation {
		opacity: 1 !important;
		transform: none !important;
		animation: none !important;
		transition: none !important;
	}

	.ap-content-layout__sticky-content {
		opacity: 1 !important;
	}
}
