/**
 * Flamingo Marine — Tabbed Feature Display (V4 strip-3, top half).
 *
 * A horizontal filmstrip stage on top of a 5-tab bar (WINGS / MEGALOUNGE /
 * GEMINITABLE / SERVINGSHIELDS / FLEXSTORAGE). The active tab carries a pink
 * underline. The active feature image fills ~80% of the inner width and the
 * NEXT feature image peeks ~18% from the right edge (matching the V4 mockup).
 * Clicking (or arrowing to) a tab translateX-slides the track so that tab's
 * panel becomes the main image and the following panel peeks, over ~440ms.
 *
 * Each caption is overlaid on its own image, bottom-left, with a soft scrim for
 * legibility — so the peeking panel shows its caption too. prefers-reduced-motion
 * users get an instant slide. With JS off, the WINGS panel sits as the main image
 * and the tabs are inert (acceptable no-JS path).
 */

.flm-tfd {
	background-color: var(--wp--preset--color--surface-deep);
	color: var(--wp--preset--color--text-primary);
}

/* --- Inner group --------------------------------------------------------- */

/* The inner group ships as layout:default (full-width) so it is NOT pinned to
   the theme's 720px constrained contentSize. We cap it at the wide size and
   centre it, so the stage reads as a large near-full-width centrepiece and the
   tab bar spreads evenly across that full width (matching the V4 mockup). */
.flm-tfd__inner {
	width: 100%;
	max-width: var(--wp--style--global--wide-size, 1180px);
	margin-left: auto;
	margin-right: auto;
}

/* --- Stage (clipping viewport for the filmstrip) ------------------------- */

/* The stage is the fixed-size viewport that clips the track. Its width is the
   full inner width; its height is set by a wide cinematic ratio so the large
   main image reads as the section centrepiece. The track inside is wider than
   the stage (5 panels at ~80% each) and slides under this clip. */
.flm-tfd__stage {
	position: relative;
	border-radius: 8px;
	overflow: hidden;
	width: 100%;
	aspect-ratio: 16 / 7;
}

/* Filmstrip track: a single horizontal flex row of all 5 panels. translateX is
   applied inline by JS to slide the active panel to the left edge. The track is
   the full height of the stage so each panel fills it vertically. */
.flm-tfd__track {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--flm-tfd-gap, 14px);
	height: 100%;
	transform: translateX(0);
	transition: transform 440ms cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}

/* Each panel is ~80% of the stage width, so exactly one full panel shows as the
   main image and the next panel peeks ~18% past the gap on the right edge.
   flex-shrink:0 keeps the basis fixed so the row overflows and slides. */
.flm-tfd__panel {
	position: relative;
	flex: 0 0 var(--flm-tfd-panel-basis, 80%);
	margin: 0;
	height: 100%;
	border-radius: 6px;
	overflow: hidden;
}

.flm-tfd__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Scrim under the caption for legibility over bright water imagery. */
.flm-tfd__panel::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(
		to top,
		rgba(0, 0, 0, 0.55) 0%,
		rgba(0, 0, 0, 0.18) 22%,
		rgba(0, 0, 0, 0) 42%
	);
}

.flm-tfd__caption {
	position: absolute;
	left: var(--wp--preset--spacing--xl);
	right: var(--wp--preset--spacing--xl);
	bottom: var(--wp--preset--spacing--lg);
	z-index: 1;
	max-width: 60ch;
	font-family: var(--wp--preset--font-family--plex, inherit);
	font-size: var(--wp--preset--font-size--body, 1rem);
	font-weight: 400;
	line-height: 1.45;
	color: var(--wp--preset--color--text-primary);
	text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

/* --- Tab bar ------------------------------------------------------------- */

.flm-tfd__tablist {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 0;
	margin-top: var(--wp--preset--spacing--lg);
	/* Hairline baseline the active underline rides over. */
	border-bottom: 1px solid var(--wp--preset--color--surface-elev-1, rgba(255, 255, 255, 0.12));
}

.flm-tfd__tab {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	flex: 1 1 0;
	margin: 0;
	padding: 0 var(--wp--preset--spacing--md) var(--wp--preset--spacing--sm);
	border: 0;
	background: transparent;
	font-family: var(--wp--preset--font-family--plex, inherit);
	/* Feature names read too small under the images (corporate feedback #23) —
	   bumped from the 0.875rem caption size. */
	font-size: 1.0625rem;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	text-align: center;
	white-space: nowrap;
	line-height: 1.2;
	color: var(--wp--preset--color--text-secondary);
	cursor: pointer;
	transition: color 200ms ease;
	-webkit-tap-highlight-color: transparent;
}

/* The active tab's underline doubles as the auto-advance timer (BugHerd #99):
   one pink line under the label that fills 0 -> 100% over the dwell, driven by
   the JS. With JS off it sits full so the active tab still reads as selected.
   Rides -1px over the tablist hairline so it reads as one continuous line. */
.flm-tfd__tab-fill {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 2px;
	background: var(--wp--preset--color--accent-pink);
	transform: scaleX(0);
	transform-origin: left center;
	pointer-events: none;
}
.flm-tfd__tab.is-active .flm-tfd__tab-fill {
	transform: scaleX(1);
}

/* The tabs are equal-width flex columns (flex: 1 1 0) so they spread evenly
   across the full inner width. All labels are centred within their column
   (BugHerd #110/#111 — the end tabs previously hugged the outer edges, which
   read as uneven). */

.flm-tfd__tab:hover {
	color: var(--wp--preset--color--text-primary);
}

.flm-tfd__tab.is-active {
	color: var(--wp--preset--color--text-primary);
}

.flm-tfd__tab:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-pink);
	outline-offset: 3px;
	border-radius: 2px;
}

/* --- Nav arrows + auto-advance progress timer ---------------------------- */

/* Prev/next arrows sit above the stage, right-aligned, styled to match the news
   filmstrip nav so the controls read as one family (BugHerd #12). */
.flm-tfd__nav {
	display: flex;
	justify-content: flex-end;
	margin-bottom: var(--wp--preset--spacing--md);
}

/* Desktop: lift the arrow row up beside the "MEET THE FLAMINGO 5" button in
   the welcome band above (one aligned row — BugHerd g30637912 pt.1; measured
   delta between the two row centers was 121px on home + ROVE). */
@media (min-width: 768px) {
	.flm-tfd__nav.flm-tfd__nav {
		/* Relative offset, NOT a negative margin: a negative margin-block-start
		   collapsed through the section wrapper and dragged its whole box up
		   over the "MEET THE FLAMINGO 5" button, swallowing every click on it
		   (BugHerd #209 — live regression). Relative keeps the box in flow. */
		position: relative;
		top: -121px;
		/* Negative bottom margin pulls the stage up to sit ~48px under the
		   button row instead of the ~138px dead band Megan flagged. */
		margin-bottom: -106px;
		/* Full-width row, but only the arrows should be clickable — anything
		   underneath (the CTA) must stay reachable. */
		pointer-events: none;
	}
	.flm-tfd__nav .flm-tfd__arrows,
	.flm-tfd__nav .flm-tfd__arrow {
		pointer-events: auto;
	}
}

/* Mobile: no arrows — the track is hand-swipable instead (g30637912 pt.2+3). */
@media (max-width: 767px) {
	.flm-tfd__nav { display: none; }
}

.flm-tfd__arrows {
	display: flex;
	gap: 0.5rem;
}

.flm-tfd__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, 0.28);
	background: transparent;
	color: var(--wp--preset--color--text-primary);
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.flm-tfd__arrow:hover,
.flm-tfd__arrow:focus-visible {
	border-color: var(--wp--preset--color--accent-pink);
	background-color: var(--wp--preset--color--accent-pink);
	color: #fff;
	outline: none;
}
.flm-tfd__arrow:focus-visible {
	box-shadow: 0 0 0 2px var(--wp--preset--color--focus);
}

/* The auto-advance timer is now the active tab's underline fill
   (.flm-tfd__tab-fill above), not a separate bar on the stage — BugHerd #99. */

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 767px) {
	/* Taller, more immersive frame on phones (was 4/3, read as too short). */
	.flm-tfd__stage {
		aspect-ratio: 4 / 5;
	}

	/* On narrow screens the peek crowds the small image, so each panel fills the
	   full stage width and the track shows one feature at a time. */
	.flm-tfd {
		--flm-tfd-panel-basis: 100%;
		--flm-tfd-gap: 0px;
	}

	.flm-tfd__panel {
		border-radius: 0;
	}

	/* Stationary tabs (BugHerd #136): the old overflow-x strip panned under
	   touch, so the bar "shifted" while scrolling. Wrap into fixed rows (3 + 2)
	   like desktop instead. Each tab carries its own hairline so the active
	   pink fill rides a line on both rows (the container hairline would only
	   underline the last row). */
	.flm-tfd__tablist {
		flex-wrap: wrap;
		border-bottom: 0;
		/* Rows were touching: a row-1 label's hairline/active bar sat directly
		   on the row-2 labels (client punch list 2026-08-05). */
		row-gap: 0.5rem;
	}

	.flm-tfd__tab {
		flex: 1 1 33%;
		text-align: center;
		/* Slimmer type + padding so three long labels (GEMINITABLE …) fit per
		   row at 390px; the 33% basis then yields 3 + 2 with the last row
		   split 50/50. */
		font-size: 0.75rem;
		padding-inline: 0.25rem;
		/* Clear space between the label and its own hairline. */
		padding-bottom: 0.5rem;
		border-bottom: 1px solid var(--wp--preset--color--surface-elev-1, rgba(255, 255, 255, 0.12));
	}

	.flm-tfd__caption {
		font-size: var(--wp--preset--font-size--caption, 0.875rem);
	}
}

/* --- Reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.flm-tfd__track,
	.flm-tfd__tab {
		transition: none;
	}
}
