.libraryDetail {
  position: relative;
  padding: 220px 0;
}

.libraryDetail__inner {
  max-width: 2400px;
  margin: 0 auto;
  padding: 0 120px;
}

.libraryDetail__heading {
  text-align: center;
  margin-bottom: 140px;
}

.libraryDetail__title {
  margin: 0;
  font-size: 50px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.libraryDetail__subTitle {
  margin: 20px 0 0;
  font-size: 15px;
  line-height: 1.4;
}

/* section */
.librarySection + .librarySection {
  margin-top: 140px;
}

.librarySection__head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 20px;
  margin-bottom: 48px;
}

.librarySection__title {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
  font-weight: 500;
  white-space: nowrap;
}

.librarySection__head::after {
  content: "";
  display: block;
  height: 1px;
  background: #8d8d8d;
}

/* cards */
.libraryCardGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 56px 32px;
  justify-content: start;
}

.libraryCard {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: black;
  text-decoration: none;
}

.libraryCard__badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 36px;
  height: 36px;
  padding: 0 8px;

  border-radius: 999px;
  background: rgba(20, 9, 8, 0.7);
  color: #fff;

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

.libraryCard__image {
  display: block;
  aspect-ratio: 1 / 0.62;
  overflow: hidden;
  background: #fff;
  line-height: 0;
  position: relative;
}

.libraryCard__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.libraryCard:hover .libraryCard__image img {
  transform: scale(1.08);
}

.playIcon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(20, 9, 8, 0.7);
  pointer-events: none;
}

.playIcon::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 52%;
  transform: translate(-50%, -50%);
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid #fff;
}

.libraryCard__title {
  display: block;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.75;
  color: inherit;
}

/* =========================
   Gallery Modal
========================= */
.galleryModal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.galleryModal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.galleryModal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.galleryModal.is-open .galleryModal__overlay {
  opacity: 1;
}

/* 中身も少し遅れて表示 */
.galleryModal__viewer,
.galleryModal__close,
.galleryModal__nav {
  opacity: 0;
  transition: opacity 0.28s ease 0.24s;
}

.galleryModal.is-open .galleryModal__viewer,
.galleryModal.is-open .galleryModal__close,
.galleryModal.is-open .galleryModal__nav {
  opacity: 1;
}

/* カードから拡大する疑似画像 */
.galleryModal__zoomClone {
  position: fixed;
  z-index: 2300;
  object-fit: cover;
  pointer-events: none;
  transform-origin: center center;
  will-change: left, top, width, height, opacity;
  transition:
    left 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    top 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.24s ease;
}

.galleryModal__dialog {
  position: relative;
  z-index: 2;
  width: auto;
  max-width: 100%;
  max-height: 100vh;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.galleryModal__viewer,
.galleryModal__close,
.galleryModal__nav {
  pointer-events: auto;
}

.galleryModal__main {
  position: relative;
  display: block;
}

.galleryModal.is-no-zoom-open .galleryModal__viewer {
  transform: translateY(12px) scale(0.98);
}

.galleryModal.is-open.is-no-zoom-open .galleryModal__viewer {
  transform: translateY(0) scale(1);
}

.galleryModal__viewer {
  width: min(1200px, calc(100vw - 80px));
  margin: 0 auto;
  position: relative;
  transition:
    opacity 0.28s ease 0.18s,
    transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.galleryModal__imageWrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 86vh;
  overflow: hidden;
  background: transparent;
  cursor: grab;
  user-select: none;
  transform-origin: center center;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ズーム：PC 1.5倍 */
.galleryModal[data-zoomed="1"] .galleryModal__imageWrap {
  transform: scale(1.5);
  cursor: zoom-out;
}

.galleryModal[data-zoomed="1"] .galleryModal__description,
.galleryModal[data-zoomed="1"] .galleryModal__thumbs {
  visibility: hidden;
  opacity: 0;
}

.galleryModal__description,
.galleryModal__thumbs {
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

/* スライドトラック */
.galleryModal__track {
  display: flex;
  width: 100%;
  will-change: transform;
}

.galleryModal__slide {
  flex: 0 0 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 86vh;
}

.galleryModal__slide img,
.galleryModal__slide video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.galleryModal__slide video {
  background: #000;
}

.galleryModal__image.is-fading {
  opacity: 0;
}

/* 説明文 */
.galleryModal__description {
  margin: 20px 0 0;
  color: #fff;
  font-size: 14px;
  line-height: 1.8;
}

/* サムネイル */
.galleryModal__thumbs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 12px;
  margin-top: 20px;
  scroll-behavior: smooth;
  -ms-overflow-style: none; /* IE / Edge */
  scrollbar-width: none; /* Firefox */
}

.galleryModal__thumbs::-webkit-scrollbar {
  display: none; /* Chrome / Safari */
}

.galleryModal__thumbButton {
  width: 96px;
  padding: 0;
  border: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.galleryModal__thumbButton.is-active {
  border-color: #e60012;
  transform: none;
}

.galleryModal__thumbButton img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.62;
  object-fit: cover;
}

/* counter: 画面左上固定 */
.galleryModal__counter {
  position: absolute;
  top: 24px;
  left: 48px;
  z-index: 2100;
  color: #fff;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  height: 64px;
}

/* close button: 画面右上固定 */
.galleryModal__close {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2100;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.galleryModal__close::before,
.galleryModal__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 2px;
  background: #fff;
  transform-origin: center;
}

.galleryModal__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.galleryModal__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* nav button: 画面左右固定 */
.galleryModal__nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2100;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.galleryModal__nav--prev {
  left: 16px;
}

.galleryModal__nav--next {
  right: 16px;
}

.galleryModal__nav::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  border-top: 3px solid #fff;
  border-right: 3px solid #fff;

  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3))
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
}

.galleryModal__nav--prev::before {
  transform: translate(-35%, -50%) rotate(-135deg);
}

.galleryModal__nav--next::before {
  transform: translate(-65%, -50%) rotate(45deg);
}

body.is-modal-open {
  overflow: hidden;
}

/* fixed contact button */
.libraryDetail__contactButton {
  position: fixed;
  right: 40px;
  bottom: 48px;
  z-index: 900;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 500px;
  height: 100px;
  padding: 0 32px;
  border-radius: 9999px;
  background: #e60012;
  color: #fff;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.libraryDetail__contactButton:hover {
  opacity: 0.9;
}

body.is-modal-open {
  overflow: hidden;
}

@media (max-width: 1280px) {
  .libraryCardGrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 48px 32px;
  }
}

/* SP */
@media (max-width: 800px) {
  .libraryDetail {
    padding: 96px 0;
  }

  .libraryDetail__inner {
    padding: 0 20px;
  }

  .libraryDetail__heading {
    margin-bottom: 72px;
  }

  .libraryDetail__title {
    font-size: 30px;
  }

  .libraryDetail__subTitle {
    font-size: 12px;
  }

  .librarySection + .librarySection {
    margin-top: 72px;
  }

  .librarySection__head {
    margin-bottom: 28px;
  }

  .librarySection__title {
    font-size: 14px;
  }

  .libraryCardGrid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .libraryCard__title {
    text-align: center;
  }

  .galleryModal__viewer {
    width: calc(100vw - 40px);
  }

  .galleryModal__imageWrap {
    min-height: 64vh;
  }

  /* ズーム：SP 2倍 */
  .galleryModal[data-zoomed="1"] .galleryModal__imageWrap {
    transform: scale(2);
  }

  .galleryModal__slide {
    min-height: 64vh;
  }

  .galleryModal__slide img,
  .galleryModal__slide video {
    max-width: 100%;
    max-height: 64vh;
  }

  .galleryModal__description {
    margin-top: 14px;
    font-size: 14px;
    line-height: 1.6;
  }

  .galleryModal__thumbs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    gap: 8px;
    margin-top: 14px;
  }

  .galleryModal__thumbButton {
    width: calc((100% - 16px) / 3);
    border-width: 3px;
    flex: 0 0 88px;
    width: auto;
  }

  .galleryModal__thumbButton.is-active {
    transform: none;
  }

  .galleryModal__nav {
    top: 32vh; /* 64vhの半分 */
    width: 56px;
    height: 56px;
  }

  .galleryModal__nav::before {
    width: 20px;
    height: 20px;
    border-top-width: 2px;
    border-right-width: 2px;

    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3))
      drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
  }

  .galleryModal__nav--prev {
    left: 4px;
  }

  .galleryModal__nav--next {
    right: 4px;
  }

  .galleryModal__counter {
    top: 16px;
    left: 16px;
    font-size: 12px;
    height: 48px;
  }

  .galleryModal__close {
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .galleryModal__close::before,
  .galleryModal__close::after {
    width: 28px;
  }

  .libraryDetail__contactButton {
    left: 16px;
    right: 16px;
    bottom: 16px;
    min-width: 0;
    width: auto;
    height: 64px;
    font-size: 16px;
  }
}
