/* ==========================================================================
   EMi Balance — Nút điều khiển "Tự chạy" (Autoplay Button)
   Hợp đồng DOM:
   <button type="button" class="emi-autoplay" data-state="idle|soon|running" aria-pressed="false|true" hidden>
     <span class="emi-autoplay__label">▶ Tự chạy</span>
   </button>
   ========================================================================== */

.emi-autoplay {
  position: fixed;
  right: 24px;
  bottom: 80px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 11px 20px;
  border-radius: 999px;
  font-family: 'Be Vietnam Pro', Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--emi-cream, #f7f1e6);
  background: rgba(31, 53, 87, 0.85);
  border: 1px solid rgba(247, 241, 230, 0.28);
  box-shadow: 0 4px 16px rgba(15, 26, 43, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}

.emi-autoplay__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Hover & Active */
.emi-autoplay:hover {
  background: rgba(44, 74, 117, 0.95);
  border-color: rgba(247, 241, 230, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15, 26, 43, 0.3);
}

.emi-autoplay:active {
  transform: translateY(0);
}

/* Focus indicator rõ nét, chuẩn WCAG */
.emi-autoplay:focus-visible {
  outline: 2px solid var(--emi-sky, #9cc3e4);
  outline-offset: 3px;
}

/* Trạng thái 1: idle (chờ bắt đầu / mặc định) */
.emi-autoplay[data-state="idle"] {
  background: rgba(31, 53, 87, 0.85);
  border-color: rgba(247, 241, 230, 0.28);
  color: var(--emi-cream, #f7f1e6);
}

/* Trạng thái 2: soon (2 giây trước khi chạy - viền sáng nhẹ, không hoạt ảnh nhấp nháy lặp) */
.emi-autoplay[data-state="soon"] {
  background: rgba(31, 53, 87, 0.92);
  border-color: rgba(156, 195, 228, 0.85);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(156, 195, 228, 0.28), 0 2px 8px rgba(15, 26, 43, 0.3);
}

/* Trạng thái 3: running (đang tự chạy - nền đậm vững chãi) */
.emi-autoplay[data-state="running"] {
  background: var(--emi-navy, #1f3557);
  border-color: rgba(247, 241, 230, 0.45);
  color: var(--emi-cream, #f7f1e6);
  box-shadow: 0 4px 20px rgba(15, 26, 43, 0.4);
}

/* Đảm bảo thuộc tính hidden luôn ẩn phần tử */
.emi-autoplay[hidden] {
  display: none !important;
}

/* Tắt chuyển tiếp khi người dùng yêu cầu giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  .emi-autoplay {
    transition: none !important;
    transform: none !important;
  }
  .emi-autoplay:hover {
    transform: none !important;
  }
}

/* Mobile & màn hình <= 760px: ẩn hoàn toàn (autoplay chỉ dành cho desktop) */
@media (max-width: 760px) {
  .emi-autoplay {
    display: none !important;
  }
}
