/**
 * DucorMall floating background music control
 */
.dm-bg-music {
    position: fixed;
    left: max(0.85rem, env(safe-area-inset-left, 0px));
    /* Base clearance + home indicator / browser chrome inset */
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

/* Extra lift on phones so the 60px control clears browser chrome */
@media (max-width: 768px) {
    .dm-bg-music {
        bottom: calc(1.75rem + env(safe-area-inset-bottom, 0px));
    }
}

/*
 * Product detail: sticky .dp-mobile-bar (Contact / Add to cart) sits full-width
 * at bottom with z-index 1100 and would cover the mute control. Lift mute clear
 * of the bar and keep it tappable above the bar if edges clip.
 */
@media (max-width: 991.98px) {
    body.dm-has-product-detail .dm-bg-music {
        bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px));
        z-index: 1110;
    }
}

.dm-bg-music__btn {
    pointer-events: auto;
    position: relative;
    width: 3.75rem; /* 60px */
    height: 3.75rem;
    border: 1px solid rgba(var(--dm-primary-rgb), 0.14);
    border-radius: 999px;
    background: var(--dm-surface, #fff);
    color: var(--dm-primary, #292c7a);
    box-shadow: var(--dm-shadow, 0 8px 24px rgba(15, 23, 42, 0.08));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        background-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.dm-bg-music__btn:hover {
    background: var(--dm-primary, #292c7a);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--dm-shadow-lg, 0 12px 28px rgba(15, 23, 42, 0.12));
}

.dm-bg-music__btn:focus-visible {
    outline: 2px solid var(--dm-secondary, #db3630);
    outline-offset: 3px;
}

.dm-bg-music__btn.is-playing:not(.is-muted) {
    animation: dm-bg-music-pulse 2.4s ease-in-out infinite;
}

.dm-bg-music__btn.is-muted {
    color: var(--dm-slate, #64748b);
}

.dm-bg-music__icon {
    display: block;
    width: 1.75rem; /* 28px — scales with ~60px button */
    height: 1.75rem;
}

.dm-bg-music__icon--muted {
    display: none;
}

.dm-bg-music__btn.is-muted .dm-bg-music__icon--on {
    display: none;
}

.dm-bg-music__btn.is-muted .dm-bg-music__icon--muted {
    display: block;
}

/* Auto-shown mute hint on page load when unmuted */
.dm-bg-music__tip {
    pointer-events: none;
    position: absolute;
    left: calc(100% + 0.65rem);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    white-space: nowrap;
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
    background: var(--dm-primary, #292c7a);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    box-shadow: var(--dm-shadow-lg, 0 12px 28px rgba(15, 23, 42, 0.12));
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.22s ease,
        transform 0.22s ease,
        visibility 0.22s ease;
    z-index: 1;
}

.dm-bg-music__tip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--dm-primary, #292c7a);
}

.dm-bg-music__tip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

@keyframes dm-bg-music-pulse {
    0%,
    100% {
        box-shadow:
            0 0 0 0 rgba(var(--dm-primary-rgb), 0.28),
            var(--dm-shadow, 0 8px 24px rgba(15, 23, 42, 0.08));
    }
    50% {
        box-shadow:
            0 0 0 12px rgba(var(--dm-primary-rgb), 0),
            var(--dm-shadow, 0 8px 24px rgba(15, 23, 42, 0.08));
    }
}

@media (max-width: 380px) {
    .dm-bg-music__tip {
        left: 50%;
        top: auto;
        bottom: calc(100% + 0.55rem);
        transform: translateX(-50%) translateY(4px);
    }

    .dm-bg-music__tip::before {
        right: auto;
        left: 50%;
        top: 100%;
        transform: translateX(-50%);
        border: 6px solid transparent;
        border-top-color: var(--dm-primary, #292c7a);
    }

    .dm-bg-music__tip.is-visible {
        transform: translateX(-50%) translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dm-bg-music__btn.is-playing:not(.is-muted) {
        animation: none;
    }

    .dm-bg-music__tip {
        transition: none;
    }
}
