/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #fef7ff 0%, #f3e8ff 50%, #fce7f3 100%);
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 5vw;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 2px solid #e9ecef;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #e879f9 0%, #c084fc 50%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

/* Category Section Styles */
.category-section {
    margin-bottom: 30px;
    padding: 15px;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.category-section:nth-child(1) {
    background: linear-gradient(135deg, #fdf2f8 0%, #f3e8ff 50%, #ede9fe 100%);
    border: 2px solid rgba(236, 72, 153, 0.1);
}

.category-section:nth-child(2) {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 50%, #f3e8ff 100%);
    border: 2px solid rgba(139, 92, 246, 0.1);
}

.category-section:nth-child(3) {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #f0f9ff 100%);
    border: 2px solid rgba(59, 130, 246, 0.1);
}

.category-header {
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.category-header h2 {
    font-size: 1.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.category-section:nth-child(1) .category-header h2 {
    background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
    color: white;
}

.category-section:nth-child(2) .category-header h2 {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
}

.category-section:nth-child(3) .category-header h2 {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

/* Video Grid Styles */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
}

/* Desktop: 3-5 thumbnails per row */
@media (min-width: 1200px) {
    .video-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 20px;
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .video-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 18px;
    }
}

@media (min-width: 600px) and (max-width: 899px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

/* Phone portrait: 2 thumbnails per row */
@media (max-width: 479px) and (orientation: portrait) {
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
}

/* Phone landscape: 4 thumbnails per row */
@media (max-width: 479px) and (orientation: landscape) {
    .video-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px;
    }
}

/* Larger phones and small tablets */
@media (min-width: 480px) and (max-width: 599px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px;
    }
}

/* Video Thumbnail Styles */
.video-thumbnail {
    background: transparent;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
}

.category-section:nth-child(1) .video-thumbnail {
    border-color: rgba(236, 72, 153, 0.2);
}

.category-section:nth-child(2) .video-thumbnail {
    border-color: rgba(139, 92, 246, 0.2);
}

.category-section:nth-child(3) .video-thumbnail {
    border-color: rgba(59, 130, 246, 0.2);
}

.video-thumbnail:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.category-section:nth-child(1) .video-thumbnail:hover {
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.3);
    border-color: rgba(236, 72, 153, 0.4);
}

.category-section:nth-child(2) .video-thumbnail:hover {
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.4);
}

.category-section:nth-child(3) .video-thumbnail:hover {
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.4);
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
    opacity: 0;
    z-index: 4;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.video-preview-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-thumbnail:hover .video-placeholder {
    opacity: 0;
}

.play-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    z-index: 3;
    transition: all 0.3s ease;
}

.video-thumbnail:hover .play-overlay {
    opacity: 0;
}

.video-info {
    padding: 0;
    margin: 0;
    background: transparent;
    position: relative;
    display: block;
    height: 100%;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.video-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.1;
    padding: 6px 4px;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

.video-info p {
    font-size: 0.8rem;
    line-height: 1.15;
    padding: 6px 4px;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

/* Pink theme for Homeschool */
.category-section:nth-child(1) .video-info h3 {
    background: #fce7f3;
    color: #be185d;
    margin: 0 -12px;
    width: calc(100% + 24px);
    display: block;
    padding: 6px 14px 2px 14px;
    line-height: 1.1;
}

.category-section:nth-child(1) .video-info p {
    background: #f3e8ff;
    color: #7c2d92;
    margin: 0 -12px;
    width: calc(100% + 24px);
    display: block;
    padding: 4px 14px 6px 14px;
    line-height: 1.15;
}

/* Purple theme for Fun */
.category-section:nth-child(2) .video-info h3 {
    background: #e0e7ff;
    color: #6d28d9;
    margin: 0 -12px;
    width: calc(100% + 24px);
    display: block;
    padding: 6px 14px 2px 14px;
    line-height: 1.1;
}

.category-section:nth-child(2) .video-info p {
    background: #ede9fe;
    color: #5b21b6;
    margin: 0 -12px;
    width: calc(100% + 24px);
    display: block;
    padding: 4px 14px 6px 14px;
    line-height: 1.15;
}

/* Pastel Blue theme for Misc */
.category-section:nth-child(3) .video-info h3 {
    background: #dbeafe;
    color: #1d4ed8;
    margin: 0 -12px;
    width: calc(100% + 24px);
    display: block;
    padding: 6px 14px 2px 14px;
    line-height: 1.1;
}

.category-section:nth-child(3) .video-info p {
    background: #eff6ff;
    color: #1e40af;
    margin: 0 -12px;
    width: calc(100% + 24px);
    display: block;
    padding: 4px 14px 6px 14px;
    line-height: 1.15;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    margin: 5% auto;
    width: 90%;
    max-width: 1200px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.8);
}

#modal-video {
    width: 100%;
    height: auto;
    max-height: 80vh;
    background: #000;
    object-fit: contain;
}

.youtube-thumbnail {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal .video-info {
    padding: 25px;
    background: white;
}

.modal .video-info h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.modal .video-info p {
    font-size: 1rem;
    color: #495057;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --thumbnail-size: 125px;
    }
    
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .category-header h2 {
        font-size: 1.4rem;
    }
    
    .video-grid {
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    }
    
    .video-info h3 {
        font-size: 0.85rem;
        line-height: 1.05;
        padding: 4px 2px 1px 2px;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        display: block;
    }
    
    .video-info p {
        font-size: 0.7rem;
        line-height: 1.1;
        padding: 3px 2px 4px 2px;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        display: block;
    }
}
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .video-info {
        padding: 15px;
    }
    
    .modal .video-info {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    :root {
        --thumbnail-size: 100px;
    }
    
    .container {
        padding: 10px;
    }
    
    header {
        margin-bottom: 30px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .category-header h2 {
        font-size: 1.2rem;
    }
    
    .video-grid {
        gap: 8px;
        grid-template-columns: repeat(3, 1fr);
    }
    
    .play-overlay {
        width: 20px;
        height: 20px;
        font-size: 8px;
        bottom: 4px;
        right: 4px;
    }
    
    .video-info h3 {
        font-size: 0.75rem;
        line-height: 1.0;
        padding: 3px 1px 1px 1px;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        display: block;
    }
    
    .video-info p {
        font-size: 0.65rem;
        line-height: 1.05;
        padding: 2px 1px 3px 1px;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        display: block;
    }
}
    
    .close-button {
        width: 40px;
        height: 40px;
        font-size: 30px;
        top: 10px;
        right: 15px;
    }
}

/* Large Desktop Optimization */
@media (min-width: 1200px) {
    :root {
        --thumbnail-size: 160px;
    }
    
    .video-grid {
        gap: 18px;
    }
}

/* Loading State */
.video-thumbnail.loading {
    opacity: 0.7;
    pointer-events: none;
}

.video-thumbnail.loading .video-placeholder::after {
    content: "Loading...";
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    opacity: 0.8;
}
