/* S&S Radio — listener Activity chassis.
 *
 * Two-row layout:
 *   Row 1 (controls + meters):  [Mute] [Gain] [10-band Graphic EQ] [Stereo VU]
 *   Row 2 (display):            [Next Up] [Cassette tape player] [Now playing]
 *
 * Cassette graphic is lifted verbatim from the Listening Booth — same layered
 * structure, same container queries, same cqw-driven scaling, same spool spin.
 */

:root {
    --case-color:    #2c3e50;
    --case-shadow:   #1a252f;
    --panel-dark:    #1a1a1a;
    --panel-darker:  #0e0e0e;
    --panel-recess:  #0a0a0a;
    --text-color:    #bdc3c7;
    --text-dim:      #7f8c8d;
    --accent-orange: #d35400;
    --accent-cyan:   #4dd0e1;
    --led-red:       #ff3333;
    --led-green:     #00ff00;
    --led-amber:     #ffb300;
    --eq-handle:     #f5f5f5;
    --eq-track:      #1a1a1a;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--case-shadow);
    color: var(--text-color);
    font-family: 'Aldrich', 'Lexend Mega', sans-serif;
    height: 100%;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ========================== Chassis shell ========================== */

.chassis {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0.85rem 1rem 1rem;
    background-color: #1a1a1a;
    background-image: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 50%, #0e0e0e 100%);
    border-bottom: 6px solid #0a0a0a;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.10),
        inset 0 -1px 0 rgba(0, 0, 0, 0.6),
        0 18px 40px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    overflow: hidden;
}

.chassis::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('/img/brushed-metal.jpg') center/cover no-repeat;
    opacity: 0.4;
    pointer-events: none;
}

.chassis > * { position: relative; z-index: 1; }

/* ====================== Top bar (brand + ON AIR) ====================== */

.chassis-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.45);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
    flex: 0 0 auto;
}

.brand {
    display: flex;
    flex-direction: column;
    line-height: 1;
    letter-spacing: 0.18em;
}
.brand-line-1 { font-size: 1.15rem; }
.brand-line-2 { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.18rem; }

.on-air {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.7rem;
    background: var(--panel-darker);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.on-air-led {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--led-red);
    box-shadow: 0 0 6px var(--led-red);
    animation: blink 1.2s infinite ease-in-out;
}
.on-air-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: var(--led-red);
}

.chassis-top-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.submit-song-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: var(--text-color);
    background: linear-gradient(180deg, #2a2a2a 0%, #161616 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 1px 2px rgba(0, 0, 0, 0.5);
    transition: background 140ms, color 140ms, transform 80ms;
}
.submit-song-btn:hover {
    color: #fff;
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
}
.submit-song-btn:active { transform: translateY(1px); }
@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75%      { opacity: 0.4; }
}

/* ============================ Rows ============================ */

.row {
    display: flex;
    gap: 0.6rem;
    min-height: 0;
}

.row-controls { flex: 1 1 50%; }
.row-display  { flex: 1 1 50%; }

.bay {
    background: linear-gradient(180deg, #0e0e0e 0%, #161616 100%);
    border-radius: 6px;
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.85),
        inset 0 -1px 0 rgba(255, 255, 255, 0.03),
        0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

/* ======================== Row 1: controls ======================== */

.bay-mute  { flex: 0 0 80px;  display: flex; align-items: center; justify-content: center; padding: 12px 8px; }
.bay-gain  { flex: 0 0 70px;  display: flex; align-items: stretch; padding: 10px 6px; }
.bay-eq    { flex: 1 1 auto;  padding: 10px 12px; min-width: 0; display: flex; align-items: center; justify-content: center; }
.bay-vu    { flex: 0 0 320px; display: flex; align-items: center; justify-content: center; padding: 8px; }

/* ---- Mute button ---- */

.mute-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #2a0606 0%, #1a0303 60%, #0a0202 100%);
    border: 2px solid #000;
    box-shadow:
        inset 0 1px 0 rgba(255, 100, 100, 0.15),
        inset 0 -2px 4px rgba(0, 0, 0, 0.8),
        0 3px 6px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    color: var(--text-color);
    font-family: inherit;
    transition: background 180ms, box-shadow 180ms, transform 80ms;
}
.mute-btn:active { transform: translateY(1px); }
.mute-led {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #6b1414 0%, #3a0606 60%, #1a0303 100%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
    transition: background 180ms, box-shadow 180ms;
}
.mute-btn[aria-pressed="true"] {
    background: radial-gradient(circle at 35% 30%, #ff5050 0%, #b30000 60%, #4a0000 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 200, 200, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.5),
        0 3px 6px rgba(0, 0, 0, 0.7),
        0 0 16px rgba(255, 51, 51, 0.7);
}
.mute-btn[aria-pressed="true"] .mute-led {
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #ff5050 40%, #ff0000 100%);
    box-shadow:
        inset 0 1px 2px rgba(255,255,255,0.5),
        0 0 12px var(--led-red);
}
.mute-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.18em;
    color: #888;
}
.mute-btn[aria-pressed="true"] .mute-label { color: #fff; text-shadow: 0 0 4px rgba(255,255,255,0.6); }

/* ---- Gain vertical fader ---- */

.vfader {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    padding: 8px 4px;
    min-height: 0;
}
.vfader-readout {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    color: var(--led-red);
    height: 0.85rem;
    text-shadow: 0 0 3px rgba(255,51,51,0.4);
}
/* Custom div-based vertical fader. The track is the bounding box; the rail is
   the dark recessed channel; the thumb is a draggable red pill. */
.vfader-track {
    flex: 1 1 auto;
    width: 100%;
    min-height: 60px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    touch-action: none;
}
.vfader-rail {
    width: 8px;
    height: 100%;
    background: linear-gradient(to right, #1a0606 0%, #3a1010 50%, #1a0606 100%);
    border-radius: 4px;
    border: 1px solid #000;
    box-shadow:
        inset 0 1px 2px rgba(0,0,0,0.85),
        inset 0 -1px 0 rgba(255,255,255,0.03);
}
.vfader-thumb {
    position: absolute;
    left: 50%;
    width: 32px;
    height: 18px;
    background: linear-gradient(180deg, #ff5e5e 0%, #b30000 100%);
    border: 1px solid #4a0000;
    border-radius: 9px / 7px;
    transform: translate(-50%, -50%);
    box-shadow:
        0 2px 4px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.4);
    cursor: grab;
    /* center thumb gets a subtle highlight line so the user sees where 0 is */
}
.vfader-thumb:active { cursor: grabbing; }
.vfader-thumb::before {
    content: '';
    position: absolute;
    inset: 50% 5px auto 5px;
    height: 1px;
    background: rgba(0,0,0,0.5);
    transform: translateY(-50%);
}
.vfader-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    color: var(--text-color);
}

/* ---- 10-band Graphic EQ ---- */

.eq-board {
    display: grid;
    grid-template-columns: 30px 1fr;
    grid-template-rows: 16px 1fr;
    gap: 4px;
    width: 100%;
    height: 100%;
    max-width: 380px;
    max-height: 205px;
}
.eq-corner { /* top-left filler */ }
.eq-freqs {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    align-items: center;
    text-align: center;
}
.eq-freq {
    font-family: 'Aldrich', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 0.05em;
    color: var(--text-color);
}
.eq-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 4px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.6rem;
    color: var(--text-dim);
}
.eq-scale > span:nth-child(2) { /* center 0 dB tick gets accent */
    color: var(--text-color);
}

.eq-bands {
    position: relative;
    display: flex;
    align-items: stretch;
    height: 100%;
    min-width: 0;
    overflow: hidden;
}
/* Cyan grid lines across all sliders, spanning the full bands area. */
.eq-grid-line {
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: rgba(77, 208, 225, 0.55);
    box-shadow: 0 0 3px rgba(77, 208, 225, 0.35);
    pointer-events: none;
    z-index: 1;
}

.eq-band {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.eq-track {
    position: relative;
    width: 14px;
    height: 100%;
    cursor: ns-resize;
    touch-action: none;
}
.eq-rail {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #050505 0%, #1a1a1a 50%, #050505 100%);
    border-radius: 7px;
    border: 1px solid #000;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.85),
        inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}
.eq-thumb {
    position: absolute;
    left: 50%;
    width: 24px;
    height: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #d6d6d6 100%);
    border: 1px solid #6a6a6a;
    border-radius: 12px / 7px;
    transform: translate(-50%, -50%);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    cursor: grab;
    z-index: 2;
}
.eq-thumb:active { cursor: grabbing; }
.eq-thumb::before {
    content: '';
    position: absolute;
    inset: 50% 5px auto 5px;
    height: 1px;
    background: rgba(0,0,0,0.35);
    transform: translateY(-50%);
}

/* ---- Stereo VU sweep meters ---- */

.vu-pair {
    display: flex;
    gap: 6px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}
.vu-meter {
    flex: 1 1 50%;
    background: #2c2014;
    border-radius: 6px;
    border: 1px solid #000;
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.7),
        0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 4px;
    aspect-ratio: 200 / 130;
    max-height: 100%;
}
.vu-svg {
    width: 100%;
    height: 100%;
    display: block;
}
.vu-needle {
    transform-origin: 100px 115px;
    transition: transform 60ms linear; /* JS sets the angle; transition smooths frame jitter */
}
.vu-tick { stroke: #3a2c14; stroke-width: 1; }
.vu-tick.major { stroke-width: 1.5; }
.vu-tick.red   { stroke: #aa1414; }
.vu-tick-label { font-family: 'Aldrich', sans-serif; font-size: 7px; fill: #3a2c14; }
.vu-tick-label.red { fill: #aa1414; }
.vu-arc { fill: none; stroke: #3a2c14; stroke-width: 1; }
.vu-arc.red { stroke: #aa1414; stroke-width: 2; }
.vu-vu-text {
    font-family: 'Aldrich', sans-serif;
    font-size: 11px;
    fill: #3a2c14;
}

/* ====================== Row 2: display ====================== */

.bay-tape   { flex: 1 1 44%; padding: 10px; display: flex; align-items: center; justify-content: center; min-width: 0; }
.bay-screen { flex: 1 1 28%; padding: 10px; min-width: 0; }
/* Same fixed-percent flex for both screens so they're the same size. */
#next-bay   { flex: 1 1 28%; }

/* (next-up bay reuses .screen / .screen-glass styles below) */

/* ---- Cassette (lifted from Listening Booth) ---- */

.now-playing {
    background: var(--panel-dark);
    padding: 0.5rem 0.6rem 0.6rem;
    text-align: left;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
@keyframes cassette-spin {
    to { transform: rotate(360deg); }
}
.cassette-frame {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0 0.5rem;
    position: relative;
    width: 100%;
}
.cassette-lens {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: #925527;
    mix-blend-mode: multiply;
    opacity: 0.5;
    z-index: 10;
}
.cassette-sheen {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 11;
    background:
        linear-gradient(135deg, rgba(255, 240, 220, 0.22) 0%, rgba(255, 240, 220, 0) 38%, rgba(255, 240, 220, 0) 62%, rgba(0, 0, 0, 0.22) 100%),
        radial-gradient(ellipse at 28% 18%, rgba(255, 240, 220, 0.28) 0%, rgba(255, 240, 220, 0) 55%),
        radial-gradient(ellipse at 72% 82%, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0) 55%);
    box-shadow:
        inset 0 1px 0 rgba(255, 240, 220, 0.28),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}
.cassette-track-text {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    z-index: 6;
    font-family: 'Edu TAS Beginner', 'Share Tech Mono', monospace;
    font-size: 5cqw;
    font-weight: 600;
    color: #1a130c;
    text-align: center;
    pointer-events: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    padding-top: 4.4cqw;
}
.cassette-body {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 300 / 179;
    background: #111;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    container-type: inline-size;
}
.cassette-inset {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    height: 54%;
    background: #eee;
    border-radius: 1.25cqw;
    z-index: 2;
    box-shadow: inset 0 0 1.6cqw rgba(0, 0, 0, 0.2);
}
.cassette-label {
    position: absolute;
    top: 1.9cqw;
    left: 3.1cqw;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 900;
    font-size: 2.5cqw;
    letter-spacing: 0.3cqw;
    color: #333;
    z-index: 5;
}
.cassette-window {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 26%;
    background: #222;
    border-radius: 6.25cqw;
    border: 0.6cqw solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8%;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 4;
}
.cassette-spool {
    width: 13.1cqw;
    height: 13.1cqw;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cassette-spool::before {
    content: '';
    position: absolute;
    width: 140%;
    height: 140%;
    border-radius: 50%;
    background: radial-gradient(#4a3b32 60%, transparent 61%);
    z-index: 0;
}
.cassette-spool-gear {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    z-index: 1;
    mask: radial-gradient(transparent 50%, black 52%);
    -webkit-mask: radial-gradient(transparent 50%, black 52%);
    background: repeating-conic-gradient(#ffffff 0deg 10deg, #222222 10deg 60deg);
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
}
.now-playing.playing .cassette-spool {
    animation: cassette-spin 2s linear infinite;
}
.cassette-trapezoid {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 73%;
    height: 28%;
    background: #1a1a1a;
    z-index: 3;
    clip-path: polygon(10% 0, 90% 0, 100% 100%, 0% 100%);
    border-top: 1px solid #333;
}
.cassette-trapezoid::after {
    content: '';
    position: absolute;
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 33%;
    background: #000;
    border-radius: 0.6cqw;
}

/* ---- Now-playing screen (CRT style) ---- */

.screen {
    background: var(--panel-recess);
    border-radius: 6px;
    padding: 8px;
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.85),
        inset 0 -1px 0 rgba(255, 255, 255, 0.03);
    width: 100%;
    height: 100%;
    display: flex;
}
.screen-glass {
    flex: 1;
    background: radial-gradient(circle at 50% 35%, #2a2f1f 0%, #0c0f06 80%);
    border-radius: 5px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.screen-avatar {
    max-width: 60%;
    max-height: 60%;
    border-radius: 8px;
    filter: hue-rotate(60deg) saturate(0.4) brightness(0.85);
    mix-blend-mode: screen;
    opacity: 0.85;
}
.screen-avatar:not([src]) { display: none; }
.screen-name {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.55);
    color: var(--led-green);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 0.1em;
    text-shadow: 0 0 4px rgba(0, 255, 0, 0.4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.screen-tag {
    position: absolute;
    top: 0.35rem;
    left: 0.55rem;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--led-green);
    text-shadow: 0 0 3px rgba(0, 255, 0, 0.5);
    opacity: 0.9;
}

/* ====================== Connect overlay ====================== */

.connect-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(10, 10, 10, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}
.connect-overlay[hidden] { display: none; }
.connect-inner { text-align: center; padding: 2rem; max-width: 360px; }
.connect-brand { font-size: 1.5rem; letter-spacing: 0.2em; color: var(--text-color); margin-bottom: 1.3rem; }
.connect-status { font-family: 'Share Tech Mono', monospace; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 1.3rem; min-height: 1.2em; }
.connect-join {
    background: var(--accent-orange);
    color: #0a0a0a;
    border: none;
    padding: 0.95rem 3rem;
    font-family: inherit;
    font-size: 1rem;
    letter-spacing: 0.3em;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 4px 0 #6b2900;
}
.connect-join:hover:not(:disabled) { transform: translateY(1px); box-shadow: 0 3px 0 #6b2900; }
.connect-join:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 #6b2900; }
.connect-join:disabled { opacity: 0.4; cursor: default; }
.connect-help { margin-top: 1.4rem; font-size: 0.78rem; color: var(--text-dim); line-height: 1.5; }

/* ====================== Mobile ====================== */

@media (max-width: 540px) and (orientation: portrait) {
    .row { flex-direction: column; gap: 0.4rem; }
    .bay-mute { flex: 0 0 auto; }
    .bay-gain { flex: 0 0 110px; }
    .bay-eq   { flex: 0 0 220px; }
    .bay-vu   { flex: 0 0 130px; }
    .bay-next, .bay-tape, .bay-screen { flex: 0 0 auto; }
}
