/* ==========================================================
   TIKTOK MODULE CSS - 9:16 Aspect Ratio & Mobile Strip
   ========================================================== */

/* Freeze Site Background when Lightbox is Open */
.tiktok-lightbox-open, 
.tiktok-lightbox-open body {
    overflow: hidden !important;
    height: 100vh !important;
    touch-action: none;
}

/* Section Container Styling */
.tiktok-section {
    padding: var(--space-xl) 0;
    background: var(--bg-main);
}

/* Card Styling with Locked 9:16 Ratio */
.tiktok-section .video-card {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16; /* Modern CSS Ratio */
    border-radius: var(--card-radius);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s ease;
}

.tiktok-section .video-card:hover {
    transform: scale(1.03);
    border-color: #fe2c55; /* TikTok Brand Pink */
    z-index: 10;
}

.tiktok-section .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Play Button Overlay */
.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.1);
}

.play-icon {
    width: 46px;
    height: 46px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    font-size: 1rem;
}

/* Lightbox - Background Dimmed */
.tiktok-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tiktok-lightbox.active {
    display: flex;
}

/* Updated Lightbox Box with Height Fixes */
.lightbox-box {
    position: relative;
    width: min(420px, 90vw); /* Responsive width */
    aspect-ratio: 9 / 16; /* Force ratio */
    background: #000;
    border-radius: var(--card-radius);
    box-shadow: 0 30px 60px rgba(0,0,0,0.7);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Ensure the iframe container fills the box entirely */
#tiktok-frame-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

#tiktok-frame-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.tiktok-lightbox .close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    font-size: 1.2rem;
}

/* MOBILE STRIP ADJUSTMENT */
@media (max-width: 768px) {
    .tiktok-section {
        padding: var(--space-md) 0;
    }

    /* Shrink the vertical footprint for mobile strip */
    .tiktok-section .video-card {
        max-height: 280px; 
    }

    /* Fix: Lightbox height respect screen while keeping ratio */
    .lightbox-box {
        max-height: 80vh; /* Limit to 80% of viewport height */
        width: auto;      /* Recalculate width based on height and aspect-ratio */
        aspect-ratio: 9 / 16;
    }

    .tiktok-lightbox {
        padding: 20px; 
    }
}