/**
 * Creator carousel styles.
 *
 * Values reference the theme's MCDS tokens (--wp--preset--*) rather than
 * hardcoding, so the plugin inherits the design system rather than duplicating it.
 */

.creators-carousel {
	position: relative;
}

/* The track bleeds to the RIGHT VIEWPORT EDGE, not the content container.
   Reference cards sit at 138/438/738/1038/1338 with the fifth cut by the
   viewport at 1440 — that clipped card is the scrollability cue. Held to the
   1160px container the cut landed at 1300, one card early.

   The bleed goes on the TRACK, not the .creators-carousel wrapper: the wrapper
   is `alignwide`, so WordPress caps it at wide-size and forces `margin: auto
   !important`. Overriding both worked but detached the left edge from the
   container. The track has no such constraints — percentages in its margin
   resolve against the 1160px wrapper, so `50% - 50vw` is exactly the negative
   right gutter. See 03-site-anatomy.md §5. */
.creators-carousel__track {
	margin-inline-end: calc(50% - 50vw);

	/* Cards are FIXED at 300px with 40px gaps — not fluid.
	   The reference capture is 1631px native, and earlier measurements scaled it
	   to 1440 (×0.883), which gave 265/35. But 265 × 1631/1440 = 300.1, and
	   `300px` appears verbatim in the reference's own CSS: these are fixed
	   values that do not shrink with the viewport, so the scaled figures were
	   ~12% too small. See D18 in DECISIONS.md. */
	--card-width: 300px;

	display: flex;
	gap: 40px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-padding-inline-start: 0;
	padding-block-end: var(--wp--preset--spacing--md, 16px);

	/* Hide the scrollbar; the pagination control is the affordance. */
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.creators-carousel__track::-webkit-scrollbar {
	display: none;
}

.creators-carousel__track:focus-visible {
	outline: 2px solid var(--wp--preset--color--interactive-pressed, #042F97);
	outline-offset: 4px;
}

@media (max-width: 767px) {
	.creators-carousel__track {
		--card-width: 70vw;
		gap: 16px;
	}
}

/* --- card ---------------------------------------------------------------- */

.creators-card {
	flex: 0 0 var(--card-width);
	width: var(--card-width);
	margin: 0;
	scroll-snap-align: start;
}

.creators-card__media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 9 / 16;
	padding: 0;
	border: 0;
	border-radius: 8px;
	overflow: hidden;
	background: var(--wp--preset--color--background-surface-2, #F1F4F7);
}

.creators-card__poster,
.creators-card__video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.creators-card__play {
	position: absolute;
	inset: 50% auto auto 50%;
	translate: -50% -50%;
	display: block;
	/* Reference geometry: an outlined ring around a large filled triangle, a
	   quarter of the card's width, growing to 35% on hover or keyboard focus. */
	width: 25%;
	aspect-ratio: 1;
	color: #FFFFFF;
	pointer-events: none;
	transition: width 0.25s ease-in;
}

.creators-card__play svg {
	display: block;
	width: 100%;
	height: 100%;
}

.creators-card__media:hover .creators-card__play,
.creators-card__media:focus-visible .creators-card__play {
	width: 35%;
}

.creators-card__media:focus-visible {
	outline: 2px solid var(--wp--preset--color--interactive-pressed, #042F97);
	outline-offset: 3px;
}

/* Only a card with a video is clickable; a static poster is not. */
button.creators-card__media {
	cursor: pointer;
}

/* Once played, the <video> takes the button's place as the media box, so its
   height comes from the 9:16 aspect ratio rather than the figure. */
.creators-card__media.creators-card__video {
	height: auto;
}

.creators-card__caption {
	/* Reference leaves ~25px between the card and its caption. */
	margin-block-start: 18px;
}

/* Caption colour.
   The reference uses Facebook blue #1877F2, but at 18px/400 on white that is
   4.23:1 — below the 4.5 WCAG AA threshold that 06-quality-bar.md sets as the
   baseline. MCDS interactive-primary #0866FF measures 4.82:1 and is the token
   we already adopted for the CTA in D1, so compliance and the design system
   point the same way here; only the legacy reference colour is the outlier.

   Original note: the reference sets the handle in Facebook blue rather than
   the MCDS interactive-text token (#0457CB), and puts the platform glyph AFTER
   the handle. Both matched here; the colour is a deliberate deviation from MCDS
   and is logged in DECISIONS.md. */
.creators-card__handle {
	display: inline-flex;
	align-items: center;
	flex-direction: row;
	gap: 7px;
	color: #0866FF;
	font-size: 16px;
	line-height: 20px;
	text-decoration: none;
}

.creators-card__handle:hover {
	color: var(--wp--preset--color--interactive-hover);
}

.creators-card__platform {
	display: inline-flex;
	align-items: center;
	color: #0866FF;
}

.creators-card__platform svg,
.creators-card__platform img {
	display: block;
	flex: 0 0 19px;
	width: 19px;
	height: 19px;
	overflow: visible;
}

/* --- pagination ---------------------------------------------------------- */

.creators-carousel__controls {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--md, 16px);
	/* Measured: the reference leaves ~111px between caption baseline and the
	   pagination row; the 24px default put it 54px too high. */
	margin-block-start: 79px;
}

.creators-carousel__nav {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wp--preset--color--text-primary, #1C2B33);
	cursor: pointer;
}

.creators-carousel__nav:hover:not(:disabled) {
	background: var(--wp--preset--color--background-surface-2, #F1F4F7);
}

.creators-carousel__nav:disabled {
	color: var(--wp--preset--color--text-disabled, rgba(68, 86, 100, 0.5));
	cursor: default;
}

.creators-carousel__nav:focus-visible {
	outline: 2px solid var(--wp--preset--color--interactive-pressed, #042F97);
	outline-offset: 2px;
}

.creators-carousel__counter {
	margin: 0;
	font-size: var(--wp--custom--typography-preset--label--font-size, 14px);
	line-height: var(--wp--custom--typography-preset--label--line-height, 20px);
	color: var(--wp--preset--color--text-primary, #1C2B33);
	font-variant-numeric: tabular-nums;
}

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

.creators-carousel.is-editor .creators-carousel__track {
	overflow-x: auto;
}

.creators-carousel__editor-note {
	margin-block-start: var(--wp--preset--spacing--md, 16px);
	font-size: 12px;
	color: var(--wp--preset--color--text-secondary, #5D6C7B);
}

@media (prefers-reduced-motion: reduce) {
	.creators-card__play {
		transition: none;
	}
}
