/* ==========================================================================
   DANBUG — OSTRICH CASSETTE PLAYER STYLES
   Bravío Records Audio Experience (Pixel-Perfect Alignment)
   ========================================================================== */

:root {
    --bg-main: #06070a;
    --bg-card: rgba(18, 20, 28, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.25);
    --text-primary: #f0f2f8;
    --text-secondary: #8a8e9e;
    --text-muted: #535767;
    
    /* Cassette Painted Palette Accents */
    --cassette-green: #37ba65;
    --cassette-yellow: #f8c822;
    --cassette-orange: #f45d22;
    --cassette-blue: #1ba0da;
    --cassette-purple: #8f34bb;
    --accent-red: #ff3344;
    
    /* Font families */
    --font-heading: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Space Grotesk', -apple-system, sans-serif;
    --font-mono: 'Space Mono', monospace;
    --font-hand: 'Caveat', cursive;

    /* Transitions */
    --ease-out-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-tactile: cubic-bezier(0.2, 0, 0, 1);
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- PAGE PRELOADER --- */
.page-loader {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background-color: #06070a;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s var(--ease-out-smooth), visibility 0.6s var(--ease-out-smooth);
}

.page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    text-align: center;
}

.loader-cassette-icon {
    position: relative;
    width: 80px;
    height: 52px;
    background: #11141c;
    border: 2px solid #2b3242;
    border-radius: 8px;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(248, 200, 34, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
}

.mini-spool {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #11141c;
    box-shadow: 0 0 0 2px #ffffff;
    animation: rotateMiniSpool 1.2s linear infinite;
    position: relative;
}

.mini-spool::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: #11141c;
    border-radius: 50%;
}

@keyframes rotateMiniSpool {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mini-window {
    width: 16px;
    height: 12px;
    background: #1f2533;
    border: 1px solid #3d465c;
    border-radius: 2px;
}

.loader-text-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.loader-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--cassette-yellow);
    animation: loaderPulse 1.5s infinite ease-in-out;
}

.loader-sub {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
}

@keyframes loaderPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loader-progress-bar {
    width: 140px;
    height: 3px;
    background: #181c26;
    border-radius: 999px;
    overflow: hidden;
}

.loader-progress-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--cassette-green), var(--cassette-yellow), var(--cassette-orange));
    animation: loaderFill 1.4s infinite ease-in-out;
    transform-origin: left;
}

@keyframes loaderFill {
    0% { transform: scaleX(0.1) translateX(-50%); }
    50% { transform: scaleX(0.8) translateX(20%); }
    100% { transform: scaleX(1) translateX(100%); }
}

/* --- AMBIENT GLOW & PARTICLES --- */
#particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
}

.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    transition: opacity 1s ease;
}

.glow-1 {
    width: 500px;
    height: 500px;
    top: -100px;
    left: 10%;
    background: radial-gradient(circle, var(--cassette-green), transparent 70%);
}

.glow-2 {
    width: 600px;
    height: 600px;
    bottom: -150px;
    right: 5%;
    background: radial-gradient(circle, var(--cassette-orange), transparent 70%);
}

.glow-3 {
    width: 450px;
    height: 450px;
    top: 40%;
    left: 45%;
    background: radial-gradient(circle, var(--cassette-blue), transparent 70%);
}

/* --- APP CONTAINER --- */
.app-container {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 2rem 3rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* --- TOP NAV --- */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 2rem;
}

.nav-back-link, .nav-home-link {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    transition: color 0.3s ease, transform 0.3s ease;
}

.nav-back-link:hover, .nav-home-link:hover {
    color: #fff;
    transform: translateX(-3px);
}

.nav-home-link:hover {
    transform: translateX(3px);
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    color: var(--cassette-yellow);
    background: rgba(248, 200, 34, 0.08);
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(248, 200, 34, 0.25);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--cassette-yellow);
    box-shadow: 0 0 8px var(--cassette-yellow);
    animation: pulse 1.8s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* --- PLAYER STAGE & CASSETTE 3D VIEWPORT --- */
.player-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.2rem;
    width: 100%;
}

.cassette-viewport {
    perspective: 1200px;
    width: 100%;
    max-width: 660px;
    display: flex;
    justify-content: center;
}

.cassette-3d-box {
    width: 100%;
    transition: transform 0.15s ease-out;
    transform-style: preserve-3d;
}

.cassette-card {
    position: relative;
    width: 100%;
    aspect-ratio: 832 / 524;
    transform-style: preserve-3d;
    transition: transform 0.8s var(--ease-out-smooth);
}

.cassette-card.is-flipped {
    transform: rotateY(180deg);
}

/* Cassette Faces */
.cassette-side {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 20px;
    box-shadow: 
        0 25px 50px -10px rgba(0, 0, 0, 0.85),
        0 0 35px rgba(27, 160, 218, 0.2);
}

.cassette-back {
    transform: rotateY(180deg);
}

.cassette-art-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
    background: #0d0f14;
}

.cassette-art-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 20px;
    pointer-events: none;
    user-select: none;
}

.back-img {
    filter: hue-rotate(35deg) saturate(1.1);
}

/* Plastic Gloss Reflection */
.shell-glare {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.06) 30%, transparent 60%);
    z-index: 15;
    pointer-events: none;
    border-radius: 20px;
}

/* --- PRECISION ROTATING REELS & SPOOLS --- */
/* Exact pixel-matched coordinates: 
   Left: (31.06%, 46.98%)
   Right: (69.42%, 46.71%)
*/
.reel-container {
    position: absolute;
    width: 10.2%;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.reel-left {
    left: 31.06%;
    top: 46.98%;
}

.reel-right {
    left: 69.42%;
    top: 46.71%;
}

/* Magnetic Tape Pack on each reel (smooth dark circle behind the white spool) */
.tape-pack {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, #3a2a1f 40%, #1e130c 80%, #0d0704 100%);
    box-shadow: 0 0 8px rgba(0,0,0,0.85);
    z-index: 1;
    pointer-events: none;
    transition: width 0.3s ease, height 0.3s ease;
}

/* Starting sizes for side A */
.tape-pack-left {
    width: 220%;
    height: 220%;
}

.tape-pack-right {
    width: 120%;
    height: 120%;
}

/* Spool Core (SVG Teeth Wheel) */
.spool-wheel {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
}

.wheel-svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}

/* Spinning Animation States */
.spool-wheel.is-spinning {
    animation: rotateWheel 1.8s linear infinite;
}

.spool-wheel.is-fast-spinning {
    animation: rotateWheel 0.35s linear infinite;
}

.spool-wheel.is-rewinding {
    animation: rotateWheelReverse 0.35s linear infinite;
}

@keyframes rotateWheel {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rotateWheelReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* --- CENTER TAPE VIEWPORT --- */
.center-tape-window {
    position: absolute;
    left: 44.47%;
    top: 38.17%;
    width: 11.42%;
    height: 15.27%;
    border-radius: 4px;
    overflow: hidden;
    pointer-events: none;
    z-index: 4;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.6);
}

.tape-running-strip {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 38%;
    transform: translateY(-50%);
    background: linear-gradient(180deg, #3d291e 0%, #1e130d 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.tape-window-glass {
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255,255,255,0.18) 0%, transparent 50%, rgba(255,255,255,0.06) 80%, transparent 100%);
}

/* Track Badge on bottom */
.cassette-track-badge {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(12, 14, 18, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    z-index: 10;
    pointer-events: none;
}

.badge-side {
    color: var(--cassette-yellow);
    font-weight: 700;
}

.badge-track {
    color: #e5e9f0;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   TAPE DECK CONTROLLER INTERFACE
   ========================================================================== */

.deck-controls-panel {
    width: 100%;
    max-width: 860px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 2rem 2.5rem;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.6),
        0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

/* Dashboard: Counter + Status Screen + VU Meters */
.deck-dashboard {
    display: grid;
    grid-template-columns: 140px 1fr 180px;
    gap: 1.5rem;
    align-items: stretch;
}

.deck-label {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Counter Module */
.counter-module {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.counter-display {
    background: #090a0e;
    border: 2px solid #1e222d;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    display: flex;
    justify-content: center;
    gap: 4px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
}

.counter-digit {
    background: #151820;
    color: #e5e9f0;
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
    border: 1px solid #2d3342;
    min-width: 24px;
    text-align: center;
}

.counter-reset-btn {
    background: #1a1e28;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.counter-reset-btn:hover {
    background: #252b3a;
    color: #fff;
}

/* Status Screen (Neon VFD Display) */
.deck-screen {
    background: #040808;
    border: 2px solid #142a24;
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    box-shadow: 
        inset 0 2px 10px rgba(0,0,0,0.9),
        0 0 15px rgba(27, 218, 160, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.deck-status-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #334;
    box-shadow: none;
    transition: all 0.3s ease;
}

.status-indicator.playing {
    background-color: #2bf888;
    box-shadow: 0 0 10px #2bf888;
}

.status-indicator.ff, .status-indicator.rew {
    background-color: var(--cassette-yellow);
    box-shadow: 0 0 10px var(--cassette-yellow);
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #2bf888;
}

.deck-time-display {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: #e5fdf0;
    text-shadow: 0 0 8px rgba(43, 248, 136, 0.4);
    letter-spacing: 0.05em;
    margin: 0.15rem 0;
}

.deck-audio-title {
    font-size: 0.75rem;
    font-family: var(--font-body);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* VU Meters Module */
.vu-module {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.vu-meters {
    background: #090a0e;
    border: 2px solid #1e222d;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    justify-content: center;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
}

.vu-channel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.channel-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    width: 10px;
}

.vu-bar-container {
    flex: 1;
    height: 10px;
    background: #161922;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    border: 1px solid #252a38;
}

.vu-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2bf888 0%, #2bf888 65%, #f8c822 80%, #ff3344 100%);
    border-radius: 2px;
    transition: width 0.08s ease-out;
    box-shadow: 0 0 6px rgba(43, 248, 136, 0.5);
}

/* --- PROGRESS SCRUBBER --- */
.deck-progress-container {
    width: 100%;
    padding: 0.2rem 0;
}

.tape-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #1a1e28;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    position: relative;
}

.tape-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--cassette-yellow);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--cassette-yellow);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.tape-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

/* --- MECHANICAL DECK BUTTONS --- */
.deck-buttons-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.deck-btn {
    background: linear-gradient(180deg, #2b303d 0%, #181b22 100%);
    border: 1px solid #3c4354;
    border-bottom: 4px solid #0f1116;
    border-radius: 12px;
    padding: 0;
    cursor: pointer;
    position: relative;
    box-shadow: 0 6px 12px rgba(0,0,0,0.5);
    transition: all 0.1s var(--ease-tactile);
    outline: none;
    flex: 1;
    min-width: 80px;
    max-width: 115px;
    height: 64px;
}

.deck-btn:hover {
    background: linear-gradient(180deg, #373e4f 0%, #1f232d 100%);
    border-color: #515a70;
}

.deck-btn:active, .deck-btn.is-active {
    transform: translateY(3px);
    border-bottom-width: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.btn-cap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    height: 100%;
    color: var(--text-primary);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.primary-cap {
    color: var(--cassette-green);
}

.btn-play.is-active .primary-cap {
    color: #fff;
}

.btn-play.is-active {
    background: linear-gradient(180deg, #1b8a47 0%, #0d542a 100%);
    border-color: #2bf888;
    box-shadow: 0 0 15px rgba(43, 248, 136, 0.4);
}

.btn-rewind.is-active, .btn-ff.is-active {
    background: linear-gradient(180deg, #997810 0%, #5e4807 100%);
    border-color: var(--cassette-yellow);
    box-shadow: 0 0 15px rgba(248, 200, 34, 0.35);
}

/* Side Volume & Tape Hiss */
.deck-side-controls {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-left: auto;
}

.control-knob-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.control-knob-group input[type="range"] {
    width: 80px;
    accent-color: var(--cassette-yellow);
}

.toggle-hiss-btn {
    background: #141720;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-hiss-btn.active {
    color: var(--cassette-yellow);
    border-color: rgba(248, 200, 34, 0.4);
    background: rgba(248, 200, 34, 0.08);
}

/* --- TRACKLIST DRAWER --- */
.tracklist-drawer {
    border-top: 1px solid var(--border-subtle);
    padding-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.tracklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.tracklist-count {
    color: var(--cassette-yellow);
    font-weight: 700;
}

.track-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 160px;
    overflow-y: auto;
    padding-right: 0.4rem;
}

.track-pill-list::-webkit-scrollbar {
    width: 4px;
}
.track-pill-list::-webkit-scrollbar-thumb {
    background: #2b303d;
    border-radius: 4px;
}

.track-pill {
    background: #13161e;
    color: var(--text-secondary);
    border: 1px solid #232836;
    border-radius: 8px;
    padding: 0.45rem 0.9rem;
    font-size: 0.78rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.track-pill:hover {
    background: #1d222e;
    color: #fff;
    border-color: #3f475e;
}

.track-pill.active {
    background: var(--cassette-yellow);
    color: #0c0e14;
    font-weight: 700;
    border-color: var(--cassette-yellow);
    box-shadow: 0 0 12px rgba(248, 200, 34, 0.3);
}

/* ==========================================================================
   RESPONSIVE STYLES
   ========================================================================== */

@media (max-width: 900px) {
    .deck-dashboard {
        grid-template-columns: 1fr;
    }
    
    .vu-module, .counter-module {
        display: none;
    }
    
    .deck-controls-panel {
        padding: 1.5rem;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 1rem 1rem 2rem;
    }

    .top-nav {
        flex-direction: column;
        gap: 0.8rem;
        align-items: flex-start;
    }

    .deck-buttons-row {
        gap: 0.4rem;
    }

    .deck-btn {
        min-width: 55px;
        height: 54px;
    }

    .btn-cap {
        font-size: 0.6rem;
    }

    .btn-cap svg {
        width: 18px;
        height: 18px;
    }

    .deck-side-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }
}
