/* 通用样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* 页面背景 */
body {
    background-color: #f4f4f4;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    color: #333;
    overflow-x: hidden;
}

/* 容器 */
.container {
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(to bottom, #f7e0c7 30%, #ffffff 70%);
}

/* 顶部导航栏 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: transparent;
    font-size: 18px;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.header .title {
    flex: 1;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

/* 案例内容 */
.content {
    width: 92%;
    max-width: 600px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 1;
}

/* 标题 */
.case-title {
    font-size: 22px;
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
    word-break: break-word;
    line-height: 1.4;
}

/* 时间 & 浏览量 */
.meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #666;
    margin: 12px 0;
}

/* 说明文字 */
.description {
    font-size: 16px;
    color: #444;
    margin-bottom: 16px;
    line-height: 1.6;
    word-break: break-word;
}

/* 图片 */
.case-image {
    width: 100%;
    border-radius: 10px;
    margin-top: 12px;
    transition: opacity 0.3s;
}

/* 加载提示和错误提示 */
#loading, #error-message {
    text-align: center;
    padding: 20px;
    font-size: 15px;
}

#error-message {
    color: #d32f2f;
    display: none;
}

#retry-btn {
    margin-top: 12px;
    padding: 8px 20px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #333;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 视频相关样式 */
.video-placeholder {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #f0f0f0;
    margin: 16px 0;
    border-radius: 10px;
    overflow: hidden;
    transform: translateZ(0);
}

.video-placeholder .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s;
}

.video-placeholder .play-icon:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.video-placeholder .play-icon::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 18px solid #333;
    margin-left: 4px;
}

.video-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    filter: blur(2px);
}

.video-wrapper {
    position: relative;
    width: 100%;
    margin: 16px 0;
    background-color: #000;
    border-radius: 10px;
    overflow: hidden;
    transform: translateZ(0);
    contain: content;
}

.video-wrapper video {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
    border-radius: 10px;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    will-change: transform;
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.3s;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

.video-wrapper:hover .video-controls,
.video-wrapper:focus-within .video-controls,
.video-wrapper.controls-visible .video-controls {
    opacity: 1;
}

.video-control-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    outline: none;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 9999;
    margin: 0;
    border-radius: 0;
}

.video-wrapper.fullscreen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 图片懒加载 */
.lazy-img {
    background-color: #f0f0f0;
    min-height: 100px;
    border-radius: 10px;
    opacity: 0;
}

.lazy-img.loaded {
    opacity: 1;
}

/* 富文本内容 */
.rich-content {
    font-size: 16px;
    line-height: 1.6;
}

.rich-content p {
    margin-bottom: 16px;
}

.rich-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 16px auto;
    border-radius: 10px;
}

/* 移动设备优化 */
@media (hover: none) {
    .video-controls {
        opacity: 1;
    }
}

/* 防止iOS视频全屏时样式问题 */
video::-webkit-media-controls {
    display: none !important;
}

/* 优化加载进度条样式 */
.video-loading {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%);
    z-index: 20;
}

.video-loading-progress {
    height: 100%;
    background: #ff5722;
    width: 0%;
    transition: width 0.3s ease;
}

/* 微信专用样式 */
.wechat-tip {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.8);
    color: white;
    z-index: 100;
    padding: 20px;
    text-align: center;
}

.wechat-tip p {
    margin-bottom: 12px;
    font-size: 14px;
}

.play-btn, .open-browser-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    margin-top: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s;
}

.play-btn {
    background: #07C160;
    color: white;
}

.open-browser-btn {
    background: #1976d2;
    color: white;
}

.play-btn:active, .open-browser-btn:active {
    transform: scale(0.95);
}

/* 针对X5内核的视频样式调整 */
.x5-core .video-wrapper video {
    -webkit-transform: translateZ(0);
    object-fit: contain;
}

.x5-core .video-wrapper.fullscreen {
    position: fixed !important;
    z-index: 99999 !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.wechat-browser .video-placeholder {
    background-color: #000;
}

/* 低端设备优化 */
@media (max-device-width: 768px) {
    .video-wrapper video {
        width: 100% !important;
        height: auto !important;
    }

    .header {
        padding: 10px 16px;
    }

    .content {
        padding: 16px;
        width: 94%;
    }

    .case-title {
        font-size: 20px;
    }
}

/* 播放时隐藏不必要元素 */
.video-wrapper.playing .video-preview,
.video-wrapper.playing .play-icon {
    display: none !important;
}

/* 网络状态提示 */
.network-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 1000;
    display: none;
}

.network-status.slow {
    display: block;
    background: #d32f2f;
}
/* 基础媒体容器样式 */
.media-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

/* 通用媒体项样式 */
.video-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: #f8f9fa;
}

/* 图片自适应处理 */
.image-container {
    width: auto;
    height: auto;
    display: block;
    aspect-ratio: 16/9;
    object-fit: cover;
    transition: opacity 0.3s;
}

/* 视频容器自适应 */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 比例 */
    height: 0;
    background: #000;
}

/* 视频元素填充容器 */
.video-wrapper video,
.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .media-container {
        grid-template-columns: 1fr;
    }

    .media-image {
        aspect-ratio: 4/3; /* 移动端更方正的比率 */
    }
}