/* 3D Album Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border: none;
    outline: none;
}

/* 性能优化：启用GPU加速 */
.slide, .container {
    will-change: transform;
    transform: translateZ(0); /* 强制启用硬件加速 */
}

/* 移动端触摸优化 */
* {
    -webkit-tap-highlight-color: transparent; /* 移除点击高亮 */
    -webkit-touch-callout: none; /* 禁用长按菜单 */
}

/* 心情模式样式 */
.mood-happy {
    filter: brightness(1.1) saturate(1.2);
}

.mood-love {
    filter: sepia(0.3) hue-rotate(330deg);
}

.mood-excited {
    filter: contrast(1.2) brightness(1.1);
}

.mood-peaceful {
    filter: blur(0.5px) brightness(0.9);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f9ff 0%, #fef3f2 25%, #fff7ed 50%, #f0fdf4 75%, #faf5ff 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    perspective: 1000px;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    color: #4a5568;
    text-align: center;
    flex-direction: column;
    margin: 0;
    padding: 0;
    /* 移动端触摸优化 */
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* 背景渐变动画 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}



.container {
    position: relative;
    width: 200px;
    height: 200px;
    transform-style: preserve-3d;
    border: none;
    outline: none;
    background: transparent;
    touch-action: none; /* 3D容器禁用默认触摸行为 */
}

.slide {
    position: absolute;
    width: 200px;
    height: 200px;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.25, 1, 0.5, 1), opacity 1s ease-out, filter 0.3s ease-out;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    backface-visibility: visible; /* 允许背面显示，确保所有照片可见 */
    contain: layout style paint; /* 启用CSS包含 */
}

.slide.initial {
    transform: translateX(-50vw) translateZ(-200px) rotateY(0deg) scale(0.8);
    opacity: 0;
}

.slide.in-place {
    transform: var(--final-transform);
    opacity: var(--final-opacity, 1); /* 使用自定义透明度，默认为1 */
}

.slide.initial-top-left {
    transform: translate(-100vw, -100vh) scale(0.5) rotate(-45deg);
    opacity: 0;
}
.slide.initial-top-right {
    transform: translate(100vw, -100vh) scale(0.5) rotate(45deg);
    opacity: 0;
}
.slide.initial-bottom-left {
    transform: translate(-100vw, 100vh) scale(0.5) rotate(45deg);
    opacity: 0;
}
.slide.initial-bottom-right {
    transform: translate(100vw, 100vh) scale(0.5) rotate(-45deg);
    opacity: 0;
}

.slide.initial-deck {
    transform: scale(0.5) translateY(50px) rotateX(30deg);
    opacity: 0;
}


.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: transform 0.3s ease-out;
    /* 性能优化 */
    image-rendering: optimizeSpeed;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    /* 懒加载支持 */
    loading: lazy;
    /* 禁用用户选择 */
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
    /* 确保在所有角度都有良好的显示效果 */
    backface-visibility: visible;
}

.slide:hover img {
    transform: scale(1.05);
}



/* Animation keyframes removed - now handled by JavaScript for better control */



/* Control Panel Styles - Hidden for cleaner interface */
.controls {
    display: none;
}

.control-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #4a5568;
    transition: all 0.3s ease;
    position: relative;
    touch-action: manipulation; /* 优化按钮触摸响应 */
    user-select: none;
}

.control-btn:hover {
    background: #e8f4f8;
    color: #2d3748;
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

.speed-display {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    min-width: 40px;
    text-align: center;
}

/* 上传按钮特殊样式 💕 */
.upload-btn {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fa3 100%) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.upload-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.upload-btn:hover::before {
    left: 100%;
}

.upload-btn:hover {
    background: linear-gradient(135deg, #ff5a8e 0%, #ff7e94 100%) !important;
    transform: scale(1.15) !important;
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4) !important;
}

/* 加载指示器样式 */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 247, 250, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 107, 157, 0.2);
    border-top: 4px solid #ff6b9d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 1.2rem;
    color: #4a5568;
    font-weight: 300;
    text-align: center;
    opacity: 0.8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误提示优化 */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff6b9d, #c3cfe2);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(255, 107, 157, 0.3);
    z-index: 10000;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    max-width: 300px;
}

.error-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.error-message {
    display: block;
    margin-right: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.error-close {
    position: absolute;
    top: 5px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.error-close:hover {
    opacity: 1;
}

/* 照片详情视图样式 💕 */
.photo-detail-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.photo-detail-view.active {
    opacity: 1;
    visibility: visible;
}

.detail-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.detail-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.detail-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 107, 157, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #ff6b9d;
    transition: all 0.3s ease;
}

.detail-close-btn:hover {
    background: rgba(255, 107, 157, 0.3);
    transform: scale(1.1);
}

/* 3D空间中放大的照片样式 - 只设置缩放和视觉效果，不强制位置 🎯 */
.photo-album-container .slide.enlarged-photo {
    /* 不使用 transform !important，让 JavaScript 动态控制位置 */
    z-index: 1000 !important;
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    opacity: 1 !important;
    filter: brightness(1.1) contrast(1.05) saturate(1.1) !important;
    box-shadow: 0 0 40px rgba(255, 107, 157, 0.4), 0 0 60px rgba(255, 107, 157, 0.2) !important;
}

/* 确保非放大状态的照片没有box-shadow */
.photo-album-container .slide:not(.enlarged-photo) {
    box-shadow: none !important;
}

.slide.enlarged-photo img {
    border-radius: 15px;
}

/* 漂浮照片动画样式 ⭐ */
.slide.floating-detail {
    pointer-events: none; /* 漂浮时禁用交互 */
    box-shadow: 0 20px 60px rgba(255, 107, 157, 0.4) !important;
    border: 3px solid rgba(255, 255, 255, 0.8);
}

.slide.floating-detail img {
    filter: brightness(1.1) contrast(1.05) saturate(1.1);
}

/* 点击提示动画 */
/* 移除hover缩放动画，改为光晕提示 */
@keyframes pulse-hint {
    0%, 100% { 
        box-shadow: 0 10px 30px rgba(255, 107, 157, 0.2);
    }
    50% { 
        box-shadow: 0 10px 40px rgba(255, 107, 157, 0.4);
    }
}

.slide:hover {
    /* 保留轻微的hover提示，但不触发缩放避免抖动 */
    cursor: pointer;
    animation: pulse-hint 2s ease-in-out infinite;
}

/* 优化点击反馈 */
.slide {
    cursor: pointer;
    user-select: none;
}

.slide:active {
    transform: scale(0.98) !important;
    transition: transform 0.1s ease !important;
}

/* 详情模式下的特殊样式 */
body.detail-mode {
    overflow: hidden;
}

body.detail-mode .container {
    pointer-events: none;
}

body.detail-mode .slide:not(.floating-detail) {
    opacity: 0.3 !important;
    filter: blur(2px);
}

/* 移动端适配优化 */
@media (max-width: 768px) {
    .container {
        width: 160px;
        height: 160px;
    }

    .slide {
        width: 160px;
        height: 160px;
    }
    
    /* 控制面板移动端优化 */
    .controls {
        bottom: 20px;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }
    
    .control-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .speed-display {
        min-width: 50px;
        font-size: 14px;
    }
    
    /* 浮动文字移动端适配 */
    .floating-text {
        font-size: 20px;
        max-width: 90%;
        padding: 0 10px;
        letter-spacing: 1px;
    }
    
    .detail-content {
        padding: 20px;
        max-width: 90%;
        margin: 0 15px;
    }
    
    .detail-title {
        font-size: 1.6rem;
    }
    
    .detail-description {
        font-size: 1rem;
    }
    
    /* 加载屏幕文字适配 */
    .loading-text {
        font-size: 16px;
    }
    
    .loading-heart {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .container {
        width: 140px;
        height: 140px;
    }

    .slide {
        width: 140px;
        height: 140px;
    }
    
    /* 小屏幕控制面板优化 */
    .controls {
        bottom: 15px;
        gap: 6px;
        padding: 10px 8px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .speed-display {
        min-width: 45px;
        font-size: 13px;
        padding: 0 8px;
    }
    
    /* 浮动文字小屏优化 */
    .floating-text {
        font-size: 18px;
        max-width: 95%;
        padding: 0 8px;
        letter-spacing: 0.5px;
        line-height: 1.4;
    }
    
    .detail-content {
        padding: 15px;
        max-width: 95%;
        margin: 0 10px;
    }
    
    .detail-title {
        font-size: 1.4rem;
    }
    
    .detail-close-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
        top: 10px;
        right: 10px;
    }
    
    /* 加载屏幕小屏适配 */
    .loading-text {
        font-size: 14px;
        letter-spacing: 1px;
    }
    
    .loading-heart {
        width: 45px;
        height: 45px;
    }
    
    .progress-bar {
        width: 160px;
    }
}

/* 超小屏幕适配 (iPhone SE等) */
@media (max-width: 375px) {
    .container {
        width: 120px;
        height: 120px;
    }

    .slide {
        width: 120px;
        height: 120px;
    }
    
    .floating-text {
        font-size: 16px;
    }
    
    .controls {
        bottom: 10px;
        gap: 5px;
        padding: 8px 6px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
    
    .speed-display {
        min-width: 40px;
        font-size: 12px;
        padding: 0 6px;
    }
}

/* 横屏模式适配 */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        width: 140px;
        height: 140px;
    }

    .slide {
        width: 140px;
        height: 140px;
    }
    
    .controls {
        bottom: 10px;
        gap: 6px;
        padding: 8px;
    }
    
    .control-btn {
        width: 38px;
        height: 38px;
    }
    
    .floating-text {
        font-size: 18px;
        top: 45%;
    }
    
    .detail-content {
        max-height: 85vh;
        overflow-y: auto;
    }
}

/* 移动端触摸设备特定样式 */
@media (hover: none) and (pointer: coarse) {
    /* 移除hover效果，使用active状态 */
    .control-btn:hover {
        background: none;
        transform: none;
    }
    
    .control-btn:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.4);
    }
    
    .slide:active {
        transform: scale(0.95) !important;
        transition: transform 0.1s ease !important;
    }
    
    .upload-btn:active {
        transform: scale(0.95) !important;
    }
    
    /* 增大触摸区域 */
    .control-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* === 🚀 虚拟轮播优化 - 平滑过渡效果 === */
.slide img {
    opacity: 1;
    will-change: opacity;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* 空图片默认隐藏 */
.slide img[src=""] {
    opacity: 0;
}

/* 优化图片加载性能 */
.slide {
    backface-visibility: visible; /* 🔥 修复：必须显示所有面，否则某些角度的照片会被隐藏 */
    transform: translateZ(0);
    perspective: 1000px;
}

/* 确保淡入淡出平滑 */
.slide img {
    transition-property: opacity;
    transition-timing-function: ease-in-out;
}

/* 防止图片闪烁 */
.slide.loaded img {
    opacity: 1;
}
