/* =========================
   画廊页面（gallery.html）
   面板风格与站内其它面板保持一致：
   90% 透明度的白色背景、圆角矩形、细边框、柔和投影
   ========================= */

/* 背景图铺满整个视口，画廊在它上面滚动 */
body.gallery-page .hero {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 0;
}

/* 内容区：顶部留出导航栏的高度 */
.gallery-main {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 108px 3vw 90px;
}

/* 画廊面板（不限宽度） */
.gallery-panel {
    width: 100%;
    padding: 28px clamp(14px, 2.2vw, 40px) 38px;
    background: rgba(255, 255, 255, 0.9);
    color: #242020;
    border: 1px solid #ddd;
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.gallery-head {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px 20px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.gallery-title {
    font-size: clamp(26px, 3vw, 40px);
    font-weight: normal;
    letter-spacing: 2px;
    line-height: 1.3;
}

.gallery-hint {
    font-size: 15px;
    line-height: 1.6;
    color: rgba(36, 32, 32, 0.6);
    text-align: right;
}

/* =========================
   Pinterest 风格瀑布流
   ========================= */
.gallery-board {
    --gallery-gap: 18px;

    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--gallery-gap);
    width: 100%;

    /* 排布时卡片会换列，关掉滚动锚定，免得浏览器把页面滚回别处 */
    overflow-anchor: none;
}

.gallery-col {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: var(--gallery-gap);
    min-width: 0;
    overflow-anchor: none;
}

.gallery-card {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    font: inherit;
    color: inherit;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: zoom-in;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
    transition:
        box-shadow 0.35s ease,
        border-color 0.35s ease;
}

.gallery-card img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 电脑端：鼠标经过时卡片浮起、阴影加深，鼠标所在的角落被按下去（倾斜由 JS 驱动） */
@media (hover: hover) and (pointer: fine) {
    .gallery-card:hover {
        z-index: 5;
        border-color: rgba(0, 0, 0, 0.14);
        box-shadow:
            0 26px 50px rgba(0, 0, 0, 0.28),
            0 10px 20px rgba(0, 0, 0, 0.16);
    }

    .gallery-card:hover img {
        transform: scale(1.05);
    }

    .gallery-card:focus-visible img {
        transform: scale(1.05);
    }
}

.gallery-card:focus-visible {
    z-index: 5;
    outline: 2px solid rgba(44, 102, 197, 0.55);
    outline-offset: 2px;
}

/* 加载 / 空状态提示 */
.gallery-state {
    margin-top: 26px;
    font-size: 17px;
    text-align: center;
    color: rgba(36, 32, 32, 0.65);
}

.gallery-state.hidden {
    display: none;
}

/* =========================
   点击放大查看
   ========================= */
body.viewer-open {
    overflow: hidden;
}

.gallery-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;

    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5vh 4vw;

    background: rgba(0, 0, 0, 0.72);

    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.28s ease,
        visibility 0.28s;
}

.gallery-viewer.open {
    opacity: 1;
    visibility: visible;
}

/* 未打开时完全不占位 */
.gallery-viewer[hidden] {
    display: none;
}

.gallery-viewer-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.96);
    transition: transform 0.28s ease;
}

.gallery-viewer.open .gallery-viewer-image {
    transform: scale(1);
}

/* 圆形按钮：与导航栏按钮同一套配色 */
.viewer-btn {
    position: fixed;
    display: flex;
    justify-content: center;
    align-items: center;

    width: 56px;
    height: 56px;
    padding: 0;

    border: 1px solid #ddd;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

    cursor: pointer;
    transition: transform 0.3s ease;
}

.viewer-btn:hover {
    transform: scale(1.1);
}

.viewer-btn[hidden] {
    display: none;
}

.viewer-btn svg {
    width: 26px;
    height: 26px;
}

#viewerClose {
    top: 24px;
    right: 24px;
}

.viewer-btn-side {
    top: 50%;
    margin-top: -28px;
}

.viewer-btn-prev {
    left: 24px;
}

.viewer-btn-next {
    right: 24px;
}

.viewer-counter {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);

    padding: 7px 18px;

    font-size: 15px;
    letter-spacing: 1px;
    color: #242020;

    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* =========================
   手机端
   ========================= */
@media (max-width: 768px) {
    .gallery-main {
        padding: 100px 12px 100px;
    }

    .gallery-panel {
        padding: 20px 12px 26px;
        border-radius: 18px;
    }

    .gallery-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 18px;
    }

    .gallery-hint {
        font-size: 13px;
        text-align: left;
    }

    .gallery-board {
        --gallery-gap: 10px;
    }

    .gallery-card {
        border-radius: 12px;
    }

    /* 手机端不用悬停放大，改由点击查看大图 */
    .gallery-card:hover img,
    .gallery-card:focus-visible img {
        transform: none;
    }

    .viewer-btn {
        width: 46px;
        height: 46px;
    }

    .viewer-btn svg {
        width: 22px;
        height: 22px;
    }

    #viewerClose {
        top: 14px;
        right: 14px;
    }

    .viewer-btn-side {
        margin-top: -23px;
    }

    .viewer-btn-prev {
        left: 8px;
    }

    .viewer-btn-next {
        right: 8px;
    }

    .viewer-counter {
        bottom: 16px;
        padding: 6px 14px;
        font-size: 14px;
    }
}
