/* css/feed.css */

/* Category Pills */
.category-pills {
    position: fixed;
    top: 60px; /* Below the header */
    left: 0;
    right: 0;
    background-color: var(--header-bg);
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto; /* Allow horizontal scrolling on mobile */
    z-index: 900; /* Below header, above feed */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.category-pills::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, and Opera */
}
.category-pill {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--input-border);
    background-color: var(--surface-color);
    color: var(--text-color-secondary);
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap; /* Prevent wrapping */
    transition: background-color 0.2s ease, color 0.2s ease;
}
.category-pill.active, .category-pill:hover {
    background-color: var(--primary-color);
    color: var(--button-text-color);
    border-color: var(--primary-color);
}

.feed {
    margin-top: 125px; /* Offset for header (60px) + category pills (approx 65px) */
    height: calc(100vh - 125px); /* Adjust height to fill remaining space */
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    scroll-behavior: smooth;
    background-color: var(--background-color); /* Ensure feed background matches theme */
    box-sizing: border-box; /* Important for height calculation with padding/border */
}

/* OLD .reel styles - will be replaced or modified by .reel-tiktok-style */
/*
.reel {
    scroll-snap-align: start;
    height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
*/

/* NEW Styles for TikTok-like layout */
.reel-tiktok-style {
    scroll-snap-align: start;
    height: 100vh; /* Full height for snapping */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center video viewport and meta horizontally */
    justify-content: center; /* Center content vertically within the reel snap area */
    position: relative; /* For nav arrows */
    padding: 10px 0; /* Some padding for top/bottom */
    box-sizing: border-box;
}

.video-viewport-tiktok {
    position: relative; /* For absolute positioning of icons, indicator, and nav arrows */
    width: var(--tiktok-viewport-width, 360px); /* Default width, see :root in style.css */
    height: var(--tiktok-viewport-height, calc(var(--tiktok-viewport-width) * 16 / 9)); /* Maintain 9:16 aspect ratio */
    
    /* Ensure it doesn't overflow screen */
    max-width: 95vw; 
    max-height: 75vh; /* Adjust this to leave space for meta below */

    background-color: #000; /* Black background for letter/pillar-boxing if video aspect ratio differs */
    border-radius: 12px; /* Optional: rounded corners for the viewport */
    overflow: hidden; /* Clip video to viewport */
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    margin-bottom: 15px; /* Space between video viewport and meta details */
}

/* Ensure video fills the new viewport */
.video-viewport-tiktok video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed from cover to contain to prevent cropping */
    display: block; /* Remove extra space below video if any */
}

.overlay {
    /* This class might be deprecated or repurposed if meta and icons are fully handled by new structure */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    /* This overlay might not be needed if icons and meta are positioned differently */
    /* display: none; */ /* If completely replacing its role */
}

.meta {
    pointer-events: auto;
    /* Styles for old .meta, will be superseded by .meta-tiktok-style */
}

/* Icons positioning - OLD .icons styles might be partially reused or overridden */
.icons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 24px;
    pointer-events: auto;
    align-items: center;
    /* These styles are for the old layout. New styles for .video-viewport-tiktok .icons are below */
}

/* NEW Icons positioning for TikTok style */
.video-viewport-tiktok .icons {
    position: absolute;
    bottom: 20px;
    right: 10px; /* Position to the right side of the video viewport */
    display: flex;
    flex-direction: column;
    gap: 22px; /* Increased gap for TikTok feel */
    font-size: 28px; /* Slightly larger icons */
    align-items: center; /* Center icons if they have text below */
    z-index: 20; /* Above video */
}

.icons i {
    cursor: pointer;
    transition: transform 0.2s ease;
    }
    .icons i:hover:not(.liked) { /* Don't apply hover effect if already liked and animated */
        opacity: 0.8;
        transform: scale(1.1);
}

/* Like and Share icons should always be white */
.video-viewport-tiktok .icons .ri-heart-line, /* Default like icon */
.video-viewport-tiktok .icons .ri-share-forward-line { /* Share icon */
    color: #fff !important; 
    text-shadow: 0 0 5px rgba(0,0,0,0.4); /* Slight shadow for better visibility on varied video content */
}

.icons i.liked {
    color: var(--accent-color);
    animation: pop 0.3s ease;
    text-shadow: none; /* Liked icon might not need a shadow if color is vibrant */
}
/* Ensure the liked heart icon also has a shadow if needed, or specific color */
.video-viewport-tiktok .icons i.liked {
    /* color: var(--accent-color); /* This is already set */
    /* text-shadow: 0 0 5px rgba(0,0,0,0.4); /* Optional: add shadow to liked icon too */
    /* No change needed here if accent color is distinct enough */
}


@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.engagement {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 4px;
    font-weight: 500;
}

/* Theme-aware engagement text color */
.video-viewport-tiktok .icons .engagement {
    color: #fff; /* Changed to always be white */
    text-shadow: 0 0 3px rgba(0,0,0,0.3);
}

.username {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
    color: var(--text-color); /* Ensure username color adapts to theme */
}
.username.clickable-username {
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.username.clickable-username:hover,
.username.clickable-username:focus {
    opacity: 0.7;
    text-decoration: underline;
}

.one-liner-bio {
    font-size: 0.85em;
    margin-bottom: 8px;
    color: var(--text-color-secondary); /* Ensure one-liner bio color adapts to theme */
    opacity: 0.85;
}

/* Styles for uploader info in meta section */
.uploader-info {
    display: flex;
    align-items: center;
    margin-bottom: 5px; /* Space between uploader info and one-liner/caption */
}
.uploader-avatar-meta {
    width: 32px;   /* Adjust size as needed */
    height: 32px;  /* Adjust size as needed */
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px; /* Space between avatar and username */
    border: 1px solid var(--input-border); /* Optional border */
}

/* NEW Meta details styling (below video viewport) */
.meta-tiktok-style {
    width: var(--tiktok-viewport-width, 360px); /* Match viewport width */
    max-width: 95vw; /* Ensure it doesn't overflow on small screens */
    padding: 0 10px; /* Padding for the text content */
    box-sizing: border-box;
    color: var(--text-color); /* Adapts to theme */
}

.meta-tiktok-style .username {
    font-weight: bold;
    font-size: 1.05em; /* Slightly larger username */
    margin-bottom: 5px;
}
.meta-tiktok-style .username.clickable-username:hover,
.meta-tiktok-style .username.clickable-username:focus {
  opacity: 0.8; /* Simpler hover effect */
}

.meta-tiktok-style .one-liner-bio {
  font-size: 0.9em;
  color: var(--text-color-secondary); /* Use secondary text color */
  margin-bottom: 6px;
  opacity: 0.9;
}

.video-timestamp {
    font-size: 0.8em;
    color: var(--text-color-secondary);
    margin-left: 8px; /* Space from username */
}

/* Styles for categories displayed on the video reel */
.video-categories {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Space between tags */
}

.video-category-tag {
    background-color: var(--primary-color); /* Use primary color for tags */
    color: var(--button-text-color); /* White text on primary color */
    padding: 4px 10px;
    border-radius: 15px; /* Rounded corners for pill shape */
    font-size: 0.75em; /* Smaller font size */
    font-weight: 600;
}

.caption {
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
    color: var(--text-color); /* Ensure caption color adapts to theme */
    /* Allow for multiple lines */
    white-space: pre-wrap; /* Preserves whitespace and newlines */
    word-break: break-word; /* Prevents long words from overflowing */
}

/* Skeleton Loader for Reels */
.reel-skeleton {
    scroll-snap-align: start;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--skeleton-bg);
    position: relative; /* For overlay */
}

.skeleton-video {
    width: 100%;
    height: 100%;
    background-color: var(--skeleton-item-bg);
}

.skeleton-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.skeleton-meta {
    width: 70%;
}

.skeleton-line {
    height: 1em;
    background-color: var(--skeleton-item-bg-lighter);
    margin-bottom: 10px;
    border-radius: 4px;
}

.skeleton-line.short {
    width: 60%;
    height: 0.8em;
}

.skeleton-icons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.skeleton-icon {
    width: 24px;
    height: 24px;
    background-color: var(--skeleton-item-bg-lighter);
    border-radius: 50%;
}

/* Play/Pause Click Indicator */
/* Ensure indicator is positioned within the video viewport */
.video-viewport-tiktok .play-pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8); /* Initial small scale */
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    opacity: 0;
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    pointer-events: none; /* So it doesn't interfere with video click */
    z-index: 10;
}

.play-pause-indicator.show-indicator {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1); /* Scale to full size */
}


/* Feed Load Error Message */
.feed-error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh; /* Take up most of the viewport height */
    text-align: center;
    color: var(--text-color-secondary);
    padding: 20px;
}

.feed-error-container i {
    font-size: 3em; /* Large icon */
    margin-bottom: 15px;
    color: var(--error-color); /* Use a distinct error color */
}

.feed-error-container p {
    font-size: 1.1em;
    margin-bottom: 20px;
}

.feed-error-container button {
    padding: 10px 20px;
    font-size: 1em;
    color: var(--button-text-color);
    background-color: var(--accent-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.feed-error-container button:hover {
    background-color: var(--accent-color-darker);
}


/* Navigation Arrows */
.reel-tiktok-style .nav-arrow { /* Arrows are direct children of the reel */
    position: absolute;
    z-index: 30; /* Ensure they are above other reel content if necessary */
    background-color: rgba(0, 0, 0, 0.45); /* Slightly more visible */
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px; /* Slightly smaller arrows */
    height: 36px; /* Slightly smaller arrows */
    /* Center vertically */
    top: 50%;
    transform: translateY(-50%);
    right: 15px; /* Position on the right side of the reel */
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.reel-tiktok-style .nav-arrow:hover {
    background-color: rgba(0, 0, 0, 0.65);
}
.reel-tiktok-style .nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}
/* Adjust vertical position relative to the center */
.reel-tiktok-style .nav-arrow-up {
    margin-top: -25px; /* Move up from the center */
}
.reel-tiktok-style .nav-arrow-down {
    margin-top: 25px; /* Move down from the center */
}

/* Volume Toggle Icon Style */
.video-volume-toggle {
    position: absolute;
    bottom: 15px; /* Position at the bottom of the video viewport */
    left: 15px;   /* Position at the left of the video viewport */
    font-size: 24px; /* Adjust size as needed */
    color: #fff;    /* White icon */
    background-color: rgba(0, 0, 0, 0.3); /* Slight background for visibility */
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 25; /* Above video, below other icons if they overlap */
    transition: background-color 0.2s ease;
}
.video-volume-toggle:hover {
    background-color: rgba(0, 0, 0, 0.5);
}
