/* TikTok Style Feed */
html.storefront-posts-active body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Prevent body scroll if full screen */
    background: #000;
}

/* Remove padding from the tab container for posts */
html.storefront-posts-active .tab-content {
    padding: 0 !important;
}

/* Container */
.tiktok-feed-container {
    height: calc(100vh - 140px);
    /* Adjust based on header/footer height */
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    background: #000;
    position: relative;
    scrollbar-width: none;
    /* Firefox */
}

.tiktok-feed-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.tiktok-post-item {
    width: 100%;
    height: 100%;
    aspect-ratio: 3 / 4;
    scroll-snap-align: start;
    position: relative;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Media Layer */
.tiktok-media-container {
    width: 100%;
    height: 100%;
    position: relative;
    /* Changed from absolute to allow flex centering if needed, but relative usually best for contained media */
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

/* Ensure video fits within container without cropping */
.tiktok-media-container video,
.tiktok-media-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Key change: contain instead of cover */
    display: block;
    max-height: 100%;
    max-width: 100%;
}

/* Gradient Overlay - adjusted for visibility on black */
.tiktok-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 30%);
    pointer-events: none;
    z-index: 2;
}

/* Right Sidebar Actions */
.tiktok-sidebar {
    position: absolute;
    right: 10px;
    bottom: 100px;
    /* Moved up slightly to clear potential bottom nav */
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    background: transparent;
    border: none;
    padding: 0;
    text-decoration: none;
}

.action-icon {
    font-size: 28px;
    margin-bottom: 2px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    background: rgba(0, 0, 0, 0.2);
    /* Slight background for better visibility */
    backdrop-filter: blur(4px);
}

.action-btn:hover .action-icon {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.2);
}

.action-count {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.avatar-container {
    margin-bottom: 15px;
    position: relative;
}

.tiktok-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
    background: #fff;
    /* Fallback */
}

.follow-plus {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 18px;
    background: #fe2c55;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
}

/* Bottom Info */
.tiktok-info {
    position: absolute;
    bottom: 20px;
    left: 10px;
    right: 70px;
    /* Space for sidebar */
    z-index: 10;
    color: #fff;
    text-align: left;
    pointer-events: none;
}

.tiktok-info>* {
    pointer-events: auto;
}

.info-author {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-author img.store-logo-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #fff;
}

.info-caption {
    font-size: 14px;
    line-height: 1.3;
    margin-bottom: 10px;
    max-width: 100%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.info-music {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    opacity: 0.9;
}

.music-icon {
    animation: spin 3s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Liked state */
.like-btn.liked .action-icon {
    color: #fe2c55;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .tiktok-feed-container {
        height: calc(100vh - 180px);
        /* Increased subtraction to clear bottom menu */
        border-radius: 0;
    }

    .tiktok-post-item {
        border-radius: 0;
    }

    /* Move controls up on mobile to avoid bottom menu overlap */
    .tiktok-info {
        bottom: 120px;
    }

    .tiktok-sidebar {
        bottom: 240px;
    }
}

/* Desktop override to fit nicely */
@media (min-width: 1024px) {
    .tiktok-feed-container {
        height: 80vh;
        border-radius: 12px;
        margin-top: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }

    .tiktok-post-item {
        border-radius: 12px;
    }
}