/* --- 全局变量与重置 --- */
:root {
    --bg-color: #0f0f0f;
    --card-bg: #1a1a1a;
    --card-hover: #252525;
    --text-main: #f0f0f0;
    --text-muted: #888888;
    --accent: #d4af37;
    --accent-glow: rgba(212, 175, 55, 0.2);
    --border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Lato', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    /* 防止滚动时抖动 */
    padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, .serif { font-family: 'Playfair Display', serif; }
a { text-decoration: none; color: inherit; transition: var(--transition); }
button { border: none; background: none; cursor: pointer; font-family: inherit; }

/* --- 布局容器 --- */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 40px 20px 100px;
    /* 确保sticky子元素正常工作 */
    width: 100%;
}

/* --- 头部设计 --- */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 10px;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: -1px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 25px;
    font-weight: 300;
}

.nav-links {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: var(--transition);
    background: rgba(255,255,255,0.02);
}

.nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(212, 175, 55, 0.05);
}

/* --- 控制面板 (磨砂玻璃优化) --- */
.controls-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000; /* 提高层级 */
    padding: 12px 0;
    /* 优化：降低不透明度以增强模糊可见度，增加饱和度提升质感 */
    background: rgba(15, 15, 15, 0.50);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2); /* 微调边框颜色 */
    box-shadow: 0 4px 20px rgba(0,0,0,0.2); /* 增加阴影提升层次感 */
    margin-bottom: 30px;
    /* 防止iOS Safari滚动回弹效果导致的穿透问题 */
    transform: translateZ(0); 
}

.controls-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 10px; /* 防止小屏幕贴边 */
}

/* 搜索框 */
.search-box {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-box input {
    width: 100%;
    padding: 12px 45px 12px 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: white;
    font-size: 0.95rem;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--accent);
    background: rgba(0,0,0,0.4);
}

.search-icon {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.9rem;
}

/* 分类标签 */
.filter-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-tab {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.filter-tab.active {
    color: #000;
    background: var(--accent);
    font-weight: 700;
}

/* =========================================
   核心：布局系统 (Grid vs Masonry)
   ========================================= */

.gallery-grid {
    min-height: 50vh;
}

/* --- 1. 网格布局 (搜索结果、分类页) --- */
.gallery-grid.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.mode-grid .art-card {
    display: flex;
    flex-direction: column;
}

.mode-grid .img-wrapper {
    height: 200px; /* 固定高度 */
    flex-shrink: 0;
    overflow: hidden;
}

.mode-grid .art-card img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 裁剪填满 */
    transition: transform 0.6s ease;
}

/* --- 2. 瀑布流布局 (首页全部作品) --- */
.gallery-grid.mode-masonry {
    column-count: 5; /* 桌面端5列 */
    column-gap: 25px;
}

.mode-masonry .art-card {
    break-inside: avoid; /* 防止卡片被列断开 */
    margin-bottom: 25px; /* 底部间距 */
    display: inline-block; 
    width: 100%;
}

.mode-masonry .img-wrapper {
    height: auto; /* 高度自适应 */
    width: 100%;
    overflow: hidden;
}

.mode-masonry .art-card img {
    width: 100%;
    height: auto; /* 图片原始高度 */
    display: block; /* 关键：消除图片底部间隙 */
    transition: transform 0.6s ease;
}

/* --- 通用卡片样式 --- */
.art-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden; /* 确保圆角内的图片不溢出 */
}

.art-card:hover {
    transform: translateY(-5px);
    background: var(--card-hover);
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    z-index: 2;
}

.img-wrapper::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.art-card:hover .img-wrapper::after { opacity: 1; }
.art-card:hover img { transform: scale(1.05); }

.card-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-title {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 5px;
    font-weight: 400;
    line-height: 1.3;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- 分类标题 --- */
.section-header {
    grid-column: 1 / -1; 
    column-span: all;
    margin: 40px 0 20px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: 15px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    width: 100%; 
    break-inside: avoid;
}

.section-header h2 {
    font-size: 1.4rem;
    color: var(--accent);
}

.section-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- 状态提示 --- */
.status-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
    column-span: all;
    font-size: 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    width: 100%;
    break-inside: avoid;
}

/* --- 模态框 --- */
.modal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;

}
.modal-backdrop {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.50); backdrop-filter: blur(20px);
}
.modal.active { opacity: 1; pointer-events: auto; }

.modal-content {
    position: relative; width: 100%; max-width: 1100px; height: 90vh;
    background: transparent; display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 1001;
    padding: 20px; overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.modal-content::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
.close-modal {
    position: fixed; top: 20px; right: 20px; font-size: 36px;
    color: rgba(255,255,255,0.5); z-index: 1002;
}
.modal-image-container {
    max-height: 60vh; overflow: hidden; border-radius: 4px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); cursor: zoom-in;
    margin-bottom: 20px;
}
.modal-img { max-width: 100%; max-height: 60vh; object-fit: contain; display: block; }
.modal-controls { display: flex; justify-content: center; width: 100%; }
.btn-reveal {
    background: transparent; border: 1px solid var(--accent);
    color: var(--accent); padding: 10px 30px; font-size: 0.9rem;
    border-radius: 50px; display: flex; align-items: center; gap: 8px;
}
.modal-details {
    max-width: 800px; width: 100%; text-align: left;
    background: rgba(30, 30, 30, 0.6); border-radius: 8px;
    padding: 0; margin-top: 20px; max-height: 0; overflow: hidden;
    opacity: 0; border-left: 2px solid var(--accent);
    transition: max-height 0.5s ease, opacity 0.3s ease;
}
.modal-details.open { max-height: 60vh; opacity: 1; padding: 20px; overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.modal-details.open::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
.detail-title { font-size: 1.5rem; color: var(--accent); margin-bottom: 15px; }
.detail-tags { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; color: #ccc; margin-bottom: 15px; }
.tag-item b { color: var(--text-main); margin-right: 4px; }
.detail-desc { font-size: 0.95rem; line-height: 1.7; color: #ddd; }

/* --- 全屏覆盖层 --- */
.fullscreen-viewer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; z-index: 2000; display: none;
    justify-content: center; align-items: center;
}
.fullscreen-viewer.active { display: flex; }
.fullscreen-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* =========================================
   响应式适配 (重点优化移动端瀑布流)
   ========================================= */

/* 平板尺寸 */
@media (max-width: 1200px) {
    .mode-masonry { column-count: 4; }
}
@media (max-width: 900px) {
    .mode-masonry { column-count: 3; }
}

/* 手机横屏/小平板 */
@media (max-width: 768px) {
    .container { padding: 30px 15px 80px; }
    h1 { font-size: 2.2rem; }
    
    /* Grid: 2列 */
    .mode-grid { grid-template-columns: repeat(2, 1fr); gap: 15px; }
    .mode-grid .img-wrapper { height: 160px; }
    
    /* Masonry: 2列，保持瀑布流感 */
    .mode-masonry { column-count: 2; column-gap: 15px; }
    .mode-masonry .art-card { margin-bottom: 15px; }
    
    .modal-content { height: 100vh; padding: 10px; }
    .modal-image-container { max-height: 45vh; }
    .modal-img { max-height: 45vh; }
    
    /* 移动端菜单优化 */
    .controls-wrapper {
        padding: 8px 0;
    }
    .controls-inner { gap: 8px; }
}

/* 手机竖屏 (核心优化) */
@media (max-width: 480px) {
    .container { padding: 20px 10px 80px; }
    
    /* Grid: 1列 (搜索结果单列更易读) */
    .mode-grid { grid-template-columns: 1fr; gap: 20px; }
    .mode-grid .img-wrapper { height: 220px; }
    
    /* Masonry: 2列 (移动端保留2列才有瀑布流效果，1列变成列表) */
    .mode-masonry { 
        column-count: 2; 
        column-gap: 10px; /* 缩小间距 */
    }
    .mode-masonry .art-card { 
        margin-bottom: 10px; 
    }
    
    /* 字体与内边距微调 */
    .card-info { padding: 10px; }
    .card-title { font-size: 0.95rem; line-height: 1.4; }
    .card-meta { font-size: 0.7rem; flex-direction: column; align-items: flex-start; gap: 2px; }
    
    .filter-tabs { gap: 5px; }
    .filter-tab { padding: 4px 12px; font-size: 0.75rem; }
    
    .modal-details.open { padding: 15px; }
    .detail-title { font-size: 1.3rem; }
}
