:root {
    --border-radius: 8px;
}

.live-photo {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    max-width: min(800px, 80%);
    height: auto !important;
    margin: 1em auto;
    display: block;
    background-color: #f0f0f0;
    /* 默认 4:3 比例，JS 加载后会更新 */
    aspect-ratio: 4 / 3;
    /* 最小高度确保内容可见 */
    min-height: 200px;
}

.live-photo .container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* 阻止微信长按菜单 */
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.live-photo .container video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    top: 0;
    left: 0;
    /* 默认隐藏视频 */
    opacity: 0;
    transition: opacity 1s ease;
    /* 视频不响应触摸事件 */
    pointer-events: none;
    z-index: 2;
}

/* 使用背景图显示静态图片 */
.live-photo .photo-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1s ease;
    z-index: 1;
}

/* 播放时隐藏背景图，显示视频 */
.live-photo.zoom .photo-bg {
    opacity: 0;
}

.live-photo.zoom .container video {
    opacity: 1;
}

/* 遮罩层：覆盖在背景图和视频之上，处理所有触摸交互 */
.live-photo .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    /* 阻止微信长按菜单 */
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    touch-action: pan-x pan-y;
    background: transparent;
}

/* 桌面端不需要遮罩层阻挡点击 */
@media (min-width: 769px) {
    .live-photo .overlay {
        pointer-events: none;
    }
}

.live-photo.zoom .icon img {
    animation: spin 5s linear infinite;
}

/* 实况图标位置调整到左上角 */
.live-photo .icon {
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border-radius: var(--border-radius);
    position: absolute;
    left: 10px; /* 左上角 */
    top: 10px;
    height: 22px;
    background-color: rgba(240, 255, 255, 0.6705882353);
    cursor: pointer;
    user-select: none;
    z-index: 10;
}

.live-photo .icon img {
    width: 22px;
    height: 22px;
}

.live-photo .icon span {
    padding: 3px;
    color: #606060;
    font-size: 80%;
    /* 移除加粗效果 */
    font-weight: normal;
    text-transform: uppercase;
}

@container (max-width: 200px) {
    .live-photo .icon span {
        display: none;
    }
}

/* 声音开关样式 */
.live-photo .sound-toggle {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 24px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.live-photo .sound-icon {
    width: 16px;
    height: 16px;
}

.live-photo .sound-off {
    display: none;
}

.live-photo-placeholder {
    padding: 40px;
    text-align: center;
    background-color: #f5f5f5;
    border: 1px dashed #ccc;
    color: #666;
    border-radius: 8px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 响应式设计 - 电脑端优化 */
@media (min-width: 769px) {
    .live-photo {
        max-width: min(800px, 60%); /* 电脑上使用更大的宽度 */
    }
    
    .live-photo .icon {
        left: 15px;
        top: 15px;
        height: 24px;
    }
    
    .live-photo .icon img {
        width: 24px;
        height: 24px;
    }
    
    .live-photo .icon span {
        font-size: 85%;
    }
}

/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    .live-photo {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
    }
    
    .live-photo .icon {
        left: 8px;
        top: 8px;
        height: 20px;
    }
    
    .live-photo .icon img {
        width: 20px;
        height: 20px;
    }
    
    .live-photo .icon span {
        font-size: 75%;
    }
}

/* 确保视频不会显示控制条 */
.live-photo .container video::-webkit-media-controls {
    display: none !important;
}

.live-photo .container video::-webkit-media-controls-enclosure {
    display: none !important;
}

.live-photo .container video::-webkit-media-controls-panel {
    display: none !important;
}

/* 加载指示器 */
.live-photo .loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    z-index: 5;
}