/* ============================================================
   RESET & FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

/* ============================================================
   CSS VARIABLES — Light Mode (default)
   ============================================================ */
:root {
    /* Page */
    --page-bg: #dedad3;
    --page-glow-1: #e8e4db;
    --page-glow-2: #ccc8be;

    /* Body */
    --body-bg: #ffffff;
    --body-shadow-top: rgba(255, 255, 255, 0.90);
    --body-shadow-bot: rgba(0, 0, 0, 0.03);

    /* Top button */
    --btn-bg-1: #edd060;
    --btn-bg-2: #b08828;

    /* Screen */
    --screen-bg: #4e5861;
    --screen-hi: rgba(255, 255, 255, 0.55);

    /* Wheel */
    --wheel-bg: #f2f2f2;
    --wheel-hi: rgba(255, 255, 255, 0.95);
    --wheel-shadow: rgba(0, 0, 0, 0.15);
    --wheel-outer-shadow-1: rgba(0, 0, 0, 0.18);
    --wheel-outer-shadow-2: rgba(0, 0, 0, 0.10);

    /* Center button */
    --center-bg: #ffffff;
    --center-hi: rgba(255, 255, 255, 1);
    --center-shadow: rgba(0, 0, 0, 0.12);

    /* Wheel icons */
    --icon-color: rgba(90, 80, 65, 0.42);
    --icon-hover: rgba(90, 80, 65, 0.72);
    --icon-active: rgba(90, 80, 65, 0.90);

    /* Transitions */
    --theme-transition: background 0.45s ease, color 0.45s ease, box-shadow 0.45s ease;
}

/* ============================================================
   CSS VARIABLES — Dark Mode
   ============================================================ */
[data-theme="dark"] {
    /* Page */
    --page-bg: #0f0f0f;
    --page-glow-1: #1a1a1f;
    --page-glow-2: #090909;

    /* Body */
    --body-bg: #1c1c1e;
    --body-shadow-top: rgba(255, 255, 255, 0.04);
    --body-shadow-bot: rgba(0, 0, 0, 0.40);

    /* Top button (gold stays gold — looks great on dark) */
    --btn-bg-1: #edd060;
    --btn-bg-2: #b08828;

    /* Screen */
    --screen-bg: #111827;
    --screen-hi: rgba(255, 255, 255, 0.08);

    /* Wheel */
    --wheel-bg: #2c2c2e;
    --wheel-hi: rgba(255, 255, 255, 0.06);
    --wheel-shadow: rgba(0, 0, 0, 0.40);
    --wheel-outer-shadow-1: rgba(0, 0, 0, 0.50);
    --wheel-outer-shadow-2: rgba(0, 0, 0, 0.35);

    /* Center button */
    --center-bg: #3a3a3c;
    --center-hi: rgba(255, 255, 255, 0.08);
    --center-shadow: rgba(0, 0, 0, 0.50);

    /* Wheel icons */
    --icon-color: rgba(210, 210, 210, 0.40);
    --icon-hover: rgba(210, 210, 210, 0.75);
    --icon-active: rgba(210, 210, 210, 0.95);
}

/* ============================================================
   PAGE
   ============================================================ */
body {
    min-height: 100vh;
    background: var(--page-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    transition: background 0.45s ease;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 90% 70% at 50% 35%, var(--page-glow-1) 0%, var(--page-glow-2) 100%);
    z-index: -1;
    transition: background 0.45s ease;
}

/* ============================================================
   DEVICE — gold rim wrapper
   ============================================================ */
.ipod-container {
    filter:
        drop-shadow(0 28px 56px rgba(0, 0, 0, 0.20)) drop-shadow(0 8px 20px rgba(0, 0, 0, 0.12));
}

[data-theme="dark"] .ipod-container {
    filter:
        drop-shadow(0 32px 64px rgba(0, 0, 0, 0.60)) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.40));
}

.ipod-rim {
    width: 370px;
    border-radius: 40px;
    padding: 2px;
    background: linear-gradient(150deg,
            #f8e898 0%,
            #e4c050 15%,
            #b88a28 35%,
            #ddb840 50%,
            #b08020 65%,
            #f0d870 80%,
            #a87020 100%);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.65),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   DEVICE BODY — shell
   ============================================================ */
.ipod-body {
    background: var(--body-bg);
    border-radius: 39px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 18px 28px 18px;
    gap: 0;
    position: relative;
    box-shadow:
        inset 0 3px 10px var(--body-shadow-top),
        inset 0 -3px 8px var(--body-shadow-bot);
    transition: var(--theme-transition);
}

/* Sleep/wake — mode toggle button */
.top-button {
    position: absolute;
    top: -3.5px;
    right: 58px;
    width: 64px;
    height: 2px;
    background: linear-gradient(to bottom, var(--btn-bg-1), var(--btn-bg-2));
    border-radius: 4px 4px 0 0;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.15s ease;
    /* Extend hit area downward for easier clicking */
    padding-bottom: 1px;
}

.top-button::after {
    content: '';
    position: absolute;
    inset: -4px -6px 0;
    border-radius: inherit;
}

.top-button:hover {
    filter: brightness(1.2);
}

.top-button:active {
    transform: scaleY(0.75);
    filter: brightness(0.9);

}

/* ============================================================
   SCREEN — inset panel
   ============================================================ */
.screen-container {
    width: 103%;
    height: 260px;
    border-radius: 26px;
    overflow: hidden;
    background: var(--screen-bg);
    box-shadow:
        inset 0 4px 14px rgba(0, 0, 0, 0.55),
        inset 0 0 0 1px rgba(0, 0, 0, 0.20),
        0 1px 0 var(--screen-hi);
    position: relative;
    margin-bottom: 40px;
    transition: background 0.45s ease, box-shadow 0.45s ease;
}

.screen {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.06) 0%,
            transparent 35%);
}

/* Dynamic blurred album art backdrop */
.screen-background-blur {
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.8) saturate(1.4);
    z-index: 0;
    transition: background-image 1.2s ease-in-out;
    opacity: 0.85;
}

.screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.1) 0%,
            rgba(0, 0, 0, 0.4) 100%);
    z-index: 1;
    pointer-events: none;
}


/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px 6px;
    color: #fff;
    flex-shrink: 0;
}

.status-left,
.status-right {
    display: flex;
    align-items: center;
    min-width: 36px;
}

.status-right {
    justify-content: flex-end;
}

.status-center {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #fff;
}

.icon-wifi {
    width: 14px;
    height: 18px;
    color: rgba(255, 255, 255, 0.92);
}

.icon-battery {
    width: 24px;
    height: 15px;
    color: rgba(255, 255, 255, 0.92);
}

/* ============================================================
   SCREEN CONTENT
   ============================================================ */
.screen-content {
    position: relative;
    z-index: 1;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.player-view,
.search-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.32s ease, transform 0.32s ease;
}

.player-view.active,
.search-view.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.search-view {
    background: rgba(20, 24, 30, 0.58);
    backdrop-filter: blur(22px);
    z-index: 2;
}

.player-view {
    z-index: 1;
}

/* ============================================================
   NOW PLAYING
   ============================================================ */
.now-playing {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 12px 14px 10px;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.album-art-container {
    width: 105px;
    height: 105px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.album-art-container:hover {
    transform: scale(1.03);
}

.album-art-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.track-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    flex: 1;
    gap: 4px;
}

.track-title {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.3px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.track-artist {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.track-album {
    color: rgba(255, 255, 255, 0.65);
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   SCREEN CONTROLS
   ============================================================ */
.screen-controls {
    padding: 0 14px 14px;
    flex-shrink: 0;
}

.progress-container {
    width: 100%;
    height: 16px;
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 10px;
}

.progress-bar-bg {
    position: absolute;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.20);
    border-radius: 2px;
}

.progress-bar-fill {
    position: absolute;
    height: 3px;
    width: 0%;
    background: #fff;
    border-radius: 2px;
    transition: width 0.15s linear;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.progress-container:hover .progress-bar-bg,
.progress-container:hover .progress-bar-fill {
    height: 4px;
}

.bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vol-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
}

.vol-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.vol-icon.muted {
    border-color: rgba(255, 80, 80, 0.8);
    background: rgba(255, 80, 80, 0.2);
    color: #ff8888;
}

.vol-state {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.vol-state.active {
    display: flex;
}

.vol-icon svg {
    width: 24px;
    height: 24px;
}

.more-icon {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.58);
    padding: 4px;
    transition: color 0.18s;
}

.more-icon:hover {
    color: rgba(255, 255, 255, 0.90);
}

.more-icon svg {
    width: 18px;
    height: 18px;
}

/* ============================================================
   CLICK WHEEL
   ============================================================ */
.wheel-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 18px;
}

.click-wheel {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: var(--wheel-bg);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    cursor: default;
    box-shadow:
        0 4px 12px var(--wheel-outer-shadow-1),
        0 8px 24px var(--wheel-outer-shadow-2),
        inset 0 2px 5px var(--wheel-hi),
        inset 0 -2px 5px var(--wheel-shadow);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: background 0.45s ease, box-shadow 0.45s ease;
}

.center-button {
    width: 92px;
    height: 92px;
    background: var(--center-bg);
    border-radius: 50%;
    z-index: 10;
    cursor: pointer;
    box-shadow:
        0 2px 8px var(--center-shadow),
        inset 0 2px 5px var(--center-hi),
        inset 0 -1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.45s ease;
}

.center-button:active {
    transform: scale(0.95);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.10),
        inset 0 2px 6px rgba(0, 0, 0, 0.15);
}

.wheel-button {
    position: absolute;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--icon-color);
    cursor: pointer;
    z-index: 5;
    transition: color 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.wheel-button svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.wheel-button:hover {
    color: var(--icon-hover);
}

.wheel-button:active {
    color: var(--icon-active);
}

/* Positions */
.menu-btn {
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
}

.menu-btn:active {
    transform: translateX(-50%) scale(0.88);
}

.play-pause-btn {
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
}

.play-pause-btn:active {
    transform: translateX(-50%) scale(0.88);
}

.prev-btn {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.prev-btn:active {
    transform: translateY(-50%) scale(0.88);
}

.next-btn {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.next-btn:active {
    transform: translateY(-50%) scale(0.88);
}

/* ============================================================
   SEARCH VIEW
   ============================================================ */
.search-bar-container {
    padding: 12px 14px 8px;
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.search-icon {
    position: absolute;
    left: 26px;
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.45);
    pointer-events: none;
}

.search-bar-container input {
    width: 100%;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 8px 12px 8px 34px;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    backdrop-filter: blur(8px);
    transition: background 0.2s, border-color 0.2s;
    -webkit-appearance: none;
}

.search-bar-container input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.search-bar-container input:focus {
    background: rgba(255, 255, 255, 0.20);
    border-color: rgba(255, 255, 255, 0.35);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 2px 10px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.search-results::-webkit-scrollbar {
    width: 3px;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.search-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.35);
    font-size: 12px;
    text-align: center;
    padding: 20px;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
    gap: 10px;
}

.result-item:hover {
    background: rgba(255, 255, 255, 0.11);
}

.result-item:active {
    background: rgba(255, 255, 255, 0.18);
}

.result-thumb {
    width: 38px;
    height: 38px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    overflow: hidden;
}

.result-title {
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-artist {
    color: rgba(255, 255, 255, 0.52);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 20px;
}

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

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.10);
    border-top-color: rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-height: 700px) {
    .ipod-rim {
        transform: scale(0.88);
        transform-origin: top center;
    }
}

.hidden-player {
    position: absolute;
    width: 200px;
    height: 200px;
    pointer-events: none;
    opacity: 0;
    overflow: hidden;
    left: -9999px;
}