/* gallery-style.css */

/* --- 基本的なスタイル --- */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f0f0f0;
}

.gallery-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* --- ヘッダーとフッター --- */
header, footer {
    text-align: center;
    padding: 20px 0;
}

.logo-image {
    max-width: 200px;
    height: auto;
}

.home-button, .copyright-image {
    width: 50px;
    height: 50px;
    margin: 0 10px;
    vertical-align: middle;
}

/* --- ギャラリー本体 --- */
.gallery-grid {
    display: grid;
    /* ★ 変更: PC（デフォルト）では5列表示に設定 */
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

/* ★★★ 以下にレスポンシブ設定を追加・または修正 ★★★ */

/* タブレットサイズ (幅が1024px以下) */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 小さめタブレット・大きめスマホ (幅が768px以下) */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

/* スマホサイズ (幅が480px以下) */
@media (max-width: 480px) {
    .gallery-grid {
        /* スマホでは2列表示が見やすいです */
        grid-template-columns: repeat(2, 1fr);
    }
}


.gallery-item {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* --- モーダルウィンドウ（ポップアップ） --- */

/* 外側の黒い背景部分 */
.modal {
    display: none; /* ★ 修正: 初期状態は必ず非表示にする */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
}

/* コンテンツ全体を包む「表示エリア」 */
.modal-dialog {
    display: flex;
    flex-direction: column; /* 中の要素を縦に並べる */
    width: 100%;
    height: 100%;
    padding: 20px;
}

/* 上段のコントロール */
.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    flex-shrink: 0; /* 縮まないように */
    color: white;
}
.counter { font-size: 16px; }
.modal-close { font-size: 40px; font-weight: bold; cursor: pointer; transition: 0.3s; }
.modal-close:hover { color: #bbb; }

/* 中段の画像エリア */
.image-container {
    display: flex;
    align-items: center; /* 垂直方向中央揃え */
    gap: 10px; /* ボタンと画像の間の隙間 */
    flex-grow: 1; /* 空いている縦スペースをすべて使う */
    min-height: 0; /* Flexboxの表示崩れを防ぐ */
}

/* 矢印ボタン (position:absoluteを解除) */
.modal-nav {
    position: static;
    transform: none;
    background: rgba(50,50,50,0.6);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0; /* 縮まないように */
}
.modal-nav:hover { background: rgba(0,0,0,0.8); }

/* 画像を囲むビューポート */
.image-viewport {
    flex-grow: 1; /* 中央の空きスペースをすべて使う */
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* ズームした画像がはみ出ないように */
}
.modal-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease-in-out;
    cursor: grab;
}
.modal-content.is-dragging { cursor: grabbing; }

/* 下段のコントロール */
.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-top: 10px;
    flex-shrink: 0; /* 縮まないように */
}
.bottom-controls button {
    background: none;
    border: 2px solid white;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    line-height: 40px;
    text-align: center;
    transition: background-color 0.2s;
    border-radius: 50%;
}
.bottom-controls button:hover { background-color: rgba(255, 255, 255, 0.2); }
