/* Logo Marquee (acf/marquee)
   ---------------------------------------------------------------------------
   Cloned from glydways.com `.logo-marquee`, with the sizing re-derived because
   our assets are not shaped like theirs.

   THE SIZING TRAP WE AVOIDED
   Their CSS is `img { height: 6.875rem }` inside a `5.5rem` overflow-hidden
   band — i.e. the image is 110px tall in an 88px window, clipping 11px top and
   bottom. That is safe for THEM because their logos are 507x176 canvases with
   28-35% transparent padding on each side, so the visible ink is only ~34-49px
   tall and sits nowhere near the crop.

   Our logos are cropped to the ink (0-2% padding). Copying 110px verbatim would
   have rendered them ~2.5x larger than glydways' logos actually appear AND
   sliced the mark and wordmark. So we match their INK height (~44px) instead of
   their CSS number, and keep the 88px band — which leaves ~22px of clear space
   above and below, so nothing ever clips.

   Anything added later that changes --marquee-logo-h must stay comfortably
   under --marquee-band-h or clipping comes back. */

.marquee--block {
	--marquee-band-h: 5.5rem;   /* 88px — the scrolling strip's height */
	--marquee-logo-h: 2.75rem;  /* 44px — matches glydways' visible ink height */
	--marquee-gap: 1.75rem;     /* horizontal breathing room per logo */
	--marquee-dim: 0.6;         /* glydways dims the whole strip */
	--marquee-fade: 6%;         /* edge fade width (our addition) */
	--marquee-duration: 60s;    /* no-JS fallback; marquee.js computes the real one */

	overflow: hidden; /* the band is full-bleed, the strip must never widen the page */
}

/* Copy colour derives from the band unless the editor picked one explicitly.
   The :not(.has-text-color) guard is what makes the native text-colour control
   still win when it is used. */
.marquee--block.has-black-background-color:not(.has-text-color),
.marquee--block.has-black-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--cream, #efede6);
}

.marquee--head {
	margin-bottom: 2.5rem;
}

.marquee--head:empty {
	display: none;
}

/* ---------------------------------------------------------------- the strip */

.marquee--viewport {
	display: flex;
	height: var(--marquee-band-h);
	overflow: hidden;
	opacity: var(--marquee-dim);

	/* Soft edges instead of glydways' hard cut. Deliberate deviation, signed
	   off by the client. Both properties are needed: Safari only unprefixed
	   since 15.4, and the prefixed form is still what older WebKit reads. */
	-webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--marquee-fade), #000 calc(100% - var(--marquee-fade)), transparent 100%);
	mask-image: linear-gradient(to right, transparent 0, #000 var(--marquee-fade), #000 calc(100% - var(--marquee-fade)), transparent 100%);
}

.marquee--track {
	display: flex;
	flex: none; /* never let flex shrink the track — it would break the -100% maths */
	align-items: center;
	animation: lwh-marquee var(--marquee-duration) linear infinite;
}

/* Paused while the band is off-screen (IntersectionObserver in marquee.js). */
.marquee--viewport.is-paused .marquee--track {
	animation-play-state: paused;
}

.marquee--item {
	display: flex;
	align-items: center;
	flex: none;
	padding: 0 var(--marquee-gap);
}

.marquee--logo {
	height: var(--marquee-logo-h);
	width: auto;
	max-width: none; /* beat any global `img { max-width: 100% }` — tracks are wider than the viewport */

	/* Load-bearing for SVG logos. WordPress stores 1x1 dimensions for SVG
	   uploads, so wp_get_attachment_image() emits width="1" height="1"; modern
	   browsers turn those attributes into `aspect-ratio: 1/1`, which with
	   `width:auto` renders the logo as a squashed 44x44 square. `auto` sends
	   the browser back to the file's real intrinsic ratio (the viewBox). */
	aspect-ratio: auto;
	object-fit: contain;
}

.marquee--link {
	display: flex;
	align-items: center;
}

.marquee--link:focus-visible {
	outline: 2px solid var(--wp--preset--color--gold, #d6c26f);
	outline-offset: 6px;
}

/* Each track slides exactly its own width, so the next identical track lands
   precisely where this one began. */
@keyframes lwh-marquee {
	from { transform: translateX(0); }
	to   { transform: translateX(-100%); }
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 755.98px) {
	.marquee--block {
		--marquee-band-h: 4.25rem;
		--marquee-logo-h: 2rem;
		--marquee-gap: 1.125rem;
	}

	.marquee--head {
		margin-bottom: 1.75rem;
	}
}

/* -------------------------------------------------------- reduced motion */

/* glydways ships no reduced-motion handling at all; ours stops dead rather
   than scrolling. The strip stays legible because the first track renders in
   place — the user simply sees a static row of logos. */
@media (prefers-reduced-motion: reduce) {
	.marquee--track {
		animation: none;
	}
}

/* ------------------------------------------------------------ editor only */

.marquee--empty {
	margin: 0;
	opacity: 0.7;
	font-style: italic;
}

/* ACF renders the block's markup INSIDE the editor's wrapper div, so the
   background/text classes from get_block_wrapper_attributes() land on the
   PARENT in the canvas rather than on our <section>. Without this bridge the
   copy renders near-black on the black band in the editor while the front end
   is correct. Scoped to .acf-block-preview so it is canvas-only. (See the
   WP-core CSS traps list in CLAUDE.md — trap 10.) */
.acf-block-preview.has-black-background-color:not(.has-text-color) .marquee--block,
.acf-block-preview.has-black-background-color:not(.has-text-color) .marquee--block {
	color: var(--wp--preset--color--cream, #efede6);
}
