/*
 * VG Library front end. Colours derive from the theme (currentColor + accent preset)
 * so it sits naturally in light and dark theme variations.
 */
.vg-library,
.vg-stats,
.vg-single {
	--vg-accent: var(--wp--preset--color--accent-3, #503aa8);
	--vg-muted: color-mix(in srgb, currentColor 58%, transparent);
	--vg-line: color-mix(in srgb, currentColor 14%, transparent);
	--vg-surface: color-mix(in srgb, currentColor 4%, transparent);
	--vg-radius: 10px;
	--vg-small: var(--wp--preset--font-size--small, 0.875rem);
	font-size: var(--wp--preset--font-size--medium, 1rem);
}

/* ------------------------------------------------------------------ Stats */

.vg-stats {
	margin-block: 0 3rem;
}

.vg-kpis {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 1rem;
	margin: 0 0 1rem;
}

.vg-kpi {
	display: flex;
	flex-direction: column-reverse;
	gap: 0.25rem;
	padding: 1.1rem 1.25rem;
	border: 1px solid var(--vg-line);
	border-radius: var(--vg-radius);
	background: var(--vg-surface);
}

.vg-kpi dd {
	margin: 0;
	font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.5rem);
	font-weight: 600;
	line-height: 1;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}

.vg-kpi dt {
	font-size: var(--vg-small);
	color: var(--vg-muted);
	line-height: 1.35;
}

.vg-charts {
	display: grid;
	grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
	align-items: start;
	gap: 1rem;
}

@media (max-width: 781px) {
	.vg-charts {
		grid-template-columns: minmax(0, 1fr);
	}
}

.vg-chart {
	margin: 0;
	padding: 1.25rem;
	border: 1px solid var(--vg-line);
	border-radius: var(--vg-radius);
}

.vg-chart figcaption {
	font-size: var(--vg-small);
	font-weight: 600;
	margin-bottom: 1rem;
}

/* Vertical columns: completions per year. */
.vg-columns {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(0, 1fr);
	gap: 0.4rem;
	align-items: end;
}

.vg-columns li {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: center;
	min-width: 0;
	gap: 0.3rem;
}

.vg-columns__bar {
	width: 100%;
	max-width: 44px;
	/* --vg-size is 0–100; the tallest column is 160px. */
	height: calc(var(--vg-size) * 1.6px);
	min-height: 2px;
	border-radius: 4px 4px 0 0;
	background: var(--vg-accent);
}

.vg-columns__value,
.vg-columns__label {
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
	line-height: 1;
}

.vg-columns__label {
	color: var(--vg-muted);
}

/* Horizontal bars: platforms. */
.vg-bars {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.45rem;
}

.vg-bars li {
	display: grid;
	grid-template-columns: 7.5rem minmax(0, 1fr) 2rem;
	align-items: center;
	gap: 0.6rem;
	font-size: var(--vg-small);
}

.vg-bars__label {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.vg-bars__track {
	height: 8px;
	border-radius: 4px;
	background: var(--vg-surface);
}

.vg-bars__bar {
	display: block;
	height: 100%;
	width: var(--vg-size);
	min-width: 4px;
	border-radius: 4px;
	background: var(--vg-accent);
}

.vg-bars__value {
	text-align: right;
	font-variant-numeric: tabular-nums;
	color: var(--vg-muted);
}

/* ------------------------------------------------------------------ Now playing */

.vg-playing {
	margin: 0 0 2.5rem;
}

.vg-section-title {
	margin: 0 0 1rem;
	font-size: var(--wp--preset--font-size--large, 1.25rem);
	font-weight: 600;
	letter-spacing: -0.01em;
}

/* ------------------------------------------------------------------ Filters */

.vg-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 1.75rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--vg-line);
}

.vg-select select,
.vg-filters__submit {
	font: inherit;
	font-size: var(--vg-small);
	line-height: 1.2;
	height: 2.25rem;
	padding: 0 0.75rem;
	border: 1px solid var(--vg-line);
	border-radius: 999px;
	background-color: transparent;
	color: inherit;
	cursor: pointer;
}

.vg-select select {
	appearance: none;
	padding-right: 2rem;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
	background-size: 5px 5px;
	background-repeat: no-repeat;
}

.vg-select select:hover,
.vg-filters__submit:hover {
	border-color: color-mix(in srgb, currentColor 40%, transparent);
}

.vg-select select:focus-visible,
.vg-filters__submit:focus-visible {
	outline: 2px solid var(--vg-accent);
	outline-offset: 2px;
}

.vg-filters.is-auto .vg-filters__submit {
	display: none;
}

.vg-filters__count {
	margin: 0 0 0 auto;
	font-size: var(--vg-small);
	color: var(--vg-muted);
}

.vg-filters__count a {
	color: inherit;
}

/* ------------------------------------------------------------------ Grid */

.vg-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 2rem 1.25rem;
}

@media (max-width: 600px) {
	.vg-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 1.5rem 1rem;
	}
}

.vg-card {
	min-width: 0;
	margin: 0;
}

.vg-card__link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.vg-card__art {
	position: relative;
	display: block;
	aspect-ratio: 264 / 374;
	border-radius: 8px;
	overflow: hidden;
	background: var(--vg-surface);
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 14px rgb(0 0 0 / 0.08);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Beat theme rules like img { height: auto } that distort the box art. */
.vg-card__art img.vg-card__cover {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	margin: 0;
}

.vg-card__link:hover .vg-card__art,
.vg-card__link:focus-visible .vg-card__art {
	transform: translateY(-3px);
	box-shadow: 0 2px 4px rgb(0 0 0 / 0.1), 0 10px 24px rgb(0 0 0 / 0.14);
}

.vg-card__link:focus-visible {
	outline: none;
}

.vg-card__link:focus-visible .vg-card__art {
	outline: 2px solid var(--vg-accent);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.vg-card__art {
		transition: none;
	}
	.vg-card__link:hover .vg-card__art {
		transform: none;
	}
}

.vg-card__placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 1rem;
	text-align: center;
	font-size: var(--vg-small);
	color: var(--vg-muted);
}

.vg-card__title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-top: 0.7rem;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: -0.005em;
}

.vg-card__meta {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.8rem;
	color: var(--vg-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Overlays on the cover. */
.vg-card__art .vg-badge,
.vg-card__loan {
	position: absolute;
	left: 0.5rem;
	font-size: 0.7rem;
	font-weight: 600;
	line-height: 1;
	padding: 0.35rem 0.55rem;
	border-radius: 999px;
	backdrop-filter: blur(6px);
}

.vg-card__art .vg-badge {
	top: 0.5rem;
}

.vg-card__loan {
	bottom: 0.5rem;
	color: #fff;
	background: rgb(17 17 17 / 0.72);
}

.vg-card__loan::before {
	content: "↗ ";
}

.vg-card__loan--borrowed::before {
	content: "↙ ";
}

/* ------------------------------------------------------------------ Badges */

.vg-badge {
	display: inline-block;
	padding: 0.15em 0.6em;
	border-radius: 999px;
	font-size: 0.8em;
	background: #e5e7eb;
	color: #111827;
}

.vg-badge--playing { background: #dbeafe; color: #1e3a8a; }
.vg-badge--completed { background: #dcfce7; color: #14532d; }
.vg-badge--backlog { background: #fef3c7; color: #78350f; }
.vg-badge--abandoned { background: #fee2e2; color: #7f1d1d; }
.vg-badge--wishlist { background: #f3e8ff; color: #581c87; }
.vg-badge--on_hold { background: #e5e7eb; color: #1f2937; }

/* ------------------------------------------------------------------ Pagination & empty */

.vg-pages {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.35rem;
	margin-top: 2.5rem;
}

.vg-pages a {
	min-width: 2.25rem;
	height: 2.25rem;
	display: inline-grid;
	place-items: center;
	border: 1px solid var(--vg-line);
	border-radius: 999px;
	font-size: var(--vg-small);
	color: inherit;
	text-decoration: none;
}

.vg-pages a:hover {
	border-color: color-mix(in srgb, currentColor 40%, transparent);
}

.vg-pages [aria-current] {
	border-color: transparent;
	background: var(--vg-accent);
	color: #fff;
}

.vg-empty {
	padding: 3rem 1rem;
	text-align: center;
	color: var(--vg-muted);
	border: 1px dashed var(--vg-line);
	border-radius: var(--vg-radius);
}

/* ------------------------------------------------------------------ Single game */

.vg-single {
	display: grid;
	gap: 1.25rem;
	margin-bottom: 2rem;
}

.vg-single__cover {
	max-width: 220px;
	height: auto;
	border-radius: 8px;
}

.vg-single__facts {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.4rem 1.25rem;
	margin: 0;
	padding: 1.25rem;
	border: 1px solid var(--vg-line);
	border-radius: var(--vg-radius);
	font-size: var(--vg-small);
}

.vg-single__facts dt {
	color: var(--vg-muted);
}

.vg-single__facts dd {
	margin: 0;
}

/* ------------------------------------------------------------------ Score label */

/* Metacritic colours and thresholds: 75+ green, 50–74 yellow, under 50 red.
   Square = Metacritic (entered by hand), round = IGDB critic average. */
.vg-score {
	display: inline-grid;
	place-items: center;
	min-width: 2rem;
	height: 2rem;
	padding: 0 0.3rem;
	border-radius: 6px;
	font-size: 0.85rem;
	font-weight: 700;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	color: #1a1a1a;
	background: #00ce7a;
}

.vg-score--mixed {
	background: #ffbd3f;
}

.vg-score--bad {
	background: #ff6874;
}

.vg-score--igdb {
	border-radius: 999px;
}

.vg-card__art .vg-score {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
}
