/* Common styles */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #121218; /* Slightly brighter background for desktop */
    color: white;
}

#collection-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Desktop styles */
@media (min-width: 768px) {
    .mobile-view {
        display: none;
    }
    
    .desktop-view {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 20px;
        margin-top: 20px;
    }

    .video-card {
        background: #1a1a1a;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        cursor: pointer;
    }

    .video-container {
        position: relative;
        padding-top: 56.25%; /* 16:9 Aspect Ratio (9/16 = 0.5625 or 56.25%) */
        background: black;
    }

    .video-container video {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover; /* Default for landscape videos */
        background: black;
    }

    /* Add this new style for portrait videos */
    .video-container video.portrait {
        object-fit: contain; /* This will add letterboxing for portrait videos */
    }

    .video-info {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 15px;
        padding: 12px;
        align-items: center;
        background: #1a1a1a;
    }

    .video-index {
        font-size: 30px;
        font-weight: bold;
        color: #666;
    }

    .video-caption-container {
        font-size: 14px;
        color: #999;
        overflow-wrap: break-word;
        word-wrap: break-word;      /* Legacy property for broader browser support */
        word-break: break-all;   
        line-height: 1.4;
        max-width: 100%;  
    }

    .like-button-container {
        position: static;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        margin-left: auto;
    }

    .like-button {
        background: none;
        border: none;
        padding: 4px;
        cursor: pointer;
        transition: all 0.2s ease;
        color: #666;
    }

    .like-button:hover {
        transform: scale(1.1);
    }

    .like-button.active {
        color: #ff2d55;
    }

    .like-heart {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
    }

    .like-button.active .like-heart {
        fill: #ff2d55;
        stroke: #ff2d55;
    }

    .like-count {
        font-size: 12px;
        color: #666;
        font-weight: 500;
    }

    /* Hover effects */
    .video-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0);
        display: flex;
        justify-content: center;
        align-items: center;
        transition: background-color 0.2s ease;
    }

    .video-card:hover .video-overlay {
        background: rgba(0, 0, 0, 0.5);
    }

    .play-button {
        width: 40px;
        height: 40px;
        background: #007AFF;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .video-card:hover .play-button {
        opacity: 1;
    }

    .play-button::after {
        content: '';
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 8px 0 8px 16px;
        border-color: transparent transparent transparent white;
        margin-left: 4px;
    }

    /* Fullscreen video player */
    .fullscreen-player {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: black;
        z-index: 1000;
        display: none;
    }

    .fullscreen-player.active {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .fullscreen-video {
        max-width: 90%;
        max-height: 90vh;
    }

    .carousel-nav {
        position: absolute;
        bottom: 20px;
        left: 0;
        right: 0;
        display: flex;
        justify-content: center;
        gap: 8px;
        padding: 10px;
    }

    .carousel-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
    }

    .carousel-dot.active {
        background: white;
        transform: scale(1.2);
    }

    .video-item {
        border: 1px solid #ddd;
        padding: 10px;
        border-radius: 8px;
    }

    .video-item video {
        width: 100%;
        border-radius: 4px;
    }

    .video-item p {
        margin: 10px 0 0;
        font-size: 14px;
    }

    /* Add these styles for the like button */
    .like-button-container {
        position: absolute;
        z-index: 10;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .like-button {
        background: none;
        border: none;
        padding: 3px;
        cursor: pointer;
        transition: transform 0.2s;
        display: flex;
        flex-direction: column;
        align-items: center;
        color: white;
    }

    .like-button.active {
        color: #ff2d55;
    }

    .like-button:hover {
        transform: scale(1.1);
    }

    .like-heart {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }

    .like-count {
        font-size: 12px;
        color: white;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    }

    /* Mobile specific styles */
    @media (max-width: 767px) {
        .like-button-container {
            right: 20px;
            bottom: 40%;
        }

        .like-button {
            color: white;
        }

        .like-heart {
            width: 35px;
            height: 35px;
        }

        .like-count {
            font-size: 14px;
        }
    }

    /* Desktop specific styles */
    @media (min-width: 768px) {
        .video-info {
            /* Modify existing styles */
            justify-content: space-between;
            align-items: center;
        }

        .like-button-container {
            position: static;
            margin-left: auto;
        }

        .like-button {
            color: #666;
        }
    }

    /* Add styles for expand icon */
    .expand-icon {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 24px;
        height: 24px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.2s;
        z-index: 2;
    }

    .video-card:hover .expand-icon {
        opacity: 1;
    }

    /* Expanded view styles */
    .expanded-view {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #080810;
        z-index: 1000;
        display: none;
        padding: 40px;
    }

    .expanded-view.active {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .back-button {
        position: absolute;
        top: 20px;
        left: 20px;
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 1001;
    }

    .expanded-video-container {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative; /* Added for overlay positioning */
    }

    /* Style the expanded video */
    .expanded-video {
        max-width: 90%;
        max-height: 90vh;
        object-fit: contain;
        border-radius: 10px; /* Add rounded corners */
    }

    /* Add hover effects to expanded view */
    .expanded-video-container .video-overlay {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        height: 90vh;
        background: rgba(0, 0, 0, 0);
        display: flex;
        justify-content: center;
        align-items: center;
        transition: background-color 0.2s ease;
        border-radius: 10px; /* Match video border radius */
    }

    .expanded-video-container:hover .video-overlay {
        background: rgba(0, 0, 0, 0.5);
    }

    /* Show play button in expanded view */
    .expanded-video-container .play-button {
        width: 40px;
        height: 40px;
        background: #007AFF;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .expanded-video-container:hover .play-button {
        opacity: 1;
    }

    .expanded-video-container .play-button::after {
        content: '';
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 8px 0 8px 16px;
        border-color: transparent transparent transparent white;
        margin-left: 4px;
    }

    /* Add these styles in the desktop section (@media (min-width: 768px)) */
    .video-progress-bar {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 3px; /* Slightly taller for better touch target */
        background: rgba(255, 255, 255, 0.2);
        z-index: 10;
        cursor: pointer; /* Add pointer cursor */
        touch-action: none; /* Prevent scrolling while dragging on mobile */
    }

    .video-progress {
        height: 100%;
        width: 0;
        background: #007AFF; /* Use a bright color */
        transform-origin: left;
        transition: none;
        will-change: width;
        position: relative; /* For the handle */
    }

    /* Add hover effects */
    .video-progress-bar:hover {
        height: 5px; /* Expand on hover */
        background: rgba(255, 255, 255, 0.3);
    }

    .video-progress-bar:hover .video-progress {
        background: #0A84FF; /* Brighter blue on hover */
    }

    /* Add a handle that appears on hover or during dragging */
    .video-progress::after {
        content: '';
        position: absolute;
        right: -6px;
        top: 50%;
        transform: translateY(-50%) scale(0);
        width: 12px;
        height: 12px;
        background: #0A84FF;
        border-radius: 50%;
        transition: transform 0.2s;
    }

    .video-progress-bar:hover .video-progress::after,
    .video-progress-bar.dragging .video-progress::after {
        transform: translateY(-50%) scale(1);
    }

    /* Mobile-specific adjustments */
    @media (max-width: 767px) {
        .video-progress-bar {
            position: absolute;
            height: 10px;
            bottom: 80px;
            left: 0;
            right: 0;
            width: 100%;
            z-index: 100;
        }
        
        /* Always show the handle on mobile */
        .video-progress::after {
            transform: translateY(-50%) scale(1);
            width: 16px;
            height: 16px;
        }
    }

    /* Add in the desktop styles section (@media (min-width: 768px)) */
    .collection-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 10px 0 20px;
        padding: 0;
    }

    #creator-info {
        color: #999;
        font-size: 14px;
        padding: 0;
    }

    .download-button {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        background: #007AFF;
        border: none;
        border-radius: 20px;
        color: white;
        cursor: pointer;
        font-size: 14px;
        transition: opacity 0.2s;
    }

    .download-button:hover {
        opacity: 0.8;
    }

    /* Hide download button on mobile */
    @media (max-width: 767px) {
        .collection-info {
            display: none;
        }
    }
}

/* Mobile styles */
@media (max-width: 767px) {
    html, body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        position: fixed;
        overflow: hidden;
        background: #000000; /* Pure black for mobile */
    }
    
    #collection-container {
        margin: 0;
        padding: 0;
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        overflow: hidden;
        background: #000000; /* Pure black for mobile */
    }
    
    .desktop-view {
        display: none !important;
    }
    
    .mobile-view {
        display: block !important;
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        overflow-y: scroll;
        scroll-snap-type: y mandatory;
        -webkit-overflow-scrolling: touch;
        background: #000000; /* Pure black for mobile */
    }

    .mobile-video-card {
        width: 100vw;
        height: 100vh;
        position: relative;
        scroll-snap-align: start;
        scroll-snap-stop: always;
        background: #000000; /* Pure black for mobile */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-video-container {
        width: 100%;
        height: calc(100% - 45px);
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #000000; /* Pure black for mobile */
        transform: translateY(-62px);
    }

    .mobile-video {
        width: 100%;
        height: 100%;
        object-fit: contain;
        background: #000000;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 100vw;
        max-height: calc(100vh - 45px);
    }

    .mobile-video-info {
        position: absolute;
        bottom: 110px; /* Increased to account for new video position */
        left: 20px;
        right: 20px;
        color: white;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
        z-index: 2;
        pointer-events: none;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .mobile-video-caption {
        font-size: 16px;
        padding: 10px;
        position: absolute;
        bottom: 0;
        left: 0px;
        right: 0px;
        z-index: 100;
        width: 100%;
        height: 20px;
    }

    #collection-name {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0) - 0px);
        left: 0;
        right: 0;
        z-index: 100;
        background: linear-gradient(to bottom, rgba(0,0,0,1) 0%, transparent 100%);
        color: white;
        padding: 10px;
        margin: 0;
        text-align: center;
        font-size: 16px;
    }

    .desktop-view {
        display: none !important;
    }

    /* Add styles for video pillars */
    .mobile-video-card::before,
    .mobile-video-card::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        height: 0;
        background: black;
        z-index: 1;
    }

    .mobile-video-card::before {
        top: 0;
    }

    .mobile-video-card::after {
        bottom: 0;
    }

    /* Add these styles in the mobile section */
    .sound-button-container {
        position: absolute;
        right: 14px; /* Changed from 17px to 14px (moved 3px right) */
        bottom: calc(20% + 80px);
        z-index: 10;
    }

    .sound-button {
        background: none; /* Removed rgba background */
        border: none;
        padding: 8px;
        cursor: pointer;
        width: 48px; /* Increased from 35px to 48px */
        height: 48px; /* Increased from 35px to 48px */
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        transition: transform 0.2s;
    }

    .sound-button svg {
        width: 48px; /* Increased from 24px to 48px */
        height: 48px; /* Increased from 24px to 48px */
        fill: currentColor;
    }

    .sound-button:hover {
        transform: scale(1.1);
    }

    /* Add these styles in the mobile section (@media (max-width: 767px)) */
    .video-progress-bar {
        position: fixed;
        bottom: 37px;
        height: 6px;
        left: 0;
        right: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.3);
        z-index: 100;
        transform: translateY(100px);
    }

    .video-progress {
        background: #0A84FF;
    }

    /* Add iOS safe area support */
    @supports (padding: max(0px)) {
        .video-progress-bar {
            bottom: calc(37px + env(safe-area-inset-bottom, 0px));
        }
    }
}

/* Common elements */
#loading, #error {
    text-align: center;
    padding: 20px;
    font-size: 18px;
}

#error {
    color: #ff4444;
}

/* Add these styles for the like button */
.like-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.like-button {
    background: none;
    border: none;
    padding: 3px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.like-button.active {
    color: #ff2d55;
}

.like-button:hover {
    transform: scale(1.1);
}

.like-heart {
    fill: currentColor;
}

/* Add these styles at the top level of your CSS */
.voter-name-input {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
    width: 200px;
    text-align: center;
}

.voter-name-input::placeholder {
    color: rgba(255, 255, 255, 0.8);
}

/* Add these styles for the name modal */
.name-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.name-modal {
    background: #1a1a1a;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    box-sizing: border-box; /* Add this to prevent overflow */
}

.name-modal input {
    width: calc(100% - 24px); /* Adjust width to account for padding */
    padding: 12px;
    margin: 15px 0;
    border: none;
    border-radius: 6px;
    background: #333;
    color: white;
    font-size: 16px;
    box-sizing: border-box; /* Add this to prevent overflow */
}

.name-modal input::placeholder {
    color: #888;
}

.name-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.name-modal button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.name-modal button:hover {
    opacity: 0.8;
}

.name-modal-submit {
    background: #007AFF;
    color: white;
}

.name-modal-cancel {
    background: #333;
    color: white;
}

/* Add these styles at the root level (outside any media query) */
.like-button-container {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.like-button {
    background: none;
    border: none;
    padding: 3px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.like-heart {
    fill: currentColor;
}

.like-button.active {
    color: #ff2d55;
}

.like-button:hover {
    transform: scale(1.1);
}

/* Mobile specific styles */
@media (max-width: 767px) {
    .like-button-container {
        position: absolute;
        right: 20px;
        bottom: 20%;
        transform: none;
    }

    .like-heart {
        width: 30px;
        height: 30px;
    }

    .like-count {
        font-size: 14px;
        color: white;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    }
}

/* Desktop specific styles */
@media (min-width: 768px) {
    .like-button-container {
        position: static;
        margin-left: auto;
    }

    .like-heart {
        width: 20px;
        height: 20px;
    }

    .like-count {
        font-size: 12px;
        color: #666;
        text-shadow: none;
    }
}

/* Update the like button styles in both mobile and desktop sections */
.like-button {
    background: none;
    border: none;
    padding: 3px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.like-heart {
    fill: none;
    stroke-width: 1.5;
}

.like-button.active .like-heart {
    fill: #ff2d55;
    stroke: #ff2d55;
}

/* Mobile specific styles */
@media (max-width: 767px) {
    .like-button {
        color: white;
    }
    
    .like-heart {
        stroke: white;
    }
}

/* Desktop specific styles */
@media (min-width: 768px) {
    .like-button {
        color: #666;
    }
    
    .like-heart {
        stroke: #666;
    }
}

/* Base progress bar styles - outside any media query */
.video-progress-bar {
    position: absolute;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 100;
    cursor: pointer;
    touch-action: none;
}

.video-progress {
    height: 100%;
    width: 0;
    background: #007AFF;
    transform-origin: left;
    transition: none;
    will-change: width;
    position: relative;
}

/* Desktop specific styles */
@media (min-width: 768px) {
    .video-progress-bar {
        bottom: 0;
        height: 3px;
    }

    .video-progress-bar:hover {
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
    }

    .video-progress-bar:hover .video-progress {
        background: #0A84FF;
    }
}

/* Mobile specific styles */
@media (max-width: 767px) {
    .video-progress-bar {
        position: fixed;
        bottom: 100px;  /* Increased significantly to make it visible */
        height: 10px;
        background: rgba(255, 255, 255, 0.3);  /* Made more visible */
    }

    .video-progress {
        background: #0A84FF;  /* Brighter color for mobile */
    }
}

/* Update the like button styles */
.like-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 10;
}

.like-button {
    background: none;
    border: none;
    padding: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.like-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.like-heart {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: all 0.2s ease;
}

.like-button.active .like-heart {
    fill: #ff2d55;
    stroke: #ff2d55;
    transform: scale(1.1);
}

.like-count {
    font-size: 12px;
    font-weight: 500;
}

/* Desktop specific styles */
@media (min-width: 768px) {
    .like-button-container {
        position: static;
        margin-left: auto;
    }

    .like-button {
        color: #666;
    }

    .like-button:hover {
        transform: scale(1.1);
    }

    .like-button.active {
        color: #ff2d55;
    }

    .like-count {
        color: #666;
    }
}

