/* player-kit — ambience UI styles.
 *
 * The sounds screen (tiles, per-sound volume sliders, sleep timer, credits) and
 * the persistent mini bar. Extracted from Haven's stylesheet alongside
 * player.css, and driven by the same custom properties — see the theming notes
 * at the top of that file.
 *
 * Load this after player.css; the docking rules there position .snd-mini.
 */

:root {
  /* Tokens this file needs beyond the set player.css defines. */
  --mini-h: 58px;
  --nav-h: 64px;
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.18);
}

/* ── Background Sounds — persistent mini bar (mirrors .hp-mini) ──── */
/* Positioning is deliberately absent here. This file loads AFTER player.css, so a
 * `position` declaration on .snd-mini would override the docking rules there and
 * drop the bar back into document flow — which is how it ended up off the bottom
 * of the viewport the first time. player.css owns where the bars sit; this rule
 * owns what they look like. */
.snd-mini {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
  padding: var(--space-2) var(--space-3);
}

.snd-mini[hidden] {
  display: none;
}

.snd-mini-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
}

.snd-mini-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.snd-mini-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snd-mini-stop {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border: none;
  border-radius: var(--radius-full);
  padding: 7px 14px;
  cursor: pointer;
}

.snd-mini-stop:hover {
  color: var(--color-error, #e04545);
}

/* ── Background Sounds — screen ────────────────────────────────────── */
.snd-sleep-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.snd-sleep-label {
  font-size: 12px;
  color: var(--color-text-faint);
  flex-shrink: 0;
}

.snd-sleep-remaining {
  font-size: 12px;
  color: var(--color-primary-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.snd-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.snd-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.snd-tile.on {
  border-color: var(--color-primary);
}

.snd-tile-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-4) var(--space-2);
  font-family: inherit;
}

/* `line-height: 1` was four pixels shorter than the emoji it has to hold: a
 * 28px colour glyph draws about 32px tall, so the box under-reported its own
 * height and the tile's label crept up into the artwork. Grid centres either
 * an emoji or the SVG the icon helper substitutes when one exists. */
.snd-tile-icon {
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1.2;
}

.snd-tile.on .snd-tile-icon {
  animation: sndPulse 2.4s ease-in-out infinite;
}

.snd-tile-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.snd-tile-vol {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--space-3) var(--space-3);
}

.snd-tile-vol-icon {
  font-size: 13px;
  flex-shrink: 0;
}

/* touch-action:none — a horizontal slider drag must never be interpreted as
   a pan/scroll gesture on mobile, or the thumb won't move under the finger. */
.snd-tile-vol input[type='range'] {
  flex: 1;
  height: 4px;
  /* Same leak as .ps-seek (see app.css's comment on it): the app-wide
   * `input { padding: 0.6em 0.75em }` reset has nowhere to go but into the
   * used height under box-sizing: border-box, since padding can't go
   * negative — without this the track rendered several times thicker than
   * the 4px above. */
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-divider);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  touch-action: none;
}
.snd-tile-vol input[type='range']:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.snd-tile-vol input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
}

.snd-tile-vol input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
}

.snd-credits {
  margin-top: var(--space-5);
  font-size: 11px;
  color: var(--color-text-faint);
  text-align: center;
}

.snd-credits-toggle {
  font: inherit;
  font-size: 11px;
  color: var(--color-text-faint);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}

.snd-credits-list {
  margin-top: var(--space-2);
}

.snd-credit-row {
  font-size: 11px;
  color: var(--color-text-faint);
  padding: 4px 0;
  border-top: 1px solid var(--color-divider);
}

/* ── Lightweight toast ───────────────────────────────────────────── */
.haven-toast,
.pl-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: var(--z-toast);
  background: color-mix(in oklch, var(--color-surface) 94%, transparent);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklch, var(--color-primary) 28%, var(--color-divider));
  border-left: 3px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
  max-width: min(92vw, 360px);
  text-align: center;
}

.pl-toast {
  bottom: calc(var(--mini-h, 64px) + var(--nav-h, 56px) + 12px);
  z-index: var(--z-toast);
}

.haven-toast.show,
.pl-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* A catalog entry's caveat, shown on its tile. Some of these change whether the
 * sound works at all — a binaural beat through a speaker does nothing — so it
 * belongs on the tile rather than buried in credits. */
.snd-tile-note {
  margin: 0;
  padding: 0 var(--space-3) var(--space-3);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--color-text-faint);
}
