/* ==========================================================================
   OFFLINE & DOWNLOADS
   Banner, progress pill, the marks on saved songs, the download buttons and
   the storage card on Profile. Colour is the profile's --accent throughout.
   ========================================================================== */

/* ---------- "You're offline" ---------- */
.offline-banner {
    position: sticky;
    top: var(--top-inset);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: -4px 0 10px;
    padding: 7px 12px;
    background: rgba(var(--accent-rgb), 0.16);
    border: 1px solid rgba(var(--accent-rgb), 0.4);
    border-radius: 12px;
    color: var(--fg);
    font-size: 0.8rem;
    font-weight: 600;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.offline-banner .icon { color: var(--accent); flex: 0 0 auto; }
.offline-banner.hidden { display: none; }

/* What the message becomes: a small dot in the corner, out of the way. */
.offline-dot {
    position: fixed;
    /* Top right corner, level with the top of the playlist wheel where it pins
       while scrolling (the sticky header's top plus its padding). Fixed in CSS so
       it never moves on its own. At the top, in the middle, it read as a camera
       light. */
    top: calc(var(--top-inset) + 6px);
    right: 1px;
    z-index: 1900;
    width: 11px;
    height: 11px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.18);
    /* A bigger target than it looks, for a thumb. */
    outline: 10px solid transparent;
    cursor: pointer;
}
.offline-dot.hidden { display: none; }
.offline-dot.is-warn { background: #e0a030; animation: offline-dot-pulse 1.6s ease-in-out infinite; }
@keyframes offline-dot-pulse { 50% { box-shadow: 0 0 0 7px rgba(224, 160, 48, 0.25); } }
@media (prefers-reduced-motion: reduce) { .offline-dot.is-warn { animation: none; } }

/* Songs that can't be played without a connection step back. */
body.is-offline .swipeable-row:not(.is-downloaded),
body.is-offline .sx-row:not(.is-downloaded) { opacity: 0.4; }

/* ---------- Progress while downloading ---------- */
.dl-pill {
    position: fixed;
    top: calc(var(--top-inset) + 8px);
    left: 12px;
    right: 12px;
    z-index: 2100;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 460px;
    margin: 0 auto;
    padding: 10px 12px 10px 14px;
    border-radius: 16px;
    background:
        linear-gradient(90deg, rgba(var(--accent-rgb), 0.38) calc(var(--dl-fraction, 0) * 100%), transparent 0),
        var(--surface-1);
    border: 1px solid rgba(var(--accent-rgb), 0.5);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    color: var(--fg);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.4s;
    animation: dl-pill-in 0.25s ease-out;
}
.dl-pill.hidden { display: none; }
.dl-pill.is-problem { border-color: var(--warning); }
.dl-pill-icon { color: var(--accent); flex: 0 0 auto; }
.dl-pill:not(.is-done):not(.is-problem) .dl-pill-icon { animation: dl-bob 1.1s ease-in-out infinite; }
.dl-pill-text { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.dl-pill-cancel {
    flex: 0 0 auto;
    padding: 6px 12px;
    background: rgba(var(--tint-rgb), 0.1);
    color: var(--fg);
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}
.dl-pill-cancel.hidden { display: none; }
@keyframes dl-pill-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dl-bob { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(2px); } }

/* ---------- The mark on a saved song ---------- */
.list-dl-mark {
    display: none;
    flex: 0 0 auto;
    margin-right: 2px;
    color: var(--accent);
}
.is-downloaded > .song-swipe-content .list-dl-mark,
.sx-row.is-downloaded .list-dl-mark { display: inline-flex; }

/* ---------- Download buttons (Home header, playlist drawer) ---------- */
.dl-btn.hidden { display: none; }
.dl-btn.is-complete { color: var(--accent); }
.dl-btn.is-partial { color: var(--accent); }
.dl-btn.is-busy .icon { animation: dl-bob 1.1s ease-in-out infinite; color: var(--accent); }

/* ---------- Song menu ---------- */
#menu-download.hidden { display: none; }
#menu-download.is-saved { color: var(--accent); }

/* ---------- Profile card ---------- */
.dl-summary { margin: 14px 0 8px; font-size: 1.05rem; font-weight: 700; color: var(--fg); }
.dl-meter {
    height: 8px;
    margin: 0 0 8px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}
.dl-meter.hidden { display: none; }
.dl-meter-fill {
    height: 100%;
    min-width: 4px;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s;
}
.dl-keep-note { margin: 0 0 10px; }
.dl-keep-note:empty { display: none; }
.dl-empty { margin: 8px 0 0; font-size: 0.85rem; color: var(--fg-3); }
.dl-empty.hidden { display: none; }
.dl-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
}
.dl-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px;
    border-top: 1px solid var(--border);
}
.dl-row-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}
.dl-row-size { flex: 0 0 auto; font-size: 0.76rem; color: var(--fg-3); }
.dl-row-remove {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    display: grid;
    place-items: center;
    background: rgba(var(--tint-rgb), 0.07);
    color: var(--fg-2);
    border-radius: 50%;
}
.dl-row-remove:hover { background: rgba(var(--tint-rgb), 0.15); color: var(--fg); }
.dl-clear {
    margin-top: 12px;
    width: 100%;
    height: 44px;
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 10px;
    font-weight: 600;
}
.dl-clear.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
    .dl-pill, .dl-pill-icon, .dl-btn.is-busy .icon { animation: none !important; }
}
