/* ============================================================
   v6 Phase E — Per-track 🎲 dice button + popover, master button
   ============================================================ */

@layer v6-components {

  /* Per-track dice icon (sits next to the AI button) */
  .v6-track-dice {
    width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--v6-border, rgba(255, 255, 255, 0.10));
    border-radius: 6px;
    cursor: pointer;
    transition:
      background var(--duration-fast, 120ms),
      border-color var(--duration-fast, 120ms),
      transform var(--duration-instant, 50ms);
  }
  .v6-track-dice:hover {
    background: rgba(236, 72, 153, 0.20);
    border-color: var(--accent-secondary, #ec4899);
    transform: rotate(-12deg);
  }
  .v6-track-dice:active {
    transform: scale(0.92) rotate(8deg);
  }
  .v6-track-dice__glyph {
    font-size: 13px;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(236, 72, 153, 0.40));
  }

  /* Popover that appears when dice is clicked */
  .v6-track-dice__popover {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 220px;
    padding: 6px;
    background: var(--v6-panel, var(--surface-300, #18181b));
    border: 1px solid var(--v6-border-strong, rgba(255, 255, 255, 0.14));
    border-radius: 8px;
    box-shadow: var(--shadow-3, 0 12px 32px rgba(0, 0, 0, 0.50));
    animation: v6-dice-pop 160ms ease-out;
  }
  @keyframes v6-dice-pop {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  .v6-track-dice__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-primary, #fafafa);
    text-align: left;
    cursor: pointer;
    transition:
      background var(--duration-fast, 120ms),
      border-color var(--duration-fast, 120ms);
  }
  .v6-track-dice__item:hover {
    background: rgba(236, 72, 153, 0.10);
    border-color: rgba(236, 72, 153, 0.40);
  }
  .v6-track-dice__item-label {
    font-size: 12px;
    font-weight: 600;
  }
  .v6-track-dice__item-hint {
    font-size: 10px;
    color: var(--text-muted, #71717a);
    line-height: 1.3;
  }

  /* ---- v9.6 Vary panel ---- */
  .v6-track-dice__panel { min-width: 232px; gap: 8px; padding: 8px; }

  /* Scope segmented toggle (This pattern / Whole track) */
  .v6-track-dice__scope {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 3px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--v6-border, rgba(255, 255, 255, 0.10));
    border-radius: 7px;
  }
  .v6-track-dice__scope-btn {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #a1a1aa);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition:
      background var(--duration-fast, 120ms),
      color var(--duration-fast, 120ms);
  }
  .v6-track-dice__scope-btn:hover { color: var(--text-primary, #fafafa); }
  .v6-track-dice__scope-btn.is-active {
    color: #fff;
    background: var(--accent-primary, #8b5cf6);
    box-shadow: 0 1px 6px rgba(139, 92, 246, 0.45);
  }

  /* Vary block */
  .v6-track-dice__vary {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }
  .v6-track-dice__vary-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }
  .v6-track-dice__vary-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #fafafa);
  }
  .v6-track-dice__amount {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-secondary, #ec4899);
  }
  .v6-track-dice__slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(
      90deg,
      var(--accent-primary, #8b5cf6),
      var(--accent-secondary, #ec4899)
    );
    cursor: pointer;
  }
  .v6-track-dice__slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent-secondary, #ec4899);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  }
  .v6-track-dice__slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent-secondary, #ec4899);
    cursor: pointer;
  }
  .v6-track-dice__go {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--accent-primary, #8b5cf6);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition:
      background var(--duration-fast, 120ms),
      transform var(--duration-instant, 50ms);
  }
  .v6-track-dice__go:hover { background: #7c4ddb; }
  .v6-track-dice__go:active { transform: scale(0.97); }
  .v6-track-dice__go--pulse { animation: v6-dice-vary-pulse 320ms ease-out; }
  @keyframes v6-dice-vary-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.55); }
    100% { box-shadow: 0 0 0 12px rgba(236, 72, 153, 0); }
  }

  .v6-track-dice__divider {
    height: 1px;
    margin: 2px 0;
    background: var(--v6-border, rgba(255, 255, 255, 0.10));
  }

  /* Master Randomize button in the AI strip */
  #randomizeSongBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  #randomizeSongBtn .v6-track-dice__glyph {
    font-size: 14px;
  }
  #randomizeSongBtn:hover .v6-track-dice__glyph {
    animation: v6-dice-spin 600ms ease;
  }
  @keyframes v6-dice-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
}
