/*! loum.io · © 2025–2026 Louie Sellers · All rights reserved · Original at https://loum.io */
/* Sample tracks: a loose pile of sleeves in the bottom-right corner */

:root {
    --si-spring: var(--spring, cubic-bezier(0.34, 1.4, 0.64, 1));
    --si-ease: var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
    --si-bg: var(--raise, #1a1a19);
    --si-bg-2: var(--raise-2, #222220);
    --si-line: var(--line-strong, #3a3a37);
    --si-text: var(--text, #e9e7e2);
    --si-muted: var(--muted, #9a978f);
    --si-faint: var(--faint, #6b6963);
    --si-accent: var(--accent, #ff7a3d);
}

.si-touch { display: none; }
@media (hover: none) {
    .si-pointer { display: none; }
    .si-touch { display: inline; }
}

/* ---------- A sleeve ---------- */
.si-tile {
    --tx: 0px; --ty: 0px; --r: 0deg; --fx: 0px; --fy: 0px;
    --dx: 0px; --dy: 0px; --tilt: 0deg; --s: 1;
    --ax: 0px; --ay: 0px; --ar: 0deg;
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: 92px;
    height: 92px;
    margin: 0;
    padding: 9px 9px 8px;
    font: inherit;
    color: var(--si-text);
    text-align: left;
    background: var(--si-bg);
    border: 1.5px solid var(--si-line);
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 6px 16px -10px rgba(0, 0, 0, 0.7);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transform:
        translate(calc(var(--tx) + var(--fx) + var(--dx) + var(--ax)), calc(var(--ty) + var(--fy) + var(--dy) + var(--ay)))
        rotate(calc(var(--r) + var(--tilt) + var(--ar)))
        scale(var(--s));
    transition:
        transform 560ms var(--si-spring),
        box-shadow 240ms var(--si-ease),
        border-color 200ms var(--si-ease),
        opacity 240ms var(--si-ease);
    will-change: transform;
}
/* The record peeking out past the sleeve's right edge. It slides out a little further under
   the pointer and while carried, and tucks back in as the sleeve goes into the tool */
.si-record {
    position: absolute;
    top: -1.5px;
    bottom: -1.5px;
    right: calc(-20px - 1.5px);
    display: block;
    width: 20px;
    height: auto;
    overflow: hidden;
    pointer-events: none;
}
.si-vinyl { fill: #0d0d0c; stroke: none; }
.si-edge { stroke: var(--si-line); stroke-width: 1.5; transition: stroke 200ms var(--si-ease); }
.si-grooves circle { stroke: var(--si-text); stroke-width: 1; opacity: 0.24; transition: opacity 200ms var(--si-ease); }
.si-disc { transition: transform 480ms var(--si-spring); }
.si-tile:hover .si-edge, .si-tile:focus-visible .si-edge { stroke: var(--si-faint); }
.si-tile:hover .si-grooves circle, .si-tile:focus-visible .si-grooves circle { opacity: 0.32; }
.si-tile:hover .si-disc, .si-tile:focus-visible .si-disc { transform: translateX(4px); }
.si-tile.si-drag .si-disc { transform: translateX(7px); }
.si-tile.si-in .si-disc { transform: translateX(-12px); transition-duration: 300ms; transition-timing-function: var(--si-ease); }
/* The sleeve's open side: a hairline just inside the right edge */
.si-tile::after {
    content: '';
    position: absolute;
    top: 6px;
    bottom: 6px;
    right: 4px;
    border-left: 1px solid var(--si-line);
    opacity: 0.6;
}
.si-tile:hover { border-color: var(--si-faint); }
.si-tile:focus-visible { outline: 2px solid var(--si-accent); outline-offset: 3px; }
.si-words { display: flex; flex-direction: column; min-width: 0; }
.si-title { font-size: 11px; font-weight: 500; line-height: 1.3; }
.si-sub { font-size: 10px; color: var(--si-muted); line-height: 1.3; }

/* Picked up */
.si-tile.si-drag {
    cursor: grabbing;
    pointer-events: none;
    z-index: 5;
    --s: 1.06;
    border-color: var(--si-faint);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 18px 30px -14px rgba(0, 0, 0, 0.85);
    transition: box-shadow 240ms var(--si-ease), border-color 200ms var(--si-ease), opacity 240ms var(--si-ease);
}
/* Over a drop zone */
.si-tile.si-over { border-color: var(--si-accent); }
/* Went in */
.si-tile.si-in {
    --s: 0.4;
    opacity: 0;
    transition: transform 360ms var(--si-ease), opacity 260ms var(--si-ease) 60ms;
}
/* Flicked away */
.si-tile.si-fly {
    opacity: 0;
    transition: transform 520ms var(--si-ease), opacity 420ms var(--si-ease) 100ms;
}

/* ---------- The pile ---------- */
.si-pile {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    opacity: 0;
    transition: opacity 320ms var(--si-ease), transform 480ms var(--si-ease);
}
.si-pile.si-show { opacity: 1; }
.si-pile.si-away { opacity: 0; transform: translateX(60px); pointer-events: none; }

/* The note sits on its own card, so it reads over whatever is behind it */
.si-pile-head {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 4px 7px 12px;
    background: var(--si-bg);
    border: 1px solid var(--line, #2a2a28);
    border-radius: 6px;
    box-shadow: 0 8px 20px -14px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 360ms var(--si-ease) 420ms, transform 480ms var(--si-ease) 420ms;
}
.si-pile.si-show .si-pile-head { opacity: 1; transform: none; }
.si-label { margin: 0; color: var(--si-muted); font-size: 12px; line-height: 1.45; text-align: right; }
.si-label strong { color: var(--si-text); font-weight: 500; }
.si-close {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font: inherit;
    color: var(--si-faint);
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: color 140ms var(--si-ease), background-color 140ms var(--si-ease);
}
.si-close:hover { color: var(--si-text); background: var(--si-bg-2); }
.si-close:focus-visible { outline: 2px solid var(--si-accent); outline-offset: 2px; }

.si-pile-stack {
    --dx: 0px; --dy: 0px; --tilt: 0deg; --s: 1;
    position: relative;
    width: 92px;
    height: 92px;
    transform: translate(var(--dx), var(--dy)) rotate(var(--tilt)) scale(var(--s));
    transition: transform 560ms var(--si-spring), opacity 240ms var(--si-ease);
}
/* Carried whole by the "all" chip */
.si-pile-stack.si-drag { --s: 1.04; pointer-events: none; transition: none; }
.si-pile-stack.si-in {
    --s: 0.4;
    opacity: 0;
    transition: transform 360ms var(--si-ease), opacity 260ms var(--si-ease) 60ms;
}

/* "all three": a small chip in the note that carries the whole pile */
.si-all {
    padding: 0 5px;
    font: inherit;
    color: var(--si-text);
    background: var(--si-bg-2);
    border: 1px solid var(--si-line);
    border-radius: 3px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: border-color 140ms var(--si-ease), color 140ms var(--si-ease);
}
.si-all:hover { border-color: var(--si-faint); }
.si-all:active { cursor: grabbing; }
.si-all:focus-visible { outline: 2px solid var(--si-accent); outline-offset: 2px; }
/* Fans out under the pointer */
@media (hover: hover) {
    /* The stack widens under the fanned sleeves, so the gaps between them keep it open */
    .si-pile:not(.si-carry):hover .si-pile-stack,
    .si-pile.si-active .si-pile-stack,
    .si-pile:not(.si-carry):focus-within .si-pile-stack { width: calc(92px + (var(--n, 3) - 1) * 104px); }
    .si-pile:not(.si-carry):hover .si-tile,
    .si-pile.si-active .si-tile,
    .si-pile:not(.si-carry):focus-within .si-tile { --fx: calc(var(--i) * -104px); --fy: 0px; --r: calc(var(--rest) * 0.25); }
}
/* Arriving: each sleeve slides in from off the bottom-right */
.si-tile.si-pre { --ax: 60px; --ay: 160px; --ar: 18deg; opacity: 0; }

/* Mixer: decks are dark; keep the sleeves readable there */
.si-mixer .si-tile { background: #1c1c1b; }

/* ---------- Phone ---------- */
@media (max-width: 700px) {
    .si-pile { right: 14px; bottom: 18px; gap: 10px; }
    /* room above the credit line for the tiles, which rest on it at the end of the page (see restOnCredit) */
    body:has(.si-pile) .credit { padding-top: 190px; }
    .si-pile-stack, .si-tile { width: 76px; height: 76px; }
    .si-tile { padding: 7px 7px 6px; }
    .si-record { right: calc(-18px - 1.5px); width: 18px; }
    .si-label { font-size: 11px; }
    /* Above the Mixer's Collection bar */
    .si-mixer .si-pile { bottom: calc(68px + env(safe-area-inset-bottom)); }
}

/* A/B tips: the button to try next gets a quiet orange ring */
.si-hint {
    outline: 1px solid var(--si-accent);
    outline-offset: 3px;
    animation: si-hint 1.6s var(--si-ease) 2;
}
@keyframes si-hint {
    0% { outline-offset: 9px; outline-color: rgba(255, 122, 61, 0); }
    60%, 100% { outline-offset: 3px; outline-color: var(--si-accent); }
}

@media (prefers-reduced-motion: reduce) {
    .si-hint { animation: none; }
    .si-disc { transition-duration: 1ms; }
    .si-tile, .si-pile, .si-pile-head {
        transition-duration: 1ms !important;
        transition-delay: 0ms !important;
    }
}
