/* ============================================
   Site Modal System
   再利用可能なモーダル・ポップアップコンポーネント
   ============================================ */

/* --- Root Container --- */
.site-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
  visibility: hidden;
}

.site-modal.is-active {
  pointer-events: auto;
  visibility: visible;
}

/* --- Overlay (背景) --- */
.site-modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.site-modal.is-active .site-modal-overlay {
  opacity: 1;
}

/* --- Panel (コンテンツ領域) --- */
.site-modal-panel {
  position: relative;
  background-color: var(--color-surface, #ffffff);
  color: var(--color-on-surface, inherit);
  font-family: inherit;
  border-radius: 1rem;
  width: 95%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  opacity: 0;
  transform: translateY(1.25rem) scale(0.97);
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow:
    0 20px 60px -15px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(0, 0, 0, 0.05);
}

.site-modal.is-active .site-modal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* スクロールバーのスタイル */
.site-modal-panel::-webkit-scrollbar {
  width: 6px;
}

.site-modal-panel::-webkit-scrollbar-track {
  background: transparent;
}

.site-modal-panel::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* --- デスクトップ: 85% 幅 --- */
@media (min-width: 1024px) {
  .site-modal-panel {
    width: 85%;
    max-height: 85vh;
    padding: 2.5rem 3rem;
  }
}

/* --- サイズバリエーション --- */
/* 小 (フォーム、確認ダイアログ向け) */
.site-modal-sm .site-modal-panel {
  max-width: 32rem;
}

/* 中 (記事、説明向け) */
.site-modal-md .site-modal-panel {
  max-width: 48rem;
}

/* デフォルト (lg) は max-width なし = 85% */

/* フル幅 */
.site-modal-full .site-modal-panel {
  width: 95%;
}

@media (min-width: 1024px) {
  .site-modal-full .site-modal-panel {
    width: 95%;
  }
}

/* --- 閉じるボタン --- */
.site-modal-close-btn {
  position: absolute;
  top: 0.875rem;
  right: 0.875rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  cursor: pointer;
  color: inherit;
  opacity: 0.4;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  z-index: 1;
  padding: 0;
  line-height: 1;
}

.site-modal-close-btn:hover,
.site-modal-close-btn:focus-visible {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.06);
}

.site-modal-close-btn:focus-visible {
  outline: 2px solid var(--color-primary, #3b82f6);
  outline-offset: 2px;
}

.site-modal-close-btn svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* --- Body Scroll Lock --- */
body.modal-open {
  overflow: hidden;
  /* スクロールバー消失によるレイアウトシフト防止 */
  padding-right: var(--scrollbar-width, 0px);
}

/* --- モーダル内のコンテンツユーティリティ --- */
.site-modal-header {
  margin-bottom: 1.5rem;
  padding-right: 2rem;
}

.site-modal-body {
  line-height: 1.8;
}

.site-modal-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
