/* ═══════════════════════════════════════
   ENVIR PAGE — gallery.css
   依赖：common.css / style.css（已有全局变量）
════════════════════════════════════════ */

:root {
    --card-radius: 12px;
    --card-bg:     #fff;
}

/* ═══════════════════════════════════════
   GALLERY 主区域
════════════════════════════════════════ */
#gallery {
    padding: 48px 0 80px;
    background: #f7f7f5;
    min-height: 60vh;
}

/* 卡片逐个淡入上浮（Tab 切换时 display:none→block 会触发重播）*/
@keyframes fadeUpCard {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}

.tab-pane.active .album-card {
    animation: fadeUpCard 0.32s ease both;
}

/* 每张卡片错开延迟，3列 grid 按行级联；最多 11 张（校区活动 Tab）*/
.tab-pane.active .album-card:nth-child(1)  { animation-delay:   0ms; }
.tab-pane.active .album-card:nth-child(2)  { animation-delay:  55ms; }
.tab-pane.active .album-card:nth-child(3)  { animation-delay: 110ms; }
.tab-pane.active .album-card:nth-child(4)  { animation-delay: 165ms; }
.tab-pane.active .album-card:nth-child(5)  { animation-delay: 220ms; }
.tab-pane.active .album-card:nth-child(6)  { animation-delay: 270ms; }
.tab-pane.active .album-card:nth-child(7)  { animation-delay: 315ms; }
.tab-pane.active .album-card:nth-child(8)  { animation-delay: 355ms; }
.tab-pane.active .album-card:nth-child(9)  { animation-delay: 390ms; }
.tab-pane.active .album-card:nth-child(10) { animation-delay: 420ms; }
.tab-pane.active .album-card:nth-child(11) { animation-delay: 445ms; }

/* ── 相册网格 ─────────────────────────────────────────────── */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    padding-top: 8px;
}

/* ── 相册卡片 ─────────────────────────────────────────────── */
.album-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    transition: box-shadow 0.22s ease, transform 0.22s ease;
    cursor: pointer;
}

.album-card:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    transform: translateY(-3px);
}

.album-title {
    font-size: var(--font-size-16);
    font-weight: 600;
    color: #1a1a1a;
    padding: 16px 16px 12px;
    margin: 0;
    border-bottom: 1px solid #f0f0f0;
}

/* ── 缩略图网格（最多5格：1大左+2×2右）──────────────────── */
/*
    布局：[  main  ][small1][small2]
          [  main  ][small3][small4]
    2fr 1fr 1fr，固定高度 220px
*/
.album-thumbs {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    height: 220px;
    background: #e8e8e8;
    overflow: hidden;
}

/* 无大图时（仅1张）退化为单列 */
.album-thumbs:not(:has(.thumb-main)) {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: 200px;
}

.thumb-cell {
    position: relative;
    overflow: hidden;
    background: #d8d8d8;
}

/* 大图：占左列两行 */
.thumb-cell.thumb-main {
    grid-column: 1;
    grid-row: 1 / 3;
}

.thumb-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.album-card:hover .thumb-cell img {
    transform: scale(1.04);
}

/* +N 遮罩 */
.thumb-more-mask {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.52);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: var(--font-size-22);
    font-weight: 700;
    letter-spacing: .02em;
}

.album-meta {
    font-size: var(--font-size-14);
    color: #999;
    padding: 10px 16px 14px;
    margin: 0;
}

/* ═══════════════════════════════════════
   响应式
════════════════════════════════════════ */
@media (max-width: 1024px) {
    .albums-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* #tabs sticky top 由 style.css 的 .tab-nav 全局 var(--header-height) !important 统一管理 */

/* ═══════════════════════════════════════
   Album Grid Modal（Finder 风格）
════════════════════════════════════════ */
#modal-album .modal-inner {
    background: #ebebeb;
    border-color: rgba(0,0,0,.14);
    box-shadow: 0 40px 100px rgba(0,0,0,.35);
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    width: min(940px, 100%);
    max-width: min(940px, 100%);
    min-height: 50vh;
}

#modal-album .modal-close {
    top: 6px;
    background: rgba(0,0,0,.1);
    border-color: rgba(0,0,0,.08);
    color: rgba(0,0,0,.55);
    z-index: 20;
}
#modal-album .modal-close:hover {
    background: rgba(0,0,0,.18);
    border-color: rgba(0,0,0,.14);
    color: rgba(0,0,0,.8);
}

.am-titlebar {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 16px 56px 15px 22px;
    border-bottom: 1px solid rgba(0,0,0,.1);
    background: #e6e6e6;
    flex-shrink: 0;
}

.am-title {
    min-width: 0;
    font-size: var(--font-size-16);
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.am-count {
    flex-shrink: 0;
    font-size: var(--font-size-14);
    color: #999;
    white-space: nowrap;
}

.am-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    align-content: start;
    background: #f5f5f5;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.18) transparent;
}
.am-grid::-webkit-scrollbar { width: 6px; }
.am-grid::-webkit-scrollbar-track { background: transparent; }
.am-grid::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 3px; }

.am-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 7px 6px 6px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: background 0.14s, border-color 0.14s;
    user-select: none;
    -webkit-user-select: none;
}

.am-item:hover {
    background: rgba(0, 102, 204, 0.1);
    border-color: rgba(0, 102, 204, 0.25);
}

.am-item:active {
    background: rgba(0, 102, 204, 0.18);
}

.am-thumb-wrap {
    width: 100%;
    aspect-ratio: 3 / 2;
    border-radius: 6px;
    overflow: hidden;
    background: #ccc;
    box-shadow: 0 1px 4px rgba(0,0,0,.14), inset 0 0 0 1px rgba(0,0,0,.06);
    flex-shrink: 0;
    display: flex;
}

.am-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.2s ease;
}

.am-item:hover .am-thumb {
    transform: scale(1.04);
}

.am-name {
    font-size: var(--font-size-14);
    color: #333;
    text-align: center;
    line-height: 1.4;
    word-break: break-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
}

/* ═══════════════════════════════════════
   响应式
════════════════════════════════════════ */
@media (max-width: 768px) {
    .tab-btn {
        padding: 16px 22px 14px;
        font-size: var(--font-size-16);
    }

    .tab-btn.active::after {
        left: 14px;
        right: 14px;
    }

    #gallery { padding: 28px 0 60px; }

    .albums-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Album modal 移动端 */
    #modal-album .modal-inner {
        overflow-y: hidden;
    }

    .am-titlebar {
        min-height: 52px;
        align-items: center;
        background: #e6e6e6;
        padding-top: 12px;
        padding-right: 64px;
        padding-bottom: 12px;
        padding-left: 18px;
        border-bottom: 1px solid rgba(0,0,0,.1);
    }

    #modal-album .modal-close {
        position: absolute;
        top: 8px;
        right: 12px;
        margin: 0;
        margin-bottom: 0;
        width: 36px;
        height: 36px;
    }

    .am-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 14px;
    }

    .am-title  { font-size: var(--font-size-14); }
    .am-count  { font-size: var(--font-size-14); }
    .am-name   { font-size: var(--font-size-14); }
}

@media (max-width: 768px) {
    #gallery {
        padding: 34px 0 58px;
    }

    .albums-grid{
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .album-card{
        border-radius: 14px;
        overflow: hidden;
    }

    .album-card img{
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
        object-fit: cover;
    }
}
