:root {
	--bg: #070707;
	--fg: #f5f5f7;
	--muted: #8e8e93;
	--accent: #2f80ff;
	--junk: #ff5a4f;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }

/* La historia: una sección alta con un escenario fijo dentro. */
.story { height: 420vh; position: relative; }
.stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; perspective: 1500px; perspective-origin: 50% 40%; }

.hero { position: absolute; inset: 17vh 16px auto; text-align: center; z-index: 3; }
.hero h1 { font-size: clamp(34px, 6.4vw, 76px); line-height: 0.96; letter-spacing: -0.03em; margin: 0 0 12px; }
.hero p { color: var(--muted); margin: 0; }
.cue { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted); animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 50% { transform: translateY(6px); opacity: 0.5; } }


/* El primer tramo, ligado al scroll: app.js pone la clase .tl, escribe @keyframes deck-in con las medidas de la pantalla
   y el tramo de scroll de cada animación (animation-range). Las animaciones van detrás de las reglas de cada pieza. */
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes hero-out { from { opacity: 1; } to { opacity: 0; } }  /* con «from»: si no, arranca del estilo en línea que haya */

/* El ruido de los lados: anillos finos y grises, quietos, que nacen fuera de la pantalla, cada uno más tenue que el anterior.
   Los dos lados son el mismo dibujo en espejo respecto al centro del escenario. Detrás del reproductor y del titular;
   con el scroll se apagan y desaparecen cuando se va la morralla (waves-out, ligado al scroll como el primer tramo). */
.waves { display: none; position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.waves > div { position: absolute; top: 52%; width: 0; height: 0; }
.waves > div:first-child { left: -4vw; } .waves > div:last-child { right: -4vw; }
.waves i { position: absolute; left: calc(var(--d) / -2); top: calc(var(--d) / -2); width: var(--d); height: var(--d); border-radius: 50%; border: 1.5px solid #8e8e93; box-shadow: 0 0 28px #ffffff14, inset 0 0 28px #ffffff0d; opacity: var(--o); }
.waves i:nth-child(1) { --d: 18vw; --o: 0.13; } .waves i:nth-child(2) { --d: 36vw; --o: 0.1; }
.waves i:nth-child(3) { --d: 54vw; --o: 0.07; } .waves i:nth-child(4) { --d: 72vw; --o: 0.045; }
@keyframes waves-out { 0% { opacity: 1; } 84% { opacity: 0.55; } 100% { opacity: 0; } }  /* 84 %: LIST_END / FLAG_END en app.js */
.stage.tl .waves { animation: waves-out both linear; animation-timeline: scroll(root); }
@media (min-width: 1024px) { .waves { display: block; } }

/* Un velo abajo para que la frase se lea sobre los mandos. */
.stage::after { content: ""; position: absolute; inset: auto 0 0 0; height: 30vh; z-index: 2; pointer-events: none; background: linear-gradient(#07070700, #070707e6 55%); opacity: var(--scrim, 0); }
/* Bajo los pads (--cap-top, de app.js), sin bajar del 7 % de abajo: en el móvil se reservan dos líneas; en pantallas anchas
   las frases caben en una. El botón de sonido, centrado con esa línea. */
.caption { position: absolute; left: 16px; right: 16px; top: min(var(--cap-top, 100%), calc(93% - 2.300em)); z-index: 3; margin: 0; text-align: center; font-size: clamp(22px, 3.6vw, 40px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; transition: opacity 0.25s; }
.caption.out { opacity: 0; }
.sound { position: absolute; right: max(24px, 5vw); top: min(var(--cap-top, 100%), calc(93% - 30px)); z-index: 4; display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 0; border-radius: 999px; font: inherit; font-size: 13px; color: #f5f5f7b3; background: #ffffff14; box-shadow: inset 0 0 0 1px #ffffff1f; cursor: pointer; opacity: var(--scrim, 0); transition: color 0.2s, background-color 0.2s; }
.sound:hover { color: #fff; background: #ffffff24; }
.sound svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.600; stroke-linecap: round; stroke-linejoin: round; }
.sound .on, .sound[aria-pressed="true"] .off { display: none; }
.sound[aria-pressed="true"] .on { display: inline; }
.haptic { position: fixed; left: -100px; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.stage.tl .deck { animation: deck-in both cubic-bezier(0.65, 0, 0.35, 1); animation-timeline: scroll(root); }
.stage.tl::after, .stage.tl .sound { animation: scrim-in both cubic-bezier(0.65, 0, 0.35, 1); animation-timeline: scroll(root); }
.stage.tl .hero { animation: hero-out both linear; animation-timeline: scroll(root); }
@media (min-width: 761px) {
	.caption { top: min(var(--cap-top, 100%), calc(93% - 1.150em)); }
	.sound { top: min(var(--cap-top, 100%), calc(93% - clamp(22px, 3.600vw, 40px) * 1.150)); margin-top: calc((clamp(22px, 3.600vw, 40px) * 1.150 - 32px) / 2); }
}
@media (max-width: 760px) { .sound { bottom: auto; top: 76px; } .sound span { display: none; } }

/* La pantalla: 680 x 400 px de diseño. Arriba la fuente y las pestañas, a la izquierda las categorías,
   la lista en medio (10 filas de 27 px) y abajo el reproductor. */
/* Capa propia: lo que cambia con el scroll (filas, ondas, tiempo) se repinta aquí, sin tocar la carcasa. */
.screen { will-change: transform; width: 680px; height: 400px; background: #000; color: #f2f2f2; font-size: 13px; line-height: 1; display: flex; flex-direction: column; overflow: hidden; }
.screen svg { fill: none; stroke: currentColor; stroke-width: 1.500; stroke-linecap: round; stroke-linejoin: round; }
.screen b, .screen i, .screen em, .screen u, .screen small { font-style: normal; text-decoration: none; }

.s-top { height: 46px; display: flex; align-items: stretch; }
.s-src { width: 46px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px; padding-bottom: 4px; background: #1d3f86; font-size: 9px; font-weight: 700; }
.s-src svg { width: 20px; height: 20px; }
.s-src::before { content: "1"; position: absolute; left: 2px; top: 2px; padding: 0 2px; font-size: 8px; line-height: 10px; border: 1px solid #fff; }
.s-back { width: 44px; display: grid; place-items: center; font-size: 25px; font-weight: 700; }
.s-title { flex: 1; display: flex; align-items: center; gap: 7px; font-size: 17px; }
.s-title svg { width: 17px; height: 17px; }
.s-tab, .s-font, .s-info { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin-left: 2px; background: #3a3a3a; }
.s-tab { width: 66px; background: #1a7fe8; }
.s-font { width: 62px; gap: 6px; align-items: baseline; padding-top: 14px; color: #9a9a9a; }
.s-font b:nth-child(1) { font-size: 9px; } .s-font b:nth-child(2) { font-size: 13px; color: #fff; border-bottom: 2px solid #fff; } .s-font b:nth-child(3) { font-size: 17px; }
.s-info { width: 78px; }

.s-body { flex: 1; display: flex; min-height: 0; border-top: 2px solid #000; }
.s-side { width: 46px; display: flex; flex-direction: column; gap: 1px; }
.s-side span { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 6.500px; font-weight: 700; color: #d6d6d6; background: #262626; }
.s-side svg { width: 15px; height: 15px; }
.s-side .box { padding: 1px 2px; font-size: 7px; border: 1px solid; border-radius: 2px; }
.s-side .on { background: #474747; color: #3be04e; }
.s-list { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid #000; }
.s-heads { height: 32px; display: grid; grid-template-columns: 130px 40px 172px 146px 34px 62px 49px; background: #3c3c3c; color: #dcdcdc; font-size: 10px; }
.s-heads span { display: flex; align-items: center; gap: 5px; padding-left: 6px; border-right: 1px solid #000; }
.s-heads i { font-size: 8px; }
.s-heads .hash { color: #3aa0ff; font-size: 11px; }
.s-heads em { font-size: 8px; margin-left: 4px; transition: color 0.4s; }
.s-sort { padding: 0 !important; justify-content: center; }
.s-sort svg { width: 22px; height: 22px; padding: 3px; border: 1px solid #8a8a8a; border-radius: 3px; }
.s-rows { flex: 1; overflow: hidden; position: relative; }
.rows { will-change: transform; }

.row { height: 27px; display: grid; grid-template-columns: 102px 28px 40px 172px 180px 62px 49px; background: #1c1c1c; border-bottom: 1px solid #000; overflow: hidden; transition: height 0.5s ease, opacity 0.4s ease; }
.row > * { height: 26px; line-height: 26px; padding-left: 6px; white-space: nowrap; overflow: hidden; }
.row canvas { width: 102px; height: 26px; padding: 0; display: block; background: #000; }
.row .art { width: 24px; height: 24px; margin: 1px 2px; padding: 0; border-radius: 1px; }
.row .n { padding-left: 8px; }
.row .t { display: flex; align-items: center; border-left: 1px solid #000; }
.row .t::before { content: "♪"; flex: none; margin-right: 5px; font-size: 12px; }
.row .tt { flex: 0 1 auto; min-width: 0; overflow: hidden; }
.row .a { border-left: 1px solid #000; }
.row .b { padding-right: 8px; text-align: right; border-left: 1px solid #000; font-variant-numeric: tabular-nums; }
.row .k { padding-left: 10px; }
.row.playing > :nth-child(n+3) { color: #35e04a; }
.row.playing .t::before { content: "▶"; font-size: 9px; }
.row.sel > :nth-child(n+3) { background: #1a7fe8; color: #fff; }
.row .tag { display: none; flex: none; margin: 0 6px; padding: 0 5px; height: 14px; line-height: 14px; border-radius: 2px; background: var(--junk); color: #fff; font-size: 8.500px; font-weight: 700; }

/* Tidybox marca la morralla; después la quita. */
.screen.flag .row.junk > :nth-child(n+3) { background: #4a1512; }
.screen.flag .row.junk .tag { display: block; }
.screen.flag .row:not(.junk):not(.sel) { opacity: 0.5; }
.screen.flag .row.junk.sel > :nth-child(n+3) { background: #1a7fe8; }
.screen.clean .row.junk { height: 0; opacity: 0; border: 0; }
.screen.clean .row:not(.junk) { opacity: 1; }
/* Sin la morralla, la lista se apoya abajo: las pistas que quedan bajan a ocupar el hueco (sin salto: al empezar, las 24 filas ya llenan ese sitio). */
.screen.clean .rows { position: absolute; left: 0; right: 0; bottom: 0; transform: none !important; }
.screen.clean .s-heads em { color: #5df08a; }

.s-bottom { height: 50px; display: flex; align-items: center; gap: 9px; padding: 0 5px; }
.s-bottom small { display: block; font-size: 6px; font-weight: 700; color: #d6d6d6; }
.s-player { width: 34px; height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 6px; font-weight: 700; border: 1px solid #e02a2a; }
.s-player b { font-size: 17px; color: #ff5a4f; }
.s-time { font-size: 29px; font-weight: 300; font-variant-numeric: tabular-nums; }
/* Queda menos de un minuto: el tiempo se pone rojo y parpadea, como en el reproductor. */
.s-time.low > span { color: #ff3b3b; animation: s-blink 0.9s steps(1) infinite; }
@keyframes s-blink { 50% { opacity: 0.25; } }
.s-over { flex: 1; height: 40px; position: relative; }
.s-over canvas { position: absolute; left: 0; bottom: 4px; width: 100%; height: 24px; }
.s-over i { position: absolute; top: 2px; width: 7px; height: 7px; background: var(--c); }
/* Lo ya sonado se ve más apagado, a la izquierda de la raya roja (app.js mueve las dos). */
.s-played { position: absolute; left: 0; bottom: 4px; width: 54%; height: 24px; background: #000000a6; }
.s-over u { position: absolute; left: 54%; top: 10px; bottom: 2px; width: 1.500px; background: #ff3b3b; }
.s-mt, .s-tempo { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; }
.s-mt b { padding: 2px 5px; font-size: 9px; color: #ff4a3f; border: 1px solid #ff4a3f; }
.s-tempo b { padding: 2px 5px; font-size: 9px; color: #000; background: #ff8a1f; }
.s-bpm { width: 74px; height: 40px; position: relative; display: flex; align-items: flex-end; justify-content: flex-end; padding: 0 5px 2px; font-size: 25px; color: #ff8a1f; border: 1px solid #ff8a1f; font-variant-numeric: tabular-nums; }
.s-bpm small { position: absolute; left: 4px; top: 3px; color: #d6d6d6; }
.s-bpm b { position: absolute; right: 0; top: 0; padding: 1px 4px; font-size: 6px; color: #000; background: #ff8a1f; }
.s-bpm em { font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
	.s-time.low > span { animation: none; }
	.cue { animation: none; }
	.row { transition: none; }
}
