/* ==========================================================================
   TANPURA PRACTICE WIDGET — Movable Edge-Docking Acoustic Drone UI
   Unified Warm Mandir Saffron, Amber & Obsidian Design System
   ========================================================================== */

.tanpura-floating-widget {
  position: fixed;
  top: 76%;
  right: 0;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    top 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    left 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    right 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.tanpura-floating-widget.is-dragging {
  transition: none !important;
}

.tanpura-floating-widget.dock-right {
  right: 0;
  left: auto;
  align-items: flex-end;
}

.tanpura-floating-widget.dock-left {
  left: 0;
  right: auto;
  align-items: flex-start;
}

.tanpura-floating-widget.open-up {
  flex-direction: column;
}

.tanpura-floating-widget.open-down {
  flex-direction: column-reverse;
}

/* ==========================================================================
   1. COLLAPSED MINI-PILL (EDGE-SNAPPED)
   ========================================================================== */

.tanpura-mini-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, #211a16 0%, #33261e 100%);
  color: #faf7f2;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  box-shadow:
    0 8px 24px rgba(28, 25, 23, 0.35),
    0 0 0 1px rgba(245, 158, 11, 0.28);
  cursor: grab;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.22s ease,
    border-radius 0.22s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  touch-action: none;
}

.tanpura-floating-widget.is-dragging .tanpura-mini-pill {
  cursor: grabbing;
  transform: scale(1.04) translateX(0) !important;
  border-radius: 999px !important;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1.5px rgba(251, 191, 36, 0.55);
}

.tanpura-floating-widget.dock-right:not(.expanded):not(.is-dragging) .tanpura-mini-pill {
  border-radius: 999px 0 0 999px;
  padding-right: 14px;
  transform: translateX(calc(100% - 48px));
}

.tanpura-floating-widget.dock-left:not(.expanded):not(.is-dragging) .tanpura-mini-pill {
  flex-direction: row-reverse;
  padding: 6px 6px 6px 14px;
  border-radius: 0 999px 999px 0;
  transform: translateX(calc(-100% + 48px));
}

@media (hover: hover) {
  .tanpura-floating-widget.dock-right:not(.expanded):not(.is-dragging) .tanpura-mini-pill:hover,
  .tanpura-floating-widget.dock-left:not(.expanded):not(.is-dragging) .tanpura-mini-pill:hover {
    transform: translateX(0);
  }
}

.tanpura-floating-widget.expanded .tanpura-mini-pill {
  transform: translateX(0);
}

.tanpura-floating-widget.dock-right.expanded .tanpura-mini-pill {
  margin-right: 12px;
}

.tanpura-floating-widget.dock-left.expanded .tanpura-mini-pill {
  margin-left: 12px;
}

.tanpura-floating-widget.is-playing .tanpura-mini-pill {
  background: linear-gradient(135deg, #7c2d12 0%, #c85a17 55%, #d97706 100%);
  box-shadow:
    0 8px 26px rgba(200, 90, 23, 0.45),
    0 0 0 1.5px rgba(253, 224, 71, 0.55);
}

.tanpura-pill-play-btn {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1c1917;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
  transition: transform 0.15s ease, background 0.2s ease;
}

.tanpura-floating-widget.is-playing .tanpura-pill-play-btn {
  background: #ffffff;
  color: #9a3412;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}

.tanpura-pill-play-btn:active {
  transform: scale(0.92);
}

.tanpura-pill-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  padding-right: 2px;
  white-space: nowrap;
}

.tanpura-floating-widget.dock-left:not(.expanded) .tanpura-pill-info {
  text-align: right;
  padding-right: 0;
  padding-left: 2px;
}

.tanpura-pill-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: rgba(255, 255, 255, 0.74);
  font-weight: 700;
}

.tanpura-pill-pitch {
  font-size: 13px;
  font-weight: 800;
  color: #fef3c7;
}

/* Soundwave Equalizer Indicator */
.tanpura-soundwave-bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  margin-left: 2px;
}

.tanpura-floating-widget.is-playing .tanpura-soundwave-bars {
  display: flex;
}

.soundwave-bar {
  width: 2.5px;
  background: #fde68a;
  border-radius: 2px;
  animation: tanpuraWave 0.9s ease-in-out infinite;
}

.soundwave-bar:nth-child(1) {
  height: 6px;
  animation-delay: 0s;
}
.soundwave-bar:nth-child(2) {
  height: 13px;
  animation-delay: 0.2s;
}
.soundwave-bar:nth-child(3) {
  height: 8px;
  animation-delay: 0.4s;
}

@keyframes tanpuraWave {
  0%,
  100% {
    transform: scaleY(0.45);
    opacity: 0.7;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* ==========================================================================
   2. EXPANDED CONTROL DRAWER PANEL
   ========================================================================== */

.tanpura-drawer-panel {
  pointer-events: auto;
  width: 318px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(255, 253, 249, 0.97);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid #e7e0d6;
  border-radius: 20px;
  padding: 16px;
  margin: 0 12px;
  box-shadow:
    0 20px 44px rgba(28, 25, 23, 0.22),
    0 4px 12px rgba(200, 90, 23, 0.08);
  color: #1c1917;
  display: none;
  transform-origin: bottom right;
  animation: tanpuraDrawerIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: pan-y;
}

.tanpura-floating-widget.dock-left .tanpura-drawer-panel {
  transform-origin: bottom left;
}
.tanpura-floating-widget.open-down.dock-right .tanpura-drawer-panel {
  transform-origin: top right;
}
.tanpura-floating-widget.open-down.dock-left .tanpura-drawer-panel {
  transform-origin: top left;
}

[data-theme="dark"] .tanpura-drawer-panel {
  background: rgba(28, 25, 23, 0.97);
  border-color: #332e29;
  color: #f5f0eb;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.65);
}

.tanpura-floating-widget.expanded .tanpura-drawer-panel {
  display: block;
}

@keyframes tanpuraDrawerIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.tanpura-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #efe9df;
}

[data-theme="dark"] .tanpura-drawer-header {
  border-bottom-color: #2c2723;
}

.tanpura-drawer-title-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tanpura-drawer-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(200, 90, 23, 0.12);
  color: #c85a17;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .tanpura-drawer-icon {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.tanpura-drawer-heading {
  font-family: "Fraunces", Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: inherit;
  line-height: 1.2;
}

.tanpura-drawer-sub {
  font-size: 11px;
  color: #78716c;
  display: block;
}

[data-theme="dark"] .tanpura-drawer-sub {
  color: #a8a29e;
}

.tanpura-drawer-close {
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(120, 113, 108, 0.1);
  color: #57534e;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

[data-theme="dark"] .tanpura-drawer-close {
  background: rgba(255, 255, 255, 0.07);
  color: #d6d0c9;
}

.tanpura-drawer-close:hover {
  background: rgba(200, 90, 23, 0.14);
  color: #c85a17;
}

/* ==========================================================================
   3. PITCH GRID, SWARA DECK & SLIDERS
   ========================================================================== */

.tanpura-control-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  color: #78716c;
  margin-bottom: 6px;
  display: block;
}

[data-theme="dark"] .tanpura-control-label {
  color: #a8a29e;
}

.tanpura-pitch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}

.tanpura-pitch-btn {
  min-height: 36px !important;
  height: 36px;
  padding: 3px 2px !important;
  border-radius: 9px;
  border: 1px solid #e7e0d6;
  background: #faf7f2;
  color: #292524;
  font-family: inherit;
  font-size: 12px !important;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

[data-theme="dark"] .tanpura-pitch-btn {
  background: #26221e;
  border-color: #3a342e;
  color: #e7e5e4;
}

.tanpura-pitch-btn .btn-pitch-note {
  font-size: 9px;
  font-weight: 600;
  opacity: 0.68;
}

.tanpura-pitch-btn:hover {
  border-color: #d97706;
  background: #fffbeb;
}

[data-theme="dark"] .tanpura-pitch-btn:hover {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.tanpura-pitch-btn.active {
  background: linear-gradient(135deg, #c85a17 0%, #b45309 100%) !important;
  color: #ffffff !important;
  border-color: #9a3412 !important;
  box-shadow: 0 3px 10px rgba(200, 90, 23, 0.3);
}

.tanpura-pitch-btn.active .btn-pitch-note {
  opacity: 0.92;
  color: #fef3c7;
}

/* Single Resonating String Deck */
.tanpura-single-string-card {
  background: #faf7f2;
  border: 1px solid #e7e0d6;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .tanpura-single-string-card {
  background: #26221e;
  border-color: #3a342e;
}

.tanpura-single-string-card.plucking {
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}

.single-string-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.single-string-identity {
  display: flex;
  align-items: center;
  gap: 6px;
}

.single-string-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a8a29e;
  transition: background 0.15s ease, transform 0.15s ease;
}

.tanpura-floating-widget.is-playing .single-string-pulse-dot {
  background: #d97706;
  box-shadow: 0 0 8px rgba(217, 119, 6, 0.7);
}

.single-string-title {
  font-size: 12px;
  font-weight: 700;
  color: inherit;
}

.single-string-status {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

[data-theme="dark"] .single-string-status {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.single-string-swara-badge {
  font-size: 11px;
  font-weight: 800;
  color: #9a3412;
  background: rgba(200, 90, 23, 0.1);
  padding: 3px 8px;
  border-radius: 7px;
}

[data-theme="dark"] .single-string-swara-badge {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.16);
}

.single-string-tuning-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e7e0d6;
}

[data-theme="dark"] .single-string-tuning-row {
  border-top-color: #3a342e;
}

.single-string-tuning-label {
  font-size: 11px;
  font-weight: 600;
  color: #78716c;
}

[data-theme="dark"] .single-string-tuning-label {
  color: #a8a29e;
}

.single-string-swara-chips {
  display: flex;
  gap: 5px;
}

.swara-chip {
  min-height: 28px !important;
  height: 28px;
  padding: 0 12px !important;
  border-radius: 7px;
  border: 1px solid #e7e0d6;
  background: #ffffff;
  color: #44403c;
  font-family: inherit;
  font-size: 11.5px !important;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease, background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

[data-theme="dark"] .swara-chip {
  background: #1c1917;
  border-color: #3a342e;
  color: #d6d0c9;
}

.swara-chip.active {
  background: linear-gradient(135deg, #c85a17 0%, #b45309 100%) !important;
  color: #ffffff !important;
  border-color: #9a3412 !important;
}

.tanpura-sliders-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tanpura-slider-wrap label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #78716c;
  margin-bottom: 4px;
}

[data-theme="dark"] .tanpura-slider-wrap label {
  color: #a8a29e;
}

.tanpura-slider-wrap input[type="range"] {
  width: 100%;
  accent-color: #c85a17;
  cursor: pointer;
  height: 5px;
  min-height: 0 !important;
}

[data-theme="dark"] .tanpura-slider-wrap input[type="range"] {
  accent-color: #f59e0b;
}

/* Inline Card Drone Play Button (Master Bank Cards) */
.btn-pitch-drone-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px !important;
  min-width: 22px !important;
  height: 22px !important;
  min-height: 22px !important;
  border-radius: 50%;
  border: 1px solid rgba(200, 90, 23, 0.3);
  background: rgba(200, 90, 23, 0.1);
  color: #c85a17;
  cursor: pointer;
  padding: 0 !important;
  margin-left: 4px;
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease;
  vertical-align: middle;
}

.btn-pitch-drone-play:hover {
  background: #c85a17;
  color: #ffffff;
  border-color: #c85a17;
  transform: scale(1.08);
}

[data-theme="dark"] .btn-pitch-drone-play {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

[data-theme="dark"] .btn-pitch-drone-play:hover {
  background: #f59e0b;
  color: #1c1917;
  border-color: #f59e0b;
}

@media (max-width: 600px) {
  .tanpura-floating-widget {
    top: auto;
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
  .tanpura-drawer-panel {
    width: calc(100vw - 24px);
    max-width: 312px;
    padding: 14px;
  }
}

@media print {
  .tanpura-floating-widget,
  .btn-pitch-drone-play {
    display: none !important;
  }
}
