/* ============================================================
   assets/css/gallery.css
   ギャラリーセクション・Justified Grid・ライトボックス
   ============================================================ */

/* ============================================================
   ギャラリーコンテナ
   ============================================================ */

.gallery-section {
    padding: var(--space-10) 0;
}

/* Justified Galleryの初期状態対応 */
#gallery-grid {
    width: 100%;
    /* JustifiedGalleryが適用されるまでの最小高さ */
    min-height: 200px;
}

/* JustifiedGalleryライブラリが生成するラッパー */
.gallery-grid-item {
    overflow: hidden;
    cursor: zoom-in;
    display: block;
}

.gallery-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow), opacity var(--transition-base);
}

.gallery-grid-item:hover img {
    transform: scale(1.04);
    opacity: 0.92;
}

/* キャプションオーバーレイ */
.jg-caption {
    background-color: rgba(44, 44, 44, 0.85) !important;
    color: var(--color-base) !important;
    font-size: var(--font-size-xs) !important;
    font-family: var(--font-sans) !important;
    padding: var(--space-2) var(--space-3) !important;
    line-height: var(--line-height-base) !important;
}

/* ============================================================
   ライトボックス（カスタム実装）
   ============================================================ */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    touch-action: none;
}

.lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

/* ライトボックス画像コンテナ */
.lightbox__image-wrap {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox__image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    display: block;
    border-radius: var(--radius-sm);
    transition: opacity var(--transition-fast);
}

.lightbox__image.is-loading {
    opacity: 0;
}

/* キャプション */
.lightbox__caption {
    position: absolute;
    bottom: -2rem;
    left: 0;
    right: 0;
    text-align: center;
    font-size: var(--font-size-xs);
    color: rgba(250, 250, 250, 0.6);
    letter-spacing: 0.04em;
}

/* 閉じるボタン */
.lightbox__close {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(250, 250, 250, 0.7);
    cursor: pointer;
    z-index: 1001;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.lightbox__close:hover {
    color: var(--color-white);
    opacity: 1;
}

.lightbox__close svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

/* 前後ナビゲーション */
.lightbox__nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(250, 250, 250, 0.7);
    cursor: pointer;
    z-index: 1001;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.lightbox__nav:hover {
    color: var(--color-white);
    opacity: 1;
}

.lightbox__nav svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

.lightbox__nav--prev { left: var(--space-4); }
.lightbox__nav--next { right: var(--space-4); }

/* カウンター */
.lightbox__counter {
    position: fixed;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-xs);
    color: rgba(250, 250, 250, 0.5);
    letter-spacing: 0.06em;
}

/* ローディングスピナー */
.lightbox__spinner {
    position: absolute;
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: lightbox-spin 0.7s linear infinite;
}

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

/* ============================================================
   ギャラリーフィルタータブ
   ============================================================ */

.gallery-filter {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: var(--border-width) solid var(--color-border);
    margin-bottom: var(--space-8);
}
.gallery-filter::-webkit-scrollbar { display: none; }

.gallery-filter__btn {
    flex-shrink: 0;
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wide);
    color: var(--color-text-lighter);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    min-height: 44px;
    margin-bottom: -1px;
}

.gallery-filter__btn:hover { color: var(--color-text); }

.gallery-filter__btn.is-active {
    color: var(--color-text);
    border-bottom-color: var(--color-text);
    font-weight: 500;
}
