/* ========== Mode Scroll Overlay ========== */
#feed-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
}
#feed-overlay.is-open {
    display: block;
    pointer-events: auto;
}
#feed-overlay::-webkit-scrollbar { width: 0; }

/* Butang tutup */
#feed-close {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    z-index: 10001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: grid;
    place-items: center;
}
#feed-close:hover { background: rgba(0, 0, 0, .85); }

/* ========== Setiap card = 1 screen ========== */
.feed-card {
    position: relative;
    height: 100vh; /* Fallback untuk browser lama */
    height: 100dvh; /* <--- TUKAR KEPADA dvh */
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

/* MP4 */
.feed-card video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* ========== Frame umum (horizontal) — CENTER ========== */
.feed-frame {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feed-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ========== Frame vertical (9:16) — CENTER ========== */
.feed-frame--vertical {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feed-frame--vertical iframe {
    width: calc(100svh * 9 / 16);
    height: 100svh;
    max-width: 100%;
    border: 0;
    display: block;
    margin: 0 auto;
}

/* ========== Action bar menegak (kanan) ========== */
.feed-actions {
    position: absolute;
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(90px + env(safe-area-inset-bottom));
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    pointer-events: none;
}
.feed-actions > * { pointer-events: auto; }

.feed-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease;
}
.feed-action:active { transform: scale(.92); }
.feed-action svg {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6));
    transition: fill .15s;
    width: 26px;
    height: 26px;
}
.feed-action.active svg { fill: #ff3b5c; }
.feed-action-count {
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
}
.feed-action:disabled { opacity: .5; cursor: wait; }
.feed-action:focus { outline: none; }
.feed-action:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .6);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ========== Info overlay bawah ========== */
.feed-info {
    position: absolute;
    left: 0;
    right: 80px;
    bottom: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .85) 60%);
    color: #fff;
    pointer-events: none;
    z-index: 3;
}
.feed-info h3 {
    font-size: 16px;
    margin: 0 0 6px;
    line-height: 1.35;
    font-weight: 600;
}
.feed-info p {
    margin: 0;
    font-size: 13px;
    opacity: .85;
}
.feed-info a { color: #fff; pointer-events: auto; }

/* Loading spinner */
.feed-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: feed-spin .9s linear infinite;
}
@keyframes feed-spin { to { transform: rotate(360deg); } }

/* ========== Mobile ========== */
@media (max-width: 768px) {
    .feed-info {
        right: 72px;
    }
    .feed-info h3 { font-size: 15px; }
    .feed-actions {
        right: 8px;
        bottom: calc(80px + env(safe-area-inset-bottom));
        gap: 16px;
    }
    .feed-action svg { width: 28px; height: 28px; }
    .feed-action-count { font-size: 11px; }
}

/* ========== Desktop: hadkan lebar video vertical ========== */
@media (min-width: 769px) {
    .feed-frame--vertical iframe {
        width: auto;
        height: 100%;
        max-width: 56.25vh;
        aspect-ratio: 9 / 16;
    }
}

@media (min-width: 900px) {
    .feed-card { padding: 0 8vw; }
    .feed-card video,
    .feed-frame iframe { border-radius: 10px; }
}

/* ========== Panel Komen ========== */
#feed-comments-panel {
    position: fixed;
    inset: 0;
    z-index: 10005;
    background: rgba(0,0,0,0.5);
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
}
#feed-comments-panel.is-open {
    display: block;
    opacity: 1;
}
.feed-comments-inner {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 70vh;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#feed-comments-panel.is-open .feed-comments-inner {
    transform: translateY(0);
}
.feed-comments-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid #333;
    color: #fff;
}
.feed-comments-header h3 { margin: 0; font-size: 16px; }
#feed-comments-close {
    background: none; border: none; color: #fff; font-size: 24px; cursor: pointer;
}
.feed-comments-list {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 16px;
}
.feed-comment-form {
    display: flex; gap: 8px; padding: 12px 16px;
    border-top: 1px solid #333; background: #222;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.feed-comment-form input {
    flex: 1; padding: 10px 16px; border-radius: 20px;
    border: none; background: #333; color: #fff; outline: none;
}
.feed-comment-form button {
    background: #ff3b5c; color: #fff; border: none;
    padding: 0 16px; border-radius: 20px; font-weight: 600; cursor: pointer;
}
.feed-comment-item { display: flex; gap: 12px; }
.feed-comment-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #444; color: #fff; display: grid; place-items: center;
    font-size: 14px; font-weight: bold; flex-shrink: 0;
}
.feed-comment-body { flex: 1; }
.feed-comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.feed-comment-header strong { color: #eee; font-size: 13px; }
.feed-comment-date { color: #888; font-size: 11px; }
.feed-comment-delete { margin-left: auto; background: none; border: none; color: #ff3b5c; cursor: pointer; font-size: 18px; padding: 0 4px; }
.feed-comment-text { color: #ccc; font-size: 14px; line-height: 1.4; }
.feed-comment-text.deleted { font-style: italic; color: #666; }

/* ========== Menu 3 Titik (More) ========== */
.feed-more-menu {
    position: fixed;
    inset: 0;
    z-index: 10010;
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.feed-more-menu.is-open {
    display: block;
    opacity: 1;
}
.feed-more-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}
.feed-more-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}
.feed-more-menu.is-open .feed-more-sheet {
    transform: translateY(0);
}
.feed-more-handle {
    width: 40px;
    height: 4px;
    background: #444;
    border-radius: 2px;
    margin: 10px auto 15px;
}
.feed-more-items {
    display: flex;
    flex-direction: column;
    padding: 0 16px 16px;
}
.feed-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}
.feed-menu-item:hover, .feed-menu-item:active {
    background: #2a2a2a;
}
.feed-menu-item.text-danger {
    color: #ff3b5c;
}