/* ═══════════════════════════════════════════════════════
   MySpace 2009 Custom Video Player
   Overrides ALL browser default video controls
   ═══════════════════════════════════════════════════════ */

/* Hide native controls across all browsers */
.ms-player video::-webkit-media-controls,
.ms-player video::-webkit-media-controls-panel,
.ms-player video::-webkit-media-controls-play-button,
.ms-player video::-webkit-media-controls-volume-slider,
.ms-player video::-webkit-media-controls-mute-button,
.ms-player video::-webkit-media-controls-timeline,
.ms-player video::-webkit-media-controls-current-time-display,
.ms-player video::-webkit-media-controls-time-remaining-display,
.ms-player video::-webkit-media-controls-fullscreen-button,
.ms-player video::-webkit-media-controls-toggle-closed-captions-button,
.ms-player video::-webkit-media-controls-volume-slider-container,
.ms-player video::-webkit-media-controls-enclosure,
.ms-player video::-webkit-media-controls-overlay-play-button {
    display: none !important;
    -webkit-appearance: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
}

/* Firefox */
.ms-player video::-moz-range-track,
.ms-player video::-moz-range-thumb {
    display: none !important;
}

/* Player container */
.ms-player {
    position: relative;
    background: #000;
    border: 1px solid #555;
    overflow: hidden;
    width: 100%;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ms-player video {
    display: block;
    width: 100%;
    object-fit: contain;
    background: #000;
}

/* Desktop only: limit height */
@media (min-width: 769px) {
    .ms-player { max-height: 540px; }
    .ms-player video { max-height: 540px; }
}

/* Fullscreen overrides */
.ms-player.ms-fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    border: none;
    max-height: none;
}
.ms-player.ms-fullscreen video {
    width: 100%;
    height: 100%;
    max-height: none;
}

/* ── Big Center Play Button ── */
.ms-player-bigplay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 60px; height: 60px;
    background: rgba(0,0,0,0.65);
    border: 2px solid rgba(255,255,255,0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}
.ms-player-bigplay svg {
    width: 30px; height: 30px;
    fill: #fff;
    margin-left: 3px;
}
.ms-player.ms-paused .ms-player-bigplay {
    opacity: 1;
    pointer-events: auto;
}
.ms-player-bigplay:hover {
    background: rgba(0,0,0,0.8);
    transform: translate(-50%, -50%) scale(1.08);
}

/* ── Buffering Spinner ── */
.ms-player-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 4;
}
.ms-player.ms-buffering .ms-player-loading { display: block; }
.ms-player.ms-buffering .ms-player-bigplay { display: none; }

.ms-player-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ms-spin 0.8s linear infinite;
}
@keyframes ms-spin { to { transform: rotate(360deg); } }

/* ── Controls Bar ── */
.ms-player-controls {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 32px;
    background: linear-gradient(to bottom, #4a4a4a, #2a2a2a);
    border-top: 1px solid #666;
    display: flex;
    align-items: center;
    padding: 0 4px;
    gap: 2px;
    z-index: 5;
    transition: opacity 0.3s;
}

/* Auto-hide controls on desktop when playing */
.ms-player:not(.ms-paused):not(.ms-hover) .ms-player-controls {
    opacity: 0;
}
.ms-player:not(.ms-paused).ms-hover .ms-player-controls {
    opacity: 1;
}
/* Always show on mobile (touch) */
.ms-player.ms-touch .ms-player-controls {
    opacity: 1;
}
.ms-player.ms-touch:not(.ms-paused):not(.ms-controls-visible) .ms-player-controls {
    opacity: 0;
}

/* ── Buttons ── */
.ms-player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.ms-player-btn svg {
    width: 16px; height: 16px;
    fill: #ddd;
    transition: fill 0.15s;
}
.ms-player-btn:hover svg { fill: #fff; }
.ms-player-btn.active svg { fill: #5ba4cf; }

/* ── Time Display ── */
.ms-player-time {
    font: bold 10px Arial, Helvetica, sans-serif;
    color: #ccc;
    white-space: nowrap;
    padding: 0 4px;
    flex-shrink: 0;
    min-width: 70px;
    text-align: center;
}

/* ── Seek Bar ── */
.ms-player-seekbar {
    flex: 1;
    height: 10px;
    background: #1a1a1a;
    border: 1px solid #555;
    position: relative;
    cursor: pointer;
    margin: 0 4px;
    border-radius: 1px;
}

.ms-player-seekbar-buffered {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    right: 0;
    background: #555;
    border-radius: 1px;
    transform-origin: left center;
    transform: scaleX(0);
}

.ms-player-seekbar-progress {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    right: 0;
    background: linear-gradient(to bottom, #6aafe0, #3a7fc0);
    border-radius: 1px;
    z-index: 1;
    transform-origin: left center;
    transform: scaleX(0);
    will-change: transform;
}

.ms-player-seekbar-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%) translateX(0px);
    width: 12px; height: 12px;
    background: linear-gradient(to bottom, #e0e0e0, #b0b0b0);
    border: 1px solid #888;
    border-radius: 2px;
    z-index: 2;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
    will-change: transform;
}
.ms-player-seekbar-thumb:hover {
    background: linear-gradient(to bottom, #fff, #ccc);
}

/* ── Volume ── */
.ms-player-volume {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.ms-player-volslider {
    width: 50px;
    height: 8px;
    background: #1a1a1a;
    border: 1px solid #555;
    position: relative;
    cursor: pointer;
    border-radius: 1px;
}

.ms-player-volslider-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: linear-gradient(to bottom, #6aafe0, #3a7fc0);
    width: 100%;
    border-radius: 1px;
}

.ms-player-volslider-thumb {
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
    width: 10px; height: 10px;
    background: linear-gradient(to bottom, #e0e0e0, #b0b0b0);
    border: 1px solid #888;
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ══════════════════════════════════════
   Mobile: Two-row controls for touch
   ══════════════════════════════════════ */
@media (max-width: 768px) {
    /* Remove border on mobile */
    .ms-player { border: none; }

    /* Two-row control bar */
    .ms-player-controls {
        height: auto;
        flex-wrap: wrap;
        padding: 0;
        gap: 0;
        background: linear-gradient(to bottom, rgba(50,50,50,0.95), rgba(20,20,20,0.98));
    }

    /* Row 1: Full-width seek bar */
    .ms-player-seekbar {
        order: -1;
        flex: none;
        width: 100%;
        height: 20px;
        margin: 0;
        border-left: none;
        border-right: none;
        border-radius: 0;
        border-top: 1px solid #666;
        border-bottom: 1px solid #444;
    }
    .ms-player-seekbar-thumb {
        width: 22px;
        height: 22px;
        border-radius: 3px;
    }

    /* Row 2: Buttons row */
    .ms-play-btn { order: 1; }
    .ms-player-time { order: 2; }
    .ms-player-volume { order: 3; margin-left: auto; }
    .ms-loop-btn { order: 4; }
    .ms-fs-btn { order: 5; }

    /* Bigger touch targets (44px minimum per Apple HIG) */
    .ms-player-btn {
        width: 44px;
        height: 44px;
    }
    .ms-player-btn svg {
        width: 22px;
        height: 22px;
    }

    /* Time display */
    .ms-player-time {
        font-size: 12px;
        min-width: auto;
        padding: 0 6px;
        flex: 1;
        text-align: left;
    }

    /* Volume: mute button only, no slider */
    .ms-player-volslider { display: none; }

    /* Big play button */
    .ms-player-bigplay {
        width: 70px;
        height: 70px;
    }
    .ms-player-bigplay svg {
        width: 36px;
        height: 36px;
    }

    /* Spinner */
    .ms-player-spinner {
        width: 44px;
        height: 44px;
        border-width: 4px;
    }
}

/* Phone: even more compact but still touch-friendly */
@media (max-width: 480px) {
    .ms-player-seekbar { height: 24px; }
    .ms-player-seekbar-thumb { width: 26px; height: 26px; }

    .ms-player-btn { width: 40px; height: 40px; }
    .ms-player-btn svg { width: 20px; height: 20px; }

    .ms-player-time { font-size: 11px; padding: 0 4px; }

    /* Hide loop on very small screens to save space */
    .ms-loop-btn { display: none; }
}
