/**
 * Video styles - grid, cards, player, upload form
 */

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 24px;
}

.video-card {
    display: block;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    text-decoration: none;
    color: inherit;
}

/* Wrapper that also holds the "Download MP3" button so the card itself can
   stay a single link (nested links/buttons are not valid HTML). */
.video-card-wrap {
    position: relative;
}

.card-download {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-normal);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.card-download:hover,
.card-download:focus-visible {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.video-card:hover {
    border-color: var(--accent-red);
}

/* Lift the card only on devices that actually hover (avoids sticky hover). */
@media (hover: hover) {
    .video-card:hover {
        transform: translateY(-4px);
    }
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.thumbnail-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    color: var(--text-secondary);
    opacity: 0.4;
}

/* Sits against the left edge rather than dead centre: a circle in the middle
   of the frame covers the part of the image people actually look at. */
.play-icon {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

/* Small screens have no room for a centred circle without hiding the frame. */
@media (max-width: 480px) {
    .play-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
        left: 8px;
    }
}

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

/* Touch devices never fire hover, so leaving the overlay at opacity 1 made it
   sit permanently on top of the thumbnail and hide it. Hide it there instead:
   on a phone or tablet the whole card is already a single tap target. */
@media (hover: none) {
    .play-icon {
        display: none;
    }
}

.video-info {
    padding: 16px;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Video Player Page */
.video-player-container {
    max-width: 1000px;
    margin: 0 auto;
}

.video-player {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.video-player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-details {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.video-details h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 16px;
}

.video-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.video-stats-left {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.video-actions {
    display: flex;
    gap: 8px;
}

.vote-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
}

.vote-btn:hover {
    background: var(--border-color);
}

.vote-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.video-channel {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.channel-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-red-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
}

.channel-name {
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.channel-name:hover {
    color: var(--accent-red);
}

.video-description {
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
}

/* Upload Form */
.upload-container {
    max-width: 600px;
    margin: 40px auto;
}

.upload-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 40px;
    border: 1px solid var(--border-color);
}

.upload-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 32px;
    text-align: center;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.file-input-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    transition: all var(--transition-normal);
    cursor: pointer;
    color: var(--text-secondary);
}

.file-input-wrapper:hover {
    border-color: var(--accent-red);
}

.file-icon {
    font-size: 2.5rem;
}

.file-name {
    color: var(--accent-red);
    font-weight: 500;
}


/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin: 0 0 8px;
    color: var(--text-primary);
}

.empty-state p {
    margin: 0;
}

/* Video owner actions */
.video-owner-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.delete-btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-normal);
    background: transparent;
    color: var(--error-red);
    border: 1px solid var(--error-red);
}

.delete-btn:hover {
    background: rgba(231, 76, 60, 0.15);
}

/* Channel page */
.channel-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.channel-header-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-red-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
}

.channel-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* ------------------------------------------------------------------ */
/* Edit form                                                           */
/* ------------------------------------------------------------------ */

.edit-current-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.edit-current-thumb img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--radius-medium, 8px);
    background: #000;
}

.edit-current-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-check {
    margin: 4px 0 16px;
}

.form-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-help {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.edit-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ------------------------------------------------------------------ */
/* Responsive (tablet and phones)                                     */
/* ------------------------------------------------------------------ */

@media (max-width: 768px) {
    .video-grid {
        gap: 16px;
    }

    .card-download {
        min-height: 40px;
        padding: 8px 12px;
    }

    .video-info {
        padding: 12px;
    }

    .video-details {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .video-details h1 {
        font-size: 1.25rem;
        margin-bottom: 12px;
    }

    .video-stats {
        gap: 12px;
    }

    .vote-btn {
        min-height: 44px;
    }

    .upload-container {
        margin: 16px auto;
    }

    .upload-card {
        padding: 24px 20px;
    }

    .upload-card h1 {
        font-size: 1.25rem;
        margin-bottom: 24px;
    }

    .file-input-wrapper {
        padding: 24px 16px;
    }

    .channel-header {
        padding: 16px;
        gap: 16px;
    }

    .channel-header-avatar {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }

    .channel-header h1 {
        font-size: 1.25rem;
    }

    .empty-state {
        padding: 48px 16px;
    }
}

@media (max-width: 480px) {
    .video-details {
        padding: 14px;
    }

    .upload-card {
        padding: 20px 16px;
    }

    .file-input-wrapper {
        padding: 20px 12px;
    }

    .video-owner-actions {
        flex-wrap: wrap;
    }

    .channel-header {
        flex-direction: column;
        text-align: center;
    }
}
