/* モーダル概観 */
.modal-wrapper_section {
  margin: 3rem 0 6rem;
}

/* サムネイルグリッド */
.page-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin: 4rem auto 20px;
}

.page-gallery-grid figure {
  margin: 0;
}

.page-gallery-grid p {
  text-align: center;
  margin-top: 0.6rem;
  font-size: 0.9rem;
}

.page-gallery-grid img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.2s;
}

.page-gallery-grid img:hover {
  opacity: 0.7;
}

.open-gallery-modal-btn {
  display: block;
  margin: 46px auto 20px;
  padding: 13px;
  background: #937545;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  width: 100%;
  max-width: 320px;
  border: none;
  text-align: center;
  cursor: pointer;
}

/* --- モーダル --- */
#gallery-modal-container {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  background: rgba(0, 0, 0, 0.7);
}

.modal-overlay {
  position: absolute;
  inset: 0;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1368px;
  height: 89vh;
  background: #fff;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.modal-close-btn {
  position: absolute;
  top: 21px;
  right: 21px;
  font-size: 0;
  font-weight: bold;
  color: #555;
  border: none;
  background: none;
  cursor: pointer;
  z-index: 10;
  background-image: url(https://gigaplus.makeshop.jp/tsukadanojo/pc/images/kodawari/modal/icon_close.png);
  background-repeat: no-repeat;
  content: none;
  padding: 1rem;
}

/* 一覧グリッド（モーダル内） */
#modal-view-grid {
  height: 100%;
  overflow-y: auto;
  margin: 0 6rem;
  padding-right: 10px;
}

#modal-view-grid h3 {
  margin: 0 0 10px;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0 14px;
  bottom: -23px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 2rem;
  padding-top: 10px;
}

.gallery-grid .grid-item {
  position: relative;
  aspect-ratio: 3/2;
  border: 1px solid #ccc;
  overflow: hidden;
  cursor: pointer;
}

.gallery-grid .grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.grid-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  padding: 10px;
}

.grid-item-overlay span {
  font-size: 14px;
  font-weight: bold;
}

.gallery-grid .grid-item:hover .grid-item-overlay {
  opacity: 1;
}

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

/* スライダー（モーダル内） */
#modal-view-slider {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  opacity: 0;
}

#back-to-grid-btn {
  align-self: flex-start;
  margin-bottom: 10px;
  font-size: 16px;
  padding: 8px 12px;
  cursor: pointer;
  position: absolute;
  background-color: #fff;
  border: none;
  font-weight: 700;
  left: -12px;
  top: -12px;
  background-image: url(https://gigaplus.makeshop.jp/tsukadanojo/pc/images/kodawari/modal/icon_arrow-gallary.png);
  background-repeat: no-repeat;
  background-position: 12px 14px;
  background-size: 18px;
}

#back-to-grid-btn > span {
  padding-left: 26px;
}

.main-slider-caption-display {
  height: 40px;
  font-size: 15px;
  font-weight: bold;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  /* white-space: nowrap */
  height: 6rem;
}

.main-slider {
  flex: 1;
  margin-bottom: 10px;
  position: relative;
  width: 100% !important;
}

#gallery-modal-container .swiper-button-next,
#gallery-modal-container .swiper-button-prev {
  z-index: 20;
}

.main-slider .swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100% !important;
}

.main-slider img {
  width: 90%;
  height: 100%;
  object-fit: contain;
}

.thumbs-slider {
  height: 130px;
}

#gallery-modal-container .thumbs-slider .swiper-slide {
  width: 200px;
  height: 140px;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.3s;
  margin-right: 24px !important;
}

#gallery-modal-container .thumbs-slider .swiper-slide-thumb-active {
  opacity: 1;
  /* border: 3px solid #007aff */
}

.thumbs-slider img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.h3_page-gallery-grid {
  padding-bottom: 2rem;
  border-bottom: 2px solid #ddd;
  position: relative;
  margin-bottom: 2rem;
}

.h3_page-gallery-grid > h3 {
  margin: 0 auto;
  text-align: center;
  font-size: 1.6rem;
  background: #fff;
  display: inline-block;
  padding: 0 25px;
  bottom: -19px;
  left: 50%;
  transform: translate(-50%, 0);
  position: absolute;
  white-space: nowrap;
  color: #333;
}

/* サマリー画像 */
.swiper-button-next:after {
  background: url(https://gigaplus.makeshop.jp/tsukadanojo/pc/images/kodawari/arrow_r.png)
    no-repeat;
  font-size: 0;
  padding: 2rem;
}

.swiper-button-prev:after {
  background: url(https://gigaplus.makeshop.jp/tsukadanojo/pc/images/kodawari/arrow_l.png)
    no-repeat;
  font-size: 0;
  padding: 2rem;
}

.swiper-button-prev,
.swiper-button-next {
  padding: 1rem;
}

@media screen and (max-width: 769px) {
  .swiper-button-next:after {
    background-size: 35%;
    right: -41px !important;
  }

  .swiper-button-prev:after {
    background-size: 35%;
  }

  #gallery-modal-container .thumbs-slider .swiper-slide {
    margin-right: 8px !important;
  }

  .main-slider-caption-display {
    padding-top: 2rem;
  }

  .modal-close-btn {
    top: 10px;
    right: 4px;
  }
}

@media screen and (max-width: 769px) {
  .modal-content {
    height: 73vh;
    top: 38%;
  }

  #modal-view-grid {
    margin: 0;
  }

  .swiper-button-next:after {
    right: -9px;
    position: absolute;
  }

  .swiper-button-prev:after {
    left: -10px;
    position: absolute;
  }

  #gallery-modal-container .thumbs-slider .swiper-slide {
    width: 106px;
    height: 81px;
  }

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

.main-slider img {
  width: 75%;
}
