
/* Comment drawer (hidden by default) */
#comment-panel {
    position: fixed;
    bottom: -100%;
    right: 0;
    width: 30%;
    height: 55%;
    background: var(--pop-window-background);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    transition: bottom 0.3s ease;
    z-index: 1001;
    padding: 12px;
    color: var(--ink-black);
    overflow-y: auto;  

    display: flex;
    flex-direction: column;
    overflow: visible; /* allow absolute children to be visible */
}


#comment-panel.visible {
    bottom: 0;
}

#comment-header {
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    margin-bottom: 10px;
}

#comment-list {
    flex: 1;
    overflow-y: auto;
}

.comment-item {
    position: relative;       /* added for options positioning */
    display: flex;
    align-items: flex-start;  /* keep your layout */
    margin-bottom: 12px;
}

.comment-item img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin-right: 10px;
}

.comment-options {
    position: absolute;       /* position relative to comment-item */
    top: 0;
    right: 0;
    display: none;            /* JS will toggle this */
    background: var(--pop-window-background);
    /* border: 1px solid var(--paper); */
    border-radius: 8px;
    padding: 4px 8px;
    z-index: 101;
    font-size: 14px;
    white-space: nowrap;
}

.comment-options button {
    all: unset;
    cursor: pointer;
    margin-left: 5px;
    padding: 2px 6px;
    border-radius: 6px;
    background-color: var(--blue);
    color: var(--white);
    font-size: 13px;
}

.comment-options button:hover {
    background-color: var(--red-seal);
}

#comment-input-container {
    display: flex;
    border-top: 1px solid var(--paper);
    padding-top: 10px;
}

#comment-input {
    flex: 1;
    padding: 8px;
    border-radius: 15px;
    border: none;
    outline: none;
}

#send-comment{
    all:unset;
    padding:2px 15px 2px 15px;
    margin-left: 5px;
    margin-right: 5px;
    color: var(--white);
    background-color: var(--blue);
    font-size: 25px;
    font-weight:normal; 
    border-radius: 10px;
    cursor: pointer;
}

#send-comment:hover{
    transform: scale(1.1);
}


#close-comments{
    all:unset;
    padding:2px 8px 2px 8px;
    margin-left: 5px;
    margin-right: 5px;
    color: var(--white);
    /* border:1px solid var(--blue); */
    background-color: var(--blue);
    font-weight:normal; 
    border-radius: 10px;
    cursor: pointer;
}

#close-comments:hover{
    background-color: var(--red-seal);
}

#comment-btn
{
    /* border: solid 2px var(--paper);  */
    background-color: var(--blue); 
}



/* Caption drawer (hidden by default) */
#caption-panel {
    position: fixed;
    bottom: -100%;
    right: 0;
    width: 30%;
    height: 50%;
    background: var(--pop-window-background);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    transition: bottom 0.3s ease;
    z-index: 999;
    padding: 12px;
    color: var(--ink-black);

    overflow-y: auto;   /* enables vertical scrolling inside the panel */

    display: flex;
    flex-direction: column;
}


#caption-panel.visible {
    bottom: var(--mobile-nav-height);
}

#caption-header {
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    margin-bottom: 10px;
}

#caption-list {
    flex: 1;
    overflow-y: auto;
}

.caption-item {
    background-color: var(--pop-window-background);
    font-weight: normal;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.analysis-caption {
    background-color: var(--pop-window-background);
    font-weight: normal;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.analysis-caption button {
    all:unset;
    padding: 2px 8px;
    cursor: pointer;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    background:transparent;
    border-radius: 10px;
    transition: transform 0.2s ease; /* smooth scaling */
}

.analysis-caption button:hover {
    transform: scale(1.1);
}

.active-caption{
    border: solid 2px var(--blue);
}

#close-captions{
    all:unset;
    padding:2px 8px 2px 8px;
    margin-left: 5px;
    margin-right: 5px;
    color: var(--white);
    /* border:1px solid var(--blue); */
    background-color: var(--ink-black);
    font-weight:normal; 
    border-radius: 10px;
    cursor: pointer;
}

#close-captions:hover{
    background-color: var(--red-seal);
}

#caption-btn
{
    /* border: solid 2px var(--paper); */
    background-color: var(--ink-black);
}



#prev-btn:hover, #next-btn:hover, #comment-btn:hover, #caption-btn:hover{
    transform: scale(1.1);
}

.action-btn.active {
    /* border: solid 2px var(--paper); */
    transform: scale(1.0);
    background-color: var(--red-seal);
    transition: 0.2s ease;
}

#save-btn.active {
    /* border: solid 2px var(--paper); */
    transform: scale(1.0);
    background-color: var(--qing);
    transition: 0.2s ease;
}

/* #save-btn.liked {
    transform: scale(1.1);
    background-color: var(--qing);
    transition: transform 0.2s ease, background-color 0.2s ease;
} */

#save-btn.pop {
    animation: pop-heart 0.4s forwards;
}

/* Heart pop animation */
#like-btn.liked {
    transform: scale(1.1);
    background-color: var(--yellow);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

#like-btn.pop {
    animation: pop-heart 0.4s forwards;
}

.like-btn.active {
    transform: scale(1.0);
    background-color: var(--red-seal);
    transition: 0.2s ease;
}

#like-controls
{
    display: flex;
    gap: 2px;
    flex-direction: column;
}
#like-num{
    all: unset;
    font-size: 12px;
    width: 100%;
    text-align: center;
}

#video-feed {
    position: relative;
    width: 100%;
    height: var(--vh);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--page-background-color);
    overflow: hidden;
}

/* ================================
   Video wrapper (common)
================================ */
#video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ================================
   Video slide base
================================ */
.video-slide {
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.video-slide.show {
    opacity: 1;
    z-index: 1;
}



/* ================================
   Actual video element
================================ */
.feed-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ================================
   Video info bottom-left
================================ */
.video-info {
    position: absolute;
    top: 10px;           /* move to top */
    left: 10px;          /* stay on the left */
    color: var(--white);
    text-shadow: 0 2px 4px var(--profile-avatar-overlay);
    z-index: 5;          /* make sure it's above the video */
}

/* ================================
   Right-side floating buttons
================================ */
#right-controls {
    position: absolute;
    right: 10px;
    top: 40%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
}

.action-btn {
    border: none;
    /* border: solid 2px var(--paper); */
    width: 50px;
    height: 50px;
    background: var(--ink-black);
    /* border: 1px solid var(--paper); */
    color: var(--background-color);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
}

.video-caption {
    /* border: 2px solid var(--input-border); */
    position: absolute;
    bottom: var(--mobile-nav-height);
    margin-bottom: var(--mobile-nav-height);
    background-color: var(--text-color);
    left: 10px;
    right: 10px;
    color: var(--white);
    padding: 5px 10px;
    border-radius: 8px;
    z-index: 4;

    /* Fixed height */
    /*height: 30px;*/       /* adjust as needed */
    min-height: 30px;
    max-height: 60px;

    /* Allow scrolling if content exceeds height */
    overflow-y: auto;
}

.video-caption p {
    margin: 0;
    line-height: 1.2;
    padding: 5px 10px;
    border-radius: 5px;
    text-align: center;
    /* font-weight: bold; */
    display: none; /* hide initially */
}

.video-caption p.active {
    display: block;
}

#video-stack {
    display: none; /* hidden by default (desktop) */
}

#feed-tabs {
    position: absolute; /* absolute inside video-feed */
    top: 12px;           /* adjust vertical spacing */
    left: 50%;           /* move the left edge to the middle */
    transform: translateX(-50%); /* truly center the element */
    display: flex;
    gap: 24px;           /* spacing between tab buttons */
    z-index: 10;
}

.feed-tab {
    background: none;
    border: none;
    color: var(--light-ink-glass);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    padding-bottom: 6px;
}

.feed-tab.active {
    color: var(--white);
    font-weight: bold;
    /* border-bottom: 2px solid var(--white); */
}

/* ================================
   DESKTOP (min-width: 768px)
================================ */
@media (min-width: 768px) {

    .feed-tab {
        color: var(--light-ink);
    }

    .feed-tab.active {
        color: var(--text-color);
        border-bottom: 2px solid var(--text-color);
    }


    .caption-item, .analysis-caption {
        background-color: var(--paper);
    }
    .active-caption {
        border: solid 2px var(--blue);
    }

    .video-caption {
        border: 1px solid var(--input-border);
        background-color: transparent;
        margin-bottom: 0;
        position: absolute;
        bottom: 10px;
        left: 10px;
        right: 10px;
        color: var(--text-color);
        padding: 5px 10px;
        border-radius: 8px;
        z-index: 4;
    }

    #video-wrapper {
        height: 60vh;              /* height-driven scaling */
        width: auto;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        aspect-ratio: 16 / 9;
    }

    /* DESKTOP: absolute positioning for fade transitions */
    .video-slide {
        position: absolute;
        top: 30%;
        left: 50%;
        transform: translate(-50%, -50%);   /* <-- THIS centers the video */
        width: 100%;
        height: 100%;
        display: flex;                      /* <-- allows child video to center too */
        justify-content: center;
        align-items: center;
    }

    .feed-video {
        max-height: 90vh;
        max-width: 90vw;
        object-fit: contain;
        border-radius: 20px;
    }

    /* .nav-btn {
        font-size: 2rem;
        padding: 5px 15px;
        cursor: pointer;
        background: rgba(0,0,0,0.5);
        color: white;
        border: none;
        border-radius: 10px;
    } */
}


/* ================================
   MOBILE (max-width: 767px)
================================ */
@media (max-width: 767px) {

    #save-btn, #like-btn, #comment-btn, #caption-btn{
        background-color: transparent;
    }

    #save-btn.active {
        /* border: solid 2px var(--paper); */
        transform: scale(1.1);
        background-color: transparent;
        color:var(--qing);
        transition: 0.2s ease;
    }

    #like-btn.active {
        /* border: solid 2px var(--paper); */
        transform: scale(1.1);
        background-color: transparent;
        color:var(--yellow);
        transition: 0.2s ease;
    }

    .comment-options button {
        padding: 6px 10px;
        font-size: 16px;
    }

    #comment-btn{
        transform: scale(1.0);
        background-color: transparent;
        color:var(--blue);
        transition: 0.2s ease;
    }
    
    #caption-panel {
        background-color: transparent;
        border: solid 2px var(--pop-window-background);
        margin-bottom: calc(var(--mobile-nav-height) / 2);
        width: calc(100% - 28px); /* 2px left + 2px right + 12px left + 12px right*/
        margin: 0 2px; /* top/bottom 0, left/right 10px */
        padding: 12px; /* top/bottom 0, left/right 10px */
    }

    #caption-header {
        border-top-right-radius: 10px;
        border-top-left-radius: 10px;
        border-bottom-right-radius: 10px;
        border-bottom-left-radius: 10px;
        background-color: var(--pop-window-background);
        align-items: center;
        padding: 10px;
    }

    .active-caption{
        font-weight: bold;
        border: solid 2px var(--light-ink);
    }

    /* #caption-btn{

         border: solid 1px var(--paper);
    } */

    #like-num{
        color: var(--white);
    }

    .video-slide.active {
        opacity: 1;
        background-color: var(--ink-black);
    }

    /* ================================
       🔴 TikTok-style mobile stack
    ================================ */
    #video-stack {
        display: block;
        position: absolute;
        inset: 0;
        background-color: var(--text-color);
        will-change: transform;
        transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
        z-index: 1;
    }

    /* ================================
       🔵 Disable desktop wrapper
    ================================ */
    #video-wrapper {
        display: none;
    }

    /* ================================
       🔴 Each video = full viewport
    ================================ */
    #video-stack .video-slide {
        height: var(--vh);
        width: 100%;
        display: flex;             /* enable flex centering */
        justify-content: center;   /* horizontal center */
        align-items:flex-start;       /* vertical center */
        position: relative;
        overflow: hidden;
    }

    /* ================================
       🔵 TikTok video fit
    ================================ */
    #video-stack .feed-video {
        width: 100%;       /* max width = screen */
        height: auto;      /* maintain aspect ratio */
        max-height: calc(100% - var(--mobile-nav-height)); /* prevent exceeding viewport height */
        object-fit: contain; /* fits inside container without cropping */
    }

    /* ================================
       🔴 UI above video
    ================================ */
    #right-controls{
        z-index: 10;
    }

    .video-caption {
        display: none;
        background-color: transparent;
        margin-bottom: calc(var(--mobile-nav-height) * 0.3); 
        z-index: 100;
    }

    #caption-panel{
        z-index: 100;
        width: 93%;
    }

    #comment-panel{
        z-index: 1001;
        width: 93%;
    }

    /* ================================
       🔴 Prevent page scrolling
    ================================ */
    body {
        overscroll-behavior: none;
        touch-action: pan-x;
    }

    #prev-btn, #next-btn{
        display: none;
    }
}
