/* เพลงประจำเว็บ: ปุ่มเล็กมุมซ้ายล่าง (layouts/market) */
.bgm { position: fixed; left: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; font-family: var(--font-body, system-ui, sans-serif); }
.bgm [hidden] { display: none !important; }

.bgm-main {
    position: relative; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%;
    background: #17131f; color: #ffb627; cursor: pointer;
    box-shadow: 0 6px 18px rgba(23, 19, 31, 0.35), inset 0 1px rgba(255, 255, 255, 0.15);
    display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
.bgm-main:hover { background: #2b2338; }
.bgm-main:focus-visible { outline: 3px solid #ff5a36; outline-offset: 3px; }

/* วงคลื่นเรียกความสนใจ เมื่อยังไม่เปิด หรือรอแตะเพื่อเล่นต่อ */
.bgm[data-state="off"] .bgm-main::after,
.bgm[data-state="waiting"] .bgm-main::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #ffb627;
    animation: bgm-ring 2s ease-out infinite;
}
@keyframes bgm-ring { from { transform: scale(1); opacity: 0.8; } to { transform: scale(1.7); opacity: 0; } }

.bgm-ico { display: flex; align-items: flex-end; gap: 3px; height: 18px; }
.bgm-ico i { display: block; width: 4px; height: 6px; border-radius: 2px; background: currentColor; }
.bgm[data-state="playing"] .bgm-ico i { animation: bgm-eq 0.9s ease-in-out infinite alternate; }
.bgm[data-state="playing"] .bgm-ico i:nth-child(2) { animation-delay: -0.3s; }
.bgm[data-state="playing"] .bgm-ico i:nth-child(3) { animation-delay: -0.6s; }
.bgm[data-state="off"] .bgm-ico i:nth-child(1) { height: 10px; }
.bgm[data-state="off"] .bgm-ico i:nth-child(2) { height: 16px; }
.bgm[data-state="off"] .bgm-ico i:nth-child(3) { height: 8px; }
@keyframes bgm-eq { from { height: 5px; } to { height: 18px; } }

.bgm-bubble {
    position: absolute; left: 62px; bottom: 8px; margin: 0; padding: 8px 14px; max-width: calc(100vw - 100px);
    border-radius: 999px; background: #fff; color: #17131f; font-size: 0.88rem; font-weight: 600; white-space: nowrap;
    box-shadow: 0 6px 18px rgba(23, 19, 31, 0.2); border: 1px solid #e9e3d9;
    animation: bgm-pop 0.3s ease-out;
}
@keyframes bgm-pop { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.bgm-panel {
    position: absolute; left: 0; bottom: 64px; width: 236px; padding: 14px 16px 14px;
    border-radius: 16px; background: #fff; color: #17131f; border: 1px solid #e9e3d9;
    box-shadow: 0 14px 34px rgba(23, 19, 31, 0.28); display: flex; flex-direction: column; gap: 2px;
    animation: bgm-pop 0.2s ease-out;
}
.bgm-panel strong { font: 600 1rem var(--font-head, inherit); }
.bgm-panel small { color: #6b6577; }
.bgm-btns { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.bgm-btns button {
    min-width: 38px; height: 38px; padding: 0 10px; border: 1.5px solid #e9e3d9; border-radius: 999px;
    background: #fff; color: #17131f; font-size: 0.95rem; cursor: pointer;
}
.bgm-btns button:hover { border-color: #17131f; }
.bgm-btns #bgmPlay { background: #ff5a36; border-color: #ff5a36; color: #fff; min-width: 44px; }
.bgm-btns .bgm-off { margin-left: auto; font-size: 0.8rem; color: #6b6577; }

@media (max-width: 560px) {
    .bgm { left: 12px; bottom: 12px; }
    .bgm-panel { width: min(236px, calc(100vw - 24px)); }
}
@media (prefers-reduced-motion: reduce) {
    .bgm *, .bgm *::after { animation: none !important; }
}
