/* =====================================================================
 * 微信聊天 · 照片放大查看器（wechat-chat-photo-viewer.js）
 * 挂在 #app 内并铺满它：查看器与照片永远不会超出 love咪小手机屏幕。
 * 层级 100400：高于悬浮球（100350），低于全局通知（100520），保存 / 收藏提示能浮在查看器上方。
 * ===================================================================== */

#chat-page .chat-message-bubble--real-image img.chat-real-image,
#chat-page .wechat-polaroid-wrap img.wechat-polaroid-img {
    cursor: zoom-in;
}

/* 放大动画期间聊天里的原缩略图让位，看起来就是同一张照片从气泡里浮起 */
.wcpv-source-hidden {
    visibility: hidden !important;
}

.wcpv {
    --wcpv-dur: 300ms;
    --wcpv-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
    --wcpv-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
    --wcpv-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
    --wcpv-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
    position: absolute;
    inset: 0;
    z-index: 100400;
    display: none;
    overflow: hidden;
    color: #fff;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    overscroll-behavior: contain;
    border-radius: inherit;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.wcpv.is-open {
    display: block;
}

/* 明信片全屏以 #app 为边界；图片的原始长宽不能撑大这层。
 * 舞台保持原坐标系，固定的标题与操作栏为图片留出可用高度。 */
.wcpv.wcpv--postcard {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    isolation: isolate;
}

.wcpv-postcard-heading {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    right: 0;
    box-sizing: border-box;
    min-height: calc(68px + var(--wcpv-safe-top));
    padding: calc(14px + var(--wcpv-safe-top)) calc(72px + var(--wcpv-safe-right)) 10px calc(20px + var(--wcpv-safe-left));
    background: #17181c;
    pointer-events: none;
}

.wcpv-postcard-heading[hidden] {
    display: none;
}

.wcpv-postcard-heading strong,
.wcpv-postcard-heading span {
    display: block;
}

.wcpv-postcard-heading strong {
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
}

.wcpv-postcard-heading span {
    color: rgba(255, 255, 255, 0.65);
    font-size: 11px;
    line-height: 18px;
}

.wcpv--postcard .wcpv-footer {
    box-sizing: border-box;
    padding-top: 12px;
    background: #17181c;
}

.wcpv.wcpv--postcard.is-shown .wcpv-close,
.wcpv.wcpv--postcard.is-shown .wcpv-footer {
    opacity: 1;
}

.wcpv.wcpv--postcard.is-shown .wcpv-close {
    pointer-events: auto;
}

.wcpv:focus {
    outline: none;
}

.wcpv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(14, 15, 19, 0.94);
    opacity: 0;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .wcpv-backdrop {
        background: rgba(14, 15, 19, 0.86);
        -webkit-backdrop-filter: blur(14px) saturate(110%);
        backdrop-filter: blur(14px) saturate(110%);
    }
}

.wcpv-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
}

.wcpv.is-zoomed .wcpv-stage {
    cursor: grab;
}

.wcpv.is-zoomed.is-gesturing .wcpv-stage {
    cursor: grabbing;
}

.wcpv-img {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 6px;
    transform-origin: 0 0;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    user-select: none;
}

.wcpv.is-animating .wcpv-img {
    transition:
        transform var(--wcpv-dur) cubic-bezier(0.2, 0.8, 0.2, 1),
        clip-path var(--wcpv-dur) cubic-bezier(0.2, 0.8, 0.2, 1),
        -webkit-clip-path var(--wcpv-dur) cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity var(--wcpv-dur) ease;
    will-change: transform;
}

.wcpv.is-animating .wcpv-backdrop {
    transition: opacity var(--wcpv-dur) ease;
}

/* 只在拖动 / 缩放过程中提升为合成层；松手后撤掉，浏览器会按最终缩放重新栅格化，放大细看不发糊 */
.wcpv.is-gesturing .wcpv-img {
    will-change: transform;
}

.wcpv-status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    pointer-events: none;
}

.wcpv-status[hidden] {
    display: none;
}

.wcpv-status--error {
    color: #ffb4b4;
}

.wcpv-spin {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    animation: wcpvSpin 0.8s linear infinite;
}

@keyframes wcpvSpin {
    to { transform: rotate(360deg); }
}

.wcpv-close {
    position: absolute;
    top: calc(12px + var(--wcpv-safe-top));
    right: calc(12px + var(--wcpv-safe-right));
    z-index: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.wcpv-close svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.wcpv-close:active {
    background: rgba(255, 255, 255, 0.24);
}

.wcpv-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 28px calc(16px + var(--wcpv-safe-right)) calc(16px + var(--wcpv-safe-bottom)) calc(16px + var(--wcpv-safe-left));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0));
    opacity: 0;
    transition: opacity 0.2s ease;
    /* 底栏空白处的轻点穿透到舞台，按「点空白处关闭」处理 */
    pointer-events: none;
}

.wcpv.is-shown .wcpv-close,
.wcpv.is-shown .wcpv-footer {
    opacity: 1;
}

.wcpv:not(.is-shown) .wcpv-close,
.wcpv.is-dragging .wcpv-close,
.wcpv.is-dragging .wcpv-footer {
    opacity: 0;
    pointer-events: none;
}

.wcpv-meta {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    min-height: 18px;
    margin-bottom: 12px;
    font-size: 12.5px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.03em;
}

.wcpv-meta-from {
    max-width: 55%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.9);
}

.wcpv-meta-time {
    font-variant-numeric: tabular-nums;
}

.wcpv-meta-from:not(:empty) + .wcpv-meta-time:not(:empty)::before {
    content: "·";
    margin-right: 8px;
    color: rgba(255, 255, 255, 0.4);
}

.wcpv-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.wcpv-btn {
    pointer-events: auto;
    flex: 1 1 0;
    min-width: 0;
    max-width: 156px;
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font: inherit;
    font-size: 14px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.wcpv-btn[hidden] {
    display: none;
}

.wcpv-btn svg {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wcpv-btn:active {
    opacity: 0.72;
}

.wcpv-btn--primary {
    background: #fff;
    border-color: #fff;
    color: #17171b;
}

.wcpv-btn--primary.is-collected svg path {
    fill: #f0627f;
    stroke: #f0627f;
}

.wcpv-btn.is-busy {
    opacity: 0.6;
    cursor: progress;
}

.wcpv-close:focus-visible,
.wcpv-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
}

@media (max-width: 340px) {
    .wcpv-bar { gap: 8px; }
    .wcpv-btn { padding: 9px 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    .wcpv,
    .wcpv-close,
    .wcpv-footer {
        --wcpv-dur: 1ms;
        transition: none;
    }
}
