/* ===== SOLUTIONS / FEATURES 基本尺寸與排版===== */
.features-section {
  /* 尺寸與底色 */
  padding: clamp(48px, 6vw, 96px) 0;
  background-color: #f2f2f2; /* 區塊灰底 */
  text-align: center;

  /* 浮出與動畫基礎 */
  position: relative;
  overflow: visible;
  --extra-space: 0px; /* 預設不加空間（供 md+ 使用） */
  transition: padding-bottom 0.28s ease; /* md+ 會套到 padding-bottom */
}

/* 標題 */
.features-section .section-title {
  /* text-align: center; */
  font-weight: 700;
  font-size: clamp(26px, 3.8vw, 36px);
  margin-bottom: 2rem;
}

/* 卡片樣式 */
.feature-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  text-align: center;
  height: 100%;
  position: relative; /* 給浮出面板定位 */
  overflow: visible;
  /* background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04); */

  /* 互動 */
  transition: transform 0.2s ease, margin-bottom 0.3s ease;
}

/* 圖片 */
.feature-card img {
  width: 100%;
  aspect-ratio: 16 / 9; /* 你要 4:3、1:1 都行 */
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin-bottom: 1rem;
}

/* 卡片文字 */
.feature-card-title {
  font-weight: 700;
  font-size: 1.25rem; /* ≈20px */
  margin: 0.5rem 0 0.5rem;
  position: relative;
  padding-bottom: 0.5rem; /* 給橫線留空間 */
}

.feature-card-title::after {
  content: "";
  display: block;
  width: 60px; /* 短橫線長度 */
  height: 3px; /* 橫線粗細 */
  background-color: #2c295a;
  margin: 1rem auto 0;
  border-radius: 2px; /* 圓角，讓線不死板 */
  margin-left: auto;
  margin-right: auto;
}

.feature-card-text {
  flex-grow: 1; /* 讓文字撐開，按鈕永遠在底部 */
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 1rem;
}

/* 想知道更多按鈕  */
.btn-more {
  display: inline-block;
  border: 1px solid #e5e7eb;
  background: var(--color-primary);
  color: var(--white);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  line-height: 1.2;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

/* 基本：給 section 一個可動畫的底部空間變數 */
.features-section {
  --extra-space: 0px; /* 預設不加空間 */
  transition: padding-bottom 0.28s ease; /* 平滑過渡 */
  position: relative;
  overflow: visible;
}

/* 手機：collapse 內嵌樣式（推版面） */
.feature-more {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #e5e7eb;
  text-align: center;
}

/* 平板/桌機：浮出面板 + 動畫 + 動態底部留白 */
@media (min-width: 768px) {
  /* 有任一張展開時，為整段 section 增加額外底部空間（會平滑過渡） */
  .features-section {
    padding-bottom: calc(clamp(48px, 6vw, 96px) + var(--extra-space));
  }
  .features-section:has(.feature-card .collapse.show) {
    --extra-space: 120px;
  } /* 依內容量調整 100~160 */

  /* 浮出面板（單一定義） */
  .feature-card .feature-more {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% + 20px); /* 與卡片底部距離，+12/+20/+32 可調 */
    margin: 0; /* 蓋掉手機外距 */
    padding: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    z-index: 20;

    /* 動效 */
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.24s ease, transform 0.24s ease;

    /* 蓋掉手機的虛線分隔 */
    border-top: none;
  }
  .feature-card .feature-more.show {
    opacity: 1;
    transform: translateY(0);
  }

  /* 展開中的卡片提高堆疊，避免被鄰排覆蓋 */
  .feature-card:has(.collapse.show) {
    z-index: 30;
  }
}

/* 無障礙：使用者偏好減少動畫時，關掉過渡 */
@media (prefers-reduced-motion: reduce) {
  .features-section,
  .feature-card .feature-more {
    transition: none !important;
  }
}

/* ==========================================================
   IMAGE MODAL（放大圖片）
   ========================================================== */

/* 背景遮罩：霧面白底、淡入淡出（只寫一次） */
.modal-backdrop {
  background-color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  transition: opacity 0.28s ease;
}
.modal-backdrop.show {
  opacity: 0.9;
}

/* 對話框進出場動畫 */
#imageModal.modal.fade .modal-dialog {
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.28s ease;
  will-change: transform, opacity;
}
#imageModal.modal.show .modal-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* 內容容器：透明（避免雙層底色） */
#imageModal .image-modal-content {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 圖片外框：讓關閉鈕以圖片定位 */
#imageModal .image-modal-frame {
  position: relative; /* 關閉鈕定位基準 */
  display: inline-block;
  max-width: 100%;
}

/* 圖片（只寫一次，含淡入） */
#modalImage {
  display: block;
  max-width: 90vw; /* 不超出視窗 */
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  margin: 0 auto;

  opacity: 0;
  transform: translateY(6px) scale(0.995);
  transition: opacity 0.22s ease, transform 0.22s ease;
  will-change: opacity, transform;
}
#imageModal.show #modalImage {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* 關閉鈕：手機/桌機都貼在「圖片右上角」 */
#imageModal .image-modal-close {
  position: absolute;
  top: 8px;
  right: 8px; /* 與圖片邊緣距離 */
  z-index: 3;

  width: 32px;
  height: 32px;
  line-height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
#imageModal .image-modal-close::before {
  content: "✕";
  display: block;
  text-align: center;
  font-size: 1.1rem;
  line-height: 32px;
  color: #2c295a;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
#imageModal .image-modal-close:hover::before {
  color: #1d1a48;
  transform: scale(1.12);
  transition: color 0.2s ease, transform 0.2s ease;
}

/* md+：按鈕尺寸/內縮距離稍大一點，更好點 */
@media (min-width: 768px) {
  #imageModal .image-modal-close {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
  #imageModal .image-modal-close::before {
    font-size: 1.25rem;
    line-height: 36px;
  }
}

/* 無障礙：減少動畫偏好 */
@media (prefers-reduced-motion: reduce) {
  #imageModal .modal-dialog,
  #modalImage {
    transition: none !important;
  }
}

/* === THE END === */

/* 1) 平板: 統一控制 modal-dialog 寬度與左右邊距，避免不正中 */
@media (min-width: 768px) and (max-width: 1199.98px) {
  #imageModal .modal-dialog {
    /* 讓對話框以畫面寬為基準居中，不會被預設 margin 影響視覺 */
    max-width: 96vw;
    margin-left: auto;
    margin-right: auto;
    display: flex; /* 保險：在某些 iPad 上更穩定置中 */
    align-items: center;
    justify-content: center;
  }
}

/* 2) 讓「圖片 + ❌」作為同一個動畫單位，避免進場時位置不同步 */
#imageModal .image-modal-frame {
  opacity: 0;
  transform: translateY(6px) scale(0.995);
  transition: opacity 0.22s ease, transform 0.22s ease;
  will-change: opacity, transform;
}
#imageModal.show .image-modal-frame {
  opacity: 1;
  transform: translateY(0) scale(1);
}
/* 並移除圖片自身的 transform 動畫（避免與 frame 雙重套用） */
#modalImage {
  transform: none;
  transition: opacity 0.22s ease; /* 保留淡入即可 */
}

/* 3) iPad（md+）上 ❌ 的尺寸與內縮距離稍再調整，手感更好 */
@media (min-width: 768px) {
  #imageModal .image-modal-close {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
  #imageModal .image-modal-close::before {
    line-height: 36px;
    font-size: 1.25rem;
  }
}

/* 4) 超大桌機可再一點點 padding（選用） */
@media (min-width: 1400px) {
  #imageModal .image-modal-close {
    top: 14px;
    right: 14px;
  }
}

@supports (-webkit-touch-callout: none) {
  #imageModal .modal-dialog {
    justify-content: center !important;
    margin: 0 auto !important;
  }
}
