/**
 * Frontend theming for the tiny-slider "Posts Carousel".
 *
 * tiny-slider handles the layout (track, slide widths, transforms) once its
 * JS runs. These rules only cover: a graceful pre-init state, spacing, and
 * theming for the injected controls/nav so they match the active theme.
 */

.wp-block-query--carousel {
	position: relative;
}

/*
 * Before tiny-slider initialises, show items in a single row that clips
 * overflow, so there is no tall stacked flash of every post on load.
 */
.wp-block-query--carousel .wp-block-post-template {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wp-block-query--carousel .wp-block-post-template:not(.tns-slider) {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 20px;
	overflow: hidden;
	/* Neutralise WP grid layout so the pre-init row does not stack/wrap. */
	grid-template-columns: none !important;
}

.wp-block-query--carousel .wp-block-post-template:not(.tns-slider) > li,
.wp-block-query--carousel .wp-block-post-template:not(.tns-slider) > .wp-block-post {
	flex: 0 0 auto;
	width: 33%;
	margin: 0;
}

/*
 * Once tiny-slider has initialised, IT owns the layout. WordPress adds its own
 * layout classes to core/post-template (is-layout-grid / is-layout-flex plus a
 * wp-container-* grid with responsive media queries). Those set display:grid or
 * display:flex on the exact element tiny-slider controls, which overrides
 * tiny-slider's inline item widths and makes the responsive `items` counts
 * appear not to work. Force the slider element (and its wrappers) back to the
 * block/inline-block layout tiny-slider expects.
 */
.wp-block-query--carousel .wp-block-post-template.tns-slider {
	display: block !important;
	grid-template-columns: none !important;
	gap: 0 !important;
}

.wp-block-query--carousel .tns-outer,
.wp-block-query--carousel .tns-inner {
	display: block !important;
	grid-template-columns: none !important;
	gap: 0 !important;
}

/* Slides: let tiny-slider set the widths inline; just clear WP margins. */
.wp-block-query--carousel .tns-item {
	margin: 0 !important;
	max-width: none !important;
}

.wp-block-query--carousel .wp-block-post-featured-image img {
	width: 100%;
	height: auto;
	display: block;
}

/* ------------------------------------------------------------------ *
 * tiny-slider controls (prev/next arrows).
 * ------------------------------------------------------------------ */
.wp-block-query--carousel .tns-controls {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.wp-block-query--carousel .tns-controls button {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

/* Draw the arrow glyphs (keeps markup text for screen readers). */
.wp-block-query--carousel .tns-controls button::before {
	content: "\2039"; /* ‹ */
	font-size: 1.5rem;
	line-height: 1;
}

.wp-block-query--carousel .tns-controls button[data-controls="next"]::before {
	content: "\203A"; /* › */
}

.wp-block-query--carousel .tns-controls button:hover:not([disabled]) {
	background: currentColor;
	color: var(--wp--preset--color--base, #fff);
}

.wp-block-query--carousel .tns-controls button[disabled] {
	opacity: 0.35;
	cursor: default;
}

.wp-block-query--carousel .tns-controls button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * tiny-slider nav (dots).
 * ------------------------------------------------------------------ */
.wp-block-query--carousel .tns-nav {
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.wp-block-query--carousel .tns-nav button {
	width: 0.6rem;
	height: 0.6rem;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: currentColor;
	opacity: 0.3;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.wp-block-query--carousel .tns-nav button.tns-nav-active {
	opacity: 1;
	transform: scale(1.25);
}

.wp-block-query--carousel .tns-nav button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Screen-reader-only label used inside the control buttons. */
.wp-block-query--carousel .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
