/*
 * Compact, session-persistent music control. The supplied 1536 × 1024 PNG
 * contains the actual plaque between y=264 and y=641. The frame therefore
 * uses the measured 4.07:1 visible-art ratio and crops only transparent
 * canvas, never the wooden artwork.
 */

.bhw-soundscape {
    position: fixed;
    z-index: 10020;
    inset: auto auto max(0.65rem, env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
    display: block;
    width: clamp(10.75rem, 12vw, 12.5rem);
    aspect-ratio: 4.07 / 1;
    border-radius: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(0.4rem) scale(0.97);
    transition:
        opacity 180ms ease,
        transform 220ms ease;
    user-select: none;
    -webkit-user-select: none;
}

.bhw-soundscape[data-ready="true"] {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.bhw-soundscape[data-dragging="true"] {
    transition: none;
}

.bhw-soundscape__frame {
    position: absolute;
    isolation: isolate;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    cursor: grab;
    filter:
        drop-shadow(0 0.28rem 0.38rem rgba(0, 0, 0, 0.74))
        drop-shadow(0 0 0 rgba(214, 139, 53, 0));
    transition: filter 240ms ease, transform 240ms ease;
}

.bhw-soundscape__frame::after {
    position: absolute;
    z-index: 2;
    inset: -50% 20% -50% -28%;
    background: linear-gradient(
        105deg,
        transparent 31%,
        rgba(255, 224, 154, 0.04) 43%,
        rgba(255, 225, 161, 0.22) 50%,
        rgba(255, 224, 154, 0.04) 57%,
        transparent 69%
    );
    content: "";
    opacity: 0;
    pointer-events: none;
    transform: translateX(-72%);
}

.bhw-soundscape:hover .bhw-soundscape__frame,
.bhw-soundscape:focus-within .bhw-soundscape__frame {
    filter:
        drop-shadow(0 0.32rem 0.42rem rgba(0, 0, 0, 0.78))
        drop-shadow(0 0 0.3rem rgba(226, 148, 58, 0.58))
        drop-shadow(0 0 0.56rem rgba(121, 68, 24, 0.4));
    transform: translateY(-0.06rem);
}

.bhw-soundscape:hover .bhw-soundscape__frame::after,
.bhw-soundscape:focus-within .bhw-soundscape__frame::after {
    animation: bhw-soundscape-sheen 1.15s ease-out 1;
}

.bhw-soundscape[data-playing="true"] .bhw-soundscape__frame {
    animation: bhw-soundscape-breathe 3.8s ease-in-out infinite;
}

.bhw-soundscape[data-dragging="true"] .bhw-soundscape__frame {
    cursor: grabbing;
    filter:
        drop-shadow(0 0.38rem 0.48rem rgba(0, 0, 0, 0.82))
        drop-shadow(0 0 0.38rem rgba(226, 148, 58, 0.62));
    transform: scale(1.012);
}

.bhw-soundscape__art {
    position: absolute;
    z-index: 0;
    inset: 0 auto auto 0;
    width: 100%;
    max-width: none;
    height: auto;
    pointer-events: none;
    transform: translateY(-25.78%);
}

.bhw-soundscape__drag-hint {
    position: absolute;
    z-index: 3;
    inset: 0 28% 0 0;
    overflow: hidden;
    color: transparent;
    cursor: grab;
}

/*
 * The transparent buttons cover comfortable click zones. Only their small
 * centred pseudo-elements glow, so no oversized oval can escape the artwork.
 */
.bhw-soundscape__control {
    position: absolute;
    z-index: 4;
    top: 38.5%;
    display: block;
    height: 48%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0.35rem;
    background: transparent;
    box-shadow: none;
    color: transparent;
    cursor: pointer;
    outline: 0;
}

.bhw-soundscape__control::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 52%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(255, 204, 108, 0);
    box-shadow: 0 0 0 rgba(255, 188, 76, 0);
    content: "";
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.bhw-soundscape__control--play {
    left: 73.6%;
    width: 11.2%;
}

.bhw-soundscape__control--pause {
    left: 83.1%;
    width: 8.2%;
}

.bhw-soundscape__control--pause::after {
    width: 62%;
}

.bhw-soundscape__control:hover::after,
.bhw-soundscape__control:focus-visible::after {
    background: rgba(255, 205, 106, 0.13);
    box-shadow:
        0 0 0 1px rgba(255, 224, 161, 0.72),
        0 0 0.3rem rgba(255, 180, 59, 0.72),
        0 0 0.58rem rgba(151, 83, 25, 0.46);
    transform: translate(-50%, -50%) scale(1.06);
}

/* The hit target is 24px; the visible close disc inside it is only 16px. */
.bhw-soundscape__close {
    position: absolute;
    z-index: 6;
    top: 0;
    right: auto;
    left: 0;
    display: grid;
    width: 1.5rem;
    min-width: 1.5rem;
    height: 1.5rem;
    min-height: 1.5rem;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: #f3d79f;
    cursor: pointer;
    outline: 0;
}

.bhw-soundscape__close span {
    display: grid;
    width: 1rem;
    height: 1rem;
    place-items: center;
    padding: 0 0 0.04rem;
    border: 1px solid rgba(229, 186, 111, 0.74);
    border-radius: 50%;
    background: rgba(10, 9, 8, 0.9);
    box-shadow: 0 0.12rem 0.28rem rgba(0, 0, 0, 0.72);
    font: 700 0.68rem/1 Arial, sans-serif;
    opacity: 0.86;
    transition: background-color 170ms ease, box-shadow 170ms ease, opacity 170ms ease, transform 170ms ease;
}

.bhw-soundscape__close:hover span,
.bhw-soundscape__close:focus-visible span {
    background: #4e260e;
    box-shadow:
        0 0 0 1px rgba(255, 224, 161, 0.82),
        0 0 0.36rem rgba(229, 146, 53, 0.58);
    color: #fff1cf;
    opacity: 1;
    transform: scale(1.04);
}

.bhw-soundscape audio {
    display: none;
}

@keyframes bhw-soundscape-sheen {
    0% {
        opacity: 0;
        transform: translateX(-72%);
    }
    28% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateX(145%);
    }
}

@keyframes bhw-soundscape-breathe {
    0%,
    100% {
        filter:
            drop-shadow(0 0.28rem 0.38rem rgba(0, 0, 0, 0.76))
            drop-shadow(0 0 0.18rem rgba(224, 144, 51, 0.32));
    }
    50% {
        filter:
            drop-shadow(0 0.32rem 0.42rem rgba(0, 0, 0, 0.78))
            drop-shadow(0 0 0.38rem rgba(236, 157, 60, 0.54));
    }
}

@media (max-width: 43.749rem) {
    .bhw-soundscape {
        width: clamp(9.5rem, 43vw, 10.75rem);
        inset-block-end: max(0.55rem, env(safe-area-inset-bottom));
        inset-inline-start: max(0.55rem, env(safe-area-inset-left));
    }

    .bhw-soundscape__frame,
    .bhw-soundscape__drag-hint {
        cursor: default;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bhw-soundscape,
    .bhw-soundscape__frame,
    .bhw-soundscape__frame::after,
    .bhw-soundscape__control::after,
    .bhw-soundscape__close span {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}

@media (forced-colors: active) {
    .bhw-soundscape {
        outline: 2px solid ButtonText;
    }

    .bhw-soundscape__close span,
    .bhw-soundscape__control::after {
        forced-color-adjust: none;
    }
}
