/* sound.css
 *
 * The sound toggle in the top-right corner (see js/sound/sound-toggle.js).
 * Small and quiet: a cream icon on a faint dark circle, half-faded until
 * the pointer or keyboard focus is on it. The top-right corner is kept
 * free of each scene's words (see beach-words.js and night-words.js).
 */

.sound-toggle {
  position: fixed;
  /* Clear of a phone's notch and rounded corners (see the viewport meta). */
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  /* Above the transition canvas (z-index 3), so it stays put, and can be
     pressed, while a transition plays. */
  z-index: 4;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(6, 14, 40, 0.3);
  color: #f6eee2;
  opacity: 0.65;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  /* No blue flash on tap (phones add one); :active below shows the press. */
  -webkit-tap-highlight-color: transparent;
}

/* A larger area to tap than the circle shows (44 px, comfortable for a
   finger). */
.sound-toggle::before {
  content: "";
  position: absolute;
  inset: -0.25rem;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  opacity: 1;
}

.sound-toggle:active {
  background: rgba(6, 14, 40, 0.5);
}

.sound-toggle:focus-visible {
  outline: 2px solid #f6eee2;
  outline-offset: 3px;
}

.sound-toggle__icon {
  width: 1.2rem;
  height: 1.2rem;
}

/* Only the icon for the current state shows. */
.sound-toggle[aria-pressed="true"] .sound-toggle__icon--off,
.sound-toggle[aria-pressed="false"] .sound-toggle__icon--on {
  display: none;
}
