/* =====================================================================
   VF Feed — TikTok / Reels-style vertical feed for the "classic" theme.
   Loaded only on feed pages (home + single post).
   RTL-aware via logical properties. Mobile-first, responsive.
   ===================================================================== */

:root {
    --vf-card-radius: 18px;
    --vf-card-max-w: 540px;
    --vf-mobile-header: 56px;
    --vf-tab-h: 48px;
    --vf-shade-top: linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,.25) 40%, rgba(0,0,0,0) 100%);
    --vf-shade-bottom: linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.35) 45%, rgba(0,0,0,0) 100%);
    --vf-accent: #ff2d55;
    --vf-text: #fff;
    --vf-gap: 12px;
}

/* ---- Page-level adjustments on feed pages ---- */
.body-feed-page #sticky-menu-wrapper,
.body-feed-page .header-brand { display: none; }

.body-feed-page main { padding: 0 !important; }
.body-feed-page .vf-section { padding: 0 !important; margin: 0; }

/* Hide the desktop top nav band on feed home for a cleaner reels look (still keep mobile nav) */
.body-feed-page.index-page .mobile-header { background: var(--bs-body-bg); }

/* ---- App layout ---- */
.vf-app { width: 100%; min-height: 100vh; }

.vf-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 12px;
}

.vf-main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.vf-sidebar {
    flex: 0 0 320px;
    width: 320px;
    position: sticky;
    top: 12px;
    align-self: flex-start;
}

/* ---- Tabs (TikTok-like) ---- */
.vf-tabs {
    position: sticky;
    top: var(--vf-mobile-header);
    z-index: 20;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--bs-border-color, rgba(0,0,0,.08));
}

.vf-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color, #6c757d);
    font-weight: 600;
    font-size: 15px;
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.vf-tab:hover { color: var(--bs-body-color); }
.vf-tab.is-active { color: #fff; background: var(--vf-accent); }

.vf-section-title {
    text-align: center;
    padding: 18px 12px 6px;
}
.vf-section-title h2 { margin: 0; font-size: 18px; font-weight: 700; }

/* ---- Feed container ---- */
.vf-feed { display: none; flex-direction: column; gap: var(--vf-gap); padding: 12px 0 80px; }
.vf-feed.is-active { display: flex; }

.vf-feed__list { display: flex; flex-direction: column; gap: var(--vf-gap); }

.vf-empty {
    text-align: center;
    color: var(--bs-secondary-color, #6c757d);
    padding: 60px 16px;
    font-size: 15px;
}

.vf-loader { text-align: center; padding: 16px; color: var(--bs-secondary-color, #6c757d); }

/* ---- Card ---- */
.vf-card {
    position: relative;
    width: 100%;
    margin-inline: auto;
    border-radius: var(--vf-card-radius);
    overflow: hidden;
    background: #000;
    color: var(--vf-text);
    isolation: isolate;
    scroll-snap-align: start;
    /* default (desktop) height */
    min-height: 560px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
}

.vf-card__media {
    position: relative;
    width: 100%;
    min-height: inherit;
    aspect-ratio: 4 / 5;
}
.vf-card--detail .vf-card__media--detail { aspect-ratio: 16 / 12; min-height: 320px; }

.vf-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #111;
}
.vf-card__img--placeholder {
    background: linear-gradient(135deg, var(--vf-cat-color, #444) 0%, #1a1a1a 100%);
}

.vf-shade { position: absolute; inset-inline: 0; pointer-events: none; z-index: 1; }
.vf-shade--top { top: 0; height: 38%; background: var(--vf-shade-top); }
.vf-shade--bottom { bottom: 0; height: 52%; background: var(--vf-shade-bottom); }

/* Format badge */
.vf-fmt-badge {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,.45);
    color: #fff;
    backdrop-filter: blur(4px);
}

/* Category pill */
.vf-cat-pill {
    position: absolute;
    top: 12px;
    inset-inline-start: 12px;
    z-index: 3;
    display: inline-block;
    max-width: 60%;
    padding: 4px 10px;
    border-radius: 999px;
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
}
.vf-cat-pill:hover { color: #fff; filter: brightness(1.1); }

/* Top bar: author + follow */
.vf-card__top {
    position: absolute;
    top: 46px;
    inset-inline: 12px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.vf-author { display: flex; align-items: center; gap: 8px; color: #fff !important; text-decoration: none; min-width: 0; }
.vf-author__avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.8); flex-shrink: 0; }
.vf-author__name { font-weight: 700; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-author:hover .vf-author__name { text-decoration: underline; }

.vf-follow-btn {
    appearance: none;
    border: 1px solid rgba(255,255,255,.6);
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background .15s, border-color .15s, color .15s;
    flex-shrink: 0;
    line-height: 1.2;
}
.vf-follow-btn:hover { background: rgba(255,255,255,.28); }
.vf-follow-btn.is-following { background: transparent; border-color: rgba(255,255,255,.35); }
.vf-follow-btn.is-edit { text-decoration: none; display: inline-flex; align-items: center; }
.vf-follow-btn .vf-follow-btn__following { display: none; }
.vf-follow-btn.is-following .vf-follow-btn__follow { display: none; }
.vf-follow-btn.is-following .vf-follow-btn__following { display: inline; }

/* Meta row */
.vf-card__meta {
    position: absolute;
    top: 92px;
    inset-inline: 14px;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: rgba(255,255,255,.92);
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.vf-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.vf-meta-item svg { opacity: .9; }
.vf-edit-link { color: #fff !important; text-decoration: underline; }
.vf-edit-link:hover { color: #fff; }

/* Bottom block: title + summary + actions */
.vf-card__bottom {
    position: absolute;
    inset-inline: 14px;
    bottom: 14px;
    z-index: 4;
}
.vf-card__title { margin: 0 0 6px; font-size: 17px; font-weight: 700; line-height: 1.3; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.vf-card__title a { color: #fff; text-decoration: none; }
.vf-card__title a:hover { text-decoration: underline; }
.vf-card__summary {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.45;
    color: rgba(255,255,255,.92);
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vf-open-btn {
    appearance: none;
    border: 0;
    background: var(--vf-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    transition: filter .15s, transform .1s;
}
.vf-open-btn:hover { filter: brightness(1.08); }
.vf-open-btn:active { transform: scale(.97); }

/* Action row */
.vf-actions { display: flex; align-items: center; gap: 6px; }
.vf-action { position: relative; }
.vf-action__btn {
    appearance: none;
    border: 0;
    background: rgba(0,0,0,.45);
    color: #fff;
    width: 42px; height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background .15s, transform .1s;
    padding: 0;
}
.vf-action__btn:hover { background: rgba(0,0,0,.65); }
.vf-action__btn:active { transform: scale(.92); }
.vf-action__btn .vf-action__count { font-size: 12px; font-weight: 700; min-width: 0; }
.vf-action__btn--react, .vf-action__btn--comment { width: auto; padding: 0 12px; }

.vf-action--share { position: relative; }

/* Share popover (per-card) */
.vf-share-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 30;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 10px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    width: 240px;
}
.vf-share-popover .share-flex-wrapper { flex-direction: column !important; gap: 8px !important; }
.vf-share-popover .btn-social-share { width: 36px; height: 36px; border-radius: 50%; }

/* Reaction popover (host at body level) */
.vf-react-popover {
    position: absolute;
    z-index: 1080;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0,0,0,.3);
    width: 280px;
    max-width: 90vw;
}
.vf-react-popover__inner .reaction-wrapper-title { font-size: 13px; margin-bottom: 8px; }
.vf-react-popover__inner .reaction-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
.vf-react-popover__inner .reaction-btn { padding: 6px !important; }

/* ---- Single post detail hero ---- */
.vf-detail-wrap { max-width: 860px; margin: 0 auto; padding: 12px; }
.vf-card--detail { max-width: 100%; min-height: auto; }
.vf-card--detail .vf-card__media--detail { min-height: 280px; aspect-ratio: 16/9; }

.vf-detail__body {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 20px;
    border-radius: 0 0 var(--vf-card-radius) var(--vf-card-radius);
}
.vf-card--detail { border-radius: var(--vf-card-radius); }
.vf-detail__head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.vf-detail__head .vf-cat-pill { position: static; }
.vf-detail__title { font-size: 26px; font-weight: 800; line-height: 1.25; margin: 0 0 8px; }
.vf-detail__lead { font-size: 16px; color: var(--bs-secondary-color); margin: 0 0 16px; }
.vf-detail__share { margin: 12px 0; }
.vf-detail__media { margin: 12px 0; }
.vf-detail__content { font-size: 17px; line-height: 1.8; }
.vf-detail__content img { max-width: 100%; height: auto; border-radius: 12px; }
.vf-detail__adjacent { margin-top: 24px; }
.vf-detail__reactions { margin-top: 24px; }
.vf-detail__actions-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--bs-border-color, rgba(0,0,0,.08));
}
.vf-detail__actions-bar .vf-action__btn {
    background: var(--bs-secondary-bg, #f1f1f1);
    color: var(--bs-body-color);
    width: auto;
    padding: 0 20px;
    height: 44px;
    border-radius: 999px;
}
.vf-detail__actions-bar .vf-action__label { font-weight: 700; font-size: 14px; }

/* ---- Modals ---- */
.vf-modal .modal-content { border: 0; border-radius: 18px; overflow: hidden; }
.vf-modal .modal-header { background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); }

.vf-read-modal-shell .modal-body { padding: 0; }
.vf-read-modal { padding: 20px; }
.vf-read-modal__head { margin-bottom: 12px; }
.vf-read-modal__head .vf-cat-pill { position: static; }
.vf-read-modal__title { font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.vf-read-modal__lead { color: var(--bs-secondary-color); font-weight: 500; }
.vf-read-modal__body { font-size: 16px; line-height: 1.8; }
.vf-read-modal__body img { max-width: 100%; height: auto; border-radius: 10px; }
.vf-read-modal__foot {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--bs-border-color);
}
.vf-read-modal__share { flex: 1 1 auto; min-width: 200px; }
.vf-read-modal__actions { display: flex; gap: 8px; }
.vf-read-modal__actions .vf-action__btn {
    background: var(--bs-secondary-bg, #f1f1f1);
    color: var(--bs-body-color);
    width: auto;
    padding: 0 16px;
    height: 40px;
    border-radius: 999px;
}

/* Comment modal — reels style */
.vf-comment-modal .modal-dialog { max-width: 520px; }
.vf-comment-modal .modal-body { padding: 0; }
.vf-comment-body { display: flex; flex-direction: column; max-height: 80vh; }
.vf-comment-form-wrap { padding: 16px; border-bottom: 1px solid var(--bs-border-color); position: relative; }
.vf-comment-avatar { border-radius: 50%; object-fit: cover; }
.vf-comment-textarea { min-height: 70px; resize: vertical; }
.vf-comment-input { font-size: 14px; }
.vf-comment-sort { position: absolute; top: 12px; inset-inline-end: 16px; }
.vf-comment-list { flex: 1 1 auto; overflow-y: auto; padding: 12px 16px; }
.vf-load-more-comments { display: block; margin: 8px auto; font-size: 14px; font-weight: 600; }
.vf-comment-list:empty::after {
    content: attr(data-empty);
    display: block;
    text-align: center;
    color: var(--bs-secondary-color);
    padding: 30px 0;
}

/* ---- Mobile (<= 991px): fullscreen reels feel ---- */
@media (max-width: 991.98px) {
    :root { --vf-card-max-w: 100%; }

    html { scroll-snap-type: y proximity; }

    .vf-layout { padding: 0; gap: 0; }
    .vf-main { max-width: 100%; }

    .vf-tabs { top: var(--vf-mobile-header); }

    .vf-feed { padding: 8px 0 60px; gap: 8px; }
    .vf-feed__list { gap: 8px; }

    .vf-card {
        min-height: calc(100svh - var(--vf-mobile-header) - var(--vf-tab-h) - 16px);
        min-height: calc(100vh - var(--vf-mobile-header) - var(--vf-tab-h) - 16px);
        border-radius: 0;
    }
    .vf-card__media { aspect-ratio: auto; }

    .vf-detail-wrap { padding: 0; }
    .vf-card--detail { min-height: auto; border-radius: 0; }
    .vf-card--detail .vf-card__media--detail { aspect-ratio: 16/12; min-height: 240px; }
    .vf-detail__body { padding: 16px; border-radius: 0; }
    .vf-detail__title { font-size: 22px; }

    /* comment modal as bottom sheet on mobile */
    .vf-comment-modal .modal-dialog { max-width: 100%; margin: 0; }
    .vf-comment-modal .modal-content { border-radius: 18px 18px 0 0; }
    .vf-comment-modal .modal-dialog { position: fixed; bottom: 0; inset-inline: 0; }
    .vf-comment-body { max-height: 80vh; }
}

/* ---- Desktop (>= 992px): centered feed + sidebar ---- */
@media (min-width: 992px) {
    .vf-main { max-width: var(--vf-card-max-w); margin-inline: auto; }
    .vf-card { min-height: 600px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-snap-type: none; }
    .vf-card { scroll-snap-align: none; }
}

/* ---- Dark theme tweaks (Bootstrap data-bs-theme=dark) ---- */
[data-bs-theme="dark"] .vf-tabs { background: color-mix(in srgb, var(--bs-body-bg) 90%, transparent); }
[data-bs-theme="dark"] .vf-card { background: #0a0a0a; }
[data-bs-theme="dark"] .vf-detail__body,
[data-bs-theme="dark"] .vf-read-modal,
[data-bs-theme="dark"] .vf-react-popover { background: var(--bs-body-bg); }
