/* Motion layer.
   Mirrors the reference design's motion vocabulary (Konstruktion / Elementor
   Pro): a rotating headline word with a letter wave, scale-on-scroll imagery,
   slide-up entrances, counters, and a horizontal project rail. GSAP drives the
   timing; this file holds the resting states and the no-JS / failure paths. */

/* ------------------------------------------------------------------
   Hidden-until-animated states. Scoped to .js so content is never hidden
   when JavaScript is off, and released by .no-motion if the motion script
   fails to start (set by the inline failsafe in header.php).
   ------------------------------------------------------------------ */

.js [data-reveal],
.js [data-split],
.js [data-intro],
.js .ec-banner__inner,
.js .ec-phero__inner {
	visibility: hidden;
}

.no-motion [data-reveal],
.no-motion [data-split],
.no-motion [data-intro],
.no-motion .ec-banner__inner,
.no-motion .ec-phero__inner {
	visibility: visible !important;
	opacity: 1 !important;
	transform: none !important;
}

/* ------------------------------------------------------------------
   Word mask — headings rise word by word from behind a clip line
   ------------------------------------------------------------------ */

.ec-w {
	display: inline-block;
	overflow: hidden;
	vertical-align: top;
	/* Room for descenders, without changing the line box. */
	padding-bottom: 0.12em;
	margin-bottom: -0.12em;
}

.ec-w__i {
	display: inline-block;
}

/* ------------------------------------------------------------------
   Rotating word with a letter wave
   ------------------------------------------------------------------ */

.ec-rotator {
	position: relative;
	display: inline-flex;
	overflow: hidden;
	vertical-align: top;
	padding-bottom: 0.12em;
	margin-bottom: -0.12em;
	white-space: nowrap;
	transition: width 0.6s var(--ec-ease);
}

.ec-rotator__word {
	display: inline-flex;
}

.ec-rotator__char {
	display: inline-block;
	white-space: pre;
}

/* The rotating word always takes a line of its own. Otherwise a shorter word
   fits beside the lead-in on tablets and the whole headline jumps a line every
   time the word changes. */
.ec-hero__lead {
	display: block;
}

.ec-hero__title .ec-rotator {
	color: var(--ec-white);
}

/* Underline that traces the active word, as on the reference hero */
.ec-rotator::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0.18em;
	bottom: 0.1em;
	height: 0.06em;
	background: var(--ec-green-light);
	transform-origin: left;
	transform: scaleX(var(--ec-rot-line, 1));
}

/* ------------------------------------------------------------------
   Scale-on-scroll — the frame clips, the image moves
   ------------------------------------------------------------------ */

.ec-split__media,
.ec-gallery__item {
	overflow: hidden;
}

/* No permanent will-change: 74 elements held GPU layers for the life of the
   page. GSAP promotes an element only while it is actually tweening. */
[data-scale] img {
	transform-origin: 50% 50%;
}

/* ------------------------------------------------------------------
   Horizontal project rail
   ------------------------------------------------------------------ */

.ec-rail {
	position: relative;
}

.ec-rail__track {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 82%;
	gap: var(--ec-sp-4);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	cursor: grab;
}

.ec-rail__track::-webkit-scrollbar {
	display: none;
}

.ec-rail__track.is-sliding {
	scroll-snap-type: none;
	scroll-behavior: auto;
}

.ec-rail__track.is-dragging {
	cursor: grabbing;
	scroll-snap-type: none;
	scroll-behavior: auto;
	user-select: none;
}

.ec-rail__track.is-dragging a {
	pointer-events: none;
}

.ec-rail__item {
	scroll-snap-align: start;
	min-width: 0;
}

@media (min-width: 640px) {
	.ec-rail__track {
		grid-auto-columns: calc((100% - var(--ec-sp-4)) / 2);
	}
}

@media (min-width: 960px) {
	.ec-rail__track {
		grid-auto-columns: calc((100% - 2 * var(--ec-sp-4)) / 3);
	}
}

.ec-rail__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ec-sp-4);
	margin-top: var(--ec-sp-5);
}

/* On narrow phones the link and arrows left the progress line 4px wide, so
   it gets a full row of its own. */
@media (max-width: 479px) {
	/* Scoped under the bar: the base .ec-rail__progress { flex: 1 } rule sits
	   later in this file and would otherwise win. */
	.ec-rail__bar .ec-rail__progress {
		order: 3;
		flex: 1 1 100%;
	}

	.ec-rail__nav {
		margin-left: auto;
	}
}

.ec-rail__progress {
	position: relative;
	flex: 1;
	height: 1px;
	background: var(--ec-line);
	overflow: hidden;
}

.ec-rail__progress span {
	position: absolute;
	inset: 0;
	background: var(--ec-ink);
	transform-origin: left;
	transform: scaleX(var(--ec-rail-progress, 0));
	transition: transform var(--duration-fast) var(--ease-smooth-out);
}

.ec-rail__nav {
	display: flex;
	gap: var(--ec-sp-1);
}

.ec-rail__btn {
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	padding: 0;
	background: transparent;
	border: 1px solid var(--ec-ink);
	border-radius: 50%;
	color: var(--ec-ink);
	cursor: pointer;
	transition-property: background-color, color, opacity, transform;
	transition-duration: var(--duration-fast);
	transition-timing-function: var(--ease-smooth-out);
}

.ec-rail__btn:hover:not(:disabled) {
	background: var(--ec-ink);
	color: var(--ec-white);
}

.ec-rail__btn:active:not(:disabled) {
	transform: scale(0.96);
}

.ec-rail__btn:disabled {
	opacity: 0.28;
	cursor: default;
}

.ec-rail__btn--prev svg {
	transform: scaleX(-1);
}

/* ------------------------------------------------------------------
   Press feedback and number stability
   ------------------------------------------------------------------ */

.ec-btn {
	transition-property: background-color, border-color, color, transform;
}

.ec-btn:active {
	transform: scale(0.96);
}

.ec-stat__value {
	font-variant-numeric: tabular-nums;
}

/* A hairline on photography so pale images keep an edge on white */
.ec-card__media::after,
.ec-split__media::after {
	content: "";
	position: absolute;
	inset: 0;
	outline: 1px solid rgba(0, 0, 0, 0.08);
	outline-offset: -1px;
	pointer-events: none;
}

.ec-split__media {
	position: relative;
}

/* ------------------------------------------------------------------
   Reduced motion: everything rests in its final state
   ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.js [data-reveal],
	.js [data-split],
	.js [data-intro],
	.js .ec-banner__inner,
	.js .ec-phero__inner {
		visibility: visible;
	}

	.ec-rail__track {
		scroll-behavior: auto;
	}

	.ec-rotator {
		transition: none;
	}

	.ec-btn:active,
	.ec-rail__btn:active {
		transform: none;
	}
}
