/* ==========================================================================
   wp-custom-article 共通CSS (SWELL Child Theme)
   すべて Selector を #wp-custom-article 配下にスコープ
   ========================================================================== */

#wp-custom-article.wpa-article-comic {
  background-color: transparent;
}

#wp-custom-article {
  color: var(--color-text, #2c3e50);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.8;
  margin: 0 auto;
  max-width: 100%;
  box-sizing: border-box;
}

#wp-custom-article *,
#wp-custom-article *::before,
#wp-custom-article *::after {
  box-sizing: inherit;
}

/* SWELL見出しの強制リセット */
#wp-custom-article h2,
#wp-custom-article h3,
#wp-custom-article h4 {
  background: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 1.8em 0 0.8em 0 !important;
}

#wp-custom-article h2::before,
#wp-custom-article h2::after,
#wp-custom-article h3::before,
#wp-custom-article h3::after,
#wp-custom-article h4::before,
#wp-custom-article h4::after {
  content: none !important;
  display: none !important;
}

/* カスタム見出しスタイル */
#wp-custom-article h2.wpa-heading-h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a1a;
  border-left: 5px solid #e74c3c !important;
  padding-left: 0.75rem !important;
  margin-top: 2rem !important;
  margin-bottom: 1rem !important;
  line-height: 1.4;
}

#wp-custom-article h3.wpa-heading-h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2c3e50;
  border-bottom: 2px solid #ecf0f1 !important;
  padding-bottom: 0.4rem !important;
  margin-top: 1.5rem !important;
  margin-bottom: 0.8rem !important;
}

/* リード文 / あらすじカード */
#wp-custom-article .wpa-lead-card {
  background-color: #f1f3f5;
  color: #2b2d42;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  border-left: 3px solid #6c757d;
  margin-bottom: 24px;
}

#wp-custom-article .wpa-lead-card p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
}

/* 作品間の相互リンク（リードカードと同系統） */
#wp-custom-article .wpa-comic-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background-color: #f1f3f5;
  color: #2b2d42;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  margin: 0 0 24px;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

#wp-custom-article .wpa-comic-nav:hover {
  background-color: #e9ecef;
}

#wp-custom-article .wpa-comic-nav + .wpa-comic-container,
#wp-custom-article .wpa-comic-container + .wpa-comic-nav {
  margin-top: 0;
}

#wp-custom-article .wpa-comic-nav__note {
  font-size: 0.85rem;
  color: #6c757d;
  line-height: 1.5;
}

#wp-custom-article .wpa-comic-nav__title {
  font-size: 1rem;
  font-weight: 700;
  color: #2b2d42;
  line-height: 1.5;
}

#wp-custom-article .wpa-comic-nav:hover .wpa-comic-nav__title {
  text-decoration: underline;
}

/* マンガ・ギャラリーコンテナ（PC: 2列 / スマホ: 1列） */
#wp-custom-article .wpa-comic-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}

#wp-custom-article .wpa-comic-page {
  position: relative;
  width: 100%;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#wp-custom-article .wpa-comic-page:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

#wp-custom-article .wpa-comic-page img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

/* 左上の連番バッジ */
#wp-custom-article .wpa-page-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(231, 76, 60, 0.9);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  padding: 0 6px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 1;
}

/* モーダル画像拡大
   ──────────────────────────────────────────────────────
   モーダルは JS で document.body 直下へ動的生成されるため、
   #wp-custom-article 配下ではなく独立 ID でスコープしている。
   これはルールブック §5 の例外であり、意図的な設計である。
   ────────────────────────────────────────────────────── */
#wp-custom-article-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#wp-custom-article-modal.is-active {
  opacity: 1;
  pointer-events: auto;
}

#wp-custom-article-modal img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
}

#wp-custom-article-modal .wpa-modal-close,
#wp-custom-article-modal .wpa-modal-prev,
#wp-custom-article-modal .wpa-modal-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  user-select: none;
  z-index: 1;
  transition: background 0.2s ease;
}

#wp-custom-article-modal .wpa-modal-close {
  top: 20px;
  right: 20px;
}

#wp-custom-article-modal .wpa-modal-prev,
#wp-custom-article-modal .wpa-modal-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
}

#wp-custom-article-modal .wpa-modal-prev {
  left: 20px;
}

#wp-custom-article-modal .wpa-modal-next {
  right: 20px;
}

#wp-custom-article-modal .wpa-modal-close:hover,
#wp-custom-article-modal .wpa-modal-prev:hover,
#wp-custom-article-modal .wpa-modal-next:hover {
  background: rgba(255, 255, 255, 0.4);
}

#wp-custom-article-modal .wpa-modal-prev:disabled,
#wp-custom-article-modal .wpa-modal-next:disabled {
  opacity: 0;
  pointer-events: none;
}

/* フォーカスリングの確保 */
#wp-custom-article a:focus-visible,
#wp-custom-article button:focus-visible,
#wp-custom-article-modal button:focus-visible {
  outline: 3px solid #e74c3c;
  outline-offset: 2px;
}

@media (max-width: 768px) {
  #wp-custom-article .wpa-comic-container {
    grid-template-columns: 1fr;
  }
  #wp-custom-article .wpa-lead-card,
  #wp-custom-article .wpa-comic-nav {
    padding: 1.1rem;
    font-size: 0.92rem;
  }
}

/* prefers-reduced-motion 配慮 */
@media (prefers-reduced-motion: reduce) {
  #wp-custom-article .wpa-comic-page,
  #wp-custom-article .wpa-comic-nav {
    transition: none;
  }
  #wp-custom-article-modal,
  #wp-custom-article-modal .wpa-modal-close,
  #wp-custom-article-modal .wpa-modal-prev,
  #wp-custom-article-modal .wpa-modal-next {
    transition: none;
  }
}
