/* ============================================================
   GESTURE MPC — Compact Top-Bar + Full-Width Pads
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&family=Inter:wght@300;400;600;700&display=swap');

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

body {
    font-family: 'Inter', 'Helvetica Neue', sans-serif;
    background: #C9A691;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ---- Camera ---- */
#camera-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    object-fit: cover;
    transform: scaleX(-1);
    z-index: 0;
    display: none;
}
#camera-bg.active { display: block; }

body.camera-on #camera-bg { opacity: 1; }
body.camera-on .wall { opacity: 0.15; }
body.camera-on .device { background: rgba(30, 34, 24, 0.35); }
body.camera-on .top-bar { background: rgba(30, 34, 24, 0.55); }
body.camera-on .pad { background: rgba(168, 181, 162, 0.35); }
body.camera-on .piano-key.white { background: rgba(255,255,255,0.35); }
body.camera-on .piano-key.black { background: rgba(40,45,35,0.55); }

#hand-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 50;
    pointer-events: none;
    display: none;
}
#hand-canvas.active { display: block; }

/* ---- Film Grain ---- */
.film-grain {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 100;
    pointer-events: none;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ---- Wall ---- */
.wall {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 1;
    background: #C9A691;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23t)' opacity='0.15'/%3E%3C/svg%3E");
    transition: opacity 0.3s;
}
.vignette {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(60,30,15,0.35) 100%);
}

/* ---- Device (full viewport) ---- */
.device {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    display: flex;
    flex-direction: column;
    transition: background 0.3s;
}

/* ---- Top Bar ---- */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: linear-gradient(to bottom, #2A2E1F, #222618);
    border-bottom: 2px solid rgba(93,212,67,0.15);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    flex-shrink: 0;
    z-index: 11;
    transition: background 0.3s;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-shrink: 0;
}
.brand-akai {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.12em;
    color: #ddd;
}
.brand-pro {
    font-style: italic;
    font-size: 10px;
    color: #888;
    font-family: Georgia, serif;
}

/* LCD — inline horizontal */
.lcd {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: #1E2218;
    border-radius: 4px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), 0 0 10px rgba(93,212,67,0.05);
    overflow: hidden;
}
.lcd-line {
    font-family: 'VT323', monospace;
    font-size: 18px;
    color: #5DD443;
    text-shadow: 0 0 4px #5DD443, 0 0 8px rgba(93,212,67,0.4);
    white-space: nowrap;
}
.lcd-sep {
    color: #3A5030;
    font-family: 'VT323', monospace;
    font-size: 18px;
}

/* Control buttons */
.top-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.ctrl-btn {
    padding: 8px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ccc;
    background: linear-gradient(to bottom, #4A5040, #3A4030);
    border: 1px solid rgba(93,212,67,0.2);
    border-radius: 5px;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.1s;
}
.ctrl-btn:hover {
    background: linear-gradient(to bottom, #5A6550, #4A5540);
    border-color: rgba(93,212,67,0.4);
}
.ctrl-btn:active, .ctrl-btn.active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
    transform: translateY(1px);
    background: linear-gradient(to bottom, #3A4530, #2A3520);
    color: #5DD443;
    border-color: #5DD443;
    text-shadow: 0 0 6px rgba(93,212,67,0.5);
}
.ctrl-btn.stop {
    background: linear-gradient(to bottom, #8A2820, #6A1810);
    border-color: rgba(255,50,50,0.3);
    color: #faa;
}
.ctrl-btn.stop:hover {
    background: linear-gradient(to bottom, #A03028, #802018);
}

/* Action pads (STOP, CAM) */
.runaway-pad.action-pad .pad-label {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

/* Playing state — pulsing glow on toggleable pads */
.pad.playing {
    box-shadow:
        inset 0 0 15px rgba(93,212,67,0.2),
        0 0 20px rgba(93,212,67,0.3);
    border-color: rgba(93,212,67,0.5);
}
.pad.playing .pad-status {
    color: #5DD443;
}
.pad.playing::after {
    content: "PLAYING";
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #5DD443;
    text-shadow: 0 0 6px rgba(93,212,67,0.5);
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- PAD GRID — 4x4 full area ---- */
.pad-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 12px;
}

.pad {
    position: relative;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    background: rgba(168, 181, 162, 0.75);
    border: 1px solid rgba(0,0,0,0.15);
    box-shadow:
        inset 0 -2px 0 rgba(0,0,0,0.15),
        0 3px 8px rgba(0,0,0,0.15);
    transition: all 0.08s;
}
.pad .pad-key {
    position: absolute;
    top: 8px; right: 10px;
    font-size: 13px;
    font-weight: 400;
    color: #6B7A6B;
    text-transform: uppercase;
}
.pad .pad-label {
    font-size: 16px;
    font-weight: 500;
    color: #3A4A38;
}
.pad:hover {
    background: rgba(178, 191, 172, 0.85);
    box-shadow:
        inset 0 -2px 0 rgba(0,0,0,0.15),
        0 4px 12px rgba(0,0,0,0.2);
}
.pad:active, .pad.active {
    transform: scale(0.96);
    filter: brightness(1.2);
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.2),
        0 0 20px rgba(93,212,67,0.35);
    border-color: rgba(93,212,67,0.4);
}

/* Air drum hover target highlight */
.pad.air-hover,
.piano-key.air-hover {
    box-shadow: 0 0 12px rgba(93,212,67,0.25);
    border-color: rgba(93,212,67,0.35);
    transform: scale(1.03);
}

/* ---- TABLA PADS ---- */
.tabla-pad .pad-label {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #3A2E1E;
}
.tabla-pad .pad-key {
    color: rgba(80, 60, 40, 0.5);
}
.tabla-pad:nth-child(-n+8) {
    border-left: 3px solid rgba(193, 154, 107, 0.3);
}
.tabla-pad:nth-child(n+9) {
    border-left: 3px solid rgba(90, 110, 120, 0.3);
}
body.camera-on .tabla-pad {
    background: rgba(168, 181, 162, 0.3) !important;
}

/* ---- RUNAWAY PADS ---- */
.runaway-pad {
    flex-direction: column;
    gap: 4px;
    border: 2px solid rgba(255,255,255,0.08);
}
.runaway-pad .pad-label {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.runaway-pad .pad-key {
    color: rgba(255,255,255,0.4);
}
.runaway-pad .pad-status {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
}
.runaway-pad.loaded .pad-status {
    color: #5DD443;
    text-shadow: 0 0 4px rgba(93,212,67,0.4);
}
.runaway-pad.drag-over {
    border-color: #5DD443 !important;
    box-shadow: inset 0 0 30px rgba(93,212,67,0.2), 0 0 20px rgba(93,212,67,0.3) !important;
    transform: scale(1.02);
}
.runaway-pad:active, .runaway-pad.active {
    filter: brightness(1.4);
    transform: scale(0.96);
    box-shadow:
        inset 0 0 20px rgba(255,255,255,0.15),
        0 0 25px rgba(255,255,255,0.2);
}

/* ---- PIANO KEYBOARD ---- */
.piano-keyboard {
    flex: 1;
    display: flex;
    position: relative;
    gap: 0;
    padding: 12px;
    grid-template-columns: none;
}

.piano-key {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 14px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: filter 0.05s, box-shadow 0.05s;
}

.piano-key.white {
    flex: 1;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(230,230,230,0.85));
    color: #6B7A6B;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 0 0 8px 8px;
    z-index: 1;
    box-shadow:
        inset 0 -3px 0 rgba(0,0,0,0.08),
        0 4px 8px rgba(0,0,0,0.15);
}
.piano-key.black {
    width: 64px;
    height: 58%;
    background: linear-gradient(to bottom, rgba(50,55,45,0.95), rgba(30,35,25,0.9));
    color: #8A9A8A;
    border-radius: 0 0 6px 6px;
    margin-left: -32px;
    margin-right: -32px;
    z-index: 2;
    box-shadow: 0 5px 10px rgba(0,0,0,0.4);
    font-size: 9px;
}
.piano-key.white:active, .piano-key.white.active {
    background: linear-gradient(to bottom, rgba(200,230,190,0.95), rgba(180,215,175,0.9));
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.15), 0 0 15px rgba(93,212,67,0.35);
}
.piano-key.black:active, .piano-key.black.active {
    background: linear-gradient(to bottom, rgba(70,80,60,0.95), rgba(45,55,40,0.9));
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 0 12px rgba(93,212,67,0.25);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .top-bar { padding: 8px 12px; gap: 8px; }
    .brand-akai { font-size: 14px; }
    .brand-pro { display: none; }
    .lcd { font-size: 14px; padding: 4px 8px; }
    .lcd-line { font-size: 14px; }
    .ctrl-btn { padding: 6px 12px; font-size: 10px; }
    .pad .pad-label { font-size: 12px; }
    .pad .pad-key { font-size: 10px; }
    .pad-grid { gap: 6px; padding: 8px; }
}
