/* ── Shared Audio Player (.ap) ─────────────────────────────────────────────── *
 * Spotify-style line scrubber. Single component, dark + light mode.           *
 * The post viewer (feed-addon.js) uses this — Feed, profiles, shared links.    *
 * All colours are defined once via --ap-c1 / --ap-c2 custom properties.       *
 * ─────────────────────────────────────────────────────────────────────────── */

/* ── Wrapper ── */
.ap {
  --ap-c1: var(--hz-brand);
  --ap-c2: var(--hz-accent-pink);
  --ap-g1: color-mix(in srgb, var(--hz-brand) 50%, transparent);
  --ap-g2: rgba(255,77,157,.28);
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px 14px;
  background: rgba(10,24,56,.52);
}
[data-theme="light"] .ap {
  background: color-mix(in srgb, var(--hz-brand) 6%, transparent);
  border-top:    1px solid color-mix(in srgb, var(--hz-brand) 12%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--hz-brand) 12%, transparent);
}

/* ── Play / Pause button ── */
.ap-btn {
  position: relative;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--ap-c1), var(--ap-c2));
  box-shadow: 0 4px 18px var(--ap-g1), 0 2px 6px var(--ap-g2);
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  z-index: 1;
}
.ap-btn svg { width: 17px; height: 17px; fill: white; margin-left: 1px; } /* optical centring of the ▶ glyph — play never mirrors, so physical */
.ap-btn:hover  { transform: scale(1.08); box-shadow: 0 6px 24px var(--ap-g1), 0 3px 10px var(--ap-g2); }
.ap-btn:active { transform: scale(.91); transition-duration: .09s; }
/* Keyboard focus: circular ring (respects border-radius, stays round) */
.ap-btn:focus-visible {
  box-shadow: 0 4px 18px var(--ap-g1), 0 2px 6px var(--ap-g2),
              0 0 0 3px rgba(255,255,255,.85), 0 0 0 5px var(--ap-c1);
}
/* Expanding pulse ring while playing.
   Explicit top/right/bottom/left — `inset` shorthand unsupported on iOS ≤14. */
.ap-btn::after {
  content: ''; position: absolute;
  top: -5px; right: -5px; bottom: -5px; left: -5px;
  border-radius: 50%;
  border: 2px solid var(--ap-c1);
  opacity: 0; transform: scale(1);
  pointer-events: none;
}
.ap-btn.playing::after { animation: apRing 1.4s ease-out infinite; }
@keyframes apRing {
  0%   { transform: scale(1);    opacity: .75; }
  100% { transform: scale(1.65); opacity: 0;   }
}

/* ── Body ── */
.ap-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* ── Progress track (Spotify-style scrubber line) ──
   .ap-wave is the track rail.  .ap-fill is the played portion.
   .ap-thumb is the circular playhead dot.
   ::before expands the click/tap area without growing the visual 4 px line.  */
.ap-wave {
  /* A timeline runs left → right in every language (as on YouTube / Spotify in
     Arabic): the JS seeks from clientX - rect.left and writes .ap-fill width /
     .ap-thumb left as a %, so the rail is pinned LTR and its left offsets stay
     physical on purpose. */
  direction: ltr;
  position: relative;
  height: 4px;
  background: rgba(255,255,255,.18);
  border-radius: var(--hz-radius-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
[data-theme="light"] .ap-wave {
  background: color-mix(in srgb, var(--hz-brand) 20%, transparent);
}
.ap-wave::before {
  content: ''; position: absolute;
  top: -10px; right: 0; bottom: -10px; left: 0;
}

/* Played fill */
.ap-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: var(--ap-c1);
  border-radius: var(--hz-radius-2);
  pointer-events: none;
}

/* Playhead dot — hidden by default, shown on hover and while playing */
.ap-thumb {
  position: absolute;
  top: 50%; left: 0%;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: white;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 6px rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
[data-theme="light"] .ap-thumb {
  background: var(--ap-c1);
  box-shadow: 0 1px 8px var(--ap-g1);
}
.ap-wave:hover .ap-thumb { opacity: 1; }
/* Active (currently playing) — always visible + subtle pulse */
.ap-thumb.active {
  opacity: 1;
  animation: apBar .6s ease-in-out infinite alternate;
}
@keyframes apBar {
  from { transform: translate(-50%, -50%) scale(.82); }
  to   { transform: translate(-50%, -50%) scale(1.18); }
}

/* ── Footer (time display) ── */
.ap-footer {
  direction: ltr;                     /* elapsed under the left end, duration under the right — matches the LTR rail */
  display: flex; align-items: center; justify-content: space-between;
}
.ap-cur, .ap-dur {
  font-size: 11px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--t3);
}

/* Hidden audio element (appended inside .ap by the component) */
.ap > audio { display: none; }
