/* ==========================================================================
   Arabsounds Chart  –  Frontend Stylesheet  v2.1
   ========================================================================== */

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.arsc-chart {
    all: revert;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #1a1a2e;
    max-width: 820px;
    margin: 2em auto;
}

.arsc-chart *,
.arsc-chart *::before,
.arsc-chart *::after {
    box-sizing: border-box;
}

/* ── Chart header ─────────────────────────────────────────────────────────── */
.arsc-chart__head {
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.arsc-chart__titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.arsc-chart__name {
    all: revert;
    font-size: 1.5rem;
    font-weight: 800;
    color: #1a1a2e;
    margin: 0 0 2px;
    padding: 0;
    line-height: 1.2;
    letter-spacing: -.01em;
    border: none;
}

.arsc-chart__subtitle {
    display: none;
}

/* Edition switcher dropdown */
.arsc-edition-switcher {
    all: revert;
    appearance: none;
    -webkit-appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1.5px solid #dde0e8;
    border-radius: 8px;
    padding: 7px 36px 7px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    min-width: 160px;
}

.arsc-edition-switcher:focus {
    outline: none;
    border-color: #c8102e;
    box-shadow: 0 0 0 3px rgba(200,16,46,.12);
}

/* ── Track list container ─────────────────────────────────────────────────── */
.arsc-edition {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,.05);
    border: 1px solid #e8eaed;
    background: #fff;
}

/* ── Track wrapper ────────────────────────────────────────────────────────── */
.arsc-track-wrap {
    border-bottom: 1px solid #e8eaed;
    background: #fff !important;
}

.arsc-track-wrap:last-child {
    border-bottom: none;
}

/* Kill any theme nth-child striping */
.arsc-edition .arsc-track-wrap:nth-child(odd),
.arsc-edition .arsc-track-wrap:nth-child(even),
.arsc-edition .arsc-track-wrap:nth-child(1),
.arsc-edition .arsc-track-wrap:nth-child(2),
.arsc-edition .arsc-track-wrap:nth-child(3) {
    background: #fff !important;
}

/* ── Track row ────────────────────────────────────────────────────────────── */
.arsc-track {
    display: grid !important;
    grid-template-columns: 56px 148px 1fr !important;
    align-items: center !important;
    gap: 0 14px !important;
    padding: 12px 20px !important;
    background: #fff !important;
    transition: background .15s ease;
    user-select: none;
    cursor: default;
    margin: 0 !important;
    border: none !important;
    width: 100% !important;
}

.arsc-track.is-playable {
    cursor: pointer;
}

.arsc-track.is-playable:hover,
.arsc-track.is-playable:focus-visible {
    background: #f8f9ff !important;
    outline: none;
}

.arsc-track.is-open {
    background: #f0f4ff !important;
}

/* Has metric: extra column right */
.arsc-track.arsc-track--has-metric {
    grid-template-columns: 56px 148px 1fr auto !important;
}

/* ── Position badge ───────────────────────────────────────────────────────── */
.arsc-track__pos {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.arsc-pos {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    font-size: 0.82rem !important;
    font-weight: 800 !important;
    background: #eef0f4 !important;
    color: #555 !important;
    line-height: 1;
    flex-shrink: 0;
    margin: 0 !important;
    padding: 0 !important;
    text-decoration: none !important;
}

/* ── Change indicators ────────────────────────────────────────────────────── */
.arsc-change {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 5px;
}

.arsc-change svg {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
}

.arsc-change--new {
    background: #FCA103;
    color: #fff;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.62rem;
    letter-spacing: .04em;
}

.arsc-change--up   { color: #16a34a; }
.arsc-change--down { color: #dc2626; }
.arsc-change--same { color: #9ca3af; font-size: 1rem; }

/* ── Thumbnail ────────────────────────────────────────────────────────────── */
.arsc-track__thumb {
    position: relative !important;
    width: 148px !important;
    min-width: 148px !important;
    height: 83px !important;
    flex-shrink: 0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    /* Default: grey placeholder */
    background-color: #dde0e8 !important;
    background-size: cover !important;
    background-position: center top !important;
    background-repeat: no-repeat !important;
    display: block !important;
}

/* Play button overlay */
.arsc-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.28);
    opacity: 0;
    transition: opacity .18s ease;
    border-radius: 8px;
}

.arsc-play-icon svg {
    width: 26px;
    height: 26px;
    color: #fff;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,.5));
}

.arsc-track.is-playable:hover .arsc-play-icon,
.arsc-track.is-open .arsc-play-icon {
    opacity: 1;
}

/* ── Track info ───────────────────────────────────────────────────────────── */
.arsc-track__info {
    display: flex !important;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
}

.arsc-track__title {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin: 0;
    padding: 0;
}

.arsc-track__artist {
    display: block;
    font-size: 0.9rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin: 0;
    padding: 0;
}

/* ── Views / Streams badge ────────────────────────────────────────────────── */
.arsc-track__metric {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding-left: 12px;
    padding-right: 14px;
}

.arsc-metric-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.arsc-metric-badge--views   { background: #e8edff; color: #3b5bdb; }
.arsc-metric-badge--streams { background: #f0e8ff; color: #7c3aed; }

/* ── YouTube player ───────────────────────────────────────────────────────── */
.arsc-player {
    overflow: hidden;
    max-height: 0;
    transition: max-height .35s ease;
    background: #000;
}

.arsc-player.is-open {
    max-height: 480px;
}

.arsc-player__inner {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
}

.arsc-player__inner iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
    display: block;
}

/* ── Error state ──────────────────────────────────────────────────────────── */
.arsc-error {
    all: revert;
    color: #c00;
    font-style: italic;
    font-size: 0.9rem;
    padding: 8px 0;
}

/* ── Responsive: Tablet ≤640px ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .arsc-chart {
        padding-left: 12px !important;
        padding-right: 12px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .arsc-chart__head {
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
    }
    .arsc-chart__nav { flex-shrink: 0; }
    .arsc-edition-switcher { min-width: 0; width: auto; }
    .arsc-track {
        grid-template-columns: 44px 120px 1fr !important;
        gap: 0 10px !important;
        padding: 9px 12px 9px 10px !important;
    }
    .arsc-track.arsc-track--has-metric {
        grid-template-columns: 44px 120px 1fr auto !important;
    }
    .arsc-track__thumb { width: 120px !important; min-width: 120px !important; height: 68px !important;
    background-size: cover !important;
    background-position: center top !important;
}
    
    .arsc-pos              { width: 30px !important; height: 30px !important; font-size: 0.78rem !important; }
    .arsc-track__title     { font-size: 0.95rem !important; }
    .arsc-track__artist    { font-size: 0.82rem !important; }
    .arsc-chart__name      { font-size: 1.25rem !important; }
}

/* ── Responsive: Mobile ≤480px ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .arsc-chart {
        padding-left: 14px !important;
        padding-right: 14px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: 1em !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .arsc-chart__head {
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        margin-bottom: 10px !important;
    }
    .arsc-chart__titles {
        flex: 1 !important;
        min-width: 0 !important;
    }
    .arsc-chart__name {
        font-size: 1.15rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .arsc-chart__nav { flex-shrink: 0; }
    .arsc-edition-switcher {
        width: auto !important;
        min-width: 130px !important;
        font-size: 0.78rem !important;
        padding: 6px 28px 6px 10px !important;
    }
    .arsc-track {
        grid-template-columns: 38px 100px 1fr !important;
        gap: 0 8px !important;
        padding: 8px 10px !important;
    }
    /* On mobile: metric as 4th column, compact badge */
    .arsc-track.arsc-track--has-metric {
        grid-template-columns: 38px 100px 1fr auto !important;
        grid-template-rows: auto !important;
    }
    .arsc-track.arsc-track--has-metric .arsc-track__metric {
        grid-column: 4 !important;
        grid-row: 1 !important;
        padding-left: 6px !important;
        padding-top: 0 !important;
        display: flex !important;
        align-items: center !important;
    }
    .arsc-metric-badge {
        flex-direction: column !important;
        align-items: center !important;
        gap: 2px !important;
        padding: 5px 8px !important;
        font-size: 0.7rem !important;
        line-height: 1.2 !important;
        text-align: center !important;
    }
    /* Hide emoji on very small screens, keep number */
    .arsc-metric-badge > span:first-child { font-size: 0.85rem !important; }
    .arsc-track__thumb { width: 100px !important; min-width: 100px !important; height: 56px !important;
    background-size: cover !important;
    background-position: center top !important;
}
    
    .arsc-pos              { width: 26px !important; height: 26px !important; font-size: 0.72rem !important; }
    .arsc-track__title     { font-size: 0.9rem !important; }
    .arsc-track__artist    { font-size: 0.78rem !important; }
    .arsc-metric-badge     { font-size: 0.72rem !important; padding: 3px 8px !important; }
    .arsc-change--new      { font-size: 0.58rem !important; padding: 2px 4px !important; }
    .arsc-change           { margin-top: 4px !important; }
}

/* ==========================================================================
   Top 3 Hero Widget  [arabsounds_top3]
   ========================================================================== */

.arsc-top3 {
    all: revert;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    max-width: 100%;
    width: 100%;
    margin: 2em 0 0;
    padding-bottom: 2em !important;
    color: #1a1a2e;
}

.arsc-top3 * { box-sizing: border-box; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.arsc-top3__head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.arsc-top3__title {
    all: revert;
    font-size: 1.4rem;
    font-weight: 800;
    color: #1a1a2e;
    margin: 0;
    padding: 0;
    border: none;
    line-height: 1.2;
}

.arsc-top3__subtitle {
    font-size: 0.8rem;
    font-weight: 700;
    color: #E71664;
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ── Grid: big card left + sidebar right ────────────────────────────────── */
.arsc-top3__grid {
    display: grid;
    grid-template-columns: 55% 1fr;
    gap: 16px;
    align-items: start;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.arsc-top3__card {
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
    border: 1px solid #e8eaed;
    transition: box-shadow .18s ease;
}

.arsc-top3__card.is-playable {
    cursor: pointer;
}

.arsc-top3__card.is-playable:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

/* ── Thumbnail ──────────────────────────────────────────────────────────── */
.arsc-top3__thumb {
    position: relative;
    background-color: #dde0e8;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
}

.arsc-top3__thumb--main {
    height: 0;
    padding-bottom: 56.25%;
    width: 100%;
    background-color: #111;
    background-size: cover;
    background-position: center center;
}

.arsc-top3__thumb--side {
    height: 100px;
    width: 100%;
}

/* Play overlay */
.arsc-top3__card .arsc-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.25);
    opacity: 0;
    transition: opacity .18s ease;
    border-radius: 0;
}

.arsc-top3__card.is-playable:hover .arsc-play-icon,
.arsc-top3__card.is-open .arsc-play-icon {
    opacity: 1;
}

.arsc-top3__card .arsc-play-icon svg {
    width: 36px;
    height: 36px;
    color: #fff;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,.5));
}

.arsc-top3__card--side .arsc-play-icon svg {
    width: 24px;
    height: 24px;
}

/* ── Rank badge ─────────────────────────────────────────────────────────── */
.arsc-top3__rank {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    z-index: 1;
}

.arsc-top3__rank--1 { background: #fff; color: #1a1a2e; width: 42px; height: 42px; font-size: 1.1rem; }
.arsc-top3__rank--2 { background: #fff; color: #1a1a2e; }
.arsc-top3__rank--3 { background: #fff; color: #1a1a2e; }

.arsc-top3__card--side .arsc-top3__rank {
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
}

/* ── Info block ─────────────────────────────────────────────────────────── */
.arsc-top3__info {
    padding: 8px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.arsc-top3__track-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin: 0;
    padding: 0;
}

.arsc-top3__track-artist {
    display: block;
    font-size: 0.82rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin: 0;
    padding: 0;
}

.arsc-top3__card--main .arsc-top3__track-title { font-size: 1.1rem; }
.arsc-top3__card--side .arsc-top3__track-title  { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.arsc-top3__card--side .arsc-top3__track-artist { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ── Sidebar layout ─────────────────────────────────────────────────────── */
.arsc-top3__sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Sidebar aligns to top, main card determines height */
.arsc-top3__grid {
    align-items: start !important;
}

/* Hide items 4+5 by default - combined selector beats display:grid !important on --side */
.arsc-top3__card--desktop-only,
.arsc-top3__card--side.arsc-top3__card--desktop-only {
    display: none !important;
}

/* Side card: horizontal row — rank | thumb | info */
.arsc-top3__card--side {
    display: grid !important;
    grid-template-columns: 60px 160px 1fr !important;
    min-width: 0 !important;
    align-items: center !important;
    gap: 0 !important;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e8eaed;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    padding: 0 !important;
}

/* Rank number sits outside/left of the thumb */
.arsc-top3__card--side .arsc-top3__rank {
    position: static !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 0.82rem !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    background: #eef0f4 !important;
    color: #555 !important;
    flex-shrink: 0 !important;
}

/* Side thumb: fixed 16:9, no padding trick needed here */
.arsc-top3__thumb--side {
    position: relative !important;
    width: 160px !important;
    height: 90px !important;
    padding: 0 !important;
    border-radius: 0 !important;
    flex-shrink: 0 !important;
}

.arsc-top3__card--side .arsc-top3__info {
    padding: 0 14px 0 10px !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    gap: 3px !important;
}

/* Player spans full width */
.arsc-top3__card--side .arsc-player {
    grid-column: 1 / -1 !important;
}

/* ── CTA Button ─────────────────────────────────────────────────────────── */
.arsc-top3__btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(90deg, #E71664 0%, #FCA103 100%);
    color: #fff !important;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-decoration: none !important;
    border-radius: 10px;
    transition: background .18s ease, transform .12s ease;
    margin-top: 2px;
}

.arsc-top3__btn:hover {
    background: linear-gradient(90deg, #c01050 0%, #e8920a 100%);
    transform: translateY(-1px);
    color: #fff !important;
    text-decoration: none !important;
}

/* ── Player inside top3 ─────────────────────────────────────────────────── */
.arsc-top3__card .arsc-player {
    overflow: hidden;
    max-height: 0;
    transition: max-height .35s ease;
    background: #000;
}

.arsc-top3__card .arsc-player.is-open {
    max-height: 480px;
}

/* ── Desktop: show items 4+5 ────────────────────────────────────────────── */
@media (min-width: 621px) {
    .arsc-top3__card--desktop-only,
    .arsc-top3__card--side.arsc-top3__card--desktop-only {
        display: grid !important;
    }
}

/* ── Responsive: Mobile ≤620px ─────────────────────────────────────────── */
@media (max-width: 620px) {
    .arsc-top3 {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .arsc-top3__grid {
        grid-template-columns: 1fr;
        gap: 6px !important;
    }

    .arsc-top3__card--side {
        grid-template-columns: 50px 120px 1fr !important;
        min-width: 0 !important;
    }

    .arsc-top3__thumb--side {
        width: 120px !important;
        height: 68px !important;
    }

    .arsc-top3__track-title   { font-size: 0.9rem; }
    .arsc-top3__track-artist  { font-size: 0.78rem; }

    .arsc-top3__btn {
        padding: 11px 16px;
        font-size: 0.85rem;
        margin-top: -1px !important;
        margin-bottom: 0;
    }
    .arsc-top3__sidebar {
        gap: 6px !important;
        padding-bottom: 0;
    }
    .arsc-top3 {
        padding-bottom: 1.2em !important;
    }
}

/* Card link wrapper — invisible but clickable */
.arsc-top3__card-link {
    display: block;
    text-decoration: none !important;
    color: inherit !important;
    cursor: pointer;
}

.arsc-top3__card-link:hover {
    text-decoration: none !important;
}
