/* waveform.css — Waveform canvas, playhead, marker bubbles, bezier lines, cutoff line */

#waveform-container {
  position: relative;
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
  cursor: pointer;
  height: 75px;
  user-select: none;
  -webkit-user-select: none;
  margin-top: 0;
}

#waveform-container.has-target-strip {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

#waveform-container.mark-start-mode {
  cursor: grab;
}

#waveform-container.mark-start-mode.dragging {
  cursor: grabbing;
}

#waveform-container.has-markers {
  margin-top: 40px;
}

#waveform-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#playhead {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  pointer-events: none;
  z-index: 2;
  transition: left 0.05s linear;
}

#playhead::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -5px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg);
}

#waveform-container.dragging #playhead {
  transition: none;
}

#waveform-markers {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.waveform-region {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(255, 214, 10, 0.08);
  border-left: none;
  border-right: none;
}

.waveform-region-svg {
  fill: rgba(255, 214, 10, 0.08);
  stroke: none;
}

.waveform-region-svg.completed {
  fill: rgba(74, 124, 255, 0.04);
}

#waveform-hover-time {
  position: absolute;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: var(--text);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 3;
  font-variant-numeric: tabular-nums;
}

#marker-bubbles {
  position: absolute;
  top: -42px;
  left: 0;
  right: 0;
  height: 42px;
  pointer-events: none;
  z-index: 4;
}

#marker-lines {
  position: absolute;
  top: -42px;
  left: 0;
  width: 100%;
  height: calc(100% + 42px);
  pointer-events: none;
  z-index: 3;
}

.floating-bubble {
  position: absolute;
  padding: 1px 0;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  opacity: 1;
  min-width: 14px;
  width: auto;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  animation: markerFadeIn 0.25s ease both;
}

.marker-line {
  animation: markerFadeIn 0.25s ease both;
}

@keyframes markerFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes markerFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.marker-fade-out {
  animation: markerFadeOut 0.3s ease forwards !important;
}

.floating-bubble.bubble-shot {
  background: var(--yellow);
  color: #000;
  cursor: grab;
  pointer-events: auto;
}

.floating-bubble.bubble-shot:active {
  cursor: grabbing;
}

.floating-bubble.bubble-start {
  background: var(--green);
  color: #000;
  cursor: pointer;
  pointer-events: auto;
}

.floating-bubble.bubble-beep-proposed {
  background: var(--green);
  color: #000;
  opacity: 0.8;
  cursor: grab;
}

.floating-bubble.bubble-beep-proposed:active {
  cursor: grabbing;
}

.floating-bubble.bubble-end {
  background: var(--red);
  color: #fff;
}

.floating-bubble.bubble-end-number {
  background: var(--yellow);
  color: #000;
}

.marker-line {
  stroke-width: 2;
  stroke-dasharray: 3, 1;
  fill: none;
}

.marker-line.line-shot {
  stroke: var(--yellow);
}

.marker-line.line-start {
  stroke: var(--green);
  stroke-dasharray: none;
}

.marker-line.line-end {
  stroke: var(--red);
  stroke-dasharray: none;
}

.marker-line.line-end-number {
  stroke: var(--yellow);
}

.marker-line.line-beep-proposed {
  stroke: var(--green);
  stroke-dasharray: 4, 2;
}

/* Cutoff line */

.cutoff-line {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    var(--red) 0px,
    var(--red) 4px,
    transparent 4px,
    transparent 8px
  );
  pointer-events: none;
  z-index: 2;
  opacity: 0.8;
}

/* Playhead restyled during cutoff step */
#waveform-container.cutoff-mode #playhead {
  background: var(--red);
  width: 3px;
}

#waveform-container.cutoff-mode #playhead::after {
  background: var(--red);
  width: 14px;
  height: 14px;
  top: -4px;
  left: -6px;
}

/* Threshold bar */

.threshold-bar {
  position: absolute;
  height: 3px;
  background: var(--red);
  cursor: ns-resize;
  z-index: 3;
  opacity: 0.7;
}

.threshold-bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  bottom: -8px;
}

.threshold-bar::after {
  content: 'Drag to set shot threshold';
  position: absolute;
  right: 8px;
  top: -18px;
  font-size: 11px;
  color: var(--red);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.7;
}

.threshold-bar.no-label::after {
  display: none;
}

.threshold-split-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--red);
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  border-radius: 2px;
  transform: translate(-50%, -50%) rotate(45deg);
  top: 1px;
  pointer-events: none;
  z-index: 4;
  opacity: 0.85;
}

/* Zoom controls */

#waveform-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  order: 5;
}

#waveform-zoom-slider {
  flex: 0 0 90px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#waveform-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 0;
  border: none;
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='7' cy='7' r='5' stroke='rgba(255,255,255,0.85)' stroke-width='1.5' fill='rgba(74,124,255,0.25)'/%3E%3Cline x1='10.5' y1='10.5' x2='14' y2='14' stroke='rgba(255,255,255,0.85)' stroke-width='1.5' stroke-linecap='round'/%3E%3Cline x1='5' y1='7' x2='9' y2='7' stroke='rgba(255,255,255,0.85)' stroke-width='1.2' stroke-linecap='round'/%3E%3Cline x1='7' y1='5' x2='7' y2='9' stroke='rgba(255,255,255,0.85)' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: contain;
  cursor: pointer;
}

#waveform-zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 0;
  border: none;
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='7' cy='7' r='5' stroke='rgba(255,255,255,0.85)' stroke-width='1.5' fill='rgba(74,124,255,0.25)'/%3E%3Cline x1='10.5' y1='10.5' x2='14' y2='14' stroke='rgba(255,255,255,0.85)' stroke-width='1.5' stroke-linecap='round'/%3E%3Cline x1='5' y1='7' x2='9' y2='7' stroke='rgba(255,255,255,0.85)' stroke-width='1.2' stroke-linecap='round'/%3E%3Cline x1='7' y1='5' x2='7' y2='9' stroke='rgba(255,255,255,0.85)' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: contain;
  cursor: pointer;
}

#waveform-scroll-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

#waveform-scroll-thumb {
  position: absolute;
  top: -1px;
  height: 8px;
  min-width: 16px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  cursor: grab;
  transition: background 0.15s;
}

#waveform-scroll-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

#waveform-scroll-thumb:active,
#waveform-scroll-thumb.dragging {
  cursor: grabbing;
  background: rgba(255, 255, 255, 0.4);
}

/* Phase hint below waveform */

#phase-hint {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 2px 0 0;
  line-height: 1.4;
  order: 6;
}

#phase-hint .hint-red {
  color: var(--red);
  font-weight: 600;
}

#phase-hint .hint-green {
  color: var(--green);
  font-weight: 600;
}

#phase-hint .hint-yellow {
  color: var(--yellow);
  font-weight: 600;
}

/* Shot / Start nudge popups */
#shot-nudge-popup,
#start-nudge-popup {
  position: fixed;
  z-index: 6000;
  display: flex;
  gap: 2px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.btn-nudge {
  background: var(--surface-glass);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  font-size: 0.65rem;
  width: 22px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-nudge:hover {
  background: var(--surface-hover);
}
