/* =========================================
   1. 全局设置 (Global)
   ========================================= */
body {
    margin: 0; padding: 0; font-family: "CustomFont", Arial, sans-serif; background-color: #f5f5f5;
}
a { color: inherit; text-decoration: none; }

/* =========================================
   2. 顶部导航 (Header & Nav)
   ========================================= */
.header {
    position: fixed; top: 0; left: 0; width: 100%; height: 70px; z-index: 2000;
    transition: background 0.4s ease; display: flex; justify-content: center; align-items: center;
    background: #ffffff; color: #000000;
}
.logo-container { position: absolute; left: 50%; transform: translateX(-50%); }
.logo-img { height: clamp(32px, 4vw, 48px); width: auto; object-fit: contain; }
.menu-btn {
    position: absolute; right: 2%; top: 50%; transform: translateY(-50%);
    font-size: clamp(24px, 3vw, 36px); border: none; background: none; color: #1e218c; cursor: pointer;
}

/* =========================================
   3. 首屏视觉 (Hero Section)
   ========================================= */
.hero-image { padding: 80px 2% 10px; box-sizing: border-box; width: 100%; overflow: hidden; aspect-ratio: 1 / 1; object-fit: cover; }
.hero-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.main-back-text { margin: 0 auto; width: 80%; text-align: center; padding: 30px; color: #000000; }
.main-back-text h1 { font-size: 36px; margin: 0; }
.main-back-text p { font-size: 18px; margin: 10px 0 0; }
@media (orientation: landscape) { .hero-image { aspect-ratio: 2.5 / 1; } }

/* =========================================
   4. 图文功能区 (Features Layout)
   ========================================= */
.feature-section { 
    color: #000000; width: 100%; margin: 0 auto; padding: 0 2%; box-sizing: border-box; overflow-x: hidden; max-width: 1920px;
}
.feature-block { 
    margin-bottom: 80px; 
    /* 确保每个block是独立的布局上下文，防止外边距塌陷导致的重叠 */
    display: flow-root; 
}

/* [关键修复] 去掉固定高度，让内容撑开 */
.feature-item {
    position: relative; 
    display: flex; 
    align-items: stretch; /* 让子元素高度一致 (封面图和文字区等高) */
    gap: 40px; 
    flex-wrap: wrap;
    width: 100%; /* 确保占满宽度 */
}

.feature-text { 
    flex: 1 1 30%; 
    min-width: 280px; 
    z-index: 1; 
    /* 让文字垂直居中 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.feature-text h2 { margin-bottom: 12px; }
.feature-text p { margin-bottom: 20px; }
.feature-item.right-img { flex-direction: row-reverse; }

.learn-more-toggle {
    color: #ffffff; padding: 10px 30px; border: 1px solid #1e218c; background: #1e218c;
    cursor: pointer; transition: background 0.3s; white-space: nowrap;
}
.learn-more-toggle:hover { background: #4a4db5; border-color: #4a4db5; }

/* =========================================
   5. 交互式相册 (修复版)
   ========================================= */

/* 封面图容器 */
.feature-img {
    flex: 1 1 55%; /* 修改比例，让图片占据稍微多一点 */
    min-width: 300px; 
    /* 移除固定 aspect-ratio，让它跟随父容器高度，或者由图片自身比例决定 */
    position: relative;
    overflow: hidden;
    border-radius: 8px; 
    background: #eee; 
    margin: 0; 
    z-index: 1;
    display: flex; /* 消除图片底部空隙 */
}

.cover-img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    display: block; 
}

/* [外壳 Wrapper]：负责全覆盖定位，但不负责滚动 */
.gallery-wrapper {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    z-index: 100; /* 覆盖一切 */
    
    background: #f5f5f5; 
    border-radius: 8px;
    
    opacity: 0; 
    pointer-events: none; /* 默认不可点 */
    transition: opacity 0.4s ease;
    
    /* 确保它作为容器裁剪溢出，防止圆角失效 */
    overflow: hidden; 
}

/* 激活状态 */
.feature-item.active .gallery-wrapper { 
    opacity: 1; 
    pointer-events: auto; 
}

/* [关闭按钮]：绝对定位在 Wrapper 上，不随 Track 滚动 */
.gallery-close-btn {
    position: absolute; 
    top: 15px; 
    right: 15px; 
    width: 36px; 
    height: 36px;
    background: rgba(0,0,0,0.5); 
    color: #fff; 
    border: none; 
    border-radius: 50%;
    font-size: 24px; 
    line-height: 1; 
    cursor: pointer; 
    z-index: 110; /* 比 track 高 */
    backdrop-filter: blur(4px); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    padding-bottom: 4px;
    transition: background 0.3s;
}
.gallery-close-btn:hover { background: rgba(0,0,0,0.8); }

/* [滚动轨道 Track]：负责横向滚动 */
.gallery-track {
    width: 100%;
    height: 100%;
    display: flex; 
    align-items: center; /* 垂直居中 */
    
    overflow-x: auto; /* 开启滚动 */
    padding-right: 0; /* 不需要额外的 padding，卡片自带 */
    
    /* 隐藏滚动条 */
    -ms-overflow-style: none; 
    scrollbar-width: none;
    
    cursor: grab;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track.grabbing { cursor: grabbing; user-select: none; }
.gallery-track img { -webkit-user-drag: none; }


/* [动画] 从右侧滑入 */
@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 单个图片卡片 */
.gallery-card {
    position: relative; 
    height: 100%; 
    flex-shrink: 0;
    border-right: 2px solid #fff; 
    box-sizing: border-box; 
    overflow: hidden;
    
    /* 默认隐藏等待动画 */
    opacity: 0;
    transform: translateX(100px);
}

.gallery-card.animate {
    animation: slideInFromRight 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* 延迟动画 */
.gallery-card.animate:nth-child(1) { animation-delay: 0.05s; }
.gallery-card.animate:nth-child(2) { animation-delay: 0.15s; }
.gallery-card.animate:nth-child(3) { animation-delay: 0.25s; }
.gallery-card.animate:nth-child(4) { animation-delay: 0.35s; }
.gallery-card.animate:nth-child(5) { animation-delay: 0.45s; }
.gallery-card.animate:nth-child(6) { animation-delay: 0.55s; }

.gallery-card img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.gallery-card:hover img { transform: scale(1.05); }

.gallery-label {
    position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px); color: #fff; padding: 4px 10px;
    font-size: 16px; font-weight: bold; border-radius: 4px; z-index: 2;
}

/* =========================================
   6. 响应式适配 (Responsive)
   ========================================= */

/* 桌面/横屏 (Landscape): 全屏并排自适应 */
@media (min-width: 769px) {
    
    /* 1. 父容器：去掉固定高度，让内容撑开，但给个最小高度 */
    .feature-item {
        height: auto; 
        min-height: 400px;
        align-items: stretch;
    }

    /* 2. 封面图区域 */
    .feature-img {
        min-height: 400px; /* 保持与整体一致 */
    }

    /* 3. 相册轨道：变为 Flex 布局，禁止滚动 */
    .gallery-track {
        display: flex;
        justify-content: space-between; /* 均匀分布 */
        gap: 8px; /* 图片之间的间隙 */
        overflow: hidden; /* 隐藏滚动条 */
        padding: 20px 40px 20px 20px; /* 调整内边距，给关闭按钮留位置 */
        cursor: default; /* 桌面端不再显示抓手图标 */
    }

    /* 4. 图片卡片：自适应宽度 */
    .gallery-card {
        width: auto; /* 覆盖原来的固定宽度 */
        flex: 1; /* 关键：所有图片平分宽度 */
        border-right: none; /* 去掉原本的分隔线，改用 gap */
        border-radius: 4px; /* 加一点圆角 */
        
        /* 保持动画逻辑不变 */
        opacity: 0;
        transform: translateX(50px); /* 桌面端位移稍微小一点 */
    }

    /* 修正图片显示，防止被压扁 */
    .gallery-card img {
        height: 100%;
        width: 100%;
        object-fit: cover;
    }
}

/* 手机/竖屏 (Portrait) - 保持不变 */
@media (max-width: 768px) {
    .feature-item { 
        flex-direction: column; gap: 20px; height: auto; 
    }
    .feature-img, .feature-text { 
        flex: 1 1 100%; width: 100%; min-height: auto; 
    }
    .feature-img { 
        aspect-ratio: 2 / 1; margin-bottom: 20px; 
    }
    
    /* 手机端保持滚动和窥视效果 */
    .gallery-card { 
        width: 85%; 
        scroll-snap-align: center; 
        border-right: 4px solid #fff;
        opacity: 1; transform: none; animation: none !important;
    }
    .gallery-track {
        scroll-snap-type: x mandatory; 
        padding-right: 0;
        gap: 0;
    }
}