/* ============================================
   MTV REWIND v2 - Styles
   Minimal, dark, video-centric design
   ============================================ */

:root {
    --color-white: #ffffff;
    --color-black: #000000;
    --color-accent: #ff6b00;
    --color-text: rgba(255, 255, 255, 0.9);
    --color-text-dim: rgba(255, 255, 255, 0.5);
    --color-overlay: rgba(0, 0, 0, 0.4);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--color-black);
    font-family: var(--font-main);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   FULLSCREEN VIDEO
   ============================================ */

.video-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: var(--color-black);
}

.video-container #player,
.video-container iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 56.25vw; /* 16:9 */
    min-height: 100vh;
    min-width: 177.78vh; /* 16:9 */
    transform: translate(-50%, -50%);
}

/* Click overlay - captures clicks to toggle mute */
.video-click-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
}

/* Mute indicator - shows briefly when toggling */
.mute-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 100px;
    height: 100px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.mute-indicator.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.mute-indicator-icon {
    width: 48px;
    height: 48px;
    color: var(--color-white);
}

.mute-indicator-icon svg {
    width: 100%;
    height: 100%;
}



/* ============================================
   FILM GRAIN OVERLAY
   ============================================ */

.grain-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.08;
    mix-blend-mode: overlay;
}

.grain-overlay::before {
    content: '';
    position: absolute;
    inset: -200%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    animation: grain 0.5s steps(10) infinite;
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -15%); }
    40% { transform: translate(-5%, 15%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 10%); }
    80% { transform: translate(3%, -15%); }
    90% { transform: translate(-10%, 5%); }
}

/* ============================================
   GLITCH EFFECTS
   ============================================ */

.glitch-container {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

/* Scanlines */
.glitch-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    opacity: 0;
    transition: opacity 0.1s;
}

/* Static Noise Canvas */
.glitch-static {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    mix-blend-mode: overlay;
    transition: opacity 0.05s;
    image-rendering: pixelated;
    background-repeat: repeat;
}

/* RGB Split Layers */
.glitch-rgb {
    position: absolute;
    inset: 0;
    background: inherit;
    opacity: 0;
    mix-blend-mode: screen;
    transition: opacity 0.05s;
}

.glitch-rgb-r {
    background: rgba(255, 0, 0, 0.1);
    transform: translateX(0);
}

.glitch-rgb-b {
    background: rgba(0, 0, 255, 0.1);
    transform: translateX(0);
}

/* Flicker Overlay */
.glitch-flicker {
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    mix-blend-mode: overlay;
    transition: opacity 0.02s;
}

/* Glitch clip-path slices (applied via JS) */
.glitch-slice {
    position: absolute;
    inset: 0;
    background: inherit;
}

/* Active glitch state animations */
@keyframes glitch-flicker {
    0%, 100% { opacity: 0; }
    5% { opacity: 0.1; }
    10% { opacity: 0; }
    15% { opacity: 0.15; }
    20% { opacity: 0; }
    55% { opacity: 0.1; }
    60% { opacity: 0; }
    80% { opacity: 0.05; }
}

@keyframes glitch-jitter {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-2px, 1px); }
    40% { transform: translate(2px, -1px); }
    60% { transform: translate(-1px, 2px); }
    80% { transform: translate(1px, -2px); }
}

@keyframes scanline-move {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

.glitch-container.active .glitch-scanlines {
    animation: scanline-move 0.1s linear infinite;
}

/* Heavy glitch state */
.glitch-container.heavy {
    animation: glitch-jitter 0.05s linear infinite;
}

/* Horizontal distortion bars */
.glitch-container.heavy::before,
.glitch-container.heavy::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    animation: glitch-bars 0.1s linear infinite;
    pointer-events: none;
}

.glitch-container.heavy::before {
    top: 30%;
}

.glitch-container.heavy::after {
    top: 70%;
    animation-delay: 0.05s;
}

@keyframes glitch-bars {
    0%, 100% { 
        transform: translateX(0) scaleY(1);
        opacity: 0;
    }
    25% { 
        transform: translateX(-5px) scaleY(2);
        opacity: 0.3;
    }
    50% { 
        transform: translateX(10px) scaleY(1);
        opacity: 0.1;
    }
    75% { 
        transform: translateX(-3px) scaleY(3);
        opacity: 0.2;
    }
}

/* ============================================
   TRANSITION OVERLAY
   ============================================ */

.transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: var(--color-black);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.transition-overlay.active {
    opacity: 1;
    visibility: visible;
}

.transition-overlay.exit {
    opacity: 0;
    visibility: hidden;
}

.transition-text {
    font-size: 14px;
    color: var(--color-text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.transition-overlay.active .transition-text {
    opacity: 1;
    transition-delay: 0.1s;
}

/* ============================================
   UI OVERLAY
   ============================================ */

.ui-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 32px;
    pointer-events: none;
}

.ui-overlay > * {
    pointer-events: auto;
}

/* ============================================
   TOP BAR
   ============================================ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.top-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Channel Selector */
.channel-selector {
    position: relative;
}

.channel-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--color-overlay);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    color: var(--color-text);
    font-family: var(--font-main);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.channel-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.2);
}

.channel-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.channel-icon svg {
    width: 100%;
    height: 100%;
}

.dropdown-arrow {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-arrow svg {
    width: 100%;
    height: 100%;
}

.channel-selector.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Channel Dropdown */
.channel-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    backdrop-filter: blur(20px);
}

.channel-selector.open .channel-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.channel-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 14px;
}

.channel-option:hover {
    background: rgba(255,255,255,0.1);
}

.channel-option.active {
    background: var(--color-accent);
    color: var(--color-black);
}

.channel-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.channel-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.channel-option-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.channel-option-icon svg {
    width: 100%;
    height: 100%;
}

.channel-option-count {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.5;
}

/* Volume Button */
.volume-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-overlay);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.volume-btn:hover {
    background: rgba(255,255,255,0.15);
}

.volume-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.volume-icon svg {
    width: 100%;
    height: 100%;
}

/* Mobile Favorite Button - hidden on desktop */
.mobile-favorite-btn {
    display: none;
}

/* ============================================
   BOTTOM BAR
   ============================================ */

.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

/* Now Playing */
.now-playing {
    display: flex;
    align-items: center;
    gap: 16px;
}

.now-playing-thumb {
    width: 120px;
    height: 68px;
    background: rgba(255,255,255,0.1);
    background-size: cover;
    background-position: center;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.now-playing-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.now-playing-title {
    font-size: 16px;
    font-weight: 500;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.now-playing-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-dim);
    text-decoration: none;
    opacity: 0.6;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}

.now-playing-link:hover {
    opacity: 1;
    color: var(--color-accent);
}

.link-icon {
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-icon svg {
    width: 100%;
    height: 100%;
}



/* Spacebar Control - two states: centered (play) and bottom (skip) */
.spacebar-control {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

/* Playing state - move to bottom */
.spacebar-control.playing {
    top: auto;
    bottom: 24px;
    transform: translateX(-50%);
}

/* Hide initially until ready */
.spacebar-control.hidden {
    opacity: 0;
    pointer-events: none;
}

.spacebar-text-before,
.spacebar-text-after {
    font-size: 14px;
    color: var(--color-text-dim);
    text-transform: lowercase;
    transition: opacity 0.3s ease;
}

.spacebar-btn {
    position: relative;
    min-width: 160px;
    padding: 12px 32px;
    background: var(--color-overlay);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 30px;
    color: var(--color-text);
    font-family: var(--font-main);
    font-size: 14px;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.spacebar-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.spacebar-btn.holding {
    border-color: var(--color-accent);
}

.spacebar-btn.ready {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-black);
}

.spacebar-label {
    position: relative;
    z-index: 2;
}

/* Mobile icon - hidden on desktop */
.spacebar-label-mobile {
    display: none;
    width: 16px;
    height: 16px;
}

.spacebar-label-mobile svg {
    width: 16px;
    height: 16px;
    display: block;
}

.spacebar-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--color-accent);
    opacity: 0.3;
    transition: width 0.05s linear;
    z-index: 1;
}

.spacebar-btn.holding .spacebar-progress {
    opacity: 0.5;
}

/* Bottom Right */
.bottom-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.stats {
    font-size: 13px;
    color: var(--color-text-dim);
}

.shortcuts {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--color-text-dim);
    opacity: 0.6;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 4px;
}

.shortcut kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: var(--font-main);
    font-size: 11px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-black);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}

.loading-text {
    font-size: 14px;
    color: var(--color-text-dim);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   INFO DIALOG
   ============================================ */

.info-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(10px);
}

.info-overlay.open {
    opacity: 1;
    visibility: visible;
}

.info-dialog {
    position: relative;
    max-width: 400px;
    width: 90%;
    padding: 32px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease;
}

.info-overlay.open .info-dialog {
    transform: scale(1) translateY(0);
}

.info-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--color-text-dim);
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.info-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text);
}

.info-content {
    text-align: center;
}

.info-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.info-description {
    font-size: 14px;
    color: var(--color-text-dim);
    line-height: 1.6;
    margin-bottom: 28px;
}

.info-tip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 24px;
    text-align: left;
}

.info-tip p {
    font-size: 13px;
    color: var(--color-text-dim);
    margin-top: 6px;
    line-height: 1.5;
}

.info-tip code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-accent);
}

.info-credits {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-credit {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-dim);
    opacity: 0.6;
}

.info-credit a {
    font-size: 14px;
    color: var(--color-text);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.info-credit a:hover {
    color: var(--color-accent);
}

/* Make logo clickable */
.logo {
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.logo:hover {
    opacity: 0.7;
}

/* ============================================
   MOBILE STYLES
   ============================================ */

@media (max-width: 768px) {
    .ui-overlay {
        padding: 16px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .channel-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .channel-name {
        display: none;
    }
    
    /* Bottom bar - stack vertically on mobile */
    .bottom-bar {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .now-playing {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        width: 100%;
        justify-content: center;
    }
    
    .now-playing-thumb {
        width: 60px;
        height: 34px;
    }
    
    .now-playing-info {
        flex: 0 1 auto;
        min-width: 0;
    }
    
    .now-playing-title {
        font-size: 13px;
        max-width: 180px;
    }
    
    .now-playing-link {
        display: none;
    }
    
    /* Spacebar control - position relative on mobile */
    .spacebar-control.playing {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
    }
    
    /* Show mobile icon only, hide desktop label */
    .spacebar-label-desktop {
        display: none;
    }
    
    .spacebar-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .spacebar-label-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 16px;
        height: 16px;
    }
    
    /* Hide "Hold" and "to skip" text on mobile - just icon */
    .spacebar-text-before,
    .spacebar-text-after {
        display: none;
    }
    
    /* Initial "hold to play" button - larger on mobile */
    .spacebar-control:not(.playing) .spacebar-btn {
        padding: 20px 32px;
    }
    
    .spacebar-control:not(.playing) .spacebar-label-mobile {
        width: 28px;
        height: 28px;
    }
    
    /* "Hold to skip" button - wider on mobile */
    .spacebar-control.playing .spacebar-btn {
        padding: 12px 28px;
    }
    
    .bottom-right {
        display: none;
    }
    
    .shortcuts {
        display: none;
    }
    
    /* Mobile favorite button - bottom right */
    .mobile-favorite-btn {
        display: flex;
        position: fixed;
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: var(--color-overlay);
        border: 1px solid rgba(255,255,255,0.1);
        border-radius: 50%;
        color: var(--color-text);
        cursor: pointer;
        backdrop-filter: blur(10px);
        transition: all var(--transition-fast);
        z-index: 20;
    }
    
    .mobile-favorite-btn:active {
        transform: scale(0.95);
    }
    
    .mobile-favorite-btn.active {
        color: #ff6b6b;
    }
    
    .mobile-favorite-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-favorite-icon svg {
        width: 100%;
        height: 100%;
    }
}

@media (max-width: 480px) {
    .now-playing-title {
        max-width: 140px;
    }
}

/* ============================================
   SCROLLBAR (for dropdown)
   ============================================ */

.channel-dropdown::-webkit-scrollbar {
    width: 6px;
}

.channel-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.channel-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.channel-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}
