/**
 * Home "What's happening at Legend": latest legend-news in a scroll-snap carousel.
 * The track bleeds past the container to the right edge of the viewport.
 * Markup: template-parts/v2/sections/home-news.php (skeletons); live cards from assets/v2/js/home.js
 */
@layer sections {
	.lb-v2-news {
		overflow-x: clip;
	}

	.lb-v2-news__inner {
		--lb-v2-news-bleed: calc((100vw - min(100vw - 2 * var(--lb-v2-gutter), var(--lb-v2-container-max))) / 2);
		display: grid;
		gap: var(--lb-v2-space-7);
	}

	.lb-v2-news__intro {
		display: grid;
		justify-items: start;
		align-content: start;
		gap: var(--lb-v2-cta-gap);
	}

	/* Heading plus the optional paragraph under it. */
	.lb-v2-news__heading {
		display: grid;
		gap: var(--lb-v2-space-3); /* 12px: heading → paragraph */
	}

	/* Roboto 400, 18px / 26px: the shared body text style. */
	.lb-v2-news__text {
		font-size: var(--lb-v2-text-body-size);
		line-height: var(--lb-v2-text-body-leading);
		font-weight: var(--lb-v2-text-body-weight);
		letter-spacing: 0;
	}

	.lb-v2-news__carousel {
		display: grid;
		gap: 1.25rem; /* 20px: arrows → cards; 16px on desktop */
		min-width: 0;
	}

	.lb-v2-news__controls {
		display: flex;
		gap: var(--lb-v2-space-2); /* 8px */
	}

	.lb-v2-news__track {
		display: flex;
		gap: var(--lb-v2-space-5); /* 24px at every width */
		margin-inline-end: calc(-1 * var(--lb-v2-news-bleed));
		padding-inline-end: var(--lb-v2-news-bleed);
		padding-bottom: var(--lb-v2-space-2);
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: 0;
		scrollbar-width: none;
	}

	.lb-v2-news__track::-webkit-scrollbar {
		display: none;
	}

	.lb-v2-news__item {
		flex: 0 0 min(86%, 18.75rem); /* 300px on mobile */
		scroll-snap-align: start;
	}

	/* Figma mobile: the arrows and "View All" share one row between the heading and the cards. */
	@media (max-width: 47.99rem) {
		.lb-v2-news__inner {
			grid-template-columns: 1fr auto;
			gap: 1.25rem 0;
		}

		.lb-v2-news__intro,
		.lb-v2-news__carousel {
			display: contents;
		}

		.lb-v2-news__heading,
		.lb-v2-news__track {
			grid-column: 1 / -1;
		}

		.lb-v2-news__heading {
			margin-bottom: 1.25rem; /* 40px to the arrows */
		}

		.lb-v2-news__controls {
			grid-row: 2;
			grid-column: 1;
		}

		.lb-v2-news__intro > .lb-v2-link {
			grid-row: 2;
			grid-column: 2;
			align-self: center;
		}
	}

	@media (min-width: 48rem) {
		.lb-v2-news__controls {
			justify-content: flex-end;
		}

		.lb-v2-news__item {
			flex-basis: 20.625rem; /* 330px */
		}
	}

	@media (min-width: 80rem) {
		.lb-v2-news {
			padding-bottom: var(--lb-v2-section-space-sm);
		}

		.lb-v2-news__inner {
			grid-template-columns: 31.25rem minmax(0, 1fr); /* 500px intro column */
			gap: 0;
		}

		.lb-v2-news__carousel {
			gap: var(--lb-v2-space-4);
		}

		/* Figma: 80px above and below, 40px on the right. */
		.lb-v2-news__intro {
			padding: var(--lb-v2-space-10) var(--lb-v2-space-7) var(--lb-v2-space-10) 0;
		}
	}

	/* News card */
	.lb-v2-news-card {
		display: flex;
		flex-direction: column;
		height: 100%;
		overflow: hidden;
		border: 1px solid var(--lb-v2-color-grey-300);
		border-radius: var(--lb-v2-radius-card);
		background: var(--lb-v2-color-white);
	}

	.lb-v2-news-card__media {
		width: 100%;
		aspect-ratio: 328 / 275;
		object-fit: cover;
		background: var(--lb-v2-color-grey-100);
	}

	.lb-v2-news-card__body {
		display: flex;
		flex: 1;
		flex-direction: column;
		align-items: flex-start;
		padding: var(--lb-v2-space-5);
	}

	.lb-v2-news-card__meta {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		gap: var(--lb-v2-space-2);
		width: 100%;
	}

	.lb-v2-news-card__category {
		font-size: var(--lb-v2-text-label-size);
		line-height: var(--lb-v2-text-label-leading);
		font-weight: var(--lb-v2-text-label-weight);
		letter-spacing: var(--lb-v2-text-label-tracking);
		text-transform: uppercase;
	}

	.lb-v2-news-card__date {
		margin-inline-start: auto;
		color: var(--lb-v2-color-grey-400);
		font-size: var(--lb-v2-text-meta-size);
		line-height: var(--lb-v2-text-meta-leading);
	}

	.lb-v2-news-card__title {
		margin: var(--lb-v2-space-6) 0 1.25rem; /* Figma: 32px under the meta row, 20px above the link */
		font-size: var(--lb-v2-text-card-title-size);
		line-height: var(--lb-v2-text-card-title-leading);
		font-weight: var(--lb-v2-text-card-title-weight);
	}

	.lb-v2-news-card__title a:hover {
		color: var(--lb-v2-color-accent);
	}

	.lb-v2-news-card .lb-v2-link {
		margin-top: auto;
	}

	/* Skeleton placeholders while admin-ajax loads GCS cards. */
	.lb-v2-news-card--skeleton {
		pointer-events: none;
	}

	.lb-v2-news-card__media--skeleton,
	.lb-v2-news-card__skeleton-line {
		background: linear-gradient(
			90deg,
			var(--lb-v2-color-grey-100) 0%,
			var(--lb-v2-color-grey-200) 50%,
			var(--lb-v2-color-grey-100) 100%
		);
		background-size: 200% 100%;
		animation: lb-v2-news-skeleton 1.2s ease-in-out infinite;
	}

	.lb-v2-news-card__media--skeleton {
		aspect-ratio: 328 / 275;
	}

	.lb-v2-news-card__skeleton-line {
		display: block;
		border-radius: 0.25rem;
		height: 0.875rem;
	}

	.lb-v2-news-card__skeleton-line--meta {
		width: 35%;
		margin-bottom: var(--lb-v2-space-6);
	}

	.lb-v2-news-card__skeleton-line--title {
		width: 100%;
		height: 1.25rem;
		margin-bottom: var(--lb-v2-space-2);
	}

	.lb-v2-news-card__skeleton-line--title-short {
		width: 70%;
		height: 1.25rem;
		margin-bottom: 1.25rem;
	}

	.lb-v2-news-card__skeleton-line--link {
		width: 40%;
		margin-top: auto;
	}

	@keyframes lb-v2-news-skeleton {
		0% {
			background-position: 100% 0;
		}
		100% {
			background-position: -100% 0;
		}
	}

	@media (prefers-reduced-motion: reduce) {
		.lb-v2-news-card__media--skeleton,
		.lb-v2-news-card__skeleton-line {
			animation: none;
		}
	}
}
