/* =========================
   ギャラリー
========================= */

.gallery {
    display: block;
    padding: 28px 30px 40px;
}


/* =========================
   ブログカード
========================= */

.gallery-article {
    max-width: 1180px;

    margin:
        0
        auto
        28px;

    padding: 20px;

    background:
        var(--ui-panel-bg);

    border:
        1px solid
        var(--ui-panel-border);

    border-radius:
        var(--ui-panel-radius);

    box-shadow:
        var(--ui-panel-shadow);
}

.gallery-article:last-child {
    margin-bottom: 0;
}


/* =========================
   ブログ日付
========================= */

.gallery-article-meta-row {
    display: flex;

    align-items: center;

    gap: 6px;

    margin-bottom: 10px;
}

.gallery-article-date {
    display: inline-flex;

    align-items: center;

    padding:
        4px
        9px;

    border-radius:
        var(--ui-radius-round);

    background:
        var(--ui-bg-subtle);

    color:
        var(--ui-text-muted);

    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;

    letter-spacing: 0.03em;
}


/* =========================
   ブログタイトル
========================= */

.gallery-article-title {
    position: relative;

    display: block;

    width: 100%;

    margin:
        0
        0
        18px;

    padding:
        0
        34px
        0
        14px;

    border: none;

    border-left:
        3px solid
        var(--member-icon-color);

    background: transparent;
    color: #222;

    font: inherit;

    font-size: 19px;
    font-weight: 700;
    line-height: 1.55;

    text-align: left;

    cursor: pointer;
}

.gallery-article-title > .ui-icon {
    position: absolute;

    top: 50%;
    right: 4px;

    transform:
        translateY(
            -50%
        );

    color: #aaa;

    transition:
        color 0.2s ease;
}

.gallery-article-title:hover > .ui-icon {
    color: #555;
}

.gallery-article-title:hover {
    color: #000;
}

/* =========================
   ブログ画像
========================= */

.gallery-article-images {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(
                180px,
                1fr
            )
        );

    gap: 10px;
}


/* =========================
   画像カード
========================= */

.gallery-item {
    position: relative;

    display: block;

    aspect-ratio: 1 / 1;

    overflow: hidden;

    padding: 0;

    border: none;
    border-radius: 12px;

    background: #f3f3f3;

    cursor: pointer;

    box-shadow: none;

    transition:
        transform 0.2s ease,
        opacity 0.2s ease,
        box-shadow 0.2s ease;
}

.gallery-item:hover {
    box-shadow:
        0 6px 18px
        rgba(0, 0, 0, 0.10);

    transform:
        translateY(
            -2px
        );
}

.gallery-item img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    transition:
        transform 0.25s ease;
}

.gallery-item:hover img {
    transform:
        scale(
            1.025
        );
}

.gallery-article-images-link > .ui-icon,
.gallery-article-read-link > .ui-icon {
    margin-left: 3px;
}

/* =========================
   全画像を見る
========================= */

.gallery-article-images-link {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    gap: 3px;

    margin-top: 14px;

    padding:
        7px
        11px;

    border:
        1px solid
        var(--ui-border);

    border-radius:
        var(--ui-radius-md);

    background:
        var(--ui-bg-subtle);

    color:
        var(--ui-text-secondary);

    font: inherit;

    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;

    cursor: pointer;

    transition:
        color var(--ui-transition-fast),
        background var(--ui-transition-fast),
        border-color var(--ui-transition-fast),
        transform var(--ui-transition-fast);
}

.gallery-article-images-link:hover {
    color:
        var(--member-icon-color);

    background:
        var(--ui-bg);

    border-color:
        var(--member-icon-color);

    transform:
        translateY(-1px);
}


/* =========================
   本文プレビュー
========================= */

.gallery-article-preview {
    margin:
        0
        0
        14px;

    color: #555;

    font-size: 14px;
    line-height: 1.8;
}


/* =========================
   ブログを読む
========================= */

.gallery-article-read-link {
    display: inline-flex;

    align-items: center;

    padding: 0;

    border: none;

    background: transparent;

    color: #333;

    font: inherit;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition:
        color var(--ui-transition-fast);
}

.gallery-article-read-link:hover {
    color:
        var(--member-icon-color);
}


/* =========================
   拡大表示（ライトボックス）
========================= */

.lightbox {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: none;

    align-items: center;
    justify-content: center;

    padding:
        24px
        88px;

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

    backdrop-filter:
        blur(
            6px
        );

    -webkit-backdrop-filter:
        blur(
            6px
        );

    /*
     * ライトボックス外へ
     * スクロールを伝播させない
     */
    overscroll-behavior: contain;
}

.lightbox.active {
    display: flex;
}


/* =========================
   ライトボックス中央
========================= */

.lightbox-content {
    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    min-width: 0;
}


/* =========================
   メイン画像
========================= */

.lightbox-image {
    position: relative;

    z-index: 2;

    display: block;

    width: auto;
    height: auto;

    max-width: 100%;

    max-height:
        calc(
            100vh -
            190px
        );

    object-fit: contain;


    /*
     * ========================================
     * 画像選択・ドラッグ抑止
     * ========================================
     */

    user-select: none;
    -webkit-user-select: none;

    -webkit-user-drag: none;

    -webkit-touch-callout: none;


    /*
     * ========================================
     * タッチ操作
     *
     * 1本指スワイプ・ドラッグと
     * 2本指ピンチズームを
     * lightbox.js 側で制御する
     * ========================================
     */

    touch-action: none;

    transform-origin: center center;

    will-change: transform;


    border-radius: 6px;

    box-shadow:
        0 12px 50px
        rgba(
            0,
            0,
            0,
            0.45
        );
}

.lightbox-image.zoomed {
    cursor: grab;
}

.lightbox-image.zoomed.dragging {
    cursor: grabbing;
}


/* =========================
   枚数表示
========================= */

.image-counter {
    flex-shrink: 0;

    margin-top: 10px;

    padding:
        5px
        12px;

    border-radius: 999px;

    background:
        rgba(
            255,
            255,
            255,
            0.10
        );

    color: #fff;

    font-size: 13px;
    font-weight: 600;

    line-height: 1.4;

    letter-spacing: 0.03em;


    /*
     * スワイプ中の文字選択防止
     */

    user-select: none;
    -webkit-user-select: none;
}


/* =========================
   サムネイル一覧
========================= */

.lightbox-thumbnails {
    position: relative;

    z-index: 1;

    display: flex;

    align-items: center;

    gap: 8px;

    width: 100%;

    max-width: 760px;

    margin-top: 10px;

    padding:
        4px
        2px;

    overflow-x: auto;
    overflow-y: hidden;

    scroll-behavior: smooth;

    scrollbar-width: thin;

    overscroll-behavior-x: contain;


    /*
     * ========================================
     * サムネイル側は
     * 横スクロールを優先
     * ========================================
     */

    touch-action: pan-x;

    -webkit-overflow-scrolling: touch;
}


/* =========================
   サムネイル
========================= */

.lightbox-thumbnail {
    flex:
        0
        0
        58px;

    width: 58px;
    height: 58px;

    padding: 2px;

    overflow: hidden;

    border:
        2px solid
        transparent;

    border-radius: 8px;

    background:
        rgba(
            255,
            255,
            255,
            0.08
        );

    opacity: 0.55;

    cursor: pointer;

    transition:
        opacity 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease,
        background 0.2s ease;


    /*
     * 画像選択防止
     */

    user-select: none;
    -webkit-user-select: none;

    -webkit-touch-callout: none;
}

.lightbox-thumbnail:hover {
    opacity: 0.9;

    transform:
        translateY(
            -1px
        );
}

.lightbox-thumbnail.active {
    border-color: #fff;

    background:
        rgba(
            255,
            255,
            255,
            0.16
        );

    opacity: 1;
}

.lightbox-thumbnail img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    border-radius: 5px;

    pointer-events: none;


    /*
     * ========================================
     * 画像選択・ドラッグ抑止
     * ========================================
     */

    user-select: none;
    -webkit-user-select: none;

    -webkit-user-drag: none;

    -webkit-touch-callout: none;
}


/* =========================
   閉じるボタン
========================= */

.close-button {
    position: absolute;

    top: 18px;
    right: 20px;

    z-index: 1002;

    display: flex;

    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;

    padding: 0;

    border: none;
    border-radius: 50%;

    background:
        rgba(
            255,
            255,
            255,
            0.12
        );

    color: #fff;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.2s ease;

    user-select: none;
    -webkit-user-select: none;

    -webkit-tap-highlight-color: transparent;
}

.close-button:hover {
    background:
        rgba(
            255,
            255,
            255,
            0.22
        );

    transform:
        scale(
            1.04
        );
}


/* =========================
   前へ・次へ
========================= */

.nav-button {
    position: absolute;

    top: 50%;

    z-index: 1001;

    transform:
        translateY(
            -50%
        );

    display: flex;

    align-items: center;
    justify-content: center;

    width: 48px;
    height: 48px;

    padding: 0;

    border: none;
    border-radius: 50%;

    background:
        rgba(
            255,
            255,
            255,
            0.12
        );

    color: #fff;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.2s ease;

    user-select: none;
    -webkit-user-select: none;

    -webkit-tap-highlight-color: transparent;
}

.nav-button:hover {
    background:
        rgba(
            255,
            255,
            255,
            0.24
        );

    transform:
        translateY(
            -50%
        )
        scale(
            1.05
        );
}

.prev-button {
    left: 22px;
}

.next-button {
    right: 22px;
}


/* =========================
   PC
========================= */

@media (min-width: 1200px) {

    .gallery-article-images {
        grid-template-columns:
            repeat(
                5,
                1fr
            );
    }
}


/* =========================
   タブレット
========================= */

@media (
    min-width: 768px
) and (
    max-width: 1023px
) {

    .gallery {
        padding:
            24px
            20px
            36px;
    }

    .gallery-article-images {
        grid-template-columns:
            repeat(
                4,
                1fr
            );
    }
}


/* =========================
   スマホ
========================= */

@media (max-width: 767px) {

    .gallery {
        padding:
            10px
            8px
            28px;
    }

    .gallery-article {
        margin-bottom: 14px;

        padding:
            16px
            12px;

        border-radius: 14px;

        box-shadow:
            0 2px 10px
            rgba(
                0,
                0,
                0,
                0.045
            );
    }

    .gallery-article-meta-row {
        margin-bottom: 6px;
    }

    .gallery-article-date {
        font-size: 12px;
    }

    .gallery-article-title {
        margin-bottom: 14px;

        padding-right: 28px;

        font-size: 16px;
        line-height: 1.5;
    }

    .gallery-article-title > .ui-icon {
        right: 2px;
    }

    .gallery-article-images {
        grid-template-columns:
            repeat(
                2,
                1fr
            );

        gap: 6px;
    }

    .gallery-item {
        border-radius: 9px;
    }

    .gallery-article-images-link {
        margin-top: 12px;

        font-size: 13px;
    }

    .gallery-article-no-images {
        padding: 14px;

        border-radius: 10px;
    }

    .gallery-article-preview {
        margin-bottom: 12px;

        font-size: 13px;
        line-height: 1.75;
    }

    .gallery-article-read-link {
        font-size: 13px;
    }

    .lightbox {
        padding:
            52px
            8px
            12px;
    }

    .lightbox-content {
        justify-content: center;

        min-height: 0;
    }

    .lightbox-image {
        max-width: 100%;

        max-height:
            calc(
                100vh -
                190px
            );

        border-radius: 4px;
    }

    .image-counter {
        margin-top: 8px;

        padding:
            4px
            10px;

        font-size: 12px;
    }

    .lightbox-thumbnails {
        gap: 6px;

        max-width: 100%;

        margin-top: 8px;

        padding:
            3px
            4px;
    }

    .lightbox-thumbnail {
        flex:
            0
            0
            50px;

        width: 50px;
        height: 50px;

        border-radius: 7px;
    }

    .lightbox-thumbnail img {
        border-radius: 4px;
    }

    .close-button {
        top: 8px;
        right: 8px;

        width: 40px;
        height: 40px;
    }

    .nav-button {
        width: 38px;
        height: 38px;

        border-radius: 50%;

        background:
            rgba(
                255,
                255,
                255,
                0.12
            );
    }

    .prev-button {
        left: 8px;
    }

    .next-button {
        right: 8px;
    }
}


/* =========================
   PC 2カラム時のブログ一覧
========================= */

@media (min-width: 1024px) {

    .gallery-main-layout .gallery {
        padding: 0;
    }


    .gallery-main-layout .gallery-article {
        max-width: none;

        margin:
            0
            0
            26px;

        padding: 22px;

        box-shadow:
            0 6px 24px
            rgba(0, 0, 0, 0.055);
    }


    .gallery-main-layout .gallery-article:last-child {
        margin-bottom: 0;
    }


    .gallery-main-layout .gallery-article-images {
        grid-template-columns:
            repeat(
                auto-fill,
                minmax(
                    200px,
                    1fr
                )
            );

        gap: 12px;
    }


    .gallery-main-layout .gallery-item {
        border-radius: 13px;
    }
}

/* ========================================
 * タブレット縦向き 一覧前後の余白
 * カレンダー→見出し と 見出し→1件目 を 14px に統一
 * ======================================== */
@media (
    min-width: 768px
) and (
    max-width: 1023px
) and (
    orientation: portrait
) {
    .gallery {
        padding-top: 14px;
    }
}

/* =========================
   既読表示
========================= */

.gallery-article-read-badge {
    display: inline-flex;

    align-items: center;

    padding:
        4px
        9px;

    border-radius:
        var(--ui-radius-round);

    background:
        var(--ui-bg-subtle);

    color:
        var(--ui-text-muted);

    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;

    letter-spacing: 0.03em;
}

.gallery-article.is-read .gallery-article-title-text {
    color: #777;
}

/* 未描画サムネイルの幅を保持する。 */
.lightbox-thumbnail-spacer {
    height: 1px;
    pointer-events: none;
}

/* 退避中も記事の高さを保持し、マージンの相殺を防ぐ。 */
.gallery-article-slot {
    display: flow-root;
    overflow-anchor: none;
}
.gallery-article-slot > .gallery-article {
    margin-bottom: 28px;
}

@media (max-width: 767px) {
    .gallery-article-slot > .gallery-article {
        margin-bottom: 14px;
    }
}

.gallery-load-sentinel.is-error {
    height: auto;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    color: var(--ui-text-color, #555);
}


/* 指に追従する表示枠。隣の画像は2枚だけ保持する。 */
.lightbox-swipe-stage {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.lightbox-swipe-track {
    position: relative;
    width: 100%;
}

.lightbox-swipe-current,
.lightbox-swipe-neighbor {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-swipe-neighbor {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.lightbox-swipe-neighbor.previous { left: -100%; }
.lightbox-swipe-neighbor.next { left: 100%; }

.lightbox-swipe-neighbor img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-swipe-stage.is-zoomed { overflow: visible; }
.lightbox-swipe-stage.is-zoomed .lightbox-swipe-neighbor { visibility: hidden; }
