/* ==========================================================================
   Gallery Template - Typecho 洪墨时光风格图集
   整合到 Halo THYUU/星度主题
   ========================================================================== */

/* CSS 变量 - 图集专用 */
.gallery-template {
    --gallery-gap: 0px;
    --gallery-card-height: 280px;
    --gallery-card-height-sm: 200px;
    --gallery-overlay: rgba(0, 0, 0, 0.5);
    --gallery-overlay-hover: rgba(0, 0, 0, 0.3);
    --gallery-border-radius: 0px;
    --gallery-title-color: #fff;
    --gallery-meta-color: rgba(255, 255, 255, 0.75);
    --gallery-nav-dot: rgba(255, 255, 255, 0.4);
    --gallery-nav-dot-active: #fff;
    --gallery-bg: transparent;
    --gallery-transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 暗色模式适配 */
[theme="dark"] .gallery-template {
    --gallery-overlay: rgba(0, 0, 0, 0.6);
    --gallery-overlay-hover: rgba(0, 0, 0, 0.4);
    --gallery-title-color: #f0f0f0;
    --gallery-meta-color: rgba(240, 240, 240, 0.7);
    --gallery-nav-dot: rgba(255, 255, 255, 0.35);
    --gallery-nav-dot-active: #fff;
}

/* ==========================================================================
   全屏网格布局 (Grid Gallery)
   响应式: 4列 -> 3列 -> 2列 -> 1列
   ========================================================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gallery-gap);
    padding: 0;
    margin: 0;
    list-style: none;
    width: 100%;
}

/* 响应式列数调整 */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .gallery-template {
        --gallery-card-height: 220px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    .gallery-template {
        --gallery-card-height: 280px;
    }
}

/* ==========================================================================
   图集卡片 (Gallery Card)
   ========================================================================== */

.gallery-card {
    position: relative;
    height: var(--gallery-card-height);
    overflow: hidden;
    cursor: pointer;
    background: var(--thyuu--card-bg, #f0f0f0);
}

[theme="dark"] .gallery-card {
    background: var(--thyuu--card-bg-dark, #1a1a2e);
}

.gallery-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--gallery-transition);
    will-change: transform;
}

/* 图片懒加载占位 */
.gallery-card-image.lazyload {
    opacity: 0;
}

.gallery-card-image.lazyloaded,
.gallery-card-image.loaded {
    opacity: 1;
    transition: opacity 0.4s ease, transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 卡片悬浮效果 */
.gallery-card:hover .gallery-card-image {
    transform: scale(1.05);
}

/* 卡片遮罩层 */
.gallery-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to top,
        var(--gallery-overlay) 0%,
        rgba(0, 0, 0, 0) 50%,
        rgba(0, 0, 0, 0) 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.2rem;
    opacity: 0;
    transition: var(--gallery-transition);
    pointer-events: none;
}

.gallery-card:hover .gallery-card-overlay {
    opacity: 1;
}

/* 卡片标题 */
.gallery-card-title {
    color: var(--gallery-title-color);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.35rem 0;
    line-height: 1.4;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* 卡片元信息 */
.gallery-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.gallery-card-meta-item {
    color: var(--gallery-meta-color);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.gallery-card-meta-item i {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* 卡片图片数量角标 */
.gallery-card-count {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: var(--gallery-overlay);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 2px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: var(--gallery-transition);
}

.gallery-card:hover .gallery-card-count {
    opacity: 1;
}

/* ==========================================================================
   圆点导航 (Breadcrumb Dots) - 多图切换
   ========================================================================== */

.gallery-dot-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 0.5rem;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gallery-nav-dot);
    cursor: pointer;
    transition: var(--gallery-transition);
    border: none;
    padding: 0;
}

.gallery-dot:hover {
    background: var(--gallery-nav-dot-active);
    transform: scale(1.3);
}

.gallery-dot.active {
    background: var(--gallery-nav-dot-active);
    transform: scale(1.2);
}

/* ==========================================================================
   分组导航栏
   ========================================================================== */

.gallery-template .page-header {
    padding: 2rem 0 1.5rem;
    text-align: center;
}

.gallery-template .page-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--thyuu--main-text, #222);
}

[theme="dark"] .gallery-template .page-title {
    color: var(--thyuu--main-text-dark, #f0f0f0);
}

.gallery-template .page-description {
    font-size: 0.85rem;
    color: var(--thyuu--sec-text, #999);
    margin: 0;
}

[theme="dark"] .gallery-template .page-description {
    color: var(--thyuu--sec-text-dark, #888);
}

.gallery-template .taxonomy-nav {
    margin-bottom: 1.5rem;
}

.gallery-template .taxonomy-sub {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    justify-content: center;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.gallery-template .taxonomy-sub li.button {
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--gallery-transition);
    white-space: nowrap;
    background: var(--thyuu--card-bg, #f5f5f5);
    color: var(--thyuu--sec-text, #666);
    border: 1px solid transparent;
}

[theme="dark"] .gallery-template .taxonomy-sub li.button {
    background: var(--thyuu--card-bg-dark, #2a2a3e);
    color: var(--thyuu--sec-text-dark, #aaa);
}

.gallery-template .taxonomy-sub li.button:hover {
    border-color: var(--thyuu--theme-color, #4a90d9);
    color: var(--thyuu--theme-color, #4a90d9);
}

.gallery-template .taxonomy-sub li.button.current-cat {
    background: var(--thyuu--theme-color, #4a90d9);
    color: #fff;
}

.gallery-template .taxonomy-sub li.button i {
    font-style: normal;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 0.2rem;
}

/* ==========================================================================
   Fancybox 灯箱增强 - 适配图集风格
   ========================================================================== */

/* Fancybox 底部信息栏 */
.fancybox__caption__body {
    text-align: center;
}

.fancybox__caption__body .gallery-caption-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.3rem;
}

.fancybox__caption__body .gallery-caption-meta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Fancybox 圆点导航 */
.fancybox__caption__body .gallery-dot-nav {
    justify-content: center;
    margin-top: 0.6rem;
}

/* ==========================================================================
   加载占位动画
   ========================================================================== */

.gallery-loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--gallery-card-height);
    background: var(--thyuu--card-bg, #f0f0f0);
}

[theme="dark"] .gallery-loading-placeholder {
    background: var(--thyuu--card-bg-dark, #1a1a2e);
}

.gallery-loading-placeholder::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 2px solid var(--thyuu--theme-color, #4a90d9);
    border-top-color: transparent;
    border-radius: 50%;
    animation: gallery-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   空状态
   ========================================================================== */

.gallery-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--thyuu--sec-text, #999);
}

[theme="dark"] .gallery-empty {
    color: var(--thyuu--sec-text-dark, #888);
}

.gallery-empty i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
    display: block;
}

.gallery-empty p {
    font-size: 0.9rem;
    margin: 0;
}

/* ==========================================================================
   全宽布局 - 去掉页面边距
   ========================================================================== */

.gallery-template.wide-page #page {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
}

.gallery-template.wide-page .site-main {
    padding: 0;
}

.gallery-template.wide-page #main-content {
    padding: 0;
}

/* ==========================================================================
   分页样式增强
   ========================================================================== */

.gallery-template .page-navigation {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.gallery-template .page-navigation .button {
    min-width: 100px;
}

.gallery-template .page-navigation .page-numbers {
    transition: var(--gallery-transition);
}

/* ==========================================================================
   动画 - 入场效果
   ========================================================================== */

.gallery-card {
    animation: gallery-fade-in 0.5s ease-out both;
}

.gallery-card:nth-child(1) { animation-delay: 0.05s; }
.gallery-card:nth-child(2) { animation-delay: 0.1s; }
.gallery-card:nth-child(3) { animation-delay: 0.15s; }
.gallery-card:nth-child(4) { animation-delay: 0.2s; }
.gallery-card:nth-child(5) { animation-delay: 0.25s; }
.gallery-card:nth-child(6) { animation-delay: 0.3s; }
.gallery-card:nth-child(7) { animation-delay: 0.35s; }
.gallery-card:nth-child(8) { animation-delay: 0.4s; }
.gallery-card:nth-child(9) { animation-delay: 0.45s; }
.gallery-card:nth-child(10) { animation-delay: 0.5s; }
.gallery-card:nth-child(11) { animation-delay: 0.55s; }
.gallery-card:nth-child(12) { animation-delay: 0.6s; }

@keyframes gallery-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 尊重用户动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .gallery-card,
    .gallery-card-image,
    .gallery-card-overlay,
    .gallery-dot,
    .gallery-template .taxonomy-sub li.button {
        animation: none !important;
        transition: none !important;
    }
}
