/**
 * ギャラリーとモーダルのスタイル
 */

/* ギャラリーコンテナ */
.gallery-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

/* ギャラリーアイテム */
.gallery-item {
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  position: relative;
}

/* ギャラリー画像 */
.gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease;
  min-height: 200px;
  cursor: pointer;
}

.gallery-image:hover {
  transform: scale(1.03);
  filter: brightness(1.1);
}

/* モーダルウィンドウ */
.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease;
}

.image-modal.show {
  display: flex;
  background-color: rgba(0, 0, 0, 0.9);
}

/* モーダルコンテンツ */
.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  margin: 20px auto;
  padding: 0;
  background-color: transparent;
  border-radius: 4px;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.modal-content.show {
  opacity: 1;
  transform: scale(1);
}

/* モーダル画像 */
.modal-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 85vh;
  object-fit: contain;
}

/* 閉じるボタン */
.close-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  color: white;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  text-shadow: 0 0 3px black;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.close-modal:hover {
  opacity: 1;
}

/* ナビゲーションボタン */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  color: white;
  font-size: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
  z-index: 1001;
  opacity: 0.7;
  transition: opacity 0.3s, background-color 0.3s;
}

.modal-nav:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.8);
}

.modal-nav-prev {
  left: 20px;
}

.modal-nav-next {
  right: 20px;
}

/* 画像読み込みエフェクト */
.gallery-image:not(.loaded) {
  filter: blur(5px);
  opacity: 0.7;
}

.gallery-image.loaded {
  filter: blur(0);
  opacity: 1;
}

/* ギャラリーアイテムのホバーオーバーレイ */
.gallery-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.gallery-item:hover::after {
  opacity: 1;
}

/* レスポンシブデザイン */
@media screen and (max-width: 768px) {
  .gallery-container {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      gap: 10px;
  }
  
  .modal-nav {
      width: 30px;
      height: 30px;
      font-size: 18px;
  }
  
  .modal-nav-prev {
      left: 10px;
  }
  
  .modal-nav-next {
      right: 10px;
  }
  
  .close-modal {
      top: 10px;
      right: 15px;
      font-size: 28px;
  }
}