/* ===== Adventures of D&R カスタムスタイル ===== */

/* ----- ep-box アイコン色 ----- */
.content .es-BmarkExcl::before {
  background: #2B8FBF;
}

/* ----- ギャラリー装飾（CSS Grid） ----- */
.wp-block-gallery {
  display: grid !important;
  gap: 12px !important;
  padding: 8px 0;
}

/* 1枚: フル幅 */
.wp-block-gallery:has(> :nth-child(1):last-child) {
  grid-template-columns: 1fr;
}

/* 2枚: 2カラム均等 */
.wp-block-gallery:has(> :nth-child(2):last-child) {
  grid-template-columns: 1fr 1fr;
}

/* 3枚: 3カラム均等 */
.wp-block-gallery:has(> :nth-child(3):last-child) {
  grid-template-columns: 1fr 1fr 1fr;
}

/* 4枚: 2x2グリッド */
.wp-block-gallery:has(> :nth-child(4):last-child) {
  grid-template-columns: 1fr 1fr;
}

/* 5枚以上: 3カラム */
.wp-block-gallery:has(> :nth-child(5)) {
  grid-template-columns: 1fr 1fr 1fr;
}

/* 画像をグリッドセルにフィット */
.wp-block-gallery .wp-block-image {
  width: 100% !important;
  margin: 0 !important;
  flex: none !important;
  overflow: visible;
  background: none;
  box-shadow: none;
  transition: transform 0.3s ease;
}

.wp-block-gallery .wp-block-image img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(47, 72, 88, 0.12);
  display: block;
  transition: transform 0.4s ease, box-shadow 0.3s ease;
}

.wp-block-gallery .wp-block-image:hover img {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(47, 72, 88, 0.2);
}


/* ----- 画像ブロック・ギャラリーの上マージン -----
   親テーマは figure をリセット (margin:0) するため、
   .content p / div / .balloon の margin-top:2rem 規則の対象外になる。
   本文と同じ間隔を確保するため明示的にトップマージンを付与する。 */
.content .wp-block-image:not(.wp-block-gallery .wp-block-image),
.content .wp-block-gallery {
  margin-top: 2rem;
}

/* 吹き出しは margin-bottom を持たないため、直下要素との間も確保する */
.content .balloon {
  margin-bottom: 1rem;
}

/* ----- 単体画像装飾 ----- */
.content .wp-block-image:not(.wp-block-gallery .wp-block-image) {
  text-align: center;
}

.content .wp-block-image:not(.wp-block-gallery .wp-block-image) img {
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(47, 72, 88, 0.12);
  transition: transform 0.4s ease, box-shadow 0.3s ease;
  max-height: 480px;
  width: auto;
  max-width: 100%;
}

.content .wp-block-image:not(.wp-block-gallery .wp-block-image):hover img {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(47, 72, 88, 0.2);
}
/* スマホ: 2枚以上は2カラム、1枚はフル */
@media (max-width: 600px) {
  .wp-block-gallery:has(> :nth-child(3):last-child),
  .wp-block-gallery:has(> :nth-child(5)) {
    grid-template-columns: 1fr 1fr;
  }
}
/* ----- スクロールフェードイン ----- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-32px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* アニメーション対象の初期状態 */
.content h2,
.content h3,
.content .wp-block-image,
.content .wp-block-gallery,
.content .wp-block-list,
.content .ep-box,
.content p:not(.balloon__name) {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
  animation-play-state: paused;
}

/* 吹き出し: 左(Risa)は左から、右(Daiki)は右から */
.content .balloon {
  opacity: 0;
  animation-duration: 0.6s;
  animation-timing-function: ease;
  animation-fill-mode: forwards;
  animation-play-state: paused;
}

.content .balloon:has(.balloon__img-left) {
  animation-name: slideInLeft;
}

.content .balloon:has(.balloon__img-right) {
  animation-name: slideInRight;
}

/* 表示状態 — JSで .is-visible を付与 */
.content h2.is-visible,
.content h3.is-visible,
.content .wp-block-image.is-visible,
.content .wp-block-gallery.is-visible,
.content .wp-block-list.is-visible,
.content .ep-box.is-visible,
.content p.is-visible:not(.balloon__name),
.content .balloon.is-visible {
  animation-play-state: running;
}

/* 順番に表示するためのディレイ */
.content .balloon.is-visible + .balloon.is-visible {
  animation-delay: 0.15s;
}

/* ----- リンクホバー ----- */
.content a {
  transition: color 0.25s ease, opacity 0.25s ease;
}

.content a:hover {
  opacity: 0.75;
}

/* ----- ボタンホバー ----- */
.btn__link-primary,
.btn__link-secondary {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.btn__link-primary:hover,
.btn__link-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(47, 72, 88, 0.15);
}

/* ----- prefers-reduced-motion ----- */
@media (prefers-reduced-motion: reduce) {
  .content h2,
  .content h3,
  .content .wp-block-image,
  .content .wp-block-gallery,
  .content .wp-block-list,
  .content .ep-box,
  .content p:not(.balloon__name),
  .content .balloon {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }
}
