/*
 * Most Popular VST Plugins — list component.
 *
 * Everything is scoped under `.ylm-pp` and driven by custom properties declared
 * on that container, so the component can be restyled from one place and cannot
 * leak into the rest of the theme. Selectors stay shallow and specificity stays
 * low; `!important` is used only where themes routinely reset list and heading
 * styles out from under a plugin (ol margins, li markers).
 *
 * The design is deliberately self-contained rather than inheriting Rehub's card
 * styling: a ranked chart needs a visual hierarchy a generic product card does
 * not have — the rank has to read first, the review count second, the price and
 * button third.
 */

.ylm-pp {
	/* Brand */
	--ylm-pp-accent: #5b3df5;
	--ylm-pp-accent-2: #a435f0;
	--ylm-pp-accent-soft: rgba(91, 61, 245, 0.09);
	--ylm-pp-gradient: linear-gradient(135deg, #5b3df5 0%, #a435f0 100%);

	/* Surfaces */
	--ylm-pp-bg: transparent;
	--ylm-pp-card: #ffffff;
	--ylm-pp-card-hover: #ffffff;
	--ylm-pp-border: rgba(17, 17, 32, 0.09);
	--ylm-pp-border-strong: rgba(17, 17, 32, 0.16);

	/* Ink */
	--ylm-pp-ink: #14142b;
	--ylm-pp-ink-soft: rgba(20, 20, 43, 0.62);
	--ylm-pp-ink-faint: rgba(20, 20, 43, 0.42);
	--ylm-pp-on-dark: #ffffff;

	/* Accents */
	--ylm-pp-star: #ff9d00;
	--ylm-pp-star-empty: rgba(20, 20, 43, 0.16);
	--ylm-pp-save-bg: #e8fbf0;
	--ylm-pp-save-ink: #067647;

	/* Shape */
	--ylm-pp-radius: 18px;
	--ylm-pp-radius-sm: 12px;
	--ylm-pp-shadow: 0 1px 2px rgba(17, 17, 32, 0.05), 0 8px 24px -12px rgba(17, 17, 32, 0.18);
	--ylm-pp-shadow-lift: 0 2px 4px rgba(17, 17, 32, 0.06), 0 18px 40px -16px rgba(17, 17, 32, 0.28);

	background: var(--ylm-pp-bg);
	color: var(--ylm-pp-ink);
	margin: 32px 0;
	font-variant-numeric: tabular-nums;
	container-type: inline-size;
}

.ylm-pp *,
.ylm-pp *::before,
.ylm-pp *::after {
	box-sizing: border-box;
}

/* ===========================================================================
   Stat bar
   =========================================================================== */

.ylm-pp__stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 4px;
	padding: 26px 20px;
	margin-bottom: 26px;
	border-radius: var(--ylm-pp-radius);
	background: var(--ylm-pp-gradient);
	color: var(--ylm-pp-on-dark);
	position: relative;
	overflow: hidden;
	box-shadow: 0 18px 44px -22px rgba(91, 61, 245, 0.9);
}

/* A soft highlight so the panel reads as a surface rather than a flat fill. */
.ylm-pp__stats::after {
	content: "";
	position: absolute;
	top: -60%;
	right: -10%;
	width: 55%;
	height: 220%;
	background: radial-gradient(closest-side, rgba(255, 255, 255, 0.22), transparent);
	pointer-events: none;
}

.ylm-pp__stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	text-align: center;
	position: relative;
	z-index: 1;
}

.ylm-pp__stat-value {
	font-size: clamp(26px, 4.6cqi, 38px);
	font-weight: 800;
	line-height: 1;
	letter-spacing: -0.02em;
}

.ylm-pp__stat-label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	opacity: 0.82;
}

/* ===========================================================================
   List
   =========================================================================== */

.ylm-pp__list {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	display: flex;
	flex-direction: column;
	gap: 12px;
	counter-reset: none;
}

.ylm-pp__list > li::marker,
.ylm-pp__list > li::before {
	content: none !important;
}

.ylm-pp__item {
	display: grid;
	grid-template-columns: 64px 96px minmax(0, 1fr) auto;
	align-items: center;
	gap: 18px;
	padding: 16px 20px 16px 8px;
	margin: 0 !important;
	list-style: none !important;
	background: var(--ylm-pp-card);
	border: 1px solid var(--ylm-pp-border);
	border-radius: var(--ylm-pp-radius);
	box-shadow: var(--ylm-pp-shadow);
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

@media (hover: hover) {
	.ylm-pp__item:hover {
		transform: translateY(-2px);
		border-color: var(--ylm-pp-border-strong);
		box-shadow: var(--ylm-pp-shadow-lift);
		background: var(--ylm-pp-card-hover);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ylm-pp__item {
		transition: none;
	}
	.ylm-pp__item:hover {
		transform: none;
	}
}

/* --- Rank ---------------------------------------------------------------- */

.ylm-pp__rank {
	font-size: 30px;
	font-weight: 800;
	line-height: 1;
	text-align: center;
	letter-spacing: -0.04em;
	color: var(--ylm-pp-ink-faint);
}

/*
 * The top three carry a medal treatment. The payoff of a ranked list is that
 * the leaders read instantly, so they get a filled badge while the rest stay
 * as quiet numerals.
 */
.ylm-pp__item--podium .ylm-pp__rank {
	width: 52px;
	height: 52px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	font-size: 24px;
	color: #ffffff;
	box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.16);
}

.ylm-pp__item--rank1 .ylm-pp__rank {
	background: linear-gradient(150deg, #ffd76e 0%, #f0a500 100%);
	color: #4a2f00;
}

.ylm-pp__item--rank2 .ylm-pp__rank {
	background: linear-gradient(150deg, #e6ebf2 0%, #a9b4c4 100%);
	color: #2f3947;
}

.ylm-pp__item--rank3 .ylm-pp__rank {
	background: linear-gradient(150deg, #f0b088 0%, #c1713f 100%);
	color: #46230c;
}

.ylm-pp__item--rank1 {
	border-color: rgba(240, 165, 0, 0.4);
}

/* --- Thumbnail ----------------------------------------------------------- */

.ylm-pp__thumb {
	width: 96px;
	height: 96px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--ylm-pp-radius-sm);
	background: linear-gradient(180deg, rgba(20, 20, 43, 0.035), rgba(20, 20, 43, 0.06));
	overflow: hidden;
}

.ylm-pp__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	mix-blend-mode: multiply;
}

.ylm-pp__thumb-fallback {
	font-size: 24px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--ylm-pp-ink-faint);
}

/* --- Main column --------------------------------------------------------- */

.ylm-pp__main {
	min-width: 0;
}

.ylm-pp__dev {
	margin: 0 0 3px !important;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ylm-pp-accent);
}

.ylm-pp__name {
	margin: 0 0 8px !important;
	font-size: clamp(16px, 2.2cqi, 19px);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
	color: var(--ylm-pp-ink);
}

.ylm-pp__meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 10px;
	font-size: 13px;
	color: var(--ylm-pp-ink-soft);
}

/* Stars: a grey row with a clipped gold row on top, sized by percentage. */
.ylm-pp__stars {
	position: relative;
	display: inline-block;
	font-size: 14px;
	line-height: 1;
	letter-spacing: 1px;
	color: var(--ylm-pp-star-empty);
}

.ylm-pp__stars::before {
	content: "\2605\2605\2605\2605\2605";
}

.ylm-pp__stars-fill {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	overflow: hidden;
	white-space: nowrap;
	color: var(--ylm-pp-star);
}

.ylm-pp__stars-fill::before {
	content: "\2605\2605\2605\2605\2605";
}

.ylm-pp__rating {
	font-weight: 700;
	color: var(--ylm-pp-ink);
}

/* The review count is the ranking signal, so it is the emphasised figure. */
.ylm-pp__reviews {
	font-weight: 700;
	color: var(--ylm-pp-ink);
}

.ylm-pp__vendor {
	display: inline-flex;
	align-items: center;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--ylm-pp-accent-soft);
	color: var(--ylm-pp-accent);
	font-size: 11.5px;
	font-weight: 700;
}

.ylm-pp__also {
	margin: 6px 0 0 !important;
	font-size: 12px;
	color: var(--ylm-pp-ink-faint);
}

/* --- Buy column ---------------------------------------------------------- */

.ylm-pp__buy {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 7px;
	min-width: 150px;
}

.ylm-pp__price {
	display: flex;
	align-items: baseline;
	gap: 7px;
	line-height: 1;
}

.ylm-pp__price-now {
	font-size: 22px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--ylm-pp-ink);
}

.ylm-pp__price-was {
	font-size: 13px;
	color: var(--ylm-pp-ink-faint);
	text-decoration: line-through;
}

.ylm-pp__save {
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--ylm-pp-save-bg);
	color: var(--ylm-pp-save-ink);
	font-size: 11.5px;
	font-weight: 800;
	letter-spacing: 0.01em;
}

.ylm-pp__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 11px 20px;
	border-radius: 999px;
	background: var(--ylm-pp-gradient);
	color: #ffffff !important;
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
	text-decoration: none !important;
	white-space: nowrap;
	box-shadow: 0 10px 22px -12px rgba(91, 61, 245, 0.95);
	transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.ylm-pp__cta:hover,
.ylm-pp__cta:focus-visible {
	color: #ffffff !important;
	filter: brightness(1.07);
	transform: translateY(-1px);
	box-shadow: 0 14px 26px -12px rgba(91, 61, 245, 1);
}

.ylm-pp__cta:focus-visible {
	outline: 3px solid var(--ylm-pp-accent);
	outline-offset: 3px;
}

.ylm-pp__cta-icon {
	width: 17px;
	height: 17px;
	flex: 0 0 auto;
	transition: transform 0.16s ease;
}

.ylm-pp__cta:hover .ylm-pp__cta-icon {
	transform: translateX(2px);
}

@media (prefers-reduced-motion: reduce) {
	.ylm-pp__cta,
	.ylm-pp__cta-icon {
		transition: none;
	}
	.ylm-pp__cta:hover {
		transform: none;
	}
	.ylm-pp__cta:hover .ylm-pp__cta-icon {
		transform: none;
	}
}

/* ===========================================================================
   Pagination
   =========================================================================== */

.ylm-pp__pagination {
	margin-top: 28px;
}

.ylm-pp__pagination ul {
	list-style: none !important;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin: 0 !important;
	padding: 0 !important;
}

.ylm-pp__pagination li {
	margin: 0 !important;
	list-style: none !important;
}

.ylm-pp__pagination a,
.ylm-pp__pagination span {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 42px;
	height: 42px;
	padding: 0 14px;
	border: 1px solid var(--ylm-pp-border);
	border-radius: var(--ylm-pp-radius-sm);
	background: var(--ylm-pp-card);
	color: var(--ylm-pp-ink) !important;
	font-size: 14px;
	font-weight: 700;
	text-decoration: none !important;
	transition: border-color 0.16s ease, background 0.16s ease;
}

.ylm-pp__pagination a:hover {
	border-color: var(--ylm-pp-accent);
	background: var(--ylm-pp-accent-soft);
}

.ylm-pp__pagination .current {
	background: var(--ylm-pp-gradient);
	border-color: transparent;
	color: #ffffff !important;
}

.ylm-pp__pagination .dots {
	border-color: transparent;
	background: transparent;
}

/* ===========================================================================
   Teaser + empty state
   =========================================================================== */

.ylm-pp__more {
	margin: 22px 0 0 !important;
	text-align: center;
}

.ylm-pp__more-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 11px 22px;
	border: 2px solid var(--ylm-pp-accent);
	border-radius: 999px;
	color: var(--ylm-pp-accent) !important;
	font-weight: 700;
	font-size: 14px;
	text-decoration: none !important;
	transition: background 0.16s ease;
}

.ylm-pp__more-link:hover {
	background: var(--ylm-pp-accent-soft);
}

.ylm-pp__empty {
	padding: 40px 28px;
	border: 1px dashed var(--ylm-pp-border-strong);
	border-radius: var(--ylm-pp-radius);
	text-align: center;
	color: var(--ylm-pp-ink-soft);
}

.ylm-pp__empty-title {
	margin: 0 0 6px !important;
	font-size: 17px;
	font-weight: 700;
	color: var(--ylm-pp-ink);
}

.ylm-pp__empty p:last-child {
	margin-bottom: 0 !important;
}

/* ===========================================================================
   Responsive
   =========================================================================== */

/*
 * Container queries so the component reflows to the space it is actually given
 * — it may sit in a narrow sidebar column on a wide screen. The media query
 * below repeats the breakpoint for browsers without container query support.
 */
@container (max-width: 720px) {
	.ylm-pp__item {
		grid-template-columns: 48px 68px minmax(0, 1fr);
		grid-template-areas:
			"rank thumb main"
			"buy  buy   buy";
		gap: 12px 14px;
		padding: 14px;
	}

	.ylm-pp__rank {
		grid-area: rank;
		font-size: 22px;
	}

	.ylm-pp__item--podium .ylm-pp__rank {
		width: 42px;
		height: 42px;
		font-size: 19px;
	}

	.ylm-pp__thumb {
		grid-area: thumb;
		width: 68px;
		height: 68px;
	}

	.ylm-pp__main {
		grid-area: main;
	}

	/* The offer drops to a full-width row so price and button stay tappable. */
	.ylm-pp__buy {
		grid-area: buy;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		width: 100%;
		padding-top: 12px;
		border-top: 1px solid var(--ylm-pp-border);
	}

	.ylm-pp__cta {
		margin-left: auto;
	}
}

@media (max-width: 720px) {
	.ylm-pp__item {
		grid-template-columns: 48px 68px minmax(0, 1fr);
		grid-template-areas:
			"rank thumb main"
			"buy  buy   buy";
		gap: 12px 14px;
		padding: 14px;
	}

	.ylm-pp__rank {
		grid-area: rank;
		font-size: 22px;
	}

	.ylm-pp__item--podium .ylm-pp__rank {
		width: 42px;
		height: 42px;
		font-size: 19px;
	}

	.ylm-pp__thumb {
		grid-area: thumb;
		width: 68px;
		height: 68px;
	}

	.ylm-pp__main {
		grid-area: main;
	}

	.ylm-pp__buy {
		grid-area: buy;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		width: 100%;
		padding-top: 12px;
		border-top: 1px solid var(--ylm-pp-border);
	}

	.ylm-pp__cta {
		margin-left: auto;
	}

	.ylm-pp__stats {
		padding: 20px 14px;
	}
}

/* ===========================================================================
   Dark mode
   =========================================================================== */

/*
 * Only the tokens are redefined, so every rule above keeps working.
 *
 * This keys on the THEME declaring dark, not on the visitor's OS preference.
 * Those two are independent: someone running a light OS can still switch Rehub
 * into dark mode, and gating on `prefers-color-scheme` as well would leave
 * white cards sitting on a dark page. The theme knows what colour the page
 * behind this component is; the OS does not.
 *
 * The converse is deliberately not handled — a dark OS on a light theme must
 * NOT darken this component, or it becomes the only dark thing on the page.
 */
body.dark-theme .ylm-pp,
body.rh-dark-theme .ylm-pp,
body.dark_mode .ylm-pp,
html[data-theme="dark"] .ylm-pp,
[data-theme="dark"] .ylm-pp {
	--ylm-pp-card: #191a24;
	--ylm-pp-card-hover: #1e1f2b;
	--ylm-pp-border: rgba(255, 255, 255, 0.1);
	--ylm-pp-border-strong: rgba(255, 255, 255, 0.2);
	--ylm-pp-ink: #f2f2f7;
	--ylm-pp-ink-soft: rgba(242, 242, 247, 0.68);
	--ylm-pp-ink-faint: rgba(242, 242, 247, 0.45);
	--ylm-pp-star-empty: rgba(255, 255, 255, 0.2);
	--ylm-pp-accent-soft: rgba(139, 110, 255, 0.16);
	--ylm-pp-accent: #a68cff;
	--ylm-pp-save-bg: rgba(6, 118, 71, 0.22);
	--ylm-pp-save-ink: #4ade9a;
	--ylm-pp-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
	--ylm-pp-shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.5), 0 18px 40px -16px rgba(0, 0, 0, 0.75);
}

/* A multiply blend against a dark plate turns product art to mud. */
body.dark-theme .ylm-pp__thumb img,
body.rh-dark-theme .ylm-pp__thumb img,
body.dark_mode .ylm-pp__thumb img,
html[data-theme="dark"] .ylm-pp__thumb img,
[data-theme="dark"] .ylm-pp__thumb img {
	mix-blend-mode: normal;
}

body.dark-theme .ylm-pp__thumb,
body.rh-dark-theme .ylm-pp__thumb,
body.dark_mode .ylm-pp__thumb,
html[data-theme="dark"] .ylm-pp__thumb,
[data-theme="dark"] .ylm-pp__thumb {
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
}

/* ===========================================================================
   Block editor placeholder
   =========================================================================== */

.ylm-pp-block {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 26px 22px;
	border: 2px dashed rgba(91, 61, 245, 0.35);
	border-radius: 14px;
	background: rgba(91, 61, 245, 0.05);
	text-align: center;
}

.ylm-pp-block__title {
	font-size: 15px;
	font-weight: 700;
	color: #5b3df5;
}

.ylm-pp-block__desc {
	font-size: 13px;
	color: rgba(20, 20, 43, 0.65);
}

.ylm-pp-block__note {
	font-size: 12px;
	font-weight: 600;
	color: rgba(20, 20, 43, 0.45);
}
