/**
 * Affiliate Product Manager — base block styles.
 *
 * Two rules make this overridable without a specificity fight:
 *   1. every colour and measure is a --apm-* custom property, so a theme can
 *      restyle the blocks by redefining variables alone;
 *   2. component selectors are single-class, so any theme rule with a
 *      container (.wrapper .apm-tile) wins on specificity.
 *
 * Override via Settings → Block styles, or from the theme.
 */

:root {
	--apm-accent: #ff9900;
	--apm-accent-hover: #e88a00;
	--apm-accent-text: #111;

	--apm-text: #1b1d1f;
	--apm-muted: #5b6166;
	--apm-border: #e4e4e4;
	--apm-surface: #fff;
	--apm-surface-alt: #fafafa;

	--apm-badge-primary-bg: #1b1d1f;
	--apm-badge-primary-text: #fff;
	--apm-badge-outline-border: #1b1d1f;
	--apm-badge-outline-text: #1b1d1f;
	--apm-badge-muted-bg: #eef0f1;
	--apm-badge-muted-text: #5b6166;

	--apm-radius: 10px;
	--apm-gap: 1.25em;
	--apm-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	--apm-sticky-z: 900;
	--apm-sticky-shadow: 0 -2px 14px rgba(0, 0, 0, 0.14);
}

.apm-btn {
	display: inline-block;
	padding: 0.6em 1.4em;
	background: var(--apm-accent);
	color: var(--apm-accent-text);
	font-weight: 600;
	text-decoration: none;
	border-radius: 6px;
	line-height: 1.2;
	transition: background 0.15s ease, transform 0.15s ease;
}

.apm-btn:hover,
.apm-btn:focus {
	background: var(--apm-accent-hover);
	color: var(--apm-accent-text);
	transform: translateY(-1px);
}

/* Single card */
.apm-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.75em;
	padding: 1em;
	border: 1px solid #e4e4e4;
	border-radius: 10px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.apm-card__img img {
	max-width: 100%;
	height: auto;
	object-fit: contain;
}

.apm-card__title {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.35;
}

/* Card grid */
.apm-cards {
	display: grid;
	gap: 1.25em;
	grid-template-columns: 1fr;
}

@media (min-width: 600px) {
	.apm-cards--cols-2 { grid-template-columns: repeat(2, 1fr); }
	.apm-cards--cols-3 { grid-template-columns: repeat(2, 1fr); }
	.apm-cards--cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
	.apm-cards--cols-3 { grid-template-columns: repeat(3, 1fr); }
	.apm-cards--cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Feature */
.apm-feature {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1.5em;
	padding: 1.5em;
	border-radius: 12px;
	background: #fafafa;
}

.apm-feature__img,
.apm-feature__body {
	flex: 1 1 280px;
}

.apm-feature__img img {
	max-width: 100%;
	height: auto;
	object-fit: contain;
}

.apm-feature__title {
	margin-top: 0;
}

.apm-feature__desc {
	margin-bottom: 1em;
}

/* ---------------------------------------------------------------------------
 * Badges and specs — shared by the tile and the feature block.
 * ------------------------------------------------------------------------ */

.apm-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em;
	margin-bottom: 0.6em;
}

.apm-badge {
	display: inline-block;
	padding: 0.25em 0.7em;
	border: 1px solid transparent;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.4;
	background: var(--apm-badge-muted-bg);
	color: var(--apm-badge-muted-text);
}

.apm-badge--primary {
	background: var(--apm-badge-primary-bg);
	color: var(--apm-badge-primary-text);
}

.apm-badge--outline {
	background: transparent;
	border-color: var(--apm-badge-outline-border);
	color: var(--apm-badge-outline-text);
}

.apm-specs {
	margin: 0 0 1em;
}

.apm-spec {
	display: flex;
	gap: 0.5em;
	padding: 0.35em 0;
	border-bottom: 1px solid var(--apm-border);
	font-size: 0.9rem;
}

.apm-spec:last-child {
	border-bottom: 0;
}

.apm-spec dt {
	flex: 0 0 40%;
	margin: 0;
	color: var(--apm-muted);
}

.apm-spec dd {
	flex: 1 1 auto;
	margin: 0;
	color: var(--apm-text);
}

/* ---------------------------------------------------------------------------
 * Tile.
 * ------------------------------------------------------------------------ */

.apm-tile {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--apm-border);
	border-radius: var(--apm-radius);
	background: var(--apm-surface);
	box-shadow: var(--apm-shadow);
}

.apm-tile__media {
	display: block;
	padding: 1em 1em 0;
	text-align: center;
}

.apm-tile__media img {
	max-width: 100%;
	height: auto;
	object-fit: contain;
}

.apm-tile__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 1em;
}

.apm-tile__title {
	margin: 0 0 0.4em;
	font-size: 1.05rem;
	line-height: 1.35;
}

.apm-tile__rating {
	margin: 0 0 0.6em;
	color: var(--apm-muted);
	font-size: 0.85rem;
}

.apm-tile__desc {
	margin: 0 0 0.9em;
	line-height: 1.5;
}

.apm-tile__foot {
	margin-top: auto;
	padding-top: 0.4em;
}

/* ---------------------------------------------------------------------------
 * Tile grid: one column on phones, two on tablets, `cols` on desktop.
 * ------------------------------------------------------------------------ */

.apm-tiles {
	display: grid;
	gap: var(--apm-gap);
	grid-template-columns: 1fr;
}

.apm-tiles__lead {
	margin-bottom: var(--apm-gap);
}

@media (min-width: 640px) {
	.apm-tiles {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 1000px) {
	.apm-tiles--cols-2 {
		grid-template-columns: repeat(2, 1fr);
	}

	.apm-tiles--cols-3 {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* ---------------------------------------------------------------------------
 * Sticky bar.
 * ------------------------------------------------------------------------ */

.apm-sticky {
	position: fixed;
	left: 0;
	right: 0;
	z-index: var(--apm-sticky-z);
	padding: 0.6em 1em;
	background: var(--apm-surface);
	box-shadow: var(--apm-sticky-shadow);
	transition: transform 0.25s ease;
	will-change: transform;
}

.apm-sticky--bottom {
	bottom: 0;
	transform: translateY(110%);
}

.apm-sticky--top {
	top: 0;
	transform: translateY(-110%);
}

.apm-sticky.is-on {
	transform: translateY(0);
}

.apm-sticky__inner {
	display: flex;
	align-items: center;
	gap: 0.9em;
	max-width: 1100px;
	margin: 0 auto;
}

.apm-sticky__media img {
	display: block;
	width: 48px;
	height: auto;
	object-fit: contain;
}

.apm-sticky__text {
	flex: 1 1 auto;
	min-width: 0;
}

.apm-sticky__title {
	margin: 0;
	overflow: hidden;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.apm-sticky__desc {
	margin: 0;
	color: var(--apm-muted);
	font-size: 0.8rem;
	line-height: 1.3;
}

.apm-sticky__btn {
	flex: 0 0 auto;
}

/* The thumbnail is the first thing to go when the bar gets tight. */
@media (max-width: 480px) {
	.apm-sticky__media {
		display: none;
	}

	.apm-sticky__desc {
		display: none;
	}
}

@media (min-width: 1000px) {
	.apm-sticky--hide-desktop {
		display: none;
	}
}

@media (max-width: 999px) {
	.apm-sticky--hide-mobile {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.apm-btn,
	.apm-sticky {
		transition: none;
	}

	.apm-btn:hover,
	.apm-btn:focus {
		transform: none;
	}
}

/* ---------------------------------------------------------------------------
 * Image slider — [apm_card_slider] and [apm_feature_slider].
 *
 * Slides are laid out in a flex row and moved with a transform, so nothing
 * reflows while paging. The square aspect ratio is what keeps the block from
 * jumping: Amazon photos vary wildly in shape, and letting each slide size
 * itself would resize the whole card on every step.
 *
 * Dots and thumbnails are two views of the same control. The strip is useful
 * where there is room for it and unreadable where there is not, so the
 * breakpoint swaps one for the other rather than showing both.
 * ------------------------------------------------------------------------ */

.apm-slider {
	position: relative;
}

.apm-slider__viewport {
	position: relative;
	overflow: hidden;
	border-radius: var(--apm-radius);
}

.apm-slider__track {
	display: flex;
	transition: transform 0.3s ease;
}

.apm-slider__slide {
	flex: 0 0 100%;
	min-width: 100%;
}

.apm-slider__slide a {
	display: block;
	line-height: 0;
}

.apm-slider__slide img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
}

.apm-slider__arrow {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: var(--apm-text);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	box-shadow: var(--apm-shadow);
	transform: translateY(-50%);
}

.apm-slider__arrow:hover,
.apm-slider__arrow:focus-visible {
	background: #fff;
}

.apm-slider__arrow--prev {
	left: 8px;
}

.apm-slider__arrow--next {
	right: 8px;
}

/* Dots: mobile only. */
.apm-slider__dots {
	display: none;
	justify-content: center;
	gap: 6px;
	margin-top: 8px;
}

.apm-slider__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--apm-border);
	cursor: pointer;
}

.apm-slider__dot.is-active {
	background: var(--apm-accent);
}

/* Thumbnails: desktop only. */
.apm-slider__thumbs {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	margin-top: 8px;
}

.apm-slider__thumb {
	overflow: hidden;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	background: none;
	line-height: 0;
	cursor: pointer;
}

.apm-slider__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.apm-slider__thumb.is-active {
	border-color: var(--apm-accent);
}

@media (max-width: 599px) {
	.apm-slider__dots {
		display: flex;
	}

	.apm-slider__thumbs {
		display: none;
	}
}

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