/**
 * 归档页面专用样式
 * 优化加载性能，分离主题、布局和动画样式
 */

/* 基础主题设置 */
:root {
    --bg-color: #f9f9f9;
    --text-color: #333;
    --brand-color: #1C244B;
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition-fast: 0.15s ease;
    --grid-gap: 10px;
    --mobile-grid-gap: 7px;
    --card-height: 330px;
    --mobile-card-height: 468px;
    --primary-color: #1C244B;
    --secondary-color: #FFFFFF;
    --accent-color: #f5f5f5;
    --success-color: #28a745;
    --error-color: #dc3545;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

/* 全局背景和容器样式 */
html, body, .main-content, .portfolio-grid, .projects-header, .site-footer {
    background-color: var(--bg-color) !important;
}

.main-content, .container, .container-fluid {
    max-width: 100% !important;
    width: 100% !important;
}

/* 主内容区样式 */
.main-content {
    padding-top: 60px;
    margin-top: 50px !important;
}

/* 移除标题装饰 */
.projects-header {
    padding: 20px 20px 0px !important;
    margin-bottom: 0px !important;
    border-bottom: none !important;
}

.projects-header h1 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    color: var(--brand-color) !important;
}

/* 筛选按钮样式 */
.filter-btn.active {
    border-bottom-color: var(--brand-color) !important;
}

/* 网格布局 */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
    padding: 15px;
    width: 100%;
    margin-top: 20px !important;
}

/* 项目卡片样式 */
.portfolio-item {
    position: relative;
    overflow: hidden;
    margin-bottom: 5px;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-fast);
    cursor: pointer;
    height: var(--card-height);
    width: 100%;
    display: block;
    background-color: transparent !important;
    border: none;
    will-change: transform, box-shadow;
    transform: translateZ(0);
}

.portfolio-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

/* 图片容器样式 */
.portfolio-image, .project-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-out, opacity 0.5s ease;
    opacity: 0;
    will-change: transform, opacity;
    transform: translateZ(0);
    background-color: #f5f5f5; /* 加载前的背景色，与占位符颜色一致 */
}

/* 已加载图片样式 */
.project-thumbnail.loaded {
    opacity: 1;
}

/* 高质量图片显示过渡效果 */
.project-thumbnail.high-quality {
    animation: none;
}

/* 图片占位符样式 */
.image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 1;
    transition: opacity 0.2s ease;
}

/* 加载动画 */
.loading-icon {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(28, 36, 75, 0.1);
    border-top-color: rgba(28, 36, 75, 0.6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.portfolio-item:hover .portfolio-image, 
.portfolio-item:hover .project-thumbnail {
    transform: scale(1.05);
}

/* 移除多余的悬停效果 */
.portfolio-item:hover .project-thumbnail.loaded {
    transform: none;
}

/* 项目信息样式 */
.portfolio-info, .project-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: transparent !important;
    color: white;
    padding: 0;
    text-align: center;
    z-index: 1;
    opacity: 0.95;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    pointer-events: none;
}

.portfolio-item:hover .portfolio-info,
.portfolio-item:hover .project-info {
    opacity: 1;
}

/* 项目标题样式 - 增强优先级 */
body .portfolio-grid .portfolio-item .portfolio-title, 
body .portfolio-grid .portfolio-item .project-title {
    margin: 0 !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    text-shadow: 0 1px 3px rgba(0,0,0,1), 0 1px 10px rgba(0,0,0,1) !important;
    text-align: center !important;
    color: #ffffff !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 2 !important;
    padding: 10px 8px 10px !important;
    background: none !important;
    border-radius: 0 0 8px 8px !important;
    opacity: 1 !important; /* 始终显示标题 */
    transition: transform var(--transition-fast) !important;
}

/* 完全禁用标题的::before伪元素 */
body .portfolio-grid .portfolio-item .project-title::before,
body .portfolio-grid .portfolio-item .portfolio-title::before {
    display: none !important;
}

/* 隐藏"查看详情"按钮 */
.view-details {
    display: none !important; /* 完全隐藏查看详情按钮 */
}

/* 修改信息层，使其始终显示 */
.info-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    z-index: 2;
    background: none;
    pointer-events: none;
    opacity: 1; /* 始终显示 */
    transition: none;
}

/* 移除悬停效果，标题现在始终可见 */
.portfolio-item:hover .portfolio-title,
.portfolio-item:hover .project-title {
    transform: translateY(0);
}

/* 确保移动设备上标题也显示良好 - 保持现有样式 */
@media (max-width: 768px) {
    .portfolio-title, .project-title {
        font-size: 0.75rem;
        padding: 8px 6px 8px;
        /* 移动端样式由JS处理，不需要!important */
    }
}

/* 骨架屏样式 */
.skeleton {
    background-color: #f0f0f0;
    height: var(--card-height);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 图片加载中的脉冲动画 - 减少动画频率避免性能问题 */
.portfolio-item:not(:has(.project-thumbnail.loaded)) {
    animation: pulse 2s ease-in-out;
    background-color: #f0f0f0;
}

@keyframes pulse {
    0% { background-color: #f0f0f0; }
    50% { background-color: #e8e8e8; }
    100% { background-color: #f0f0f0; }
}

/* 图片加载错误样式 */
.project-thumbnail.error {
    filter: grayscale(1) brightness(0.9);
}

/* 图片不可见时隐藏 - 修改为使用visibility而非opacity，减少GPU压力 */
.project-thumbnail.distant {
    visibility: hidden;
}

/* 图片加载错误消息样式改进 */
.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 15px;
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .portfolio-item {
        transform: translateZ(0);
    }
    
    .project-thumbnail, .carousel-slide img {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 响应式调整 */
@media (max-width: 992px) {
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: var(--mobile-grid-gap) !important;
    }
    
    .portfolio-item {
        height: var(--mobile-card-height) !important;
    }
    
    .portfolio-image,
    .project-thumbnail {
        height: 100% !important;
    }
    
    /* 修改移动端弹窗外层容器样式 */
    .modal {
        padding: 0 !important; /* 移除内边距 */
        align-items: flex-end !important; /* 从底部对齐 */
    }
    
    /* 修改移动端弹窗样式，使其宽度占满屏幕 */
    .modal-content {
        max-width: 100% !important; /* 修改为100%铺满屏幕 */
        width: 100% !important; /* 确保宽度为100% */
        max-height: 95vh;
        border-radius: 0;
        margin: 0; /* 移除所有边距 */
        border-radius: 15px 15px 0 0; /* 上方圆角，底部平直 */
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
        touch-action: none; /* 防止浏览器默认触摸行为干扰自定义滑动 */
        will-change: transform; /* 提示浏览器优化 */
        position: relative; /* 确保定位上下文 */
    }
    
    /* 添加滑动关闭指示器 */
    .modal-header::before {
        content: '';
        position: absolute;
        top: 6px; /* 稍微下移，给关闭按钮留出空间 */
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background-color: #e0e0e0;
        border-radius: 2px;
        z-index: 30;
    }
    
    /* 添加滑动中的样式 */
    .modal-content.swiping {
        transition: none !important; /* 滑动时禁用过渡，实现跟手效果 */
    }
    
    /* 滑动足够距离后的关闭状态 */
    .modal-content.swipe-close {
        transform: translateY(100%) !important;
        transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1) !important;
    }
    
    /* 激活状态：滑入到可见位置 */
    .modal.active .modal-content {
        transform: translateY(0);
    }
    
    /* 优化弹窗背景过渡 */
    .modal {
        background-color: rgba(0, 0, 0, 0);
        transition: background-color 0.4s ease;
    }
    
    .modal.active {
        background-color: rgba(0, 0, 0, 0.85);
    }
    
    /* 优化标题样式，为关闭按钮留出空间 */
    .modal-header {
        padding: 15px 40px 10px 15px; /* 右侧增加内边距 */
        border-bottom: none; /* 移除边框 */
    }
    
    .modal-title {
        font-size: 18px; /* 调整字体大小 */
        margin: 0 25px; /* 为关闭按钮留出空间 */
    }
    
    /* 优化描述文本区域 */
    .modal-description {
        padding: 12px 15px 15px; /* 调整内边距 */
        font-size: 14px;
        line-height: 1.5; /* 增加行高 */
        max-height: 15vh; /* 略微增加描述区域最大高度 */
    }
    
    /* 优化比例信息显示 */
    .scale-info-container {
        padding: 8px 0;
        background-color: #f5f5f5; /* 浅灰色背景 */
    }
    
    .scale-info {
        font-size: 13px;
    }
    
    /* 调整轮播图样式以适应全宽显示 */
    .carousel-container {
        max-height: 60vh; /* 略微减小高度以适应移动端 */
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #f0f0f0; /* 浅灰色背景 */
    }
    
    .carousel-track {
        min-height: 50vh; /* 减小最小高度 */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .carousel-slide {
        padding: 0;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .carousel-slide img {
        max-width: 100% !important; /* 确保图片宽度适应容器 */
        min-width: 100% !important; /* 设置最小宽度为100% */
        object-fit: contain; /* 确保图片保持比例 */
        height: auto; /* 高度自适应 */
        max-height: 55vh; /* 最大高度控制 */
    }
    
    /* 增强滑动提示的可见性 */
    .swipe-hint {
        bottom: 20px;
        padding: 8px 15px;
        background: rgba(0,0,0,0.6);
        color: white;
        font-weight: 500;
        border-radius: 20px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    
    .carousel-nav {
        display: none !important;
    }
    
    .carousel-dots {
        display: flex !important;
    }
    
    /* 调整移动端关闭按钮样式 */
    .modal-close {
        position: absolute;
        right: 10px; /* 调整位置 */
        top: 10px; /* 调整位置 */
        width: 26px; /* 进一步缩小尺寸 */
        height: 26px; /* 进一步缩小尺寸 */
        background-color: rgba(0, 0, 0, 0.15); /* 更淡的背景色 */
        border-radius: 50%;
        color: rgba(255, 255, 255, 0.9); /* 稍微透明的白色 */
        box-shadow: none;
        z-index: 31; /* 确保在滑动指示器上方 */
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px; /* 进一步缩小图标大小 */
        padding: 0; /* 移除内边距 */
        border: none; /* 移除边框 */
        outline: none; /* 移除轮廓 */
        -webkit-tap-highlight-color: transparent; /* 移除点击高亮 */
        transition: transform 0.15s ease, background-color 0.15s ease; /* 添加过渡效果 */
    }
    
    /* 添加触摸反馈效果 */
    .modal-close:active {
        transform: scale(0.9); /* 点击时稍微缩小 */
        background-color: rgba(0, 0, 0, 0.3); /* 点击时背景变深 */
    }
    
    /* 确保关闭图标居中 */
    .modal-close i {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        line-height: 1;
        margin: 0;
    }
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 0;
}

.modal.active {
    opacity: 1;
}

.modal-header {
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    position: relative;
    min-height: 40px;
    background-color: #ffffff;
    z-index: 10;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #1C244B;
    margin: 0;
    flex-grow: 1;
    text-align: center;
}

.modal-close {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #fff;
    line-height: 1;
    transition: all 0.2s;
    background-color: rgba(0, 0, 0, 0.4);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.modal-description {
    padding: 15px;
    font-size: 14px;
    color: #1c244b;
    border-top: none;
    max-height: 12vh;
    overflow-y: auto;
    min-height: 60px;
    background-color: #ffffff;
    z-index: 10;
    position: relative;
}

.modal-content {
    max-width: 80vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    background-color: #ffffff;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    margin: 0;
    position: relative;
}

/* 轮播部分 */
.carousel-container {
    width: 100%;
    height: auto;
    max-height: 65vh;
    overflow: hidden;
    position: relative;
    background-color: #f5f5f5;
    flex-grow: 1;
    margin-bottom: 0;
    border-bottom: 1px solid #eee;
}

.carousel-track {
    width: 100%;
    height: 100%;
    position: relative;
    min-height: 500px;
}

.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-slide.active {
    opacity: 1;
    z-index: 1;
}

.carousel-nav {
    position: absolute;
    width: 100%;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 5;
}

.prev-btn, .next-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(0,0,0,0.3);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: #ffffff;
    transition: all 0.2s;
    box-shadow: none;
}

.prev-btn:hover, .next-btn:hover {
    background-color: rgba(0,0,0,0.6);
    transform: scale(1.1);
}

.swipe-hint {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.7);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #1c244b;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.carousel-dots {
    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
    z-index: 5;
    padding: 10px 0;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: all 0.2s;
}

.carousel-dot.active {
    background-color: #ffffff;
    transform: scale(1.2);
}

/* 弹窗中的图片加载骨架屏 */
.image-loading-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #f0f0f0 0%, #f5f5f5 50%, #f0f0f0 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
    z-index: 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(28, 36, 75, 0.2);
    border-top-color: #1C244B;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* 弹窗图片渐入效果 */
.carousel-slide img {
    max-width: none;
    max-height: 65vh;
    width: auto;
    height: auto;
    min-width: 70vw;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    will-change: opacity;
}

.carousel-slide img.loaded {
    opacity: 1;
}

.scale-info-container {
    text-align: center;
    padding: 10px 0;
    background-color: #fff;
    border-bottom: none;
}

.scale-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #1C244B;
    font-size: 14px;
    font-weight: 500;
}

.scale-info i {
    font-size: 16px;
    color: #1C244B;
}

/* 特定视图隐藏/显示 */
@media (min-width: 769px) {
    .swipe-hint {
        display: none;
    }
    
    .carousel-dots {
        display: none;
    }
}

@media (min-width: 769px) {
    .carousel-dots {
        display: none;
    }
}

/* 特殊样式 */
.rotate-180 {
    transform: rotate(180deg) !important;
}

.fade-out {
    opacity: 0 !important;
    transition: opacity 0.5s ease !important;
}

/* 确保桌面版本保持原有动画 */
@media (min-width: 769px) {
    .modal-content {
        transform: scale(0.95);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    
    .modal.active .modal-content {
        transform: scale(1);
        opacity: 1;
    }
} 