/* SoundSelections: one stylesheet, organised top-down:
   fonts → tokens → base → layout → masthead → toolbar → filters → grid/cards
   → states → buttons → dialog → toast → footer → utilities → motion. */

/* Fonts ---------------------------------------------------------------- */

@font-face {
	font-family: 'DM Sans';
	font-style: normal;
	font-weight: 100 1000;
	font-display: swap;
	src: url('../fonts/dm-sans-latin-wght-normal.woff2') format('woff2');
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
	font-family: 'DM Sans';
	font-style: normal;
	font-weight: 100 1000;
	font-display: swap;
	src: url('../fonts/dm-sans-latin-ext-wght-normal.woff2') format('woff2');
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Tokens --------------------------------------------------------------- */

:root {
	color-scheme: dark;

	/* Surfaces: black page; buttons, chips, inputs and tabs sit at 10% grey, 16% on hover. */
	--black: #000;
	--grey-10: hsl(0 0% 10%);
	--grey-16: hsl(0 0% 16%);
	--line: hsl(0 0% 100% / 0.1);

	/* Text: white, with 84% grey for anything secondary. */
	--white: #fff;
	--text: var(--white);
	--text-2: hsl(0 0% 84%);

	/* The one accent: cyan. Used as a black-to-cyan gradient, a glow, or a thin outline. */
	--cyan: #00ffff;
	--cyan-wash: linear-gradient(90deg, hsl(180 100% 50% / 0.3), hsl(180 100% 50% / 0.1));
	--cyan-line: hsl(180 100% 50% / 0.55);

	/* Frosted glass, as on the player bar. */
	--glass: hsl(0 0% 12% / 0.62);
	--glass-blur: blur(28px) saturate(1.8);

	--font: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

	--radius-s: 0.25rem;
	--radius-m: 0.75rem;
	--radius-l: 1.25rem;
	--radius-pill: 999px;

	--gutter: clamp(1rem, 4vw, 2.5rem);
	--gap: clamp(0.75rem, 2vw, 1.5rem);
	--max-width: 80rem;
	--tap: 2.75rem;

	--ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
	--fast: 120ms;
	--base: 200ms;
	--slow: 320ms;
}

/* Base ----------------------------------------------------------------- */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: 6rem;
	scrollbar-color: hsl(0 0% 40%) transparent; /* thumb is 3.7:1 against the black track */
	accent-color: var(--cyan);
}

body {
	margin: 0;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--black);
	color: var(--text);
	font-family: var(--font);
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.5;
}

::selection {
	background: var(--cyan);
	color: var(--black);
}

h1,
h2,
p {
	margin: 0;
}

/* `hidden` must win over component display rules (e.g. inline-flex chips). */
[hidden] {
	display: none !important;
}

img {
	display: block;
	max-width: 100%;
}

button,
input,
select {
	font: inherit;
	color: inherit;
}

a {
	color: var(--text);
	text-underline-offset: 0.2em;
	transition: color var(--fast) ease-out;
}

a:hover {
	color: var(--text-2);
}

:focus-visible {
	outline: 2px solid var(--cyan);
	outline-offset: 2px;
}

.icon {
	flex: none;
}

/* Layout --------------------------------------------------------------- */

.container {
	width: 100%;
	max-width: var(--max-width);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

main {
	flex: 1;
	padding-block: 1.25rem 3rem;
}

main:focus {
	outline: none;
}

/* Masthead: pure black, a big two-weight wordmark, a hairline dot grid ---------- */

.masthead {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	padding-block: clamp(2.25rem, 7vw, 5rem) clamp(1.75rem, 4vw, 3.25rem);
	background: var(--black);
}

/* Texture only on the right, fading out behind the text so nothing competes with it.
   Left off phones, where there is no empty space to put it in. */
@media (min-width: 48rem) {
	.masthead::before {
		content: '';
		position: absolute;
		inset: 0;
		z-index: -1;
		background: radial-gradient(circle, hsl(0 0% 100% / 0.16) 1px, transparent 1.5px) 0 0 / 24px 24px;
		-webkit-mask-image: linear-gradient(100deg, transparent 45%, #000 100%);
		mask-image: linear-gradient(100deg, transparent 45%, #000 100%);
	}
}

.site-name {
	/* Fills the width on phones; capped on large screens. */
	font-size: clamp(2.25rem, 12.5vw, 7rem);
	line-height: 0.95;
	letter-spacing: -0.05em;
	white-space: nowrap;
}

@media (min-width: 48rem) {
	.site-name {
		font-size: clamp(3rem, 9vw, 7rem);
	}
}

.site-name-bold {
	font-weight: 700;
}

.site-name-light {
	font-weight: 300;
}

.tagline {
	margin-top: clamp(0.75rem, 2vw, 1.125rem);
	color: var(--text-2);
	/* Scales with the screen so it stays on one line from about 800px up, wrapping only when it must. */
	font-size: clamp(1rem, 2vw, 1.375rem);
	letter-spacing: -0.01em;
	/* `pretty` only avoids a lone last word; it never narrows the text to even out the lines. */
	text-wrap: pretty;
}

.masthead-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.375rem 0.875rem;
	margin-top: clamp(1rem, 2.5vw, 1.5rem);
	color: var(--text-2);
	font-size: 0.75rem;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.live {
	display: inline-flex;
	align-items: center;
	gap: 0.625rem;
	color: var(--text);
}

.live-dot {
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--cyan);
	animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
	0% {
		box-shadow: 0 0 0 0 hsl(180 100% 50% / 0.55);
	}
	70%,
	100% {
		box-shadow: 0 0 0 0.5rem hsl(180 100% 50% / 0);
	}
}

/* A divider between the two facts, only where they sit on one line. */
@media (min-width: 40rem) {
	.masthead-stats::before {
		content: '';
		display: inline-block;
		width: 1px;
		height: 0.75em;
		margin-right: 0.875rem;
		background: hsl(0 0% 100% / 0.3);
	}
}

/* Toolbar: frosted glass, like the player bar -------------------------------- */

.toolbar {
	position: sticky;
	top: 0;
	z-index: 10;
	container: toolbar / scroll-state;
	padding-block: 0.75rem;
}

/* The frosted-glass bar sits behind the controls. It is only drawn once the toolbar is pinned
   to the top of the screen (Chrome and Edge); until then the controls float on the black page.
   Browsers that can't tell when it's pinned always show it, so scrolling content never runs
   underneath bare controls. */
.toolbar-surface {
	position: absolute;
	inset: 0;
	z-index: -1;
	background: hsl(0 0% 8% / 0.94);
	border-block: 1px solid var(--line);
	transition: opacity var(--slow) ease-out;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.toolbar-surface {
		background: var(--glass);
		-webkit-backdrop-filter: var(--glass-blur);
		backdrop-filter: var(--glass-blur);
	}
}

@supports (container-type: scroll-state) {
	.toolbar-surface {
		opacity: 0;
	}

	@container toolbar scroll-state(stuck: top) {
		.toolbar-surface {
			opacity: 1;
		}
	}
}

.toolbar-inner {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.filters {
	flex: 1;
	min-width: 0;
	display: flex;
	gap: 0.75rem;
	align-items: center;
}

/* Once the bar sticks to the top of the screen (Chrome and Edge), it shows the name, so the
   identity never scrolls away. Elsewhere it stays hidden. */
.toolbar-brand {
	display: none;
	flex: none;
	align-items: center;
	color: var(--text);
	font-size: 1.125rem;
	letter-spacing: -0.04em;
	text-decoration: none;
	transition: opacity var(--base) ease-out, translate var(--base) var(--ease-out), display var(--base) allow-discrete;
}

@container toolbar scroll-state(stuck: top) {
	@media (min-width: 48rem) {
		.toolbar-brand {
			display: flex;

			@starting-style {
				opacity: 0;
				translate: -0.5rem 0;
			}
		}
	}
}

.search-field {
	position: relative;
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
}

.search-field .icon {
	position: absolute;
	left: 1rem;
	color: var(--text-2);
	pointer-events: none;
}

.search-input {
	width: 100%;
	min-height: var(--tap);
	padding: 0.625rem 1rem 0.625rem 2.875rem;
	background: var(--grey-10);
	border: 1px solid transparent;
	border-radius: var(--radius-m);
	font-size: 1rem;
	text-overflow: ellipsis;
	appearance: none;
	transition: background-color var(--fast) ease-out, border-color var(--fast) ease-out;
}

.search-input::placeholder {
	color: var(--text-2);
	opacity: 0.8;
}

.search-input::-webkit-search-cancel-button {
	appearance: none;
}

.search-input:hover {
	background: var(--grey-16);
}

.search-input:focus {
	background: var(--grey-16);
	border-color: var(--cyan-line);
	outline: none;
}

.search-input:focus-visible {
	box-shadow: 0 0 0 3px hsl(180 100% 50% / 0.25);
}

.sort {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.625rem;
	color: var(--text-2);
	font-size: 0.875rem;
}

/* The button that opens the menu: 10% grey, 16% on hover and while open, like the chips. */
.sort-button {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: var(--tap);
	padding: 0.5rem 0.875rem 0.5rem 1rem;
	background: var(--grey-10);
	border: 1px solid transparent;
	border-radius: var(--radius-m);
	color: var(--text);
	font-size: 0.9375rem;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color var(--fast) ease-out;
}

.sort-button:hover,
.sort-button[aria-expanded='true'] {
	background: var(--grey-16);
}

.sort-glyph,
.sort-chevron {
	color: var(--text-2);
}

/* The arrow shows which way round the list currently runs. */
.sort-button[data-order='asc'] .sort-glyph-desc,
.sort-button:not([data-order='asc']) .sort-glyph-asc {
	display: none;
}

.sort-chevron {
	transition: rotate var(--base) var(--ease-out);
}

.sort-button[aria-expanded='true'] .sort-chevron {
	rotate: 180deg;
}

/* The menu: frosted glass, with what to sort by above a line and which way round below it. */
.sort-menu {
	--tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
	position: absolute;
	top: calc(100% + 0.375rem);
	right: 0;
	z-index: 1;
	min-width: 14.5rem;
	padding: 0.375rem;
	background: hsl(0 0% 11% / 0.96);
	border: 1px solid var(--line);
	border-radius: var(--radius-m);
	box-shadow: 0 24px 48px -12px hsl(0 0% 0% / 0.8);
	transition: opacity var(--fast) ease-out, translate var(--base) var(--ease-out);

	@starting-style {
		opacity: 0;
		translate: 0 -0.25rem;
	}
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.sort-menu {
		background: hsl(0 0% 11% / 0.9);
		-webkit-backdrop-filter: var(--glass-blur);
		backdrop-filter: var(--glass-blur);
	}
}

.sort-group {
	min-inline-size: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.sort-group + .sort-group {
	margin-top: 0.375rem;
	padding-top: 0.375rem;
	border-top: 1px solid var(--line);
}

.sort-option {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 2.5rem;
	padding: 0.5rem 0.75rem;
	border-radius: calc(var(--radius-m) - 0.25rem);
	color: var(--text);
	font-size: 0.9375rem;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
}

/* A cyan tick marks the choice in force; the radio itself is invisible but covers the row. */
.sort-option::before {
	content: '';
	flex: none;
	width: 1.125rem;
	height: 1.125rem;
	background: var(--cyan);
	-webkit-mask: var(--tick) center / contain no-repeat;
	mask: var(--tick) center / contain no-repeat;
	opacity: 0;
}

.sort-option input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
	appearance: none;
}

.sort-option:hover {
	background: var(--grey-16);
}

.sort-option:has(:checked) {
	background: var(--cyan-wash);
}

.sort-option:has(:checked)::before {
	opacity: 1;
}

.sort-option:has(:focus-visible) {
	outline: 2px solid var(--cyan);
	outline-offset: -2px;
}

@media (max-width: 30rem) {
	/* Keep the search field wide enough for its placeholder: the arrow stays, the chevron goes. */
	.filters {
		gap: 0.5rem;
	}

	.sort-button {
		gap: 0.375rem;
		padding-inline: 0.625rem;
		font-size: 0.875rem;
	}

	.sort-chevron {
		display: none;
	}

	.search-field .icon {
		left: 0.75rem;
		width: 1.125rem;
		height: 1.125rem;
	}

	.search-input {
		padding-left: 2.375rem;
		padding-right: 0.5rem;
	}

	.sort-label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}
}

/* Results, tags & notices --------------------------------------------------- */

.results-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 1rem;
	min-height: var(--tap);
	color: var(--text-2);
	font-size: 0.8125rem;
	font-weight: 500;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-block: 0.25rem 1.75rem;
}

@media (max-width: 40rem) {
	/* One swipeable row on phones instead of a wall of chips. */
	.tags {
		flex-wrap: nowrap;
		overflow-x: auto;
		margin-inline: calc(var(--gutter) * -1);
		padding-inline: var(--gutter);
		padding-block: 0.25rem;
		scroll-padding-inline: var(--gutter);
		scrollbar-width: none;
		mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - 2.5rem), transparent);
	}

	.tags::-webkit-scrollbar {
		display: none;
	}
}

/* Chips: tags and small actions. 10% grey, 16% on hover, cyan when selected. */
.tag-chip,
.chip-button {
	flex: none;
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	min-height: 2.25rem;
	padding: 0.25rem 1rem;
	background: var(--grey-10);
	border: 1px solid transparent;
	border-radius: var(--radius-pill);
	color: var(--text);
	font-size: 0.875rem;
	font-weight: 500;
	letter-spacing: 0;
	text-transform: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color var(--fast) ease-out, border-color var(--fast) ease-out;
}

.tag-chip:hover,
.chip-button:hover {
	background: var(--grey-16);
}

.tag-chip[aria-pressed='true'] {
	background: var(--cyan-wash);
	border-color: var(--cyan-line);
}

.tag-count {
	color: var(--text-2);
	font-size: 0.75rem;
}

.notice {
	display: grid;
	justify-items: start;
	gap: 1rem;
	margin-block: 1rem 2rem;
	padding: 1.25rem 1.5rem;
	background: linear-gradient(90deg, hsl(180 100% 50% / 0.14), var(--grey-10) 45%);
	border: 1px solid var(--line);
	border-radius: var(--radius-m);
	color: var(--text-2);
}

/* Grid & cards ------------------------------------------------------------ */

.grid {
	display: grid;
	/* Two columns at the narrowest, so most phones still show off the artwork.
	   CARD_IMAGE_SIZES in js/constants.js mirrors these widths. */
	grid-template-columns: repeat(auto-fill, minmax(min(13.5rem, calc((100% - var(--gap)) / 2)), 1fr));
	gap: clamp(1.5rem, 3vw, 2.5rem) var(--gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Below 400px two columns get too small to read, so each playlist gets the full width. */
@media (max-width: 24.99rem) {
	.grid {
		grid-template-columns: 1fr;
	}
}

/* Every card has the same four rows, top to bottom: artwork, title, tags, stats. */
.card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
	min-width: 0;
}

.card-art {
	position: relative;
	aspect-ratio: 1;
	margin-bottom: 0.25rem;
	overflow: hidden;
	border-radius: var(--radius-s);
	background: var(--art, var(--grey-10));
	box-shadow: 0 0 0 1px hsl(0 0% 100% / 0.06);
	transition: transform var(--base) var(--ease-out), box-shadow var(--base) var(--ease-out);
}

.card-art img,
.sheet-art img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity var(--slow) ease-out;
}

/* Artwork fades in over its palette colour once loaded. */
:is(.card-art, .sheet-art) img.is-loading {
	opacity: 0;
}

:is(.card-art, .sheet-art) img:not([src]) {
	visibility: hidden;
}

/* Placeholder for playlists without artwork (or whose artwork failed): a black-to-cyan tile. */
.card.no-art .card-art,
.sheet.no-art .sheet-art {
	background: linear-gradient(160deg, hsl(180 100% 50% / 0.08), hsl(180 55% 22%) 140%), var(--black);
}

.card.no-art .card-art::after,
.sheet.no-art .sheet-art::after {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--cyan);
	opacity: 0.8;
	/* Lucide "music" icon. */
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 16V3a1 1 0 0 0-1.28-.96l-10 2.917a1 1 0 0 0-.72.96V19'/%3E%3Ccircle cx='18' cy='16' r='3'/%3E%3Ccircle cx='6' cy='19' r='3'/%3E%3C/svg%3E") center / 28% no-repeat;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 16V3a1 1 0 0 0-1.28-.96l-10 2.917a1 1 0 0 0-.72.96V19'/%3E%3Ccircle cx='18' cy='16' r='3'/%3E%3Ccircle cx='6' cy='19' r='3'/%3E%3C/svg%3E") center / 28% no-repeat;
}

.card:hover .card-art {
	transform: translateY(-4px);
	box-shadow: 0 20px 36px -16px var(--art, var(--cyan)), 0 0 0 1px hsl(0 0% 100% / 0.14);
}

.badge {
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	padding: 0.125rem 0.5rem;
	background: var(--cyan);
	border-radius: var(--radius-pill);
	color: var(--black);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* One line, so titles line up across a row; the full title is in the link's tooltip. */
.card-title {
	overflow: hidden;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.card-link {
	color: inherit;
	text-decoration: none;
}

/* The whole card is clickable; the tag chips sit above this overlay. */
.card-link::after {
	content: '';
	position: absolute;
	inset: -0.25rem;
	border-radius: var(--radius-s);
}

.card-link:focus-visible {
	outline: none;
}

.card-link:focus-visible::after {
	outline: 2px solid var(--cyan);
	outline-offset: 2px;
}

/* One chip per tag. The row keeps its height when there are none, so the rows below stay level. */
.card-tags {
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: 0.375rem;
	min-height: 1.625rem;
}

/* Block rather than inline-flex, so a tag too long for the card ends in an ellipsis. */
.card-tags .tag-chip {
	position: relative;
	z-index: 1;
	display: block;
	min-height: 1.625rem;
	max-width: 100%;
	padding: 0 0.625rem;
	overflow: hidden;
	font-size: 0.75rem;
	line-height: 1.5rem;
	text-overflow: ellipsis;
}

/* Pinned to the bottom, so stats line up even when a neighbour's tags wrap onto a second line. */
.card-stats {
	margin-top: auto;
	color: var(--text-2);
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
}

/* Loading skeleton ----------------------------------------------------------- */

.card.is-skeleton .card-art,
.skeleton-line {
	background: linear-gradient(90deg, var(--grey-10) 25%, var(--grey-16) 50%, var(--grey-10) 75%);
	background-size: 200% 100%;
	animation: shimmer 1.4s linear infinite;
	box-shadow: none;
}

.skeleton-line {
	height: 0.875rem;
	border-radius: var(--radius-s);
}

.skeleton-line.short {
	width: 55%;
}

@keyframes shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Buttons -------------------------------------------------------------------- */

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: var(--tap);
	padding: 0.5rem 1.375rem;
	background: var(--grey-10);
	border: 1px solid transparent;
	border-radius: var(--radius-pill);
	color: var(--text);
	font-size: 0.9375rem;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--fast) ease-out, border-color var(--fast) ease-out, box-shadow var(--base) ease-out;
}

.button:hover {
	background: var(--grey-16);
	color: var(--text);
}

/* The main action: black fading into cyan, like the selected quality in TIDAL's own settings. */
.button-primary {
	background: linear-gradient(100deg, var(--grey-10) 0%, hsl(180 100% 50% / 0.34) 100%), var(--black);
	border-color: var(--cyan-line);
}

.button-primary:hover {
	background: linear-gradient(100deg, var(--grey-16) 0%, hsl(180 100% 50% / 0.42) 100%), var(--black);
	box-shadow: 0 0 24px -4px hsl(180 100% 50% / 0.5);
}

/* The copy button shows a tick for a moment after copying. */
.when-copied {
	display: none;
}

[data-copied] .when-idle {
	display: none;
}

[data-copied] .when-copied {
	display: block;
	color: var(--cyan);
}

/* Playlist dialog: frosted glass tinted with the playlist's own artwork colour -------- */

.sheet {
	width: min(100% - 2rem, 66rem);
	max-width: none;
	/* A set height, so the player always fits inside the padding whatever the playlist; the
	   details beside it scroll when they need to. */
	height: min(100% - 2rem, 50rem);
	max-height: none;
	padding: 0;
	overflow: hidden;
	overscroll-behavior: contain;
	background:
		radial-gradient(110% 70% at 0% 0%, color-mix(in srgb, var(--art, var(--cyan)) 30%, transparent), transparent 65%),
		hsl(0 0% 7% / 0.94);
	border: 1px solid var(--line);
	border-radius: var(--radius-l);
	box-shadow: 0 40px 100px -20px hsl(0 0% 0% / 0.95);
	color: var(--text);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.sheet {
		background:
			radial-gradient(110% 70% at 0% 0%, color-mix(in srgb, var(--art, var(--cyan)) 30%, transparent), transparent 65%),
			hsl(0 0% 8% / 0.72);
		-webkit-backdrop-filter: var(--glass-blur);
		backdrop-filter: var(--glass-blur);
	}
}

.sheet::backdrop {
	background: hsl(0 0% 0% / 0.72);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

.sheet-layout {
	position: relative;
	display: grid;
	height: 100%;
	grid-template-columns: minmax(0, 19rem) minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
	grid-template-areas: 'info player';
	gap: 2rem;
	/* The top padding leaves room for the close button, clear of TIDAL's player. */
	padding: 3.5rem 2rem 2rem;
}

/* Artwork, details and actions: one column that scrolls beside the player if it is too tall. */
.sheet-info {
	grid-area: info;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.sheet-close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 2;
	display: grid;
	place-items: center;
	width: var(--tap);
	height: var(--tap);
	padding: 0;
	background: var(--grey-10);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color var(--fast) ease-out;
}

.sheet-close:hover {
	background: var(--grey-16);
}

.sheet-art {
	flex: none;
	position: relative;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: var(--radius-s);
	background: var(--art, var(--grey-16));
	box-shadow: 0 28px 56px -24px var(--art, var(--cyan));
}

.sheet-head {
	flex: none;
	display: grid;
	gap: 0.25rem;
}

.sheet-tag {
	color: var(--cyan);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.sheet-title {
	font-size: clamp(1.5rem, 3vw, 2rem);
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.02em;
	overflow-wrap: anywhere;
	text-wrap: balance;
}

.sheet-stats {
	color: var(--text-2);
	font-size: 0.875rem;
}

.sheet-body {
	flex: none;
	display: grid;
	align-content: start;
	gap: 1rem;
}

.sheet-description {
	color: var(--text-2);
	white-space: pre-line;
	text-wrap: pretty;
}

.sheet-description:empty {
	display: none;
}

.sheet-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.copy-status {
	color: var(--text-2);
	font-size: 0.875rem;
	overflow-wrap: anywhere;
}

.copy-status:empty {
	display: none;
}

.sheet-player {
	grid-area: player;
	position: relative;
	min-height: 0;
	overflow: hidden;
	border-radius: var(--radius-m);
	background: var(--grey-10);
}

.sheet-player iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	opacity: 0;
	transition: opacity var(--slow) ease-out;
}

.sheet-player[data-state='loaded'] iframe {
	opacity: 1;
}

/* Spinner while the embed loads. */
.sheet-player[data-state='loading']::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 2rem;
	height: 2rem;
	margin: -1rem 0 0 -1rem;
	border: 2px solid var(--grey-16);
	border-top-color: var(--cyan);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

.player-message {
	position: absolute;
	inset: auto 1rem 1rem;
	padding: 0.75rem 1rem;
	background: var(--black);
	border-radius: var(--radius-s);
	color: var(--text-2);
	font-size: 0.875rem;
}

@keyframes spin {
	to {
		transform: rotate(1turn);
	}
}

@media (max-width: 52rem) {
	/* Phones and small tablets: full-screen sheet, compact header, player up top. */
	.sheet {
		width: 100%;
		max-height: 100%;
		height: 100%;
		margin: 0;
		overflow: auto;
		border: 0;
		border-radius: 0;
	}

	/* Actions before the player: on a phone, "Open in TIDAL" is the main event. The sheet scrolls
	   as a whole, so the details join the layout's own grid. */
	.sheet-layout {
		height: auto;
		min-height: 100%;
		grid-template-columns: 5.5rem minmax(0, 1fr);
		grid-template-rows: auto auto auto auto;
		grid-template-areas:
			'art head'
			'body body'
			'player player'
			'desc desc';
		gap: 1rem;
		align-items: center;
		padding: 1rem var(--gutter) max(1.5rem, env(safe-area-inset-bottom));
	}

	.sheet-info {
		display: contents;
	}

	.sheet-art {
		grid-area: art;
	}

	.sheet-head {
		grid-area: head;
		padding-right: 3rem;
	}

	.sheet-body {
		grid-area: body;
	}

	.sheet-description {
		grid-area: desc;
	}

	.sheet-player {
		grid-area: player;
		height: min(62dvh, 32rem);
	}
}

/* Dialog motion (entry via @starting-style; exit needs overlay + discrete display). */
.sheet,
.sheet::backdrop {
	transition-property: opacity, transform, display, overlay;
	transition-duration: var(--slow);
	transition-timing-function: var(--ease-out);
	transition-behavior: allow-discrete;
}

.sheet {
	opacity: 0;
	transform: translateY(1.5rem) scale(0.98);
}

.sheet::backdrop {
	opacity: 0;
}

:is(.sheet[open]):where(:not([data-closing])) {
	opacity: 1;
	transform: none;

	&::backdrop {
		opacity: 1;
	}

	@starting-style {
		opacity: 0;
		transform: translateY(1.5rem) scale(0.98);

		&::backdrop {
			opacity: 0;
		}
	}
}

/* Toast ------------------------------------------------------------------------ */

.toast {
	position: fixed;
	bottom: max(1rem, env(safe-area-inset-bottom));
	left: 50%;
	z-index: 20;
	max-width: calc(100% - 2rem);
	padding: 0.75rem 1.25rem;
	background: hsl(0 0% 14% / 0.94);
	border: 1px solid var(--line);
	border-radius: var(--radius-pill);
	box-shadow: 0 16px 40px -8px hsl(0 0% 0% / 0.8);
	color: var(--text);
	font-size: 0.9375rem;
	font-weight: 500;
	transform: translateX(-50%);
	transition: opacity var(--base) ease-out, translate var(--base) var(--ease-out);

	@starting-style {
		opacity: 0;
		translate: 0 1rem;
	}
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.toast {
		background: var(--glass);
		-webkit-backdrop-filter: var(--glass-blur);
		backdrop-filter: var(--glass-blur);
	}
}

/* Footer ------------------------------------------------------------------------ */

.site-footer {
	padding-block: 1.5rem;
	border-top: 1px solid var(--line);
	color: var(--text-2);
	font-size: 0.875rem;
}

.footer-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem 1.5rem;
}

/* Error page ---------------------------------------------------------------------- */

.error-page {
	display: grid;
	gap: 1.25rem;
	justify-items: start;
	padding-block: 4rem;
}

.error-reference {
	color: var(--text-2);
	font-size: 0.875rem;
}

/* Utilities ------------------------------------------------------------------------ */

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	z-index: 30;
	padding: 0.75rem 1rem;
	background: var(--white);
	border-radius: var(--radius-pill);
	color: var(--black);
	font-weight: 600;
	transform: translateY(-200%);
}

.skip-link:focus {
	transform: none;
}

/* Motion preferences ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
	}

	.card:hover .card-art {
		transform: none;
	}

	.sheet,
	.sheet::backdrop {
		transition-duration: 0.1s;
	}

	.sheet,
	:is(.sheet[open]):where(:not([data-closing])) {
		transform: none;

		@starting-style {
			transform: none;
		}
	}
}
