/* Northern Sky - Projects Stack
   Structural / layout CSS only. Colors, typography, spacing and the
   animation timing are controlled per-instance from the Elementor Style
   tab (see the widget's "selectors" in class-projects-stack-widget.php).

   Stacking mechanic: each .nsm-stack-item is a normal-flow block whose
   height equals the visible card height. As the page scrolls, each item
   pins to the top of the viewport (position: sticky) in DOM order, so a
   later item's sticky position visually slides up and covers the earlier
   (lower z-index) card underneath it - no JS required for the pin/cover
   itself. Note: an ancestor with overflow:hidden/auto between this widget
   and the scrolling viewport will break position: sticky. */

.nsm-projects-stack,
.nsm-projects-stack *,
.nsm-projects-stack *::before,
.nsm-projects-stack *::after {
	box-sizing: border-box;
}

.nsm-projects-stack {
	position: relative;
	width: 100%;
}

.nsm-projects-stack-empty {
	padding: 40px;
	text-align: center;
	opacity: 0.6;
}

.nsm-stack-item {
	position: sticky;
	top: 0;
	width: 100%;
	height: 90vh;
}

.nsm-stack-card {
	position: absolute;
	inset: 20px;
	border-radius: 24px;
	overflow: hidden;
}

.nsm-stack-bg-wrap {
	position: absolute;
	inset: 0;
	overflow: hidden;
}

.nsm-stack-bg-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	opacity: 0;
	transform: translateY(var(--nsm-stack-bg-offset, 40px)) scale(1);
	transition-property: opacity, transform;
	transition-timing-function: cubic-bezier(0.16, 0.84, 0.44, 1);
	transition-duration: var(--nsm-stack-bg-duration, 0.9s);
	transition-delay: var(--nsm-stack-bg-delay, 0.1s);
	will-change: transform, opacity;
}

.nsm-stack-item.nsm-in-view .nsm-stack-bg-image {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* Mobile Background Image Field (acf_image_mobile_field) - only present in
   the markup at all when that field resolved to something (see
   render_projects()), so .nsm-stack-bg-image-mobile hidden-by-default here
   just keeps it out of the way until the 767px swap below. */
.nsm-stack-bg-image-mobile {
	display: none;
}

/* Tablet Background Image Field (acf_image_tablet_field) - same idea as the
   mobile field above, only present in the markup when that field resolved
   to something. Hidden by default; swapped in between 768px and 1024px by
   the Tablet media query below. */
.nsm-stack-bg-image-tablet {
	display: none;
}

.nsm-stack-no-bg-reveal .nsm-stack-bg-image {
	opacity: 1;
	transform: translateY(0) scale(1);
	transition: transform var(--nsm-stack-hover-duration, 0.9s) ease;
}

/* Hover zoom - independent of the entrance transform above; the settled
   translateY(0) position is preserved, only the scale changes. */
.nsm-stack-card:hover .nsm-stack-bg-image {
	transform: translateY(0) scale(var(--nsm-stack-hover-scale, 1.06));
	transition-duration: var(--nsm-stack-hover-duration, 0.9s);
	transition-delay: var(--nsm-stack-hover-delay, 0.4s);
}

.nsm-stack-overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.nsm-stack-content {
	position: relative;
	z-index: 1;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	padding: 48px 56px;
}

.nsm-stack-divider {
	width: 100%;
	border: none;
	border-top-style: solid;
	border-top-width: 1px;
	margin: 0 0 24px;
}

.nsm-stack-row {
	display: flex;
	align-items: flex-start;
	gap: 32px;
	width: 100%;
}

.nsm-stack-label-col {
	flex: 0 0 170px;
	max-width: 170px;
}

.nsm-stack-label {
	display: inline-block;
	text-transform: uppercase;
	white-space: nowrap;
}

.nsm-stack-description {
	flex: 1 1 auto;
	min-width: 0;
}

.nsm-stack-description p {
	margin: 0;
}

.nsm-stack-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	text-decoration: none;
	border-bottom-style: solid;
	border-bottom-width: 1px;
	padding-bottom: 4px;
	width: fit-content;
	transition: color 0.3s ease, border-color 0.3s ease;
}

.nsm-stack-btn-text {
	display: inline-block;
	transition: color 0.3s ease;
}

.nsm-stack-btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	transition: transform 0.3s ease, color 0.3s ease;
}

.nsm-stack-heading {
	flex: 0 1 auto;
	margin: 0;
	margin-left: auto;
	line-height: 1.15;
}

@media (prefers-reduced-motion: reduce) {
	.nsm-stack-bg-image {
		transition: none !important;
		opacity: 1 !important;
		transform: translateY(0) scale(1) !important;
	}

	.nsm-stack-card:hover .nsm-stack-bg-image {
		transform: translateY(0) scale(1) !important;
	}
}

/* Tablet */
@media (max-width: 1024px) {
	/* Swap to the Tablet Background Image Field's image, when one was set
	   for this card (.nsm-has-tablet-bg only gets added when
	   acf_image_tablet_field resolved to something) - otherwise the desktop
	   image just keeps showing here too, same as always. This stays active
	   down through mobile widths too (max-width: 1024px covers them); the
	   Mobile media query below re-overrides back to the mobile image
	   whenever a mobile-specific image is also set, so Mobile always wins
	   below 768px when both are present. */
	.nsm-stack-bg-wrap.nsm-has-tablet-bg .nsm-stack-bg-image-desktop {
		display: none;
	}

	.nsm-stack-bg-wrap.nsm-has-tablet-bg .nsm-stack-bg-image-tablet {
		display: block;
	}

	.nsm-stack-item {
		height: 85vh;
	}

	.nsm-stack-content {
		padding: 32px;
	}

	.nsm-stack-row {
		gap: 20px;
	}

	.nsm-stack-label-col {
		flex-basis: 120px;
		max-width: 120px;
	}
}

/* Mobile - stack the row into a column so nothing gets crushed. Matches
   the "Card Height" Style control's own mobile_default (see
   class-projects-stack-widget.php) - kept in sync as a plain fallback for
   whenever the widget renders outside Elementor's own generated CSS. */
@media (max-width: 767px) {
	/* Swap to the Mobile Background Image Field's image, when one was set
	   for this card (.nsm-has-mobile-bg only gets added to .nsm-stack-bg-wrap
	   when acf_image_mobile_field resolved to something) - otherwise the
	   desktop image just keeps showing here too, same as always. */
	.nsm-stack-bg-wrap.nsm-has-mobile-bg .nsm-stack-bg-image-desktop {
		display: none;
	}

	/* Mobile wins over Tablet below 767px when both fields are set on the
	   same card - re-hides the tablet image the block above just showed. */
	.nsm-stack-bg-wrap.nsm-has-mobile-bg .nsm-stack-bg-image-tablet {
		display: none;
	}

	.nsm-stack-bg-wrap.nsm-has-mobile-bg .nsm-stack-bg-image-mobile {
		display: block;
	}

	.nsm-stack-item {
		/* 100vh, not a shorter value: each card pins in place while the
		   next one scrolls up to cover it, so anything less than a full
		   screen leaves a visible gap below the card (the section
		   background, or a sliver of the next card) until the visitor
		   scrolls further. */
		height: 100vh;
	}

	.nsm-stack-card {
		inset: 12px;
		border-radius: 16px;
	}

	.nsm-stack-content {
		padding: 24px 20px;
		/* Matches the base/desktop rule's flex-start (content pinned to
		   the top, image filling the rest below via object-fit: cover on
		   .nsm-stack-bg-image) - this used to flip to flex-end here,
		   bottom-packing the label/heading/description/button instead,
		   which also meant that stack could overflow past the top of a
		   shorter mobile card and get clipped by the card's own
		   overflow:hidden. No override needed now; it just inherits
		   flex-start from the base rule. */
	}

	.nsm-stack-row {
		flex-direction: column;
		gap: 16px;
	}

	/* The reference mobile design reads label, then heading, then
	   description/button - a different order than the desktop row (label,
	   description, heading side by side) - so the heading and description
	   swap visual order here via flex "order" without touching the
	   markup. This is a plain, one-time layout choice at a fixed
	   breakpoint (not something that ever needs to animate/transition),
	   so it's safe here in a way it would not be for something like an
	   auto-advancing carousel. */
	/* !important on flex-basis/max-width here because the "Label Column
	   Width" Style control's own selector sets flex-basis from the same
	   numeric value used for a desktop/tablet ROW layout - that value
	   doesn't have a sensible mobile equivalent (flex-basis means HEIGHT
	   once the row becomes a column below), so this is what actually
	   wins on mobile instead of a mobile_default. See the control's own
	   comment in class-projects-stack-widget.php. */
	.nsm-stack-label-col {
		flex: 0 0 auto !important;
		max-width: 100% !important;
		order: 1;
	}

	.nsm-stack-heading {
		order: 2;
		margin-left: 0;
		max-width: 100% !important;
		text-align: left !important;
	}

	.nsm-stack-description {
		order: 3;
		max-width: 100% !important;
	}
}
