/**
 * WP LivePhoto LPK — Frontend Styles
 * Apple LivePhotosKit JS + 自定义降级播放器
 */

/* ── 基础容器 ────────────────────────────────────────────────── */
.wp-lp-container {
    position: relative;
    display: inline-block;
    overflow: hidden;
    border-radius: 8px;
    line-height: 0;
    max-width: 100%;
}

/* LivePhotosKit 播放器容器 */
.wp-lp-container.lpk-player {
    /* LivePhotosKit 会自动设置 position:relative + display:inline-block */
    /* 需要给它宽高让它能渲染 */
    width: 100%;
}

/* 降级播放器 */
.wp-lp-container.lpk-fallback {
    cursor: pointer;
}

/* ── LivePhotosKit 播放器样式覆盖 ─────────────────────────────── */
/* LivePhotosKit 会给元素添加 .lpk-live-photo-player 类 */
.lpk-live-photo-player {
    border-radius: 8px !important;
    overflow: hidden !important;
}

/* 隐藏 LivePhotosKit 内置的播放提示（我们用自定义的） */
.lpk-live-photo-player .lpk-hint {
    display: none !important;
}

/* ── 自定义降级播放器结构 ──────────────────────────────────────── */
.lp-fb-wrap {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    background: #000;
}

/* 图片层 */
.lp-fb-static {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
    transition: opacity 0.35s ease;
    z-index: 1;
}

/* 视频层 */
.lp-fb-motion {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 2;
}

/* hover 时：隐藏图片，显示视频 */
.wp-lp-container.lpk-fallback:hover .lp-fb-static { opacity: 0; }
.wp-lp-container.lpk-fallback:hover .lp-fb-motion { opacity: 1; }
.wp-lp-container.lpk-fallback:not(:hover) .lp-fb-motion { opacity: 0; }
.wp-lp-container.lpk-fallback:not(:hover) .lp-fb-static { opacity: 1; }

/* ── LIVE Badge — Apple iPhone Live Photos 官方风格 ───────────── */
.lp-badge {
    position: absolute;
    top: 8px; left: 8px;
    z-index: 10;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    background: rgba(0, 0, 0, 0.58);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    letter-spacing: 0.6px;
    border-radius: 999px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    user-select: none;
}

/* 红点呼吸动画 */
.lp-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff3b30;
    flex-shrink: 0;
    animation: lp-pulse 1.6s ease-in-out infinite;
}

@keyframes lp-pulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.75); }
}

/* ── 播放提示圆圈 ─────────────────────────────────────────────── */
.lp-fb-hint {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    width: 56px; height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border-radius: 50%;
    backdrop-filter: blur(4px);
    transition: opacity 0.2s;
    pointer-events: none;
}
.lp-fb-hint svg { width: 24px; height: 24px; }
.wp-lp-container.lpk-fallback:hover .lp-fb-hint { opacity: 0; }

/* ── Caption ─────────────────────────────────────────────────── */
.wp-lp-caption {
    margin: 6px 0 0;
    font-size: 13px;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

/* ── 画廊网格 ────────────────────────────────────────────────── */
.wp-lp-gallery {
    display: grid;
    grid-template-columns: repeat(var(--lp-cols, 3), 1fr);
    gap: var(--lp-gap, 12px);
    margin: 16px 0;
}

.wp-lp-gallery-item {
    display: flex;
    flex-direction: column;
}

.wp-lp-gallery .wp-lp-container {
    width: 100%;
    display: block;
    border-radius: 6px;
}

.wp-lp-gallery .wp-lp-caption {
    font-size: 12px;
}

.wp-lp-gallery-caption {
    margin: 8px 0 0;
    font-size: 13px;
    color: #888;
    text-align: center;
}

/* ── 灯箱 ────────────────────────────────────────────────────── */
#lp-lb {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
#lp-lb[hidden] { display: none; }

.lp-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.92);
    cursor: pointer;
}

.lp-lb-close,
.lp-lb-prev,
.lp-lb-next {
    position: absolute;
    z-index: 10;
    width: 44px; height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-family: sans-serif;
}
.lp-lb-close:hover,
.lp-lb-prev:hover,
.lp-lb-next:hover { background: rgba(255,255,255,0.22); }

.lp-lb-close { top: 16px; right: 16px; }
.lp-lb-prev  { left: 16px;  top: 50%; transform: translateY(-50%); }
.lp-lb-next  { right: 16px; top: 50%; transform: translateY(-50%); }

.lp-lb-content {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 90vh;
}

.lp-lb-img-wrap {
    position: relative;
    cursor: pointer;
    display: inline-block;
}
.lp-lb-img-wrap:hover .lp-lb-img { opacity: 0; }
.lp-lb-img-wrap:hover .lp-lb-video { opacity: 1; }

.lp-lb-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    transition: opacity 0.35s ease;
}

.lp-lb-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.lp-lb-ui {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 14px;
    background: rgba(0,0,0,0.6);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 13px;
}

.lp-lb-counter {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.lp-lb-caption { margin: 0; font-size: 13px; }

.lp-lb-btn {
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.lp-lb-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Dark mode ───────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .lp-badge {
        background: rgba(0,0,0,0.65);
        box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    }
    .wp-lp-caption { color: #aaa; }
    .wp-lp-gallery-caption { color: #888; }
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .wp-lp-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .lp-badge {
        top: 6px; left: 6px;
        font-size: 10px;
        padding: 3px 7px;
    }
    .lp-badge-dot { width: 5px; height: 5px; }
    .lp-lb-prev  { left: 4px; }
    .lp-lb-next  { right: 4px; }
    .lp-lb-close { top: 8px; right: 8px; }
    .lp-lb-ui {
        bottom: 8px;
        font-size: 12px;
        gap: 10px;
        padding: 5px 10px;
    }
    .lp-fb-hint { width: 44px; height: 44px; }
}
