/* ============================================================
   Facebook Reels 页面 · 高保真还原
   白色 FB 全局顶栏 + 黑色 Reels 播放区 + 右侧操作栏 + 留言抽屉
   16 语种（含 RTL 阿拉伯语）自适应
   ============================================================ */

:root {
    --fb-blue: #1877f2;
    --fb-text: #050505;
    --fb-gray: #65676b;
    --fb-line: #e4e6eb;
    --fb-soft: #f0f2f5;
    --header-h: 56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "PingFang SC",
        "Microsoft JhengHei", "Microsoft YaHei", "Hiragino Sans", "Yu Gothic UI", "Malgun Gothic",
        "Noto Sans TC", "Noto Sans Arabic", "Noto Sans Devanagari", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { display: block; }

/* ============================================================
   Facebook 全局顶栏
   ============================================================ */
.fb-header {
    position: relative;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #fff;
    color: var(--fb-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.fb-head-left {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fb-logo {
    flex: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fb-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 240px;
    height: 40px;
    padding: 0 12px;
    border-radius: 20px;
    background: var(--fb-soft);
    color: var(--fb-gray);
}

.fb-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--fb-text);
}

.fb-search input::placeholder { color: var(--fb-gray); }

.fb-nav {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.fb-nav-item {
    width: 112px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid transparent;
    border-radius: 8px;
    color: var(--fb-gray);
    transition: background .15s ease, color .15s ease;
}

.fb-nav-item:hover { background: #f2f2f2; }

.fb-nav-item.is-active {
    color: var(--fb-blue);
    border-bottom-color: var(--fb-blue);
    border-radius: 8px 8px 0 0;
}

.fb-head-right {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.fb-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fb-line);
    color: var(--fb-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}

.fb-icon-btn:hover { background: #d8dadf; }

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #e41e3f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.fb-profile {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--fb-text);
    border-radius: 20px;
}

.fb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fb-line);
    color: #8a8d91;
    display: grid;
    place-items: center;
    overflow: hidden;
}

/* ============================================================
   Reels 区域
   ============================================================ */
.reels-view {
    position: relative;
    height: calc(100vh - var(--header-h));
    background: #000;
    overflow: hidden;
}

.reels-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
}

.reels-close {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #2b2d31;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}

.reels-close:hover { background: #3a3c40; }

.reels-wordmark {
    margin: 0;
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: .2px;
}

.reels-body {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 54px;
    padding: 74px 120px 22px;
}

/* 视频卡片 */
.reel-wrap {
    position: relative;
    height: 100%;
    aspect-ratio: 9 / 16;
    max-width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    flex: none;
}

.reel-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    cursor: pointer;
}

.reel-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, .28) 0%, rgba(0, 0, 0, 0) 20%),
        linear-gradient(0deg, rgba(0, 0, 0, .86) 0%, rgba(0, 0, 0, .38) 30%, rgba(0, 0, 0, 0) 58%);
}

/* 静音按钮 */
.sound-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease;
}

.sound-btn:hover { background: rgba(0, 0, 0, .75); }
.sound-btn .ic-muted { display: none; }
.sound-btn.is-muted .ic-muted { display: block; }
.sound-btn.is-muted .ic-sound { display: none; }

/* 作者 / 文案 */
.reel-caption-block {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 16px 18px 12px;
    color: #fff;
}

.cap-author {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cap-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, .55);
    flex: none;
}

.cap-name {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.verified { display: inline-flex; align-items: center; }

.cap-sep { opacity: .85; }

.cap-follow {
    border: none;
    background: none;
    padding: 0;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.cap-follow:hover { text-decoration: underline; }
.cap-follow.is-following { color: rgba(255, 255, 255, .8); font-weight: 600; }

.cap-text {
    margin: 0;
    font-size: 16px;
    line-height: 1.36;
    white-space: pre-line;
    word-break: break-word;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

.cap-text.is-collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.see-more {
    display: none;
    margin: 4px 0 0;
    padding: 0;
    border: none;
    background: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

.see-more.is-visible { display: inline-block; }
.see-more:hover { text-decoration: underline; }

.translation-toggle {
    display: block;
    margin-top: 12px;
    padding: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, .78);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: start;
}

.translation-toggle:hover { text-decoration: underline; }

/* 右侧操作栏 */
.rail {
    align-self: flex-end;
    margin-bottom: 78px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    color: #fff;
}

.rail-btn {
    border: none;
    background: none;
    padding: 0;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
    transition: opacity .15s ease, transform .12s ease;
}

.rail-btn:hover { opacity: .82; }
.rail-btn:active { transform: scale(.94); }

.rail-count {
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}

#likeBtn.is-active { color: #fff; }
#likeBtn.is-active .ic-thumb path { fill: currentColor; stroke: none; }

/* 最右侧上下切换 */
.reels-nav {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reels-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .4);
    background: transparent;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.reels-nav-btn:hover {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .7);
}

/* ============================================================
   留言抽屉（浅色）
   ============================================================ */
.drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.drawer-scrim.is-open { opacity: 1; pointer-events: auto; }

.comments-drawer {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    z-index: 160;
    width: 380px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: var(--fb-text);
    box-shadow: -8px 0 24px rgba(0, 0, 0, .22);
    transform: translateX(105%);
    transition: transform .28s ease;
}

.comments-drawer.is-open { transform: none; }

.cd-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--fb-line);
}

.cd-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.cd-count {
    margin-inline-start: 4px;
    font-size: 14px;
    font-weight: 400;
    color: var(--fb-gray);
}

.cd-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--fb-soft);
    color: var(--fb-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cd-close:hover { background: #e4e6eb; }

.comments-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 16px 14px;
    scrollbar-width: thin;
    scrollbar-color: #ccd0d5 transparent;
}

.comments-list::-webkit-scrollbar { width: 8px; }
.comments-list::-webkit-scrollbar-thumb { background: #ccd0d5; border-radius: 4px; }

.view-more {
    display: inline-block;
    margin: 4px 0 8px;
    color: var(--fb-gray);
    font-size: 14px;
    font-weight: 600;
}

.view-more:hover { text-decoration: underline; }

.comment {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.c-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: none;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    background: #bcc0c4;
    object-fit: cover;
}

.c-avatar-1 { background: linear-gradient(135deg, #f7b733, #fc4a1a); }
.c-avatar-2 { background: linear-gradient(135deg, #1877f2, #6a5cff); }
.c-avatar-3 { background: linear-gradient(135deg, #00c6a7, #1e9b8a); }
.c-avatar-me { background: #e4e6eb; color: #8a8d91; }

.c-body { min-width: 0; }

.c-name {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--fb-text);
}

.c-text {
    margin: 2px 0 4px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--fb-text);
    word-break: break-word;
}

.c-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--fb-gray);
    font-size: 12px;
}

.c-foot a { font-weight: 600; }
.c-foot a:hover { text-decoration: underline; }

.comment-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--fb-line);
    background: #fff;
}

.comment-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 14px;
    border-radius: 20px;
    background: var(--fb-soft);
}

.comment-input-wrap input {
    flex: 1;
    min-width: 0;
    padding: 9px 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--fb-text);
}

.comment-input-wrap input::placeholder { color: var(--fb-gray); }

.send-btn {
    padding: 8px 10px;
    border: none;
    border-radius: 16px;
    background: none;
    color: var(--fb-blue);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    opacity: .5;
    transition: opacity .15s ease, background .15s ease;
}

.send-btn.is-ready { opacity: 1; }
.send-btn:hover { background: rgba(24, 119, 242, .1); }

/* ============================================================
   RTL
   ============================================================ */
html[dir="rtl"] .reels-nav { right: auto; left: 18px; }
html[dir="rtl"] .sound-btn { left: auto; right: 12px; }

html[dir="rtl"] .comments-drawer {
    right: auto;
    left: 0;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .22);
    transform: translateX(-105%);
}

html[dir="rtl"] .comments-drawer.is-open { transform: none; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1200px) {
    .fb-nav-item { width: 84px; }
    .fb-search { width: 200px; }
    .reels-body { gap: 36px; padding: 72px 80px 20px; }
}

@media (max-width: 900px) {
    .fb-search { display: none; }
    .fb-nav { display: none; }
    .fb-header { padding: 0 10px; }
    .fb-head-right { gap: 6px; }

    .reels-body {
        position: relative;
        display: block;
        padding: 64px 10px 10px;
    }

    .reel-wrap {
        height: auto;
        width: 100%;
        max-height: 100%;
        aspect-ratio: 9 / 16;
        margin: 0 auto;
    }

    .rail {
        position: absolute;
        right: 10px;
        bottom: 96px;
        margin: 0;
        gap: 18px;
    }

    .reels-nav { display: none; }

    .cap-text { font-size: 15px; }
    .cap-name { font-size: 15px; }
    .reel-caption-block { padding-right: 56px; }

    .comments-drawer {
        top: var(--header-h);
        width: 100%;
        max-width: 420px;
    }
}

@media (max-width: 480px) {
    .fb-icon-btn { width: 36px; height: 36px; }
    .fb-avatar { width: 36px; height: 36px; }
    .reels-top { padding: 10px 12px; }
    .reels-close { width: 40px; height: 40px; }
    .reels-wordmark { font-size: 22px; }
    .reels-body { padding: 58px 8px 8px; }
    .reel-caption-block { padding: 12px 56px 10px 14px; }
    .cap-avatar { width: 32px; height: 32px; }
    .rail { right: 6px; bottom: 92px; }
}

@media (max-height: 640px) and (min-width: 901px) {
    .reels-body { padding-top: 60px; padding-bottom: 14px; }
    .rail { margin-bottom: 50px; gap: 16px; }
    .cap-text { font-size: 15px; }
    .translation-toggle { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
