/* =====================================================================
   OSE · Sound panel · styles/components/sound-panel.css
   ---------------------------------------------------------------------
   The header's sound control, on every page: a speaker button (sound
   waves when sound is on, crossed out when off) that opens a small
   panel with the sound switch and the volume. It drives the same sound
   as the home cockpit's ÂM THANH switch and ÂM LƯỢNG fader. Hidden
   without JS (there is no sound without it). Component tokens only:
   --sound-panel-*.

   Markup (chrome/nav.html, inside .nav__actions)
     <div class="sound-panel" data-js="sound-panel">
       <button class="sound-panel__toggle" type="button" aria-expanded="false"
               aria-controls="sound-panel" data-state="off">
         <span class="visually-hidden">Âm thanh</span></button>
       <div class="sound-panel__box" id="sound-panel" hidden>
         <button class="sound-panel__switch" type="button" role="switch" aria-checked="false">
           <span class="sound-panel__label">Âm thanh</span>
           <span class="sound-panel__state" data-on="Bật" data-off="Tắt">Tắt</span></button>
         <label class="sound-panel__volume"><span class="sound-panel__label">Âm lượng</span>
           <input class="sound-panel__range" type="range" min="0" max="100" step="5" value="30"></label>
       </div>
     </div>
   States   toggle: data-state on | off, aria-expanded, hover, focus-visible
            switch: aria-checked (the state chip turns navy: Bật)
   Script   js/components/sound-panel.js
   ===================================================================== */

@layer components {
  .sound-panel {
    position: relative;
    display: none;
  }

  .js .sound-panel {
    display: inline-flex;
  }

  .sound-panel__toggle {
    --_icon: var(--sound-panel-icon-off);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: var(--sound-panel-toggle-size);
    block-size: var(--sound-panel-toggle-size);
    padding: 0;
    border: 0;
    border-radius: var(--sound-panel-toggle-radius);
    background-color: var(--sound-panel-toggle-bg);
    color: var(--sound-panel-color);
    cursor: pointer;
    transition: background-color var(--sound-panel-duration) var(--sound-panel-ease);
  }

  .sound-panel__toggle[data-state="on"] {
    --_icon: var(--sound-panel-icon-on);
  }

  .sound-panel__toggle::before {
    content: "";
    inline-size: var(--sound-panel-icon-size);
    block-size: var(--sound-panel-icon-size);
    background-color: currentColor;
    -webkit-mask: var(--_icon) center / contain no-repeat;
    mask: var(--_icon) center / contain no-repeat;
    forced-color-adjust: none;
  }

  @media (hover: hover) {
    .sound-panel__toggle:hover,
    .sound-panel__switch:hover {
      background-color: var(--sound-panel-toggle-hover);
    }
  }

  .sound-panel__toggle:focus-visible,
  .sound-panel__toggle.is-focus-visible,
  .sound-panel__switch:focus-visible,
  .sound-panel__switch.is-focus-visible {
    outline: none;
    box-shadow: var(--sound-panel-focus-ring);
  }

  .sound-panel__box {
    position: absolute;
    inset-block-start: calc(100% + var(--sound-panel-offset));
    inset-inline-end: 0;
    z-index: var(--sound-panel-z);
    display: grid;
    gap: var(--sound-panel-gap);
    padding: var(--sound-panel-pad);
    border-radius: var(--sound-panel-radius);
    background-color: var(--sound-panel-bg);
    box-shadow: var(--sound-panel-shadow);
    color: var(--sound-panel-color);
    white-space: nowrap;
  }

  .sound-panel__box[hidden] {
    display: none;
  }

  /* static: in the flow (styleguide demos) */
  .sound-panel--static .sound-panel__box {
    position: static;
  }

  .sound-panel__label {
    font: var(--sound-panel-label-font);
    letter-spacing: var(--sound-panel-label-tracking);
    text-transform: var(--sound-panel-label-case);
  }

  .sound-panel__switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sound-panel-gap);
    min-block-size: var(--sound-panel-row-height);
    padding-inline: var(--sound-panel-state-pad);
    border: 0;
    border-radius: var(--sound-panel-row-radius);
    background-color: var(--sound-panel-toggle-bg);
    color: inherit;
    cursor: pointer;
    transition: background-color var(--sound-panel-duration) var(--sound-panel-ease);
  }

  .sound-panel__state {
    padding-inline: var(--sound-panel-pad);
    border-radius: var(--sound-panel-state-radius);
    background-color: var(--sound-panel-state-off);
    font: var(--sound-panel-label-font);
    letter-spacing: var(--sound-panel-label-tracking);
    text-transform: var(--sound-panel-label-case);
  }

  .sound-panel__switch[aria-checked="true"] .sound-panel__state {
    background-color: var(--sound-panel-state-on);
    color: var(--sound-panel-state-on-text);
  }

  .sound-panel__volume {
    display: grid;
    gap: var(--sound-panel-gap);
    padding-inline: var(--sound-panel-state-pad);
    color: var(--sound-panel-label-color);
  }

  .sound-panel__range {
    inline-size: 100%;
    min-block-size: var(--sound-panel-row-height);
    accent-color: var(--sound-panel-accent);
  }

  @media (prefers-reduced-motion: reduce) {
    .sound-panel__toggle,
    .sound-panel__switch {
      transition: none;
    }
  }
}
