/* ==========================================================================
   PODUNK PLAYER: the hands-on cassette deck (apps/player.js)
   ========================================================================== */

.player2 { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; background: #030000; }

/* --------------------------------------------------------------------------
   The deck
   -------------------------------------------------------------------------- */

.deck2 {
	margin: 12px;
	padding: 12px 14px 16px;
	border: 2px solid #2a1010;
	border-radius: 3px;
	background:
		repeating-linear-gradient(90deg, rgb(255 255 255 / 0.018) 0 1px, transparent 1px 3px),
		linear-gradient(180deg, #1f1616, #0d0909 70%);
	box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08), 0 12px 30px rgb(0 0 0 / 0.7);
}
.deck2__top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.deck2__brand { font-family: var(--f-display); font-size: 16px; color: var(--red); text-shadow: var(--text-glow); }
.deck2__model { color: #a88; font-size: 16px; text-transform: uppercase; letter-spacing: 0.08em; }
.deck2__led { width: 9px; height: 9px; margin-left: auto; border-radius: 50%; background: #3a0a0a; box-shadow: inset 0 1px 2px #000; transition: background 0.1s, box-shadow 0.1s; }
.deck2.is-playing .deck2__led { background: var(--red); box-shadow: 0 0 8px var(--red); }
.deck2__led.is-peak { background: #ffe0e0; box-shadow: 0 0 12px #fff; }

.deck2__main { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; }

/* The cassette door: hinged at the bottom, swings towards you. */
.deck2__door {
	position: relative;
	aspect-ratio: 1.5;
	border: 2px solid #3a1515;
	border-radius: 4px;
	background: radial-gradient(80% 80% at 50% 40%, #1a0707, #050000);
	box-shadow: inset 0 0 24px #000;
	perspective: 700px;
	cursor: var(--cursor-hover);
	transition: border-color 0.2s, box-shadow 0.2s;
}
.deck2__flap {
	position: absolute;
	inset: 6%;
	border: 2px solid #4a1d1d;
	border-radius: 3px;
	background: rgb(0 0 0 / 0.35);
	transform-origin: 50% 100%;
	transform-style: preserve-3d;
	transition: transform 0.26s cubic-bezier(.3, .7, .3, 1.2);
}
.deck2__door.is-open .deck2__flap { transform: rotateX(-32deg) translateY(3%); }
.deck2__bay { position: absolute; inset: 9% 6%; display: grid; place-items: center; }
.deck2__bay .tape { width: 100%; transition: transform 0.16s ease-out; }
.deck2__bay .tape.is-lifting { transform: translateY(-16%) rotate(-2deg); }
.deck2__bay .tape.is-seating { animation: tape-seat 0.3s ease-out; }
@keyframes tape-seat { 0% { transform: translateY(-6%); } 70% { transform: translateY(2%); } 100% { transform: none; } }
.deck2__glass {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		linear-gradient(115deg, rgb(255 255 255 / 0.14) 0 14%, transparent 26% 62%, rgb(255 255 255 / 0.05) 70%, transparent 78%),
		rgb(255 69 69 / 0.04);
}
.deck2__slot {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-family: var(--f-display);
	font-size: 12px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--pink);
	text-shadow: var(--text-glow);
	animation: slot-pulse 1.8s ease-in-out infinite;
	pointer-events: none;
}
.deck2__door.is-loaded .deck2__slot { display: none; }
@keyframes slot-pulse { 50% { opacity: 0.35; } }
.deck2__door.is-target { border-color: var(--red); border-style: dashed; }
.deck2__door.is-hover { box-shadow: inset 0 0 24px #000, var(--glow-strong); border-style: solid; }

/* Side panel: VU meters, counter, time, knob. */
.deck2__vus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vu {
	position: relative;
	aspect-ratio: 1.35;
	overflow: hidden;
	border: 3px solid #0b0505;
	border-radius: 4px;
	/* Backlit face: bright where the lamp sits behind the pivot, warmer towards the edges. */
	background: radial-gradient(125% 105% at 50% 96%, #fff8e8 0%, #fbe6be 42%, #ecc58a 78%, #cf9d5c 100%);
	box-shadow:
		inset 0 7px 10px -5px rgb(0 0 0 / 0.6),
		inset 0 0 0 1px rgb(0 0 0 / 0.45),
		inset 0 0 18px rgb(255 140 40 / 0.35),
		0 0 0 1px rgb(255 69 69 / 0.22),
		0 3px 8px rgb(0 0 0 / 0.6);
}
/* Glass over the face. */
.vu::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(162deg, rgb(255 255 255 / 0.42) 0%, rgb(255 255 255 / 0.1) 30%, transparent 31%);
	pointer-events: none;
}
.vu__face { position: absolute; inset: 0; width: 100%; height: 100%; }
.vu__arc { fill: none; stroke: #241010; stroke-width: 0.8; }
.vu__arc.is-red { stroke: #9e1b1b; }
.vu__zone { fill: none; stroke: #d42a2a; stroke-width: 3.2; }
.vu__tick { stroke: #241010; }
.vu__tick.is-red { stroke: #b31d1d; }
.vu__num { fill: #2a1212; font-family: var(--f-num); font-size: 6.4px; font-weight: 700; text-anchor: middle; }
.vu__num.is-red { fill: #c22424; }
.vu__sign { fill: #2a1212; font-family: var(--f-num); font-size: 11px; font-weight: 700; text-anchor: middle; }
.vu__sign.is-red { fill: #c22424; }
.vu__mark { fill: #2a1212; font-family: var(--f-num); font-size: 9px; font-weight: 800; letter-spacing: 0.08em; text-anchor: middle; }
.vu__needle {
	position: absolute;
	left: calc(50% - 0.75px);
	bottom: 8%;
	width: 1.5px;
	height: 72%;
	border-radius: 1px;
	background: linear-gradient(#c22424 0 14%, #140808 14%);
	transform-origin: 50% 100%;
	transform: rotate(-48deg);
	filter: drop-shadow(1.5px 2px 1px rgb(70 30 0 / 0.35));
	will-change: transform;
}
/* The housing over the needle's pivot, with the channel printed on it. */
.vu__pivot {
	position: absolute;
	left: 50%;
	bottom: 0;
	width: 44%;
	height: 25%;
	transform: translateX(-50%);
	border-radius: 50% 50% 0 0 / 100% 100% 0 0;
	background: linear-gradient(#3b2620, #110806 70%);
	box-shadow: inset 0 1px 0 rgb(255 230 200 / 0.22), 0 -1px 4px rgb(0 0 0 / 0.35);
}
.vu__label { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); font-family: var(--f-num); font-size: 9px; font-weight: 800; color: #f1dcb8; }
/* Peak lamp: lights while that channel is in the red. */
.vu__label::after { content: ''; position: absolute; left: calc(100% + 4px); top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: #4a1010; box-shadow: inset 0 1px 1px #000; transition: background 0.08s, box-shadow 0.08s; }
.vu.is-peak .vu__label::after { background: #ff4545; box-shadow: 0 0 6px #ff4545, 0 0 2px #fff; }

.deck2__dials { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.counter { display: inline-flex; gap: 2px; padding: 3px; border: 1.5px solid #3a1515; background: #000; }
.counter__digit { width: 14px; height: 20px; overflow: hidden; background: #f5efe6; color: #000; font-family: var(--f-num); font-size: 13px; font-weight: 700; text-align: center; }
.counter__strip { display: block; width: 14px; line-height: 20px; word-break: break-all; transform: translateY(calc(var(--d, 0) * -20px)); transition: transform 0.25s ease-out; }
.deck2__time { font-family: var(--f-num); font-size: 12px; color: var(--pink); }
.knob {
	--turn: 0deg;
	position: relative;
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 2px solid #000;
	background:
		repeating-conic-gradient(rgb(255 255 255 / 0.06) 0 4deg, transparent 4deg 12deg),
		radial-gradient(circle at 35% 30%, #4a4040, #120c0c 70%);
	box-shadow: 0 3px 6px #000, inset 0 1px 0 rgb(255 255 255 / 0.15);
	touch-action: none;
	cursor: grab;
}
.knob__cap { position: absolute; inset: 0; transform: rotate(var(--turn)); }
.knob__cap::before { content: ''; position: absolute; left: 50%; top: 5px; width: 3px; height: 13px; margin-left: -1.5px; background: var(--red); box-shadow: var(--glow); }
.knob:focus-visible { outline-offset: 4px; }

/* Piano keys: they go down, and PLAY stays down while it plays. */
.deck2__keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.pkey {
	display: grid;
	place-items: center;
	height: 54px;
	border: 1px solid #000;
	border-radius: 2px;
	background: linear-gradient(180deg, #3a3232 0%, #1d1717 55%, #120d0d 100%);
	color: #f5efe6;
	box-shadow: 0 6px 0 #070404, 0 7px 10px rgb(0 0 0 / 0.6), inset 0 1px 0 rgb(255 255 255 / 0.18);
	transition: transform 0.08s, box-shadow 0.08s, color 0.15s;
	touch-action: none;
}
.pkey .pd-glyph { width: 20px; height: 20px; }
.pkey:hover { color: #fff; }
.pkey:active,
.pkey.is-pressed,
.pkey.is-held,
.pkey.is-latched {
	transform: translateY(5px);
	box-shadow: 0 1px 0 #070404, 0 2px 4px rgb(0 0 0 / 0.6), inset 0 1px 0 rgb(255 255 255 / 0.08);
}
.pkey--play.is-latched { color: var(--red); filter: drop-shadow(0 0 6px rgb(255 69 69 / calc(0.9 * var(--glow-k)))); }

/* Reels turn while it plays; FF and REW whizz. */
.deck2.is-playing .deck2__bay .tape__reel { animation: spin 1.8s linear infinite; }
.deck2.is-ff .deck2__bay .tape__reel { animation: spin 0.22s linear infinite; }
.deck2.is-rew .deck2__bay .tape__reel { animation: spin 0.22s linear infinite reverse; }

/* --------------------------------------------------------------------------
   Cassettes (used in the rack, the deck and in flight)
   -------------------------------------------------------------------------- */

.tape {
	--pack-l: 0.6;
	--pack-r: 0.4;
	position: relative;
	display: block;
	aspect-ratio: 1.58;
	container-type: inline-size;
	border-radius: 5% / 8%;
	background:
		linear-gradient(180deg, rgb(255 255 255 / 0.07), transparent 40%),
		var(--shell);
	box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08), inset 0 -6px 12px rgb(0 0 0 / 0.35), 0 4px 10px rgb(0 0 0 / 0.5);
	color: var(--ink);
	transition: transform 0.25s var(--ease-out), opacity 0.2s, filter 0.2s;
}
.tape--clear { border: 1px solid rgb(255 255 255 / 0.18); }
.tape__label {
	position: absolute;
	left: 7%;
	right: 7%;
	top: 8%;
	height: 60%;
	padding: 3% 5% 0;
	border-radius: 3%;
	background: var(--label);
	overflow: hidden;
}
.tape__title {
	display: block;
	padding-right: var(--side, 12%);
	font-family: var(--f-display);
	font-size: 8cqi;
	line-height: 1.05;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--ink);
}
/* Long titles (fitLabel in apps/player.js) wrap, and the stripe drops to just above the reels. */
.tape--long .tape__title { white-space: normal; text-wrap: balance; }
.tape--long .tape__stripe { top: 52%; }
.tape__side { position: absolute; right: 5%; top: 5%; font-family: var(--f-num); font-size: 7cqi; font-weight: 800; color: var(--ink); }
.tape__stripe { position: absolute; left: 0; right: 0; top: 34%; height: 7%; background: var(--ink); opacity: 0.85; }
.tape__window {
	position: absolute;
	left: 22%;
	right: 22%;
	top: 44%;
	height: 21%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 5%;
	border-radius: 20cqi;
	border: 1px solid rgb(0 0 0 / 0.6);
	background: rgb(12 4 4 / 0.92);
	overflow: hidden;
}
.tape__reel {
	position: relative;
	width: 12cqi;
	aspect-ratio: 1;
	border-radius: 50%;
	background:
		radial-gradient(circle, #f5efe6 0 24%, transparent 25%),
		repeating-conic-gradient(#f5efe6 0 16deg, transparent 16deg 60deg);
	border: 1.4cqi solid #f5efe6;
}
/* The wound tape around each hub: the left empties as the right fills. */
.tape__reel--l { box-shadow: 0 0 0 calc(0.6cqi + var(--pack-l) * 5cqi) #3d1414; }
.tape__reel--r { box-shadow: 0 0 0 calc(0.6cqi + var(--pack-r) * 5cqi) #3d1414; }
.tape__base {
	position: absolute;
	left: 20%;
	right: 20%;
	bottom: 0;
	height: 22%;
	background:
		radial-gradient(circle at 30% 60%, rgb(0 0 0 / 0.7) 0 6%, transparent 7%),
		radial-gradient(circle at 70% 60%, rgb(0 0 0 / 0.7) 0 6%, transparent 7%),
		rgb(0 0 0 / 0.28);
	clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
}
.tape__screws {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		radial-gradient(circle at 4% 6%, #8a8080 0 1.2cqi, transparent 1.4cqi),
		radial-gradient(circle at 96% 6%, #8a8080 0 1.2cqi, transparent 1.4cqi),
		radial-gradient(circle at 4% 94%, #8a8080 0 1.2cqi, transparent 1.4cqi),
		radial-gradient(circle at 96% 94%, #8a8080 0 1.2cqi, transparent 1.4cqi);
}
.tape--flying { box-shadow: 0 24px 40px rgb(0 0 0 / 0.65), var(--glow); }
.tape--dragging { filter: brightness(1.1); }

/* --------------------------------------------------------------------------
   The rack
   -------------------------------------------------------------------------- */

.rack { padding: 2px 12px 16px; }
.rack__title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 4px 2px 10px; }
.rack__title span:first-child { font-family: var(--f-display); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); text-shadow: var(--text-glow); }
.rack__hint { color: var(--pink); font-size: 17px; }
.rack__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.rack__shelf + .rack__shelf { margin-top: 22px; padding-top: 14px; border-top: 1px dashed rgb(255 69 69 / 0.3); }
.rack__cell { display: grid; align-content: start; gap: 6px; }
.rack__cell > .rack__slot { width: 100%; }
/* Price tag under a tape (added by apps/music.js): buy it, or get the MP3 once it is yours. */
.tapebuy-form { display: contents; }
.tapebuy {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 30px;
	border: 1.5px solid var(--red-deep);
	background: #0a0101;
	color: var(--white);
	font-family: var(--f-num);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-decoration: none;
	transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tapebuy::before { content: 'BUY'; color: var(--pink); font-weight: 600; }
.tapebuy:hover,
.tapebuy:focus-visible { border-color: var(--red); background: var(--red); color: var(--black); outline: none; }
.tapebuy:hover::before { color: var(--black); }
.tapebuy.is-in-cart { border-color: var(--red); color: var(--red); }
.tapebuy.is-in-cart::before { content: ''; }
.tapebuy.is-owned::before { content: 'GET'; }
.rack__slot {
	padding: 7px;
	border: 1.5px solid #2a1010;
	background: linear-gradient(180deg, #0d0404, #050000);
	box-shadow: inset 0 -3px 0 #1a0606;
	touch-action: pan-y;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
	cursor: grab;
}
.rack__slot.is-lifted .tape { transform: translateY(-6px) rotate(-3deg) scale(1.05); box-shadow: 0 14px 22px rgb(0 0 0 / 0.7), var(--glow); }
.rack__slot:hover .tape,
.rack__slot:focus-visible .tape { transform: translateY(-4px) rotate(-1.5deg); }
.rack__slot.is-out .tape { opacity: 0.12; filter: grayscale(1); transform: none; }
.rack__slot.is-landing .tape { opacity: 0; }

@media (max-width: 899px) {
	.deck2 { margin: 10px; }
	.deck2__main { grid-template-columns: 1fr; }
	/* Meters beside the dials, so the deck still fits on one screen. */
	.deck2__side { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 10px; align-items: center; }
	.deck2__dials { flex-wrap: wrap; justify-content: center; gap: 8px 12px; margin-top: 0; }
	.rack__grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
	.rack__slot { padding: 5px; }
	.pkey { height: 58px; }
}

/* Locked demos (core/demos.js): padlocked tapes and the way in. */
.rack__slot { position: relative; }
.rack__slot.is-locked { cursor: not-allowed; }
.rack__slot.is-locked .tape { filter: grayscale(0.7) brightness(0.55); }
.rack__lock {
	position: absolute;
	right: 4px;
	top: 4px;
	width: 26px;
	height: 26px;
	background: #050000 url(../icons/lock.svg) center / 20px no-repeat;
	border: 1.5px solid var(--red);
	box-shadow: var(--glow);
	pointer-events: none;
}
.rack__slot.is-denied { animation: shake 0.28s 2; }
.demolock {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	margin: 0 2px 12px;
	padding: 12px 14px;
	border: 1.5px dashed rgb(255 69 69 / 0.55);
	background: rgb(255 69 69 / 0.05);
}
.demolock__icon { width: 34px; flex: none; }
.demolock__title { margin: 0; font-family: var(--f-display); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); text-shadow: var(--text-glow); }
.demolock__text { margin: 4px 0 10px; color: var(--pink); font-size: 18px; line-height: 1.2; }
.demolock__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.demolock.is-flash { animation: demolock-flash 0.9s ease-out; }
@keyframes demolock-flash { 0%, 40% { border-color: var(--red); box-shadow: var(--glow-strong); background: rgb(255 69 69 / 0.16); } }
@media (prefers-reduced-motion: reduce) {
	.rack__slot.is-denied, .demolock.is-flash { animation: none; }
}

/* The archive's tape vault rows are also li.tape: keep the cassette styles above off them. */
.tapes__list > .tape { aspect-ratio: auto; container-type: normal; border-radius: 0; background: none; box-shadow: none; color: inherit; }
.tapes__list > .tape .tape__title { padding-right: 0; font-size: 14px; line-height: 1.2; color: inherit; white-space: normal; }
