/* ==========================================
   画像表示ライブラリ CSS
   image-modal.css
   ========================================== */

/* ------------------------------------------
   1. リセット・基本設定
   ------------------------------------------ */

/* すべての要素のボックスサイジングを統一 */
.image-modal-overlay,
.image-modal-overlay *,
.image-modal-overlay *::before,
.image-modal-overlay *::after {
  box-sizing: border-box;
}

/* ------------------------------------------
   2. オーバーレイ（背景）
   ------------------------------------------ */

.image-modal-overlay {
  /* 画面全体を覆う */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  
  /* 半透明の黒背景 */
  background-color: rgba(0, 0, 0, 0.7);
  
  /* 中央配置のための設定 */
  display: flex;
  justify-content: center;
  align-items: center;
  
  /* デフォルトは非表示 */
  opacity: 0;
  visibility: hidden;
  
  /* アニメーション用の設定 */
  transition: opacity 0.3s ease, visibility 0.3s ease;
  
  /* スクロール防止 */
  overflow: hidden;
}

/* モーダルが表示されている状態 */
.image-modal-overlay--active {
  opacity: 1;
  visibility: visible;
}

/* ------------------------------------------
   3. モーダル本体（白い背景）
   ------------------------------------------ */

.image-modal-container {
  /* モーダルの基本設定 */
  position: relative;
  background-color: #ffffff;
  padding: 0;
  
  /* 最大サイズを設定（画面からはみ出さないように） */
  max-width: 90vw;
  max-height: 90vh;
  
  /* シャドウで浮いた感じを演出 */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  
  /* 内容がはみ出た場合はスクロール可能に */
  overflow: auto;
  
  /* フレックスボックスで子要素を縦に配置 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  
  /* アニメーション用の設定 */
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

/* モーダルが表示されている状態 */
.image-modal-overlay--active .image-modal-container {
  transform: scale(1);
}

/* ------------------------------------------
   4. 閉じるボタン
   ------------------------------------------ */

.image-modal-close {
  /* 位置をモーダルの右上に固定 */
  position: absolute;
  top: 0; /*もとは10px*/
  right: 0;
  
  /* ボタンのサイズ */
  width: 30px;
  height: 30px;
  
  /* ボタンのスタイル */
  border: none;
  cursor: pointer;
  background-color: #ffffff;
  
  /* テキストのスタイル */
  font-size: 30px;
  line-height: 1;
  color: #000000;
  mix-blend-mode: darken;
  
  /* 中央配置 */
  display: flex;
  justify-content: center;
  align-items: center;
  
  /* アニメーション */
  transition: 0.3s ease;
  
  /* アクセシビリティのため、フォーカス時のアウトラインを確保 */
  outline-offset: 2px;
}

/* ホバー時・フォーカス時のスタイル */
.image-modal-close:hover,
.image-modal-close:focus {
  background-color: #000000;
  color: #ffffff;
}

/* アクティブ時（クリック時）のスタイル */
.image-modal-close:active {
  background-color: #898989;
}

/* ------------------------------------------
   5. 画像
   ------------------------------------------ */

.image-modal-image {
  /* 画像の基本設定 */
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 70px); /* モーダルの余白とキャプション分を引く */
  width: auto;
  height: auto;
  
  /* 画像の縦横比を維持 */
  object-fit: contain;
}

/* ------------------------------------------
   6. キャプション
   ------------------------------------------ */

.image-modal-caption {
  /* テキストのスタイル */
  font-size: 14px;
  /*line-height: 1.6;*/
  color: #484848;
  text-align: center;
  
  /* 幅の設定 */
  max-width: 100%;
  width: 100%;
  
  /* 余白 */
  padding: 0px 10px 25px 10px;
  
  /* 改行を許可 */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* キャプションが空の場合は非表示 */
.image-modal-caption:empty {
  display: none;
}

/* ------------------------------------------
   7. アニメーション
   ------------------------------------------ */

/* フェードイン・フェードアウトのアニメーションは
   上記のtransitionプロパティで既に設定済み */

/* ------------------------------------------
   8. レスポンシブ対応
   ------------------------------------------ */

/* タブレット以下のサイズ */
@media screen and (max-width: 768px) {
  .image-modal-container {
    padding: 0;
    max-width: 95vw;
    max-height: 95vh;
    gap: 15px;
  }
  
  .image-modal-image {
    max-height: calc(95vh - 70px);
  }
  
  .image-modal-caption {
    font-size: 13px;
  }
  
  .image-modal-close {
    /* モバイルではタッチしやすいように少し大きく */
    width: 30px;
    height: 30px;
    font-size: 28px;
  }
}

/* スマートフォンサイズ */
@media screen and (max-width: 480px) {
  .image-modal-container {
    padding: 0;
  }
  
  .image-modal-image {
    max-height: calc(95vh - 60px);
  }
  
  .image-modal-caption {
    font-size: 12px;
    padding: 0 5px 15px 5px;
  }
}

/* ------------------------------------------
   9. ユーティリティ
   ------------------------------------------ */

/* 完全に非表示にするクラス */
.image-modal-hidden {
  display: none !important;
}

/* bodyのスクロールを無効化（JavaScriptから使用） */
body.image-modal-no-scroll {
  overflow: hidden;
}
