.wallpaper-gallery,
.wallpaper-grid,
.wallpaper-card {
	min-width: 0;
}

.wallpaper-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(0.5rem, 2vw, 1.25rem);
}

.wallpaper-card__trigger {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	border-radius: var(--bc-radius-md);
	background: transparent;
	color: inherit;
	cursor: zoom-in;
	text-align: start;
}

.wallpaper-card__media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 9 / 16;
	border: 1px solid var(--bc-color-border-subtle);
	border-radius: var(--bc-radius-md);
	background: var(--bc-color-surface-elevated);
	overflow: hidden;
	transition: border-color var(--bc-transition-fast);
}

.wallpaper-card__media--placeholder::before {
	position: absolute;
	inset: 12%;
	border: 1px solid var(--bc-color-border-strong);
	border-radius: 50%;
	content: "";
}

.wallpaper-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--bc-transition-normal);
}

.wallpaper-card__label {
	position: absolute;
	right: 0.65rem;
	bottom: 0.65rem;
	display: inline-flex;
	min-width: 2rem;
	min-height: 2rem;
	align-items: center;
	justify-content: center;
	padding-inline: 0.45rem;
	border: 1px solid rgb(255 255 255 / 0.24);
	border-radius: var(--bc-radius-pill);
	background: rgb(5 5 5 / 0.82);
	color: var(--bc-color-text-primary);
	font-size: var(--bc-font-size-xs);
	font-weight: 750;
	letter-spacing: 0.06em;
}

.wallpaper-card__trigger:hover .wallpaper-card__media,
.wallpaper-card__trigger:focus-visible .wallpaper-card__media {
	border-color: var(--bc-color-text-muted);
}

.wallpaper-card__trigger:hover .wallpaper-card__image {
	transform: scale(1.015);
}

.wallpaper-card__trigger:focus-visible {
	outline: 2px solid var(--bc-color-text-primary);
	outline-offset: 3px;
}

.has-wallpaper-viewer-open {
	overflow: hidden;
}

.wallpaper-viewer {
	position: fixed;
	inset: 0;
	z-index: 2000;
	padding: clamp(0.75rem, 3vw, 2rem);
	background: rgb(0 0 0 / 0.9);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.wallpaper-viewer[hidden] {
	display: none;
}

.wallpaper-viewer__dialog {
	position: relative;
	display: grid;
	width: min(100%, 68rem);
	min-width: 0;
	gap: clamp(1.25rem, 4vw, 3rem);
	margin: auto;
	padding: clamp(1rem, 3vw, 2rem);
	border: 1px solid var(--bc-color-border-subtle);
	border-radius: var(--bc-radius-lg);
	background: var(--bc-color-surface-elevated);
	box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 0.45);
}

.wallpaper-viewer__close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	z-index: 1;
	display: grid;
	width: 2.75rem;
	height: 2.75rem;
	place-items: center;
	padding: 0;
	border: 1px solid var(--bc-color-border-strong);
	border-radius: var(--bc-radius-pill);
	background: rgb(5 5 5 / 0.88);
	color: var(--bc-color-text-primary);
	cursor: pointer;
	font-size: 1.6rem;
	line-height: 1;
}

.wallpaper-viewer__close:hover {
	border-color: var(--bc-color-text-primary);
}

.wallpaper-viewer__close:focus-visible,
.wallpaper-viewer__download:focus-visible {
	outline: 2px solid var(--bc-color-text-primary);
	outline-offset: 3px;
}

.wallpaper-viewer__preview {
	display: grid;
	width: min(100%, 25rem);
	aspect-ratio: 9 / 16;
	place-items: center;
	justify-self: center;
	margin: 0;
	border: 1px solid var(--bc-color-border-subtle);
	border-radius: var(--bc-radius-md);
	background: #000;
	overflow: hidden;
}

.wallpaper-viewer__preview img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.wallpaper-viewer__details {
	min-width: 0;
	align-self: center;
}

.wallpaper-viewer__eyebrow {
	margin: 0 0 var(--bc-space-md);
	color: var(--bc-color-accent);
	font-size: var(--bc-font-size-xs);
	font-weight: 750;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.wallpaper-viewer__details h3 {
	margin: 0;
	font-size: clamp(1.75rem, 5vw, 3rem);
	letter-spacing: -0.035em;
	line-height: 1.05;
	overflow-wrap: anywhere;
}

.wallpaper-viewer__metadata {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--bc-space-md);
	margin-block: clamp(1.5rem, 4vw, 2.5rem);
}

.wallpaper-viewer__metadata div {
	min-width: 0;
	padding-block-start: var(--bc-space-md);
	border-top: 1px solid var(--bc-color-border-subtle);
}

.wallpaper-viewer__metadata dt {
	color: var(--bc-color-text-muted);
	font-size: var(--bc-font-size-xs);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.wallpaper-viewer__metadata dd {
	margin: var(--bc-space-xs) 0 0;
	color: var(--bc-color-text-primary);
	font-weight: 650;
	overflow-wrap: anywhere;
}

.wallpaper-viewer__download[aria-disabled="true"] {
	border-color: var(--bc-color-border-strong);
	background: var(--bc-color-surface-secondary);
	color: var(--bc-color-text-muted);
	cursor: not-allowed;
}

@media (min-width: 36rem) {
	.wallpaper-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 48rem) {
	.wallpaper-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.wallpaper-viewer__dialog {
		grid-template-columns: minmax(17rem, 0.85fr) minmax(16rem, 1fr);
		align-items: center;
	}

	.wallpaper-viewer__preview {
		max-height: calc(100vh - 4rem);
		max-height: calc(100dvh - 4rem);
	}
}

@media (min-width: 64rem) {
	.wallpaper-grid {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}
}

@media (min-width: 78rem) {
	.wallpaper-grid {
		grid-template-columns: repeat(6, minmax(0, 1fr));
	}
}

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