/* Video Grid Container - CSS Grid */
.video-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
    gap: 32px;
    padding: 10px 0;
}

/* Shared Video Section Styles */
.home-video-section {
    border-bottom: 1px solid var(--section-border-color);
}

.home-video-section h3 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.2rem;
    color: var(--section-title-color);
    padding-bottom: 15px;
}

.video-card {
    flex: 0 0 460px;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: flex-basis 0.3s ease, box-shadow 0.3s ease;
    z-index: 1;
    position: relative;
    /* Card Style */
    background-color: var(--bg-secondary-color, #fff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Subtle grey border */
    /* Subtle shadow */
}

.video-card:hover {
    transform: translateY(-2px);
    z-index: 10;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    /* Enhanced shadow on hover */
}

/* Playing State - Expanded (PC Default) */
.video-card.playing {
    /* Calculated to leave space for 340px Ad Slot + 32px Gap */
    /* 100% - (340px + 32px) = 100% - 372px */
    flex: 0 0 calc(100% - 375px) !important;
    z-index: 100 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    background-color: transparent !important;
    /* Remove background to blend */
    border: none !important;

    /* Constraint for Ultra-wide screens: 
       Limit width so height doesn't exceed viewport.
       16:9 ratio -> Height = Width * 0.5625
       If Max Height = 72vh, Max Width = 72 / 0.5625 = 128vh.
       Let's use 128vh to be safer and ensure bottom isn't cut off. */
    max-width: 128vh;
}

/* Ensure Ad Slot stays next to the playing video and aligns to center */
.video-card.playing+.inline-grid-ad-container {
    align-self: center;
    /* Center verticaly in the row */
}

/* ===== Player Row (Inline, inserted below clicked card's row) ===== */
.player-row {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    animation: slideDown 0.3s ease-out forwards;
    box-sizing: border-box;
    width: 100%;
    position: relative;
    align-items: flex-end;
}

.player-row-video {
    /* 기본: 영상이 전체 너비, 광고는 아래 */
    width: 100%;
    max-height: 80vh;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

/* 1280px media query removed to force full width */

.player-row-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none;
    display: block;
}

.player-row-ad {

    .home-video-section h3 {
        padding-left: 12px;
    }
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
    /* border-radius removed, handled by card overflow */
    background-color: #000;
    line-height: 0;
}

.video-thumbnail iframe,
.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-info {
    display: flex;
    flex-direction: column;
    padding: 6px 20px;
    /* Reduced vertical padding */
    background-color: var(--bg-secondary-color, #fff);
    /* Match card background */
    cursor: pointer;
}

/* Dark mode adjustment for card background */
html body.dark-mode .video-card {
    background-color: #1e1e1e;
    /* Dark card background */
    border: 1px solid #333;
    /* Subtle grey border for dark mode */
}

html body.dark-mode .video-info {
    background-color: #1e1e1e;
    /* Dark info background */
    border-top: none;
    /* No extra border for info part */
}

.video-title {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-color);
    margin: 0 0 2px 0;
    /* Reduced margin */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    /* Changed to 1 line */
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4rem;
    height: 1.4rem;
    /* Fixed height for 1 line */
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
    text-align: center;
    /* Center align */
}

.video-card:hover .video-title {
    color: var(--primary-color, #4a90e2);
}

.video-meta {
    font-size: 0.85rem;
    color: var(--text-secondary-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    line-height: 1.4;
}

.video-meta .channel-name {
    margin-right: 4px;
    font-weight: 500;
}

.video-meta .channel-name:hover {
    color: var(--text-color);
}

.video-meta .separator {
    margin: 0 4px;
}

html body.dark-mode .video-title {
    color: #f1f1f1;
}

html body.dark-mode .video-meta {
    color: #aaaaaa;
}

html body.dark-mode .video-meta .channel-name:hover {
    color: #fff;
}

.share-buttons {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

.btn-share {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.btn-share:hover {
    background-color: #f8f9fa;
    border-color: #bbb;
    color: #333;
}

.btn-share i {
    font-size: 0.8rem;
}

.video-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.video-delete-btn:hover {
    opacity: 1;
    background-color: #dc3545;
    transform: scale(1.1);
}

.video-delete-btn:active {
    transform: scale(0.95);
}

.video-delete-btn.deleting {
    background-color: #6c757d;
    pointer-events: none;
}

.video-delete-btn.deleting i::before {
    content: "\f110";
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.video-card.deleting {
    opacity: 0.5;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

.video-card.deleted {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.8);
        height: 0;
        margin: 0;
        padding: 0;
    }
}

/* ===== Ad Slot (Standalone) ===== */
.inline-grid-ad-container {
    display: none;
    /* Initially hidden */
    flex: 0 0 460px;
    max-width: 100%;
    box-sizing: border-box;
    /* Ensure height is reserved when visible */
    min-height: 258px;
    transition: all 0.3s ease;
}

.inline-grid-ad-container.visible-ad {
    display: flex !important;
    /* Force visible */
    opacity: 1 !important;
    flex-direction: column;
    /* Slide Up Animation */
    animation: slideUp 0.5s ease-out forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* PC Specific Layout for Ad Slot */
/* Layout Tier 2: Intermediate (481px - 972px) - Grid 300px, max 2 columns */
@media (min-width: 481px) and (max-width: 972px) {
    .video-grid-container {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        grid-auto-flow: dense;
        gap: 20px;
        padding-bottom: 50px;
    }

    .video-card {
        grid-column: auto;
        flex: unset;
        width: 100%;
        margin: 0;
    }
}

/* Layout Tier 3: Desktop (973px+) - Fluid Grid */
@media (min-width: 973px) {

    /* Grid Layout - Fluid Columns */
    .video-grid-container {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
        gap: 32px;
        grid-auto-flow: dense;
        padding-bottom: 50px;
    }

    .video-card {
        grid-column: auto;
        flex: unset;
        width: 100%;
        margin: 0;
    }
}

.inline-grid-ad {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
    /* Ensure it fills container */
    flex: 1;
}

.inline-grid-ad .ad-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 3px;
    position: absolute;
    top: 8px;
    right: 10px;
}

.inline-grid-ad .ad-placeholder-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.15);
    text-align: center;
}

/* Responsive for Ad Slot */
@media (max-width: 900px) {
    .inline-grid-ad-container {
        flex: 0 0 calc(50% - 12px);
        min-height: auto;
        aspect-ratio: 16/9;
        display: none;
        /* Hide on mobile initially unless visible-ad */
    }

    .inline-grid-ad-container.visible-ad {
        display: flex !important;
        flex: 0 0 100% !important;
        /* Full width on tablet/mobile when visible */
    }

    .inline-grid-ad {
        display: flex;
    }

    /* Ensure inner content is flex */
}

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

    .inline-grid-ad-container {
        flex: 0 0 100%;
    }

    .inline-grid-ad-container.visible-ad {
        flex: 0 0 100% !important;
    }
}

/* Make Video Cards 100% full width on mobile (overriding content-container padding) */
@media (max-width: 768px) {
    .video-grid-container {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        gap: 0;
        /* Remove gap so cards stack directly if needed, or keep minimal gap */
    }

    .video-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        margin-bottom: 15px;
    }

    html body.dark-mode .video-card {
        border-left: none;
        border-right: none;
        border-radius: 0;
        border-color: #333;
    }
}

/* Play Button Overlay */
.play-button-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 34px;
    background-color: rgba(33, 33, 33, 0.6);
    /* YouTube color */
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 5;
}

.play-button-overlay:hover {
    background-color: #f00;
    /* YouTube Red on hover */
}

/* Play Triangle */
.play-button-overlay::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    margin-left: 4px;
    /* Optical centering */
    border-left: 14px solid white;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* ==========================================================================
   Load More Button - Sophisticated Gradient Style (Solid Version)
   ========================================================================== */
.load-more-container {
    text-align: center;
    margin: 40px 0 20px 0;
    display: flex;
    justify-content: center;
    position: relative;
}

.load-more-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 40px;

    /* Modern Glass/Outline Appearance */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-color, #eee);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    font-family: var(--font-family-base);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1;
    overflow: hidden;
    box-shadow: none;
}

/* Hover State */
.load-more-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.load-more-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Dark Mode Support */
html body.dark-mode .load-more-btn {
    background: rgba(255, 255, 255, 0.03);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

html body.dark-mode .load-more-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Spinner */
.load-more-spinner span {
    border-color: currentColor !important;
    border-top-color: transparent !important;
}

/* Cooldown Text - Ensure readability */
.load-more-cooldown {
    font-size: 0.85rem;
    font-weight: 400;
    color: inherit;
    margin-left: 5px;
}