/* ==========================================================================
   Atlas of Wales — optional map soundscape control

   The standalone first-time invitation card that used to live here was removed
   on 2026-08-10: the map tour's own soundscape step already made the same offer
   in the same words, and on a phone the second card covered a third of the map.
   The tour styles its card in assets/map-tour.css; this file styles the toggle.

   Scoped entirely to .map-soundscape* / .atlas-soundscape* — no global/element
   selectors, safe to load only on the map page. Reuses the .map-key__toggle
   visual language (dark glass, gold hairline border, copper accent) so the
   soundscape control reads as part of the existing bottom-right control cluster.
   Controller: assets/map-soundscape.js.
   ========================================================================== */

/* ---- toggle control ----------------------------------------------------
   Desktop: stays put in the bottom-right corner always — the standalone Map
   key toggle pill that used to share this corner is now hidden on desktop
   (superseded by the bottom-centre nav dock's own Map key button, which opens
   the panel elsewhere), so there is nothing left here to shift beside. Mobile
   still has a real top-right Map key pill, so .is-beside-key keeps shifting
   there (see the max-width:768px override below), toggled by JS. */
.map-soundscape {
    position: absolute;
    right: 18px;
    bottom: 30px;
    z-index: 31;                  /* above the mobile atlas-panel (30); below sheets (40+) */
    display: inline-flex;
}

.map-soundscape[hidden] { display: none; }

.map-soundscape__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 40px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(229, 191, 112, 0.20);
    border-radius: 8px;
    background: rgba(3, 10, 11, 0.80);
    box-shadow: 0 16px 38px rgba(0,0,0,0.38), inset 0 1px 0 rgba(255,255,255,0.04);
    backdrop-filter: blur(12px);
    color: #f3dda2;
    cursor: pointer;
    position: relative;
}

.map-soundscape__toggle:hover { background: rgba(229, 191, 112, 0.12); }

.map-soundscape__toggle:focus-visible {
    outline: 2px solid rgba(243, 221, 162, 0.7);
    outline-offset: 2px;
}

/* equalizer bars — the icon. Dim + short when inactive; bright + full when on. */
.map-soundscape__bar {
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: #c58956;
    opacity: 0.5;
    transform: scaleY(0.42);
    transform-origin: 50% 50%;
}

/* muted-state slash: a non-colour signal that sound is off (colour-blind safe) */
.map-soundscape__slash {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 50%;
    height: 2px;
    border-radius: 2px;
    background: #e7d3a6;
    transform: rotate(-32deg);
    box-shadow: 0 1px 0 rgba(0,0,0,0.55);
    opacity: 1;
    pointer-events: none;
}

/* active (playing-enabled) state */
.map-soundscape__toggle[aria-pressed="true"] {
    border-color: rgba(229, 191, 112, 0.42);
    background: rgba(197, 137, 86, 0.20);
    color: #f7e6bf;
}
.map-soundscape__toggle[aria-pressed="true"] .map-soundscape__bar {
    opacity: 1;
    background: #f0c079;
}
.map-soundscape__toggle[aria-pressed="true"] .map-soundscape__slash {
    opacity: 0;
}

/* animate only while audio is actually playing (class toggled by JS) */
.map-soundscape__toggle.is-playing .map-soundscape__bar {
    animation: map-soundscape-eq 900ms ease-in-out infinite;
}
.map-soundscape__toggle.is-playing .map-soundscape__bar:nth-child(1) { animation-delay: -600ms; }
.map-soundscape__toggle.is-playing .map-soundscape__bar:nth-child(2) { animation-delay: -200ms; }
.map-soundscape__toggle.is-playing .map-soundscape__bar:nth-child(3) { animation-delay: -420ms; }

@keyframes map-soundscape-eq {
    0%, 100% { transform: scaleY(0.35); }
    50%      { transform: scaleY(1); }
}

/* ---- mobile: control joins the top-right Map key ----------------------- */
@media (max-width: 768px) {
    .map-soundscape {
        right: 12px;
        bottom: auto;
        top: calc(12px + env(safe-area-inset-top, 0px));
    }
    .map-soundscape.is-beside-key {
        right: 124px;             /* left of the top-right Map key pill (right:12) */
    }
}

/* ---- reduced motion: no equaliser animation ---------------------------- */
@media (prefers-reduced-motion: reduce) {
    .map-soundscape__toggle.is-playing .map-soundscape__bar { animation: none; }
    .map-soundscape__toggle[aria-pressed="true"] .map-soundscape__bar { transform: scaleY(0.72); }
}
