/*
 * Shared SWMP3 / Interval Signals waveform transport.
 *
 * Site styles define --waveform-played, --waveform-unplayed and
 * --waveform-playhead. The generated PNG is only an alpha mask; changing these
 * variables rethemes the player without regenerating waveform files.
 */

.wfp-player,
.wfp-player * {
  box-sizing: border-box;
}

/* The custom player owns a hidden media element. It intentionally has no
   native controls, avoiding Android installed-PWA white-box rendering bugs. */
.wfp-audio {
  display: none !important;
}

.wfp-player {
  --wfp-progress: 0%;
  width: 100%;
  margin: 4px 0 10px;
}

.wfp-controls {
  display: grid;
  grid-template-columns: 44px minmax(140px, 1fr) auto 44px 92px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.wfp-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line, #33404d);
  border-radius: 50%;
  background: linear-gradient(180deg, #2b3540, #202832);
  color: var(--text, #d5dde5);
  cursor: pointer;
}

.wfp-button:hover {
  border-color: var(--waveform-played, var(--accent, #8cc6f0));
  color: var(--waveform-played, var(--accent, #8cc6f0));
}

.wfp-button:active {
  transform: translateY(1px);
}

.wfp-icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.wfp-icon-pause,
.wfp-icon-muted {
  display: none;
}

.wfp-player.is-playing .wfp-icon-play,
.wfp-player.is-muted .wfp-icon-volume {
  display: none;
}

.wfp-player.is-playing .wfp-icon-pause,
.wfp-player.is-muted .wfp-icon-muted {
  display: block;
}

.wfp-waveform {
  position: relative;
  min-width: 0;
  height: 52px;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

/* Always-present conventional seek bar. The canvas covers it only after a
   waveform PNG decodes successfully; missing/stale PNGs therefore degrade to a
   fully usable accent/gray progress line rather than a broken-image surface. */
.wfp-waveform::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 0;
  right: 0;
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--waveform-played, var(--accent, #8cc6f0)) 0 var(--wfp-progress),
    var(--waveform-unplayed, #68737d) var(--wfp-progress) 100%
  );
}

.wfp-player.has-waveform .wfp-waveform::before {
  opacity: 0;
}

/* The only visible waveform surface is one transparent canvas. */
.wfp-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  background: transparent !important;
  border: 0;
  pointer-events: none;
}

.wfp-canvas[hidden] {
  display: none;
}

.wfp-playhead {
  position: absolute;
  z-index: 2;
  top: 2px;
  bottom: 2px;
  left: var(--wfp-progress);
  width: 3px;
  background: var(--waveform-playhead, #eaf6ff);
  box-shadow: 0 0 3px rgba(0, 0, 0, .85);
  transform: translateX(-1.5px);
  pointer-events: none;
}

/* Transparent range input retains native mouse, touch, keyboard and screen-
   reader behavior. Suppress the large card-colored focus rectangle; keyboard
   focus is indicated by widening the playhead instead. */
.wfp-seek {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  touch-action: none;
}

.wfp-seek:focus,
.wfp-seek:focus-visible {
  outline: none;
  box-shadow: none;
}

.wfp-seek:focus-visible + .wfp-playhead {
  width: 5px;
  transform: translateX(-2.5px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .75), 0 0 6px rgba(0, 0, 0, .9);
}

/* Created by JavaScript only on hover/fine-pointer devices. It is a genuine
   MP3 link so right-click receives the browser's native link context menu.
   Left-button pointer handling in waveform-player.js preserves click/drag
   seeking and prevents ordinary navigation or downloading. */
.wfp-download-target {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: block;
  background: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

.wfp-time {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
  color: var(--text, #d5dde5);
  font: 15px var(--mono, Menlo, "Courier New", Courier, monospace);
  font-variant-numeric: tabular-nums;
}

.wfp-separator {
  color: var(--dim, #8593a1);
}

.wfp-volume {
  width: 92px;
  min-width: 0;
  margin: 0;
  accent-color: var(--waveform-played, var(--accent, #8cc6f0));
  cursor: pointer;
}

@media (max-width: 700px) {
  .wfp-controls {
    grid-template-columns: 40px minmax(64px, 1fr) auto 40px;
    gap: 6px;
  }

  .wfp-button {
    width: 40px;
    height: 40px;
  }

  .wfp-icon {
    width: 20px;
    height: 20px;
  }

  .wfp-waveform {
    height: 44px;
  }

  .wfp-time {
    font-size: 13px;
    gap: 3px;
  }

  /* Phone hardware buttons handle volume. Keeping only mute leaves enough
     horizontal room for the waveform and elapsed/total time. */
  .wfp-volume {
    display: none;
  }
}

@media (max-width: 390px) {
  .wfp-controls {
    grid-template-columns: 36px minmax(52px, 1fr) auto 36px;
    gap: 5px;
  }

  .wfp-button {
    width: 36px;
    height: 36px;
  }

  .wfp-icon {
    width: 18px;
    height: 18px;
  }

  .wfp-waveform {
    height: 40px;
  }

  .wfp-time {
    font-size: 11.5px;
    gap: 2px;
  }
}
