/* ═══════════════════════════════════════════════════════════════
   모바일 반응형 수정: 애니멀 토템 & 운명의 꽃
   - Overflow/Width, Touch/Click, Absolute Positioning, Flex/Grid
═══════════════════════════════════════════════════════════════ */

/* ─── 1. Overflow & Width 방지 ─── */
@media (max-width: 768px) {
  .feature-card-grid::before {
    inset: -12px 0;
    border-radius: 20px;
  }
  .feature-card-grid {
    overflow-x: hidden;
  }
  .tarot-tile,
  .feat-collection__grid > *,
  .tarot-collection__grid > * {
    min-width: 0;
  }
  .tarot-tile__body {
    min-width: 0;
    overflow: hidden;
  }
  .tarot-tile__title,
  .tarot-tile__desc {
    overflow-wrap: break-word;
    word-break: keep-all;
  }
  .feat-collection,
  .tarot-collection {
    overflow-x: hidden; /* overflow-y는 메인 스크롤용으로 visible 유지 */
  }
}

/* ─── 메인 화면 스크롤: 컬렉션/카드 내부 스크롤바 제거 → 페이지 스크롤만 동작 ─── */
#inputPage .feat-collection,
#inputPage .feat-collection--animal,
#inputPage .feat-collection--oracle,
#inputPage .feat-collection--cosmic,
#inputPage .feat-collection--flower,
#inputPage .tarot-collection,
#inputPage .feature-card-grid,
#inputPage .feat-collection__grid,
#inputPage .tarot-collection__grid {
  overflow-y: visible !important;
  overflow-x: hidden !important;
  max-height: none !important;
  height: auto !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
#inputPage .feat-collection::-webkit-scrollbar,
#inputPage .tarot-collection::-webkit-scrollbar,
#inputPage .feature-card-grid::-webkit-scrollbar,
#inputPage .feat-collection__grid::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* 메인 컬렉션 카드 뒤의 보조 백그라운드(회색 뒷판) 제거 */
#inputPage .feat-collection::before,
#inputPage .feat-collection::after,
#inputPage .tarot-collection::before,
#inputPage .tarot-collection::after,
#inputPage .fg-group__cards::before,
#inputPage .fg-group__cards::after {
  content: none !important;
  display: none !important;
  background: none !important;
  box-shadow: none !important;
}

#inputPage .fc-closed-peek {
  display: none !important;
}

/* 컬렉션 토글 힌트(눌러서 열기) 가독성 강화 */
#inputPage .fc-toggle-hint__text {
  font-size: clamp(0.92rem, 2.35vw, 1.04rem) !important;
  font-weight: 800 !important;
  letter-spacing: 0.045em;
  color: rgba(246, 241, 255, 0.98) !important;
  text-shadow: 0 0 8px rgba(196, 171, 255, 0.45);
}

#inputPage .fc-toggle-hint__arrow {
  font-size: 1.02em !important;
  color: rgba(229, 210, 255, 0.96) !important;
}

/* 컬렉션 래퍼 보조 레이어/배경 제거 + 스크롤 UX 개선 */
#inputPage .feature-card-grid::before,
#inputPage .feature-card-grid::after,
#inputPage .feature-card-grid > .fg-group::before,
#inputPage .feature-card-grid > .fg-group::after,
#inputPage .feature-card-grid > .fg-group > .fg-group__cards::before,
#inputPage .feature-card-grid > .fg-group > .fg-group__cards::after {
  content: none !important;
  display: none !important;
  background: none !important;
  box-shadow: none !important;
  pointer-events: none !important;
}

#inputPage .feature-card-grid > .fg-group,
#inputPage .feature-card-grid > .fg-group > .fg-group__cards {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

#inputPage .feature-card-grid {
  gap: 28px !important;
  margin-top: 28px !important;
  margin-bottom: 28px !important;
}

@media (max-width: 480px) {
  .feature-card-grid::before {
    inset: -8px 0;
  }
}

/* ─── 2. 운명의 꽃 카드 — absolute 요소가 터치를 가로채지 않도록 ─── */
.feature-card--destiny-flower .df-bud-icon,
.feature-card--destiny-flower .destiny-flower-glow,
.feature-card--destiny-flower .destiny-flower-sticker,
.feature-card--destiny-flower .df-garden-petal-field,
.feature-card--destiny-flower .df-garden-petal-field span,
.feature-card--destiny-flower .astrology-card-glow {
  pointer-events: none;
}

/* 운명의 꽃 feature-card 모바일 overflow 방지 */
@media (max-width: 768px) {
  .feature-card--destiny-flower .feature-card__img-wrap {
    min-height: 180px;
  }
  .feature-card--destiny-flower .feature-card__detail-content {
    padding: 14px 16px 18px;
  }
  .feature-card--destiny-flower .destiny-flower-stage {
    padding: 10px;
  }
  .feature-card--destiny-flower .df-source-tabs {
    gap: 6px;
  }
  .feature-card--destiny-flower .df-source-tab {
    min-height: 36px;
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}

/* ─── 3. dp-fsel (운세 선택 모달) — 프로필 카드 모바일 (한 칸에 2개씩) ─── */
@media (max-width: 480px) {
  .dp-fsel-btns {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .dp-fsel-btn {
    min-height: 44px;
    padding: 10px 12px;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
  }
  .dp-fsel-btn-icon {
    font-size: 1.4rem;
  }
  .dp-fsel-btn-label {
    font-size: 0.75rem;
    white-space: normal;
    word-break: keep-all;
    text-align: center;
    line-height: 1.2;
  }
  .dp-fsel-modal {
    padding: 24px 16px max(36px, env(safe-area-inset-bottom, 36px));
    max-height: 85dvh;
  }
  .dp-fsel-profile {
    margin-bottom: 14px;
  }
  .dp-fsel-zodiac {
    font-size: 2.2rem;
  }
  .dp-fsel-pname {
    font-size: 1rem;
  }
  .dp-fsel-ask {
    font-size: 0.82rem;
    margin-bottom: 14px;
  }
  .dp-fsel-close-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    top: 12px;
    right: 12px;
  }
}

/* ─── 4. 터치 영역 확보 & Z-index ─── */
.tarot-tile--animal-totem,
.tarot-tile--bloom,
.tarot-tile--astro-flower,
.tarot-tile--jami-flower,
.tarot-tile--sukuyo-fl {
  position: relative;
  z-index: 5;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* feat-collection 그리드: 모바일 터치 즉시 반응 (스크롤 지연 방지) */
@media (max-width: 768px) {
  .feat-collection__grid,
  .feat-collection--animal .feat-collection__grid,
  .feat-collection--flower .feat-collection__grid {
    touch-action: manipulation;
  }
}

/* feat-collection cosmos가 타일 위에 겹쳐도 터치 통과 (애니멀 토템 클릭 보장) */
.feat-collection__cosmos,
.feat-collection__cosmos .fc-star,
.tarot-collection__cosmos,
.tarot-collection__cosmos .tc-star {
  pointer-events: none;
}

/* 모바일: 오버레이 열림 시 확실한 표시 및 스크롤 (iOS Safari 등) — body 직계로 이동 시 viewport 전체 덮음 */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .animal-totem-overlay.is-open,
  .df-studio-overlay.is-show,
  .df-studio-overlay[style*="display: block"] {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100vw !important;
    z-index: 99999 !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    min-height: 100vh !important;
    min-height: -webkit-fill-available !important;
    -webkit-overflow-scrolling: touch !important;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    -webkit-tap-highlight-color: transparent;
  }
  /* 운명의 꽃 시트: 모바일 overflow 방지 */
  .df-studio-overlay .df-studio-sheet {
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* ─── 5. 애니멀 토템 오버레이 모바일 overflow 방지 ─── */
@media (max-width: 768px) {
  .animal-totem-shell {
    padding: 0 12px max(24px, env(safe-area-inset-bottom, 0px));
    max-width: 100%;
    overflow-x: hidden;
  }
  .animal-totem-overlay {
    overflow-x: hidden;
  }
}

/* ─── 6. 매우 좁은 화면 (360px 이하) ─── */
@media (max-width: 360px) {
  .feat-collection__grid,
  .tarot-collection__grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .tarot-tile {
    min-height: 120px;
  }
  .dp-fsel-btns {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .dp-fsel-btn {
    padding: 8px 10px;
    min-height: 42px;
  }
  .dp-fsel-btn-icon {
    font-size: 1.2rem;
  }
  .dp-fsel-btn-label {
    font-size: 0.7rem;
  }
}
