/* =============================================================
   SW Audio Player — Frontend styly
   Verze: 1.3.0
   ============================================================= */

/* ── LIGHT ───────────────────────────────────────────────── */
.ap-root {
  --ap-bg:       #ffffff;
  --ap-surface:  #f6f4f1;
  --ap-border:   rgba(0, 0, 0, 0.12);
  --ap-border2:  rgba(0, 0, 0, 0.18);
  --ap-text:     #1a1a1a;
  --ap-muted:    #999;
  --ap-muted2:   #666;
  --ap-gold:     #c97f0a;
  --ap-gold-h:   #e08f10;
  --ap-gold-bg:  rgba(201, 127, 10, 0.10);
  --ap-track:    #e0ddd8;
  --ap-r:        14px;

  font-family:     inherit;
  box-sizing:      border-box;
  /* Container query — layout reaguje na šířku přehrávače,
     ne na šířku viewportu. Díky tomu funguje správně
     i v úzkých sloupcích na desktopu. */
  container-type:  inline-size;
}

/* ── DARK — Bootstrap ────────────────────────────────────── */
[data-bs-theme=dark] .ap-root {
  --ap-bg:       #1a1a1a;
  --ap-surface:  #242424;
  --ap-border:   rgba(255, 255, 255, 0.08);
  --ap-border2:  rgba(255, 255, 255, 0.15);
  --ap-text:     #f0f0f0;
  --ap-muted:    #666;
  --ap-muted2:   #aaa;
  --ap-gold:     #e8a020;
  --ap-gold-h:   #f0b83a;
  --ap-gold-bg:  rgba(232, 160, 32, 0.13);
  --ap-track:    #333333;
}

/* ── DARK — systémová preference ────────────────────────── */
@media (prefers-color-scheme: dark) {
  .ap-root {
    --ap-bg:       #1a1a1a;
    --ap-surface:  #242424;
    --ap-border:   rgba(255, 255, 255, 0.08);
    --ap-border2:  rgba(255, 255, 255, 0.15);
    --ap-text:     #f0f0f0;
    --ap-muted:    #666;
    --ap-muted2:   #aaa;
    --ap-gold:     #e8a020;
    --ap-gold-h:   #f0b83a;
    --ap-gold-bg:  rgba(232, 160, 32, 0.13);
    --ap-track:    #333333;
  }
}

/* ── KARTA ───────────────────────────────────────────────── */
.ap-card {
  background:    var(--ap-bg);
  border:        0.5px solid var(--ap-border2);
  border-radius: var(--ap-r);
  box-sizing:    border-box;
  max-width:     560px;
  overflow:      hidden; /* cover image se ořízne dle border-radius */
}

/* ── COVER — ikona (bez obrázku) ────────────────────────── */
.ap-cov {
  width:           46px;
  height:          46px;
  border-radius:   8px;
  flex-shrink:     0;
  background:      var(--ap-gold-bg);
  border:          0.5px solid var(--ap-border2);
  display:         flex;
  align-items:     center;
  justify-content: center;
  color:           var(--ap-gold);
  font-size:       20px;
  overflow:        hidden;
}

/* ── COVER PANEL — vlastní obrázek ──────────────────────── */
/* Vždy čtverec: width je dána kontextem, aspect-ratio zajistí výšku */
.ap-cover-panel {
  flex-shrink: 0;
  overflow:    hidden;
}
.ap-cover-panel img {
  width:      100%;
  height:     100%;
  object-fit: cover;
  display:    block;
}

/* ── PLAY TLAČÍTKO ───────────────────────────────────────── */
.ap-pbtn {
  width:           42px;
  height:          42px;
  border-radius:   50%;
  flex-shrink:     0;
  background:      var(--ap-gold);
  border:          none;
  cursor:          pointer;
  display:         flex;
  align-items:     center;
  justify-content: center;
  color:           #fff;
  font-size:       18px;
  transition:      background .15s, transform .1s;
}
.ap-pbtn:hover  { background: var(--ap-gold-h); }
.ap-pbtn:active { transform: scale(.92); }

/* ── META ────────────────────────────────────────────────── */
.ap-meta    { flex: 1; min-width: 0; }
.ap-mtitle  { font-size: 14px; font-weight: 500; color: var(--ap-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-msub    { font-size: 12px; color: var(--ap-muted2); margin-top: 2px; }

/* ── SEEK BAR ────────────────────────────────────────────── */
.ap-seek  { height: 5px; background: var(--ap-track); border-radius: 3px; cursor: pointer; position: relative; touch-action: none; margin-bottom: 5px; }
.ap-sf    { height: 100%; background: var(--ap-gold); border-radius: 3px; width: 0%; pointer-events: none; }
.ap-sth   {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--ap-bg); border: 2px solid var(--ap-gold);
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  left: 0%; pointer-events: none;
}
.ap-times { display: flex; justify-content: space-between; }
.ap-t     { font-size: 11px; color: var(--ap-muted); }

/* ── HLASITOST ───────────────────────────────────────────── */
.ap-vol     { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ap-vol-ico { color: var(--ap-muted2); font-size: 15px; flex-shrink: 0; }
.ap-vol-tr  {
  width: 90px; height: 4px; background: var(--ap-track); border-radius: 2px;
  cursor: pointer; position: relative; touch-action: none; flex-shrink: 0;
}
.ap-vf  { height: 100%; background: var(--ap-gold); border-radius: 2px; width: 80%; pointer-events: none; }
.ap-vth {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ap-bg); border: 2px solid var(--ap-gold);
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  left: 80%; pointer-events: none;
}
.ap-vpct { font-size: 11px; color: var(--ap-muted); min-width: 26px; }

/* ── SINGLE — bez obrázku ────────────────────────────────── */
.ap-single         { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.ap-s-row1         { display: flex; align-items: center; gap: 12px; }
.ap-s-row3         {
  display: flex; align-items: center; justify-content: flex-end;
  border-top: 0.5px solid var(--ap-border); padding-top: 10px;
}

/* ── SINGLE — s cover obrázkem (horizontální layout) ─────── */
.ap-single.ap-has-cover {
  display:        flex;
  flex-direction: row;
  align-items:    flex-start;
  padding:        0;
  max-width:      680px;
}
.ap-single.ap-has-cover .ap-cover-panel {
  width:        160px;
  aspect-ratio: 1 / 1; /* vždy čtverec */
}
.ap-single.ap-has-cover .ap-player-panel {
  flex:           1;
  min-width:      0;
  padding:        18px 20px;
  display:        flex;
  flex-direction: column;
  gap:            12px;
}

/* ── PLAYLIST — bez obrázku ──────────────────────────────── */
.ap-pl-head    { padding: 18px 20px 16px; border-bottom: 0.5px solid var(--ap-border); display: flex; flex-direction: column; gap: 12px; }
.ap-pl-top     { display: flex; align-items: center; gap: 12px; }
.ap-pl-ctrls   { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ap-ctrl {
  background: transparent; border: none; cursor: pointer;
  color: var(--ap-muted2); padding: 6px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.ap-ctrl:hover { color: var(--ap-gold); background: var(--ap-gold-bg); }
.ap-csp  { flex: 1; min-width: 8px; }
.ap-cts  { display: flex; align-items: center; gap: 3px; white-space: nowrap; flex-shrink: 0; }

/* ── PLAYLIST — s cover obrázkem (grid layout) ───────────── */
.ap-playlist.ap-has-cover {
  display:               grid;
  grid-template-columns: 160px 1fr;
  grid-template-rows:    auto auto;
  max-width:             680px;
}
.ap-playlist.ap-has-cover .ap-cover-panel {
  grid-column:  1;
  grid-row:     1;
  aspect-ratio: 1 / 1; /* vždy čtverec */
}
.ap-playlist.ap-has-cover .ap-pl-head {
  grid-column: 2;
  grid-row:    1;
  border-left: 0.5px solid var(--ap-border);
}
/* seznam přes celou šířku */
.ap-playlist.ap-has-cover .ap-pl-list {
  grid-column: 1 / 3;
  grid-row:    2;
  border-top:  0.5px solid var(--ap-border);
}

/* ── SEZNAM SKLADEB ──────────────────────────────────────── */
.ap-pl-list  { list-style: none; margin: 0; padding: 0; }
.ap-pl-item  {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; border-top: 0.5px solid var(--ap-border);
  cursor: pointer; transition: background .12s;
}
.ap-pl-item:hover          { background: var(--ap-surface); }
.ap-pl-item.active         { background: var(--ap-gold-bg); }
.ap-pl-num   { font-size: 12px; color: var(--ap-muted); width: 18px; text-align: center; flex-shrink: 0; line-height: 1; }
.ap-pl-item.active .ap-pl-num { color: var(--ap-gold); }
.ap-pl-ii    { flex: 1; min-width: 0; }
.ap-pl-in    { font-size: 13px; color: var(--ap-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-pl-item.active .ap-pl-in  { color: var(--ap-gold); font-weight: 500; }
.ap-pl-ia    { font-size: 11px; color: var(--ap-muted); margin-top: 1px; }
.ap-pl-id    { font-size: 11px; color: var(--ap-muted); flex-shrink: 0; }

/* animovaná tečka aktivní skladby */
.ap-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ap-gold); vertical-align: middle;
  animation: ap-dot 1.1s ease-in-out infinite;
}
@keyframes ap-dot {
  0%, 100% { transform: scale(1);   opacity: 1;  }
  50%       { transform: scale(.4); opacity: .3; }
}

/* =============================================================
   CONTAINER QUERIES
   Reagují na šířku samotného přehrávače — fungují správně
   v úzkých sloupcích na desktopu i na malých mobilech.
   ============================================================= */

/* Střední šířka — skryj procenta hlasitosti */
@container (max-width: 480px) {
  .ap-vpct    { display: none; }
  .ap-vol-tr  { width: 70px; }
}

/* Úzký přehrávač — přepni na vertikální layout */
@container (max-width: 400px) {

  /* Obecné zmenšení */
  .ap-single,
  .ap-pl-head   { padding: 13px; }
  .ap-pl-item   { padding: 9px 13px; }
  .ap-card      { border-radius: 10px; }
  .ap-cov       { width: 38px; height: 38px; font-size: 16px; }
  .ap-pbtn      { width: 36px; height: 36px; font-size: 15px; }

  /* Hlasitost v playlistu schovej (šetří místo) */
  .ap-pl-ctrls .ap-vol,
  .ap-pl-ctrls .ap-vol-ico { display: none; }

  /* Čas na nový řádek */
  .ap-pl-ctrls .ap-csp { display: none; }
  .ap-cts { width: 100%; justify-content: flex-end; padding-top: 2px; }

  /* Single s cover — přepni na vertikální layout */
  .ap-single.ap-has-cover {
    flex-direction: column;
    align-items:    stretch;
  }
  .ap-single.ap-has-cover .ap-cover-panel {
    width:        100%;  /* plná šířka karty */
    aspect-ratio: 1 / 1; /* zůstane čtverec */
  }

  /* Playlist s cover — přepni na vertikální grid */
  .ap-playlist.ap-has-cover {
    grid-template-columns: 1fr;
    grid-template-rows:    auto auto auto;
  }
  .ap-playlist.ap-has-cover .ap-cover-panel {
    grid-column:  1;
    grid-row:     1;
    width:        100%;
    aspect-ratio: 1 / 1;
  }
  .ap-playlist.ap-has-cover .ap-pl-head {
    grid-column: 1;
    grid-row:    2;
    border-left: none;
    border-top:  0.5px solid var(--ap-border);
  }
  .ap-playlist.ap-has-cover .ap-pl-list {
    grid-column: 1;
    grid-row:    3;
  }
}
