/* ============================================================
   Facebook 照片查看器 · 高保真还原
   白色 FB 顶栏 + 深色大图区 + 相册胶片条 + 右侧帖子/评论面板
   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-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;
}

/* ============================================================
   照片查看器
   ============================================================ */
.photo-view {
    display: flex;
    height: calc(100vh - var(--header-h));
    background: #000;
    color: #fff;
}

.viewer {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.viewer-top {
    flex: none;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
}

.top-btn {
    width: 40px; height: 40px;
    border: none; border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex: none;
    transition: background .15s ease;
}

.top-btn:hover { background: rgba(255, 255, 255, .22); }

.viewer-title { flex: 1 1 auto; min-width: 0; }

.viewer-name {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-sub {
    margin: 2px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, .68);
    display: flex;
    align-items: center;
    gap: 6px;
}

#photoIndex { direction: ltr; display: inline-block; }

.viewer-actions { display: flex; align-items: center; gap: 8px; }

.photo-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 76px;
}

.photo-frame {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#photoImg {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, .55);
    cursor: zoom-in;
}

.photo-frame.is-zoomed {
    position: fixed;
    inset: 0;
    z-index: 400;
    height: auto;
    padding: 20px;
    background: #000;
}

.photo-frame.is-zoomed #photoImg {
    max-height: calc(100vh - 40px);
    cursor: zoom-out;
    border-radius: 0;
    box-shadow: none;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 48px; height: 48px;
    border: none; border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s ease;
}

.nav-btn:hover { background: rgba(255, 255, 255, .3); }
.nav-btn.prev { left: 12px; }
.nav-btn.next { right: 12px; }

.filmstrip {
    flex: none;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.thumb {
    width: 44px; height: 58px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    background: #111;
    opacity: .55;
    cursor: pointer;
    flex: none;
    transition: opacity .15s ease, border-color .15s ease;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { opacity: .9; }
.thumb.is-active { opacity: 1; border-color: #fff; }

/* ============================================================
   右侧帖子面板
   ============================================================ */
.post-panel {
    flex: 0 0 380px;
    width: 380px;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: var(--fb-text);
    border-left: 1px solid #d8dadf;
}

.panel-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 16px 6px;
}

.post-head { display: flex; align-items: flex-start; gap: 10px; }

.page-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; flex: none;
}

.post-id { flex: 1 1 auto; min-width: 0; }

.page-name {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--fb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-name:hover { text-decoration: underline; }

.post-meta {
    margin: 2px 0 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--fb-gray);
}

.globe { flex: none; }

.follow-btn {
    flex: none;
    border: none;
    background: none;
    padding: 0;
    color: var(--fb-blue);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.follow-btn:hover { text-decoration: underline; }
.follow-btn.is-following { color: var(--fb-gray); font-weight: 600; }

.post-body { margin-top: 14px; }

.caption {
    margin: 0;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-line;
    word-break: break-word;
}

.caption.is-collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.see-more {
    display: none;
    margin-top: 4px;
    padding: 0;
    border: none;
    background: none;
    color: var(--fb-gray);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

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

.post-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--fb-line);
    font-size: 14px;
    color: var(--fb-gray);
}

.reaction-summary { display: flex; align-items: center; }

.rea {
    width: 20px; height: 20px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 1px solid #fff;
    font-size: 12px;
    margin-right: -4px;
}

.rea-like { background: #e7f3ff; }
.rea-haha { background: #fff3cd; }
.rea-count { margin-left: 8px; color: var(--fb-text); font-size: 14px; }

.summary-counts { display: flex; align-items: center; gap: 6px; }

.post-actions {
    display: flex;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--fb-line);
}

.pa-btn {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
    border: none;
    background: none;
    border-radius: 6px;
    color: var(--fb-gray);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.pa-btn:hover { background: #f2f2f2; }
.pa-btn.is-active { color: var(--fb-blue); }
.pa-btn.is-active svg path { fill: currentColor; stroke: none; }

.comments-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--fb-gray);
}

.comments-list { padding-bottom: 8px; }

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

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

.comment { display: flex; gap: 8px; margin: 12px 0; }
.c-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.c-body { min-width: 0; }
.c-name { margin: 0; font-size: 13px; font-weight: 700; }
.c-text { margin: 2px 0 4px; font-size: 15px; line-height: 1.4; word-break: break-word; }
.c-link { color: var(--fb-blue); word-break: break-all; }
.c-link:hover { text-decoration: underline; }
.c-foot { display: flex; align-items: center; gap: 14px; font-size: 12px; font-weight: 600; color: var(--fb-gray); }
.c-foot a:hover { text-decoration: underline; }

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

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

.comment-input-wrap {
    flex: 1 1 auto;
    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 {
    border: none; border-radius: 16px;
    background: none;
    padding: 8px 10px;
    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"] .nav-btn.prev { left: auto; right: 12px; }
html[dir="rtl"] .nav-btn.next { right: auto; left: 12px; }
html[dir="rtl"] .post-panel { border-left: none; border-right: 1px solid #d8dadf; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1200px) {
    .fb-nav-item { width: 84px; }
    .fb-search { width: 200px; }
    .post-panel { flex-basis: 340px; width: 340px; }
    .photo-stage { padding: 6px 62px; }
}

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

    .photo-view {
        display: block;
        height: auto;
        min-height: calc(100vh - var(--header-h));
    }

    .viewer { height: auto; }

    .viewer-top { height: 54px; padding: 0 8px; }
    .viewer-name { font-size: 14px; }

    .photo-stage {
        height: 62vh;
        min-height: 320px;
        padding: 4px 8px;
    }

    .nav-btn { width: 40px; height: 40px; }
    .nav-btn.prev { left: 6px; }
    .nav-btn.next { right: 6px; }

    .filmstrip { height: 72px; justify-content: flex-start; padding: 0 8px; }

    .post-panel {
        width: 100%;
        flex-basis: auto;
        border-left: none;
        border-top: 1px solid #d8dadf;
    }

    .panel-scroll { overflow: visible; padding: 14px 14px 6px; }
}

@media (max-width: 480px) {
    .fb-icon-btn { width: 36px; height: 36px; }
    .fb-avatar { width: 36px; height: 36px; }
    .viewer-top .top-btn { width: 36px; height: 36px; }
    .photo-stage { height: 58vh; }
    .caption { font-size: 14px; }
}

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