/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --c-primary:        #0B5A6A;
  --c-primary-dark:   #094d5c;
  --c-primary-light:  #d3f1ec;
  --c-primary-xlight: #eafaf7;
  --c-white:          #ffffff;
  --c-text:           #1a2e35;
  --c-text-muted:     #55606E;
  --c-border:         #e2e8f0;
  --c-bg:             #ffffff;
  --radius-card:      14px;
  --radius-pill:      100px;
  --shadow-card:      0 4px 20px rgba(11, 90, 106, 0.11), 0 1px 4px rgba(0, 0, 0, 0.05);
  --transition:       0.16s ease;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: transparent;
  padding: 6px;
}

/* ── Accessibility helpers ─────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Loading overlay ───────────────────────────────────────────── */
.loader {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.90);
  z-index: 10;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-card);
  backdrop-filter: blur(2px);
}

.loader[aria-hidden="false"] {
  display: flex;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--c-primary-light);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Player card ───────────────────────────────────────────────── */
.player-card {
  position: relative;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 22px 14px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────── */
.player-header {
  position: relative;        /* anchor for the absolute title */
  display: flex;
  align-items: center;
  min-height: 20px;
}

.player-brand {
  position: relative;        /* stays on top of the absolute title */
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--c-primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

/* ── Title (ticker / marquee) ──────────────────────────────────── */

/* Absolutely centered in the full header — ignores brand on the left */
.player-title-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;  /* centered by default (text fits) */
  overflow: hidden;
  pointer-events: none;     /* don't block clicks on the brand */
}

.player-title-text {
  display: inline-block;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  pointer-events: auto;
}

/* Ticker / marquee when text overflows */
.player-title-text.scrolling {
  animation: ticker var(--marquee-duration, 10s) linear infinite;
  animation-delay: 0.5s;
}

/* WCAG 2.2.2 – pause moving content on hover or focus */
.player-title-wrap:hover .player-title-text.scrolling,
.player-title-wrap:focus-within .player-title-text.scrolling {
  animation-play-state: paused;
}

@keyframes ticker {
  0%,  18%    { transform: translateX(0); }
  72%, 90%    { transform: translateX(var(--marquee-dist, -100px)); }
  91%, 100%   { transform: translateX(0); }
}

/* ── Progress section ──────────────────────────────────────────── */
.progress-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-display {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--c-text-muted);
  min-width: 34px;
  flex-shrink: 0;
  font-weight: 500;
}

.time-total {
  text-align: right;
}

/* Progress bar wrapper (tall click target) */
.progress-wrap {
  flex: 1;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  border-radius: var(--radius-pill);
}

.progress-wrap:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Visual track */
.progress-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--c-primary-light);
  position: relative;
  overflow: visible;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--c-primary);
  border-radius: var(--radius-pill);
  transition: width 0.1s linear;
}

/* Draggable thumb */
.progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-primary);
  border: 2px solid var(--c-white);
  box-shadow: 0 1px 5px rgba(11, 90, 106, 0.45);
  left: 0%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s, left 0.1s linear;
  pointer-events: none;
}

.progress-wrap:hover .progress-thumb,
.progress-wrap:focus-visible .progress-thumb,
.progress-wrap.dragging .progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

/* ── Controls section ──────────────────────────────────────────── */
.controls-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Base button */
.ctrl-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  border-radius: 50%;
  color: var(--c-primary);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}

.ctrl-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* Small controls (restart, volume) */
.ctrl-btn--sm {
  width: 38px;
  height: 38px;
}

.ctrl-btn--sm:hover {
  background: var(--c-primary-xlight);
}

/* Skip ±10s */
.ctrl-btn--skip {
  width: 44px;
  height: 44px;
}

.ctrl-btn--skip:hover {
  background: var(--c-primary-xlight);
}

.skip-label {
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  color: var(--c-primary);
  letter-spacing: -0.02em;
}

/* Play / Pause (main CTA) */
.ctrl-btn--play {
  width: 56px;
  height: 56px;
  background: var(--c-primary);
  color: var(--c-white);
  border-radius: 50%;
  box-shadow: 0 3px 12px rgba(11, 90, 106, 0.38);
}

.ctrl-btn--play:hover {
  background: var(--c-primary-dark);
  transform: scale(1.06);
  box-shadow: 0 5px 18px rgba(11, 90, 106, 0.48);
}

.ctrl-btn--play:active {
  transform: scale(0.96);
}

.ctrl-btn--play:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 3px;
}

/* ── Status message ────────────────────────────────────────────── */
.player-status {
  min-height: 0;
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  text-align: center;
}

/* ── Speed section ─────────────────────────────────────────────── */
.speed-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.speed-label {
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.speed-btns {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.speed-btn {
  border: 1.5px solid var(--c-border);
  background: var(--c-white);
  color: var(--c-text-muted);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.7;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.speed-btn:hover {
  background: var(--c-primary-xlight);
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.speed-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

.speed-btn.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--c-white);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 420px) {
  .player-card {
    padding: 12px 14px 11px;
    gap: 11px;
  }

  .ctrl-btn--play {
    width: 50px;
    height: 50px;
  }

  .ctrl-btn--sm {
    width: 34px;
    height: 34px;
  }

  .ctrl-btn--skip {
    width: 38px;
    height: 38px;
  }

  .speed-btn {
    padding: 2px 9px;
    font-size: 11px;
  }
}

@media (max-width: 320px) {
  .player-brand span {
    display: none;
  }

  .speed-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
}
