/* ═══════════════════════════════════════════════════════════════
   SHEET MUSIC VISUALIZER  ·  Tamil Bookshelf MIDI Player
   v4.0  —  Full music notation · Proper piano-key sync · Animated
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,600;1,400;1,600&family=Outfit:wght@300;400;500;600;700&display=swap');

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --smv-bg:           #080604;
  --smv-surface:      #0e0b08;
  --smv-paper:        #f5eed8;
  --smv-gold:         #c9943a;
  --smv-gold-hi:      #f0c860;
  --smv-gold-lo:      rgba(201,148,58,.20);
  --smv-cream:        #f5eed8;
  --smv-cream-dim:    rgba(245,238,216,.55);
  --smv-cream-faint:  rgba(245,238,216,.06);
  --smv-border:       rgba(201,148,58,.16);
  --smv-text:         rgb(255 242 210 / 90%);
  --smv-text-dim:     rgb(255 213 109 / 90%);
  --smv-green:        #42c87e;
  --smv-playhead:     #ff4444;
  --smv-staff-line:   rgba(245,238,216,.52);
  --smv-ledger:       rgba(245,238,216,.40);
  --smv-white-key:    #f4edd8;
  --smv-black-key:    #120c06;
  --smv-piano-w:      90px;
  --smv-piano-h:      400px;
}

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

/* ── OUTER SHELL ─────────────────────────────────────────────── */
#staff-visualizer {
  background: var(--smv-bg);
  border: 1px solid var(--smv-border);
  border-radius: 18px;
  margin: 14px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow:
    inset 0 2px 24px rgba(0,0,0,.85),
    0 10px 50px rgba(0,0,0,.65),
    0 0 0 1px rgba(201,148,58,.05);
  font-family: 'Outfit', sans-serif;
}

#keyboard-container {
  display: contents;
}

/* ── CONTROLS BAR ────────────────────────────────────────────── */
#smv-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: rgba(0,0,0,.55);
  border-bottom: 1px solid var(--smv-border);
  flex-wrap: wrap;
  flex-shrink: 0;
  z-index: 20;
  min-height: 38px;
}

.smv-lbl {
  font-size: .8rem;
  color: var(--smv-text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}

.smv-pill {
  padding: 2px 10px;
  border: 1px solid rgba(201,148,58,.20);
  border-radius: 22px;
  background: rgba(8,6,4,.90);
  color: var(--smv-text);
  font-family: 'Outfit', sans-serif;
  font-size: .8rem;
  cursor: pointer;
  transition: border-color .14s, color .14s, background .14s, box-shadow .14s;
  white-space: nowrap;
  line-height: 1.7;
  outline: none;
}
.smv-pill:hover {
  border-color: var(--smv-gold);
  color: var(--smv-gold-hi);
  background: rgba(201,148,58,.07);
  box-shadow: 0 0 8px rgba(201,148,58,.18);
}
.smv-pill.active {
  background: linear-gradient(135deg, var(--smv-gold) 0%, #8a5c14 100%);
  color: #08060400;
  color: #080604;
  border-color: var(--smv-gold);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(201,148,58,.38);
}

.smv-sel {
  padding: 3px 8px;
  border: 1px solid rgba(201,148,58,.20);
  border-radius: 8px;
  background: rgba(8,6,4,.90);
  color: var(--smv-text);
  font-family: 'Outfit', sans-serif;
  font-size: .8rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(201,148,58,.55)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 7px;
}
.smv-sel:focus { border-color: var(--smv-gold); }
.smv-sel option { background: #0e0b08; color: #c8a870; }

.smv-sep {
  width: 1px; height: 16px;
  background: var(--smv-border);
  flex-shrink: 0; margin: 0 2px;
}

.smv-badge-ctrl {
  margin-left: auto;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--smv-border);
  border-radius: 22px;
  padding: 3px 12px;
  font-size: .8rem;
  color: var(--smv-gold);
  letter-spacing: .5px;
  white-space: nowrap;
  font-weight: 600;
}

/* ── STAGE  (piano left · score right) ───────────────────────── */
#smv-stage {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ── PIANO ────────────────────────────────────────────────────── */
#smv-piano-wrap {
  flex-shrink: 0;
  width: var(--smv-piano-w);
  height: var(--smv-piano-h);
  position: relative;
  border-right: 2px solid rgba(201,148,58,.28);
  background: linear-gradient(180deg, #1c140a 0%, #0a0704 100%);
  overflow: hidden;
  z-index: 10;
  align-self: flex-start;
}

/* Gold cap on top of piano */
#smv-piano-wrap::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--smv-gold) 0%, rgba(201,148,58,.18) 100%);
  z-index: 3;
}

#smv-piano-canvas {
  display: block;
  width: var(--smv-piano-w);
  height: var(--smv-piano-h);
  image-rendering: crisp-edges;
}

/* Piano connector overlay — score draws into this */
#smv-connector-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: .55;
}

/* ── SCORE ────────────────────────────────────────────────────── */
#smv-score-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 20% 50%, rgba(30,18,6,.55) 0%, transparent 70%),
    var(--smv-bg);
}

#smv-canvas,
#smv-trail-canvas,
#smv-glow-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
}

#smv-canvas      { z-index: 2; }
#smv-glow-canvas { z-index: 4; opacity: .72; mix-blend-mode: screen; pointer-events: none; }
#smv-trail-canvas{ z-index: 6; pointer-events: none; opacity: .6; }

/* ── INFO BAR ─────────────────────────────────────────────────── */
#smv-info {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 26px;
  background: rgba(0,0,0,.55);
  border-top: 1px solid var(--smv-border);
  flex-shrink: 0;
  font-size: .8rem;
  color: var(--smv-text-dim);
  z-index: 20;
}
.smv-info-chip { display: flex; align-items: center; gap: 5px; }
.smv-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.smv-val { color: var(--smv-gold-hi); font-weight: 600; }
.smv-legend { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.smv-leg-item { display: flex; align-items: center; gap: 4px; font-size: .8rem; }
.smv-leg-sw { width: 8px; height: 8px; border-radius: 2px; }

/* ── ACTIVE NOTE RING ANIMATION (CSS override for JS-spawned elements) ── */
@keyframes smv-ring-expand {
  from { transform: scale(.5); opacity: .9; }
  to   { transform: scale(3.5); opacity: 0; }
}
@keyframes smv-note-pop {
  0%   { transform: scale(.6); opacity: 0; }
  55%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes smv-key-flash {
  0%   { opacity: .0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  #staff-visualizer  { border-radius: 12px; }
  #smv-piano-wrap    { width: 60px; }
  #smv-piano-canvas  { width: 60px; }
  :root { --smv-piano-w: 60px; }
  .smv-badge-ctrl    { display: none; }
  .smv-sep           { display: none; }
}
@media (max-width: 480px) {
  #smv-piano-wrap { display: none; }
  :root { --smv-piano-w: 0px; }
  .smv-lbl { display: none; }
  #smv-info .smv-legend { display: none; }
}
