/* ═══════════════════════════════════════════════════════════════
   TABLA VISUALIZER — Tamil Bookshelf MIDI Player
   tabla-visualizer.css  v2.0.0  (2026-05-20)

   FIXES in v2.0:
     • bolHitCentre animation: translateX(-50%) was missing from
       intermediate keyframes causing a jump on #bz-48/#bz-46/#bz-47
     • Hover transform conflict resolved — centred zones use a
       data-centred attribute approach via :is() selector
     • Added .bayaan-active / .dayaan-active glow (referenced in JS
       but missing from CSS)
     • striking-hand z-index raised above combo pads (was 30, now 35)
     • Waveform canvas properly visible on all viewport sizes
     • Minor: combo bol-zones position:static preserved in .tabla-combos
   ═══════════════════════════════════════════════════════════════ */

/* ── Custom properties ── */
:root {
    --gold:        #ffc768;
    --gold-dim:    rgba(201,148,58,0.28);
    --tabla-brown: #2a1508;
    --tabla-amber: #c9843a;
    --tabla-dark:  #0d0906;
    --bayaan-bg:   rgba(60,28,8,0.72);
    --dayaan-bg:   rgba(28,42,62,0.72);
    --combo-bg:    rgba(50,20,60,0.72);
    --text-dim:    #d1cfcf;
    --text-muted:  #888;
    --border2:     rgba(201,148,58,0.25);
}

/* ── Outer wrapper ── */
#midiPlayerInterface { margin: 14px 0; }

#staff-visualizer {
    background: url(../images/bg.jpg) no-repeat center bottom;
    background-size: cover;
    border: 1px solid var(--border2);
    border-radius: 14px;
    overflow: hidden;
    height: 520px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    box-shadow:
        inset 0 2px 10px rgba(0,0,0,0.65),
        0 6px 28px rgba(0,0,0,0.45),
        0 0 0 1px rgba(201,148,58,0.09);
}

#keyboard-container {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   TABLA SCENE
   ══════════════════════════════════════════════════════════════ */
.tabla-scene {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    background: radial-gradient(
        ellipse 80% 60% at 50% 90%,
        rgba(60,28,8,0.55) 0%,
        transparent 70%
    );
}

/* FX canvas overlaid on scene */
#tabla-fx-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    mix-blend-mode: screen;
}

/* ══════════════════════════════════════════════════════════════
   TABLA DRUMS
   ══════════════════════════════════════════════════════════════ */
.tabla-drum {
    position: absolute;
    bottom: 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    z-index: 5;
    transition: filter 0.2s;
}

.tabla-drum.bayaan { left: 8%;  width: 32%; }
.tabla-drum.dayaan { right: 12%; width: 28%; }

/* Drum images */
.drum-static-hand {
    width: 100%;
    max-width: 240px;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.65))
            drop-shadow(0 2px 6px rgba(201,148,58,0.15));
    pointer-events: none;
    user-select: none;
    display: block;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    transition: filter 0.15s;
}

/* FIX: drum glow on strike — referenced by JS but was missing */
.tabla-drum.bayaan-active .drum-static-hand {
    filter: drop-shadow(0 0 28px rgba(201,132,58,0.9))
            drop-shadow(0 8px 24px rgba(0,0,0,0.65))
            brightness(1.22);
}
.tabla-drum.dayaan-active .drum-static-hand {
    filter: drop-shadow(0 0 28px rgba(74,158,221,0.9))
            drop-shadow(0 8px 24px rgba(0,0,0,0.65))
            brightness(1.22);
}

/* ── Bol zones ── */
.bol-zone {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 1.2px;
    cursor: pointer;
    user-select: none;
    z-index: 10;
    transition:
        background  0.12s,
        box-shadow  0.12s,
        transform   0.08s;
    border: 1.5px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(2px);
}

.tabla-drum.bayaan .bol-zone { background: var(--bayaan-bg); color: #e8c060; }
.tabla-drum.dayaan .bol-zone { background: var(--dayaan-bg); color: #88ccee; }
.bol-zone.combo               { background: var(--combo-bg);  color: #cc88ee; font-size: 0.72rem; }

/* Bayaan zone positions */
#bz-48 {  /* GE — top centre */
    width: 38%; aspect-ratio: 1;
    top: 14%; left: 50%; transform: translateX(-50%);
}
#bz-50 {  /* GA — bottom right */
    width: 44%; aspect-ratio: 1;
    bottom: 30%; right: 8%;
}
#bz-44 {  /* KE — bottom left */
    width: 36%; aspect-ratio: 1;
    bottom: 30%; left: 5%;
}

/* Dayaan zone positions */
#bz-46 {  /* NA — top */
    width: 30%; aspect-ratio: 1;
    top: 8%; left: 50%; transform: translateX(-50%);
}
#bz-40 {  /* TA — centre right */
    width: 36%; aspect-ratio: 1;
    top: 32%; right: 6%;
}
#bz-42 {  /* TI — centre left */
    width: 30%; aspect-ratio: 1;
    top: 32%; left: 5%;
}
#bz-47 {  /* TUN — bottom centre */
    width: 32%; aspect-ratio: 1;
    bottom: 26%; left: 50%; transform: translateX(-50%);
}

/* ── Hover: non-centred zones ── */
#bz-50:hover,
#bz-44:hover,
#bz-40:hover,
#bz-42:hover {
    transform: scale(1.08);
    box-shadow: 0 0 18px rgba(201,148,58,0.35);
    border-color: rgba(201,148,58,0.5);
}

/* FIX: centred zones must keep translateX(-50%) through hover/active */
#bz-48:hover { transform: translateX(-50%) scale(1.08); box-shadow: 0 0 18px rgba(201,148,58,0.35); border-color: rgba(201,148,58,0.5); }
#bz-46:hover { transform: translateX(-50%) scale(1.08); box-shadow: 0 0 18px rgba(74,158,221,0.35);  border-color: rgba(74,158,221,0.5); }
#bz-47:hover { transform: translateX(-50%) scale(1.08); box-shadow: 0 0 18px rgba(74,158,221,0.35);  border-color: rgba(74,158,221,0.5); }

/* ── Hit animation — non-centred ── */
.bol-zone.bol-active {
    animation: bolHit 0.38s ease-out forwards;
}

@keyframes bolHit {
    0%   { transform: scale(1.18); box-shadow: 0 0 32px rgba(255,200,80,0.9); border-color: rgba(255,200,80,0.8); background: rgba(201,148,58,0.55); }
    35%  { transform: scale(1.22); }
    100% { transform: scale(1);    box-shadow: none; border-color: rgba(255,255,255,0.12); }
}

/* FIX: centred zones — keep translateX(-50%) in ALL keyframes */
#bz-48.bol-active { animation-name: bolHitCentreL; }
#bz-46.bol-active { animation-name: bolHitCentreR; }
#bz-47.bol-active { animation-name: bolHitCentreR; }

@keyframes bolHitCentreL {
    0%   { transform: translateX(-50%) scale(1.18); box-shadow: 0 0 32px rgba(255,200,80,0.9); border-color: rgba(255,200,80,0.8); background: rgba(201,148,58,0.55); }
    35%  { transform: translateX(-50%) scale(1.22); }
    100% { transform: translateX(-50%) scale(1);    box-shadow: none; border-color: rgba(255,255,255,0.12); }
}

@keyframes bolHitCentreR {
    0%   { transform: translateX(-50%) scale(1.18); box-shadow: 0 0 32px rgba(74,158,221,0.9); border-color: rgba(74,158,221,0.8); background: rgba(28,100,180,0.55); }
    35%  { transform: translateX(-50%) scale(1.22); }
    100% { transform: translateX(-50%) scale(1);    box-shadow: none; border-color: rgba(255,255,255,0.12); }
}

/* ══════════════════════════════════════════════════════════════
   COMBO PADS (DHA / DHIN)
   ══════════════════════════════════════════════════════════════ */
.tabla-combos {
    position: absolute;
    bottom: 12%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 8;
}

/* Combo zones are static (in flex row), not absolutely positioned */
.tabla-combos .bol-zone {
    position: static;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    font-size: 0.75rem;
    /* Override aspect-ratio so static layout works */
    aspect-ratio: unset;
}

.tabla-combos .bol-zone:hover {
    transform: scale(1.08);
    box-shadow: 0 0 18px rgba(201,148,58,0.35);
    border-color: rgba(201,148,58,0.5);
}

/* Combo zones — hit animation (no translateX needed, static in flex) */
.tabla-combos .bol-zone.bol-active {
    animation: bolHit 0.38s ease-out forwards;
}

/* ══════════════════════════════════════════════════════════════
   STRIKING HANDS
   ══════════════════════════════════════════════════════════════ */
.striking-hand {
    position: absolute;
    bottom: 0;
    width: 120px;
    pointer-events: none;
    user-select: none;
    z-index: 35; /* FIX: raised above combo pads (z-index 8) */
    filter: drop-shadow(0 4px 14px rgba(0,0,0,0.55));
    opacity: 0.92;
    transform-origin: bottom center;
}

#stick-l { left: 26%;  transform: rotate(-12deg); }
#stick-r { right: 22%; transform: rotate(12deg) scaleX(-1); }

/* Strike animation */
.striking-hand.striking { animation: handStrike 0.32s ease-out forwards; }
#stick-l.striking { animation-name: handStrikeLeft;  }
#stick-r.striking { animation-name: handStrikeRight; }

@keyframes handStrikeLeft {
    0%   { transform: rotate(-12deg) translateY(0);
           filter: drop-shadow(0 4px 14px rgba(0,0,0,0.55)); }
    22%  { transform: rotate(-42deg) translateY(-32px) translateX(20px);
           filter: drop-shadow(0 0 26px rgba(201,148,58,0.85)) drop-shadow(0 4px 14px rgba(0,0,0,0.55)); }
    55%  { transform: rotate(-8deg) translateY(-6px); }
    100% { transform: rotate(-12deg) translateY(0); }
}

@keyframes handStrikeRight {
    0%   { transform: rotate(12deg) scaleX(-1) translateY(0);
           filter: drop-shadow(0 4px 14px rgba(0,0,0,0.55)); }
    22%  { transform: rotate(42deg) scaleX(-1) translateY(-32px) translateX(20px);
           filter: drop-shadow(0 0 26px rgba(74,158,221,0.85)) drop-shadow(0 4px 14px rgba(0,0,0,0.55)); }
    55%  { transform: rotate(8deg) scaleX(-1) translateY(-6px); }
    100% { transform: rotate(12deg) scaleX(-1) translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   MIDI MONITOR STRIP
   ══════════════════════════════════════════════════════════════ */
.midi-monitor {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: rgba(8,5,3,0.82);
    border-top: 1px solid var(--border2);
    backdrop-filter: blur(10px);
    z-index: 40;
    display: flex;
    align-items: center;
}

.monitor-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
}

.monitor-info {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-shrink: 0;
}

.monitor-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.monitor-value {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 2px;
    min-width: 64px;
    transition: color 0.18s;
}

.monitor-num {
    font-family: 'Outfit', monospace, sans-serif;
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Bol history */
.bol-history {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
}

.bh-item {
    font-family: 'Outfit', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    transition: opacity 0.3s;
    white-space: nowrap;
}

/* FIX: waveform canvas was sometimes invisible; ensure correct display */
#waveform-visualizer {
    width: 120px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(201,148,58,0.15);
    display: block; /* prevent inline baseline gap */
}

/* ══════════════════════════════════════════════════════════════
   BOL POPUP
   ══════════════════════════════════════════════════════════════ */
.tabla-bol-popup {
    position: absolute;
    top: 20%;
    left: 42%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--gold);
    color: #0d0906;
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 5px 18px;
    border-radius: 24px;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: opacity 0.08s;
}

.tabla-bol-popup.show {
    animation: bolPopup 0.62s ease-out forwards;
}

@keyframes bolPopup {
    0%   { opacity: 0; transform: translateX(-50%) translateY(0px)   scale(0.5); }
    15%  { opacity: 1; transform: translateX(-50%) translateY(-12px)  scale(1.05); }
    50%  { opacity: 1; transform: translateX(-50%) translateY(-20px)  scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-32px)  scale(0.9); }
}

/* ══════════════════════════════════════════════════════════════
   VIEW SELECTOR / KIT ROW
   ══════════════════════════════════════════════════════════════ */
.drum-kit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px 0;
    flex-wrap: wrap;
}

.drum-kit-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.drum-kit-pill {
    padding: 4px 13px;
    border: 1px solid var(--border2);
    border-radius: 20px;
    background: rgba(13,10,8,0.9);
    color: var(--text-dim);
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s, background 0.18s, box-shadow 0.18s;
    white-space: nowrap;
}

.drum-kit-pill:hover {
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 8px rgba(201,148,58,0.18);
}

.drum-kit-pill.active {
    background: var(--gold);
    color: #0d0a08;
    border-color: var(--gold);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(201,148,58,0.35);
}

.drum-view-sep {
    width: 1px;
    height: 18px;
    background: rgba(201,148,58,0.22);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    #staff-visualizer      { height: 320px; border-radius: 10px; }
    .monitor-value         { font-size: 1rem; }
    .striking-hand         { width: 80px; }
    #stick-l               { left: 20%; }
    #stick-r               { right: 16%; }
    .tabla-combos .bol-zone { width: 56px; height: 56px; font-size: 0.65rem; }
    .drum-kit-pill         { font-size: 0.68rem; padding: 3px 9px; }
}

@media (max-width: 480px) {
    #staff-visualizer      { height: 240px; }
    .midi-monitor          { height: 44px; }
    .monitor-value         { font-size: 0.88rem; }
    .bol-history           { display: none; }
    .drum-kit-label        { display: none; }
    .drum-view-sep         { display: none; }
    .striking-hand         { width: 64px; }
    .tabla-combos          { gap: 10px; }
    .tabla-combos .bol-zone { width: 48px; height: 48px; }
    #waveform-visualizer   { width: 80px; height: 36px; }
}
