/*
 * Single page — music section, "cards shaped like the episode cards" (music design 1, canvas page "singlemusic2", MuCards).
 * Sits between the episodes and the comments. Markup: partials/single/anime/musics.php (.atv-mu-*).
 * Behaviour: public/js/animetv-music-player.js (filter .js-mu-type, «پخش همه» .js-mu-all, card .is-active / .is-playing,
 * progress .js-mu-fill, «موزیک‌سرا» hearts .js-mua-card-sara.is-on).
 * Colours: --s3-* tokens (single-s3.css) and the capsule glass --et-* tokens (episode-tools.css); day mode at the end.
 */
.atv-mu {
    --mu-name-on: #ffd47e;
    --mu-glow: 0 0 0 3px rgba(245, 185, 66, 0.08), 0 14px 30px -18px rgba(245, 185, 66, 0.8);
    --mu-glow-line: rgba(245, 185, 66, 0.55);
    --mu-glow-bg: linear-gradient(270deg, rgba(245, 185, 66, 0.07), rgba(245, 185, 66, 0) 62%);
    --mu-track: rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 34px;
}
.atv-mu + .atv-s3-comments {
    margin-top: 34px;
}
.atv-mu [hidden],
.atv-mu .atv-mu-card[hidden] {
    display: none !important;
}
.atv-mu button {
    margin: 0;
    font: inherit;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    min-height: 0;
    cursor: pointer;
}
.atv-mu button:focus-visible,
.atv-mu a:focus-visible {
    outline: 2px solid var(--s3-accent);
    outline-offset: 2px;
}

/* ---------- Head capsule: type filter + «پخش همه» ---------- */
.atv-mu .atv-mu-tools {
    align-items: center;
}
.atv-mu-cap {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    height: 50px;
    padding: 4px;
    border-radius: 999px;
    background: var(--et-glass, linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)));
    border: 1px solid var(--et-glass-line, rgba(255, 255, 255, 0.09));
    box-shadow: var(--et-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.09));
    box-sizing: border-box;
}
.atv-mu-seg {
    display: flex;
    gap: 2px;
    min-width: 0;
}
.atv-mu .atv-mu-seg button {
    height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--s3-muted);
    background: transparent;
    white-space: nowrap;
    transition: color 0.25s, background 0.25s, box-shadow 0.25s;
}
.atv-mu .atv-mu-seg button:hover {
    color: var(--s3-text-2);
}
.atv-mu .atv-mu-seg button.is-on {
    color: var(--et-on, #ffffff);
    background: var(--et-thumb, linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06)));
    box-shadow: var(--et-thumb-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 6px 16px -8px rgba(0, 0, 0, 0.85));
}
.atv-mu-seg em {
    font-style: normal;
    font-size: 11px;
    color: var(--s3-muted);
    transition: color 0.25s;
}
.atv-mu-seg button.is-on em {
    color: var(--et-on-icon, #f5b942);
}
.atv-mu-sep {
    flex-shrink: 0;
    width: 1px;
    height: 22px;
    background: var(--et-sep, rgba(255, 255, 255, 0.1));
}
.atv-mu .atv-mu-all {
    flex-shrink: 0;
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--s3-accent-ink);
    background: linear-gradient(180deg, #ffd47e, #f5b942);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 10px 26px -10px rgba(245, 185, 66, 0.85);
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}
.atv-mu .atv-mu-all:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 14px 30px -10px rgba(245, 185, 66, 1);
}
.atv-mu .atv-mu-all:active {
    transform: translateY(0);
}
.atv-mu-all i {
    font-size: 12px;
}

/* ---------- Track cards (same shape as the episode cards) ---------- */
.atv-mu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 10px;
}
.atv-mu-card {
    --mu-c: #4cdeb2;
    --mu-s: rgba(76, 222, 178, 0.12);
    --mu-l: rgba(76, 222, 178, 0.36);
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 9px 12px 9px 8px;
    border-radius: var(--s3-radius, 14px);
    border: 1px solid var(--s3-line-soft);
    background: var(--s3-surface);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.atv-mu-card.is-op {
    --mu-c: #f5b942;
    --mu-s: rgba(245, 185, 66, 0.13);
    --mu-l: rgba(245, 185, 66, 0.38);
}
.atv-mu-card.is-ed {
    --mu-c: #b797ff;
    --mu-s: rgba(139, 92, 246, 0.15);
    --mu-l: rgba(167, 139, 250, 0.4);
}
.atv-mu-card:hover {
    border-color: var(--s3-line);
}
.atv-mu-card.is-active {
    border-color: var(--mu-glow-line);
    background: var(--mu-glow-bg), var(--s3-surface);
    box-shadow: var(--mu-glow);
}
.atv-mu-card.is-in {
    animation: atvMuIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes atvMuIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* Cover tile: play on hover, equaliser while playing (pause on hover). */
.atv-mu .atv-mu-tile {
    position: relative;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--s3-surface-2);
    color: var(--s3-muted);
    font-size: 17px;
}
.atv-mu-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    transition: transform 0.4s;
}
.atv-mu-card:hover .atv-mu-tile img {
    transform: scale(1.08);
}
.atv-mu-ov,
.atv-mu-eq {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: rgba(10, 11, 15, 0.45);
    font-size: 15px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}
.atv-mu-card:hover .atv-mu-ov,
.atv-mu-tile:focus-visible .atv-mu-ov,
.atv-mu-card.is-active .atv-mu-ov {
    opacity: 1;
}
.atv-mu-card.is-active .atv-mu-ov,
.atv-mu-eq {
    color: #f5b942;
    background: rgba(10, 11, 15, 0.6);
}
.atv-mu-eq {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.atv-mu-eq span {
    width: 3px;
    height: 5px;
    border-radius: 2px;
    background: currentColor;
    animation: atvMuEq 1s ease-in-out infinite;
}
.atv-mu-eq span:nth-child(2) {
    animation-delay: 0.2s;
}
.atv-mu-eq span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes atvMuEq {
    50% {
        height: 15px;
    }
}
.atv-mu-card.is-playing .atv-mu-eq {
    opacity: 1;
}
.atv-mu-card.is-playing .atv-mu-ov {
    opacity: 0;
}
.atv-mu-card.is-playing:hover .atv-mu-eq,
.atv-mu-card.is-playing .atv-mu-tile:focus-visible .atv-mu-eq {
    opacity: 0;
}
.atv-mu-card.is-playing:hover .atv-mu-ov,
.atv-mu-card.is-playing .atv-mu-tile:focus-visible .atv-mu-ov {
    opacity: 1;
}

/* Name + type badge · kind · duration */
.atv-mu-tx {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.5;
}
.atv-mu-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--s3-text);
    unicode-bidi: plaintext;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.25s;
}
.atv-mu-card.is-active .atv-mu-name {
    color: var(--mu-name-on);
}
.atv-mu-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 12px;
    color: var(--s3-muted);
    white-space: nowrap;
    overflow: hidden;
}
.atv-mu-tp {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 0.3px;
    line-height: 1;
    color: var(--mu-c);
    background: var(--mu-s);
    box-shadow: inset 0 0 0 1px var(--mu-l);
}
.atv-mu-kind {
    overflow: hidden;
    text-overflow: ellipsis;
}
.atv-mu-time {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.atv-mu-time::before {
    content: "·";
    margin-left: 8px;
}

/* Heart («موزیک‌سرا») + download */
.atv-mu-acts {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 2px;
}
.atv-mu .atv-mu-ib {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: var(--s3-muted);
    background: transparent;
    font-size: 15px;
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}
.atv-mu .atv-mu-ib:hover {
    color: var(--s3-text);
    background: var(--s3-surface-2);
}
.atv-mu .atv-mu-ib.is-heart.is-on {
    color: #ff6b8a;
}
.atv-mu .atv-mu-ib.is-heart.is-on i {
    animation: atvMuPop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes atvMuPop {
    40% {
        transform: scale(1.3);
    }
}

/* Progress line under the playing card (fills from the start side, like the rest of the RTL page). */
.atv-mu-pg {
    position: absolute;
    right: 0;
    left: 0;
    bottom: 0;
    height: 3px;
    background: var(--mu-track);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.atv-mu-card.is-active .atv-mu-pg {
    opacity: 1;
}
.atv-mu-pg i {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 100%;
    border-radius: 0 0 0 3px;
    background: linear-gradient(270deg, #ffd47e, #f5b942);
    box-shadow: 0 0 8px rgba(245, 185, 66, 0.8);
    transition: width 0.25s linear;
}

/* ---------- Day mode ---------- */
#animetvApp.day .atv-mu {
    --mu-name-on: #9a6200;
    --mu-glow: 0 0 0 3px rgba(245, 185, 66, 0.14), 0 14px 28px -18px rgba(184, 121, 0, 0.55);
    --mu-glow-line: rgba(214, 150, 20, 0.6);
    --mu-glow-bg: linear-gradient(270deg, rgba(245, 185, 66, 0.12), rgba(245, 185, 66, 0) 62%);
    --mu-track: rgba(15, 23, 42, 0.07);
}
#animetvApp.day .atv-mu-card {
    --mu-c: #0f7a5e;
    --mu-s: rgba(16, 185, 129, 0.1);
    --mu-l: rgba(15, 122, 94, 0.3);
}
#animetvApp.day .atv-mu-card.is-op {
    --mu-c: #9a6200;
    --mu-s: rgba(245, 185, 66, 0.16);
    --mu-l: rgba(184, 121, 0, 0.35);
}
#animetvApp.day .atv-mu-card.is-ed {
    --mu-c: #6d28d9;
    --mu-s: rgba(139, 92, 246, 0.1);
    --mu-l: rgba(109, 40, 217, 0.28);
}
#animetvApp.day .atv-mu .atv-mu-all {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 22px -12px rgba(184, 121, 0, 0.7);
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
    .atv-mu {
        margin-top: 28px;
    }
    .atv-mu .atv-mu-tools {
        width: 100%;
    }
    .atv-mu-cap {
        width: 100%;
    }
    .atv-mu-seg {
        flex: 1 1 auto;
    }
    .atv-mu .atv-mu-seg button {
        flex: 1 1 0;
        min-width: 0;
        padding: 0 8px;
    }
    .atv-mu .atv-mu-all {
        padding: 0 13px;
    }
}
@media (max-width: 400px) {
    .atv-mu-cap {
        flex-wrap: wrap;
        height: auto;
        border-radius: 24px;
    }
    .atv-mu-seg {
        flex-basis: 100%;
    }
    .atv-mu-sep {
        display: none;
    }
    .atv-mu .atv-mu-all {
        flex: 1 1 100%;
    }
    .atv-mu-card {
        gap: 10px;
    }
    .atv-mu .atv-mu-ib {
        width: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .atv-mu *,
    .atv-mu-card {
        animation: none !important;
        transition: none !important;
    }
}
