/**
 * 云裳动态背景系统 CSS 样式
 * 为动态背景提供基础样式和优化
 */

/* 动态背景画布基础样式 */
#yunshang-dynamic-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 0.5s ease;
}

/* 响应式优化 */
@media screen and (max-width: 768px) {
    #yunshang-dynamic-background {
        opacity: 0.7;
    }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    #yunshang-dynamic-background {
        opacity: 0.8;
    }
}

@media screen and (min-width: 1025px) {
    #yunshang-dynamic-background {
        opacity: 0.85;
    }
}

/* 性能优化 - 启用硬件加速 */
#yunshang-dynamic-background {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 减少重绘区域 */
.yunshang-content-wrapper {
    isolation: isolate;
    position: relative;
    z-index: 1;
}

/* 确保文字可读性 */
.yunshang-dynamic-background-active {
    position: relative;
    z-index: 10;
}

.yunshang-dynamic-background-active * {
    position: relative;
    z-index: 20;
}

/* 背景与内容的层级关系 */
body:not(.yunshang-no-background) #yunshang-dynamic-background {
    display: block;
}

body.yunshang-no-background #yunshang-dynamic-background {
    display: none;
}

/* 平滑过渡效果 */
.yunshang-background-transition {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 加载状态 */
.yunshang-background-loading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.yunshang-background-loaded {
    opacity: 0.85;
}

/* 移动设备优化 */
@media (prefers-reduced-motion: reduce) {
    #yunshang-dynamic-background {
        animation: none;
        transition: none;
    }
    
    .yunshang-background-transition {
        transition: none;
    }
}

/* 高性能渲染优化 */
@media screen and (min-width: 1200px) {
    #yunshang-dynamic-background {
        /* 大屏幕设备可以承受更高性能消耗 */
        opacity: 0.9;
    }
}

/* 低性能设备降级 */
@media screen and (max-width: 480px) {
    #yunshang-dynamic-background {
        /* 移动设备降低复杂度 */
        opacity: 0.6;
    }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    #yunshang-dynamic-background {
        opacity: 0.7;
        filter: brightness(0.8) contrast(1.2);
    }
}

/* 节能模式 */
.yunshang-power-saving #yunshang-dynamic-background {
    opacity: 0.4;
    animation-play-state: paused;
}

/* 内容区域保护 */
.yunshang-main-content {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

/* 文字对比度优化 */
.yunshang-readable-text {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 100;
}

/* 表单元素保护 */
.yunshang-form,
.yunshang-input,
.yunshang-button {
    position: relative;
    z-index: 50;
    background: rgba(255, 255, 255, 0.95);
}

/* 导航菜单保护 */
.yunshang-navigation {
    position: relative;
    z-index: 100;
    background: rgba(255, 255, 255, 0.98);
}

/* 卡片组件保护 */
.yunshang-card {
    position: relative;
    z-index: 30;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
}

/* 特殊场景优化 */
.yunshang-fullscreen-mode #yunshang-dynamic-background {
    opacity: 0.6;
    z-index: -2;
}

.yunshang-focus-mode #yunshang-dynamic-background {
    opacity: 0.3;
    filter: blur(2px);
}

/* 调试辅助类 */
.yunshang-debug-background {
    border: 2px dashed #ff0000;
}

/* 性能监控显示 */
.yunshang-performance-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 3px;
    z-index: 9999;
    display: none;
}

.yunshang-show-performance .yunshang-performance-info {
    display: block;
}

/* 兼容性处理 */
@supports (backdrop-filter: blur(10px)) {
    .yunshang-main-content,
    .yunshang-card,
    .yunshang-form {
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.85);
    }
}

@supports not (backdrop-filter: blur(10px)) {
    .yunshang-main-content,
    .yunshang-card,
    .yunshang-form {
        background: rgba(255, 255, 255, 0.95);
    }
}

/* 打印样式 */
@media print {
    #yunshang-dynamic-background {
        display: none !important;
    }
    
    .yunshang-main-content,
    .yunshang-card,
    .yunshang-form {
        background: white !important;
        backdrop-filter: none !important;
    }
}