.wp-block-tpx-category-collection {
	container-type: inline-size;
	min-width: 0;
}
.tpx-category-template {
	--tpx-category-gap: 24px;
	--tpx-category-effective-columns: var(--tpx-category-columns, 3);
	display: grid;
	grid-template-columns: repeat(var(--tpx-category-effective-columns), minmax(0, 1fr));
	gap: var(--tpx-category-gap);
	list-style: none;
	padding: 0;
	margin: 0;
	box-sizing: border-box;
	min-width: 0;
}
.tpx-category-template > .tpx-category-card {
	position: relative;
	min-width: 0;
	box-sizing: border-box;
	list-style: none;
	margin: 0;
	overflow-wrap: anywhere;
}
.tpx-category-card > :first-child { margin-block-start: 0; }
.tpx-category-card > :last-child { margin-block-end: 0; }
.tpx-category-template.is-fixed {
	grid-template-columns: repeat(var(--tpx-category-effective-columns), var(--tpx-category-width, 280px));
}
.tpx-category-template.is-fixed.is-responsive {
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--tpx-category-width, 280px)), var(--tpx-category-width, 280px)));
	max-width: calc(var(--tpx-category-columns, 3) * var(--tpx-category-width, 280px) + (var(--tpx-category-columns, 3) - 1) * var(--tpx-category-gap));
}
.tpx-category-template.is-stack { grid-template-columns: minmax(0, 1fr); }
.tpx-category-template.is-stack.is-fixed { grid-template-columns: var(--tpx-category-width, 280px); }
.tpx-category-template.is-stack.is-fixed.is-responsive { grid-template-columns: minmax(0, min(100%, var(--tpx-category-width, 280px))); }
.tpx-category-template.is-carousel {
	display: flex;
	max-width: none;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
	padding-block: 2px 12px;
}
.tpx-category-template.is-carousel > .tpx-category-card {
	flex: 0 0 calc((100% - (var(--tpx-category-effective-columns) - 1) * var(--tpx-category-gap)) / var(--tpx-category-effective-columns));
	scroll-snap-align: start;
}
.tpx-category-template.is-carousel.is-fixed > .tpx-category-card { flex-basis: var(--tpx-category-width, 280px); }
.tpx-category-template.is-carousel.is-fixed.is-responsive > .tpx-category-card { flex-basis: min(100%, var(--tpx-category-width, 280px)); }
.tpx-category-carousel-controls { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.tpx-category-carousel-controls[hidden] { display: none; }
.tpx-category-carousel-controls button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
    background: var(--wp--preset--color--warm-grey, #e6e6e6); color: #252525; cursor: pointer;
}
.tpx-category-carousel-controls button::before { content: ''; width: 8px; height: 8px; border: solid currentColor; border-width: 2px 2px 0 0; transform: translateX(-2px) rotate(45deg); }
.tpx-category-carousel-controls [data-direction="previous"]::before { transform: translateX(2px) rotate(-135deg); }
.tpx-category-carousel-controls button:disabled { opacity: .35; cursor: default; }
.tpx-category-carousel-controls button:focus-visible { outline: 2px solid var(--wp--preset--color--red, #ff0033); outline-offset: -3px; }
.tpx-category-card a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
@media (hover: hover) { .tpx-category-carousel-controls button:not(:disabled):hover { background: #d6d6d6; } }
.wp-block-tpx-category-name a { color: inherit; text-decoration: none; }
.wp-block-tpx-category-name a:hover { text-decoration: underline; }
.wp-block-tpx-category-link { display: inline-block; }
.tpx-category-pagination { margin-top: 32px; }
.tpx-category-pagination ul { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; list-style: none; margin: 0; padding: 0; }
.tpx-category-pagination a, .tpx-category-pagination span { display: inline-block; padding: 8px 12px; }
.tpx-category-pagination .current { font-weight: 700; text-decoration: underline; }
@container (max-width: 700px) {
	.tpx-category-template.is-responsive { --tpx-category-effective-columns: min(2, var(--tpx-category-columns, 3)); }
}
@container (max-width: 420px) {
	.tpx-category-template.is-responsive { --tpx-category-effective-columns: 1; }
}

/* Mobile rows reach the screen edges; padding keeps the first/last cards aligned. */
@media (max-width: 700px) {
    .tpx-category-template.is-carousel {
        box-sizing: border-box;
        width: calc(100% + var(--tpx-carousel-left, 0px) + var(--tpx-carousel-right, 0px)) !important;
        max-width: none !important;
        margin-left: calc(-1 * var(--tpx-carousel-left, 0px)) !important;
        margin-right: calc(-1 * var(--tpx-carousel-right, 0px)) !important;
        padding-left: var(--tpx-carousel-left, 0px);
        padding-right: var(--tpx-carousel-right, 0px);
        scroll-padding-left: var(--tpx-carousel-left, 0px);
        scroll-padding-right: var(--tpx-carousel-right, 0px);
        overscroll-behavior-x: contain;
    }
}

@media (max-width: 700px) {
    /* Match Query Loop cards even when the collection uses fixed widths. */
    .tpx-category-template.is-carousel > .tpx-category-card,
    .tpx-category-template.is-carousel.is-fixed > .tpx-category-card,
    .tpx-category-template.is-carousel.is-fixed.is-responsive > .tpx-category-card {
        flex: 0 0 min(310px, 85%);
    }
}
