/* ============================================================
   「Select Type」modal（Figma Quote Material Modal／AI Material Modal）
   桌機：884px 置中對話框（圓角 20、1px #EBECEC 框）；手機：滿版面板、卡片兩欄、按鈕固定底部。
   由 front/js/modals.js 控制開關；AI Preview 主視窗（.aip）另以 AJAX 載入疊在當頁。
   ============================================================ */
.stm {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "Plus Jakarta Sans", sans-serif;
  color: #181a1b;
}
.stm[hidden] { display: none !important; }

.stm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 26, 27, 0.6);
}

.stm__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 884px;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  background: #ffffff;
  border: 1px solid #ebecec;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.stm__close {
  position: absolute;
  top: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #4c5152;
  transition: background-color 0.15s ease-out;
}
.stm__close:hover { background: #f4f5f5; color: #181a1b; }

.stm__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 48px 32px 8px;
}

.stm__head { text-align: center; margin-bottom: 28px; }
.stm__title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.3px;
  margin: 0 0 6px;
}
.stm__subtitle { font-size: 16px; line-height: 1.5; color: #4c5152; margin: 0; }

.stm__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stm-card { position: relative; cursor: pointer; }
.stm-card.is-disabled { cursor: not-allowed; }
.stm-card__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.stm-card__box {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid #ebecec;
  border-radius: 12px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.stm-card:hover .stm-card__box { border-color: #b5b9ba; }
.stm-card.is-disabled .stm-card__box { opacity: 0.55; }
/* 選取框：以 ::after 疊在內容最上層畫 2px 藍框（inset box-shadow 會被貼齊上緣的圖片蓋住，造成上細下粗） */
.stm-card__box::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  transition: border-color 0.15s ease;
}
.stm-card__input:checked + .stm-card__box { border-color: #3360ff; }
.stm-card__input:checked + .stm-card__box::after { border-color: #3360ff; }
.stm-card__input:focus-visible + .stm-card__box {
  outline: 2px solid #3360ff;
  outline-offset: 2px;
}

.stm-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 3px 10px;
  border-radius: 99px;
  background: #e5484d;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.stm-card__media {
  display: block;
  aspect-ratio: 5 / 4;
  background: #f3f4f6;
  overflow: hidden;
}
.stm-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stm-card__text { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px 16px; }
.stm-card__name { font-size: 16px; font-weight: 600; line-height: 1.4; }
.stm-card__tagline { font-size: 14px; color: #656b6e; line-height: 1.4; }

.stm__hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 14px;
  color: #c0392b;
}

.stm__foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 24px 32px 32px;
}

@media (max-width: 1023px) {
  .stm__dialog { width: 720px; }
  .stm__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .stm { padding: 0; align-items: stretch; }
  .stm__dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .stm__close { top: 12px; right: 12px; }
  .stm__body { padding: 64px 20px 16px; }
  .stm__head { margin-bottom: 20px; }
  .stm__title { font-size: 24px; }
  .stm__subtitle { font-size: 14px; }
  .stm__grid { gap: 12px; }
  .stm-card__text { padding: 10px 12px 12px; }
  .stm-card__name { font-size: 15px; }
  .stm-card__tagline { font-size: 13px; }
  .stm__foot { padding: 12px 20px 20px; border-top: 1px solid #ebecec; }
  .stm__foot .button { width: 100%; }
}

/* AI Preview 以 AJAX 載入時的 host（.aip 本身為 fixed 全螢幕） */
.aip-host[hidden] { display: none !important; }
