/* ========================================================
   [자수한스푼] 전역 반응형 디자인 아키텍처 (Fluid & Container Queries)
   - 모바일 / 태블릿 / 데스크톱 및 레이아웃 빌더 캔버스 동시 완벽 지원
   ======================================================== */

/* 1. 컨테이너 쿼리 지원 컨테이너 지정 (웹 화면 및 빌더 실시간 캔버스) */
.site-wrapper,
#layout-builder-root,
#builder-live-canvas,
.canvas-block-node,
.smartstore-detail-container,
.checkout-container,
.section-block {
  container-type: inline-size;
}

/* 2. 데스크톱 기본 상태: 모바일 햄버거 토글 버튼 숨김 */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-primary);
  line-height: 1;
}

/* ========================================================
   [브레이크포인트 1] 1024px 이하 (노트북 및 소형 데스크톱)
   ======================================================== */
@media (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@container (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ========================================================
   [브레이크포인트 2] 860px 이하 (태블릿 및 표준 모바일)
   ======================================================== */
@media (max-width: 860px) {
  :root {
    --header-height: var(--header-height-mobile, 56px);
  }

  .container {
    padding: 0 var(--container-padding, 16px);
  }

  /* 햄버거 메뉴 토글 노출 */
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 헤더 네비게이션 드롭다운 메뉴 */
  .nav-menu {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: #ffffff;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 16px 16px;
    border-bottom: 2px solid var(--color-accent);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s ease;
    z-index: 99;
  }

  .nav-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .nav-link {
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 12px 8px;
    border-bottom: 1px solid #f1f3f5;
    display: block;
    width: 100%;
  }

  .nav-link.active::after {
    display: none;
  }
  .nav-link.active {
    color: var(--color-accent);
    font-weight: 700;
  }

  .header-actions {
    gap: 6px;
  }
  .header-actions .btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  /* 섹션 공통 헤더 폰트 및 줄바꿈 */
  .section-header {
    margin-bottom: 24px;
  }
  .section-title {
    font-size: clamp(1.3rem, 4.5vw, 1.6rem) !important;
    white-space: normal !important;
    word-break: keep-all;
    line-height: 1.35;
  }
  .section-subtitle {
    font-size: clamp(0.85rem, 2.5vw, 0.95rem) !important;
    white-space: normal !important;
    word-break: keep-all;
  }

  /* 1. 히어로 비주얼 배너 모바일/태블릿 적응형 레이아웃 (텍스트 충돌/뭉게짐 원천 차단) */
  .block-hero-banner.full-screen {
    min-height: clamp(440px, 70dvh, 580px) !important;
    padding: 20px 0;
  }

  .hero-content-overlay {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 14px !important;
    padding: 30px 16px !important;
    position: absolute !important;
    inset: 0 !important;
    pointer-events: none !important;
    box-sizing: border-box !important;
  }

  .hero-draggable-text-box,
  .hero-draggable-btn-box {
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    pointer-events: auto !important;
  }

  .hero-draggable-text-box .hero-text-anim-card {
    display: flex !important;
    justify-content: center !important;
  }

  .hero-text-content {
    text-align: center !important;
    white-space: normal !important;
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
    line-height: 1.4 !important;
  }

  .hero-draggable-text-box:nth-of-type(1) .hero-text-content {
    font-size: clamp(1.45rem, 5.2vw, 2.1rem) !important;
    font-weight: 800 !important;
  }
  .hero-draggable-text-box:nth-of-type(2) .hero-text-content {
    font-size: clamp(0.9rem, 2.8vw, 1.15rem) !important;
    font-weight: 500 !important;
  }
  .hero-draggable-text-box:nth-of-type(n+3) .hero-text-content {
    font-size: clamp(0.82rem, 2.5vw, 1rem) !important;
  }

  .hero-standalone-images-container {
    opacity: 0.3 !important;
  }

  .hero-multi-img-layer {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-width: 85% !important;
    max-height: 70% !important;
    pointer-events: none !important;
  }

  .hero-draggable-btn-box {
    margin-top: 10px !important;
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
  }
  .hero-draggable-btn-box .btn {
    font-size: 0.92rem !important;
    padding: 11px 22px !important;
  }

  /* 2. 제품 소개 / 상세 블록 (스마트스토어 1열 스택 최적화) */
  .detail-top-wrapper {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  .detail-gallery.layout-thumbs-left {
    flex-direction: column-reverse !important;
    gap: 10px !important;
  }

  .detail-gallery.layout-thumbs-left .sub-thumbs-vertical {
    flex-direction: row !important;
    max-height: none !important;
    overflow-x: auto !important;
    width: 100%;
    padding-bottom: 4px;
  }

  .detail-title {
    font-size: clamp(1.2rem, 4.5vw, 1.55rem) !important;
    line-height: 1.35;
    white-space: normal !important;
    word-break: keep-all;
  }

  .detail-summary {
    font-size: 0.875rem !important;
    line-height: 1.5;
    white-space: normal !important;
    word-break: keep-all;
  }

  .action-buttons-grid {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .action-buttons-grid .btn,
  .btn-detail-cart,
  .btn-detail-pay {
    flex: 1 1 0;
    min-height: 48px;
    font-size: 0.92rem !important;
  }

  /* 3. 상품 카드 및 쇼케이스 그리드 2열 */
  .grid-cols-4,
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .product-card .card-title {
    font-size: 0.9375rem !important;
    white-space: normal !important;
    word-break: keep-all;
    line-height: 1.4;
  }

  .product-price {
    font-size: 1.05rem !important;
  }

  .product-card .btn-sm {
    padding: 7px 4px !important;
    font-size: 0.78rem !important;
  }

  /* 4. 2분할 스토리 미디어 블록 세로 스택 */
  .block-text-media .container > div {
    flex-direction: column !important;
    gap: 24px !important;
    text-align: center;
  }
  .block-text-media h2 {
    font-size: clamp(1.3rem, 4.5vw, 1.7rem) !important;
    white-space: normal !important;
    word-break: keep-all;
  }
  .block-text-media .container > div > div:first-child > div:last-child {
    justify-content: center !important;
  }

  /* 5. 푸터 반응형 */
  .footer-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .footer-links {
    flex-wrap: wrap;
    gap: 12px;
  }

  /* 6. 플로팅 퀵바 모바일 위치 */
  .floating-quick-bar {
    right: 12px;
    bottom: 24px;
    top: auto;
    transform: none;
    border-radius: 8px;
    border-right: 1px solid var(--color-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  }
  .quick-bar-btn {
    width: 42px;
    height: 42px;
  }

  /* 7. 체크아웃 그리드 1열 전환 */
  .checkout-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
}

/* Container Query: 태블릿 및 모바일 (캔버스 및 모듈화 컨테이너 동일 적용) */
@container (max-width: 860px) {
  .section-title {
    font-size: clamp(1.3rem, 4.5cqw, 1.6rem) !important;
    white-space: normal !important;
    word-break: keep-all;
    line-height: 1.35;
  }
  .section-subtitle {
    font-size: clamp(0.85rem, 2.5cqw, 0.95rem) !important;
    white-space: normal !important;
    word-break: keep-all;
  }

  .block-hero-banner.full-screen {
    min-height: 480px !important;
  }

  .hero-draggable-text-box {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
  }

  .hero-draggable-text-box .hero-text-anim-card {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
  }

  .hero-text-content {
    text-align: center !important;
    white-space: normal !important;
    word-break: keep-all !important;
    line-height: 1.35 !important;
    margin: 0 auto !important;
  }

  .hero-draggable-text-box:nth-of-type(1) .hero-text-content {
    font-size: clamp(1.45rem, 5.5cqw, 2.2rem) !important;
  }
  .hero-draggable-text-box:nth-of-type(2) .hero-text-content {
    font-size: clamp(0.88rem, 2.8cqw, 1.1rem) !important;
  }

  .hero-multi-img-layer {
    max-width: 82% !important;
    max-height: 52% !important;
  }

  .hero-draggable-btn-box {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 320px !important;
    margin: 10px auto 0 !important;
    display: flex !important;
    justify-content: center !important;
  }

  .detail-top-wrapper {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .detail-gallery.layout-thumbs-left {
    flex-direction: column-reverse !important;
    gap: 10px !important;
  }

  .detail-gallery.layout-thumbs-left .sub-thumbs-vertical {
    flex-direction: row !important;
    max-height: none !important;
    overflow-x: auto !important;
    width: 100%;
  }

  .grid-cols-4,
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .block-text-media .container > div {
    flex-direction: column !important;
    gap: 20px !important;
    text-align: center;
  }
}

/* ========================================================
   [브레이크포인트 3] 520px 이하 (스마트폰 소형 화면)
   ======================================================== */
@media (max-width: 520px) {
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  #showcase-items-grid {
    grid-template-columns: 1fr !important;
  }

  .header-logo-img {
    height: 32px;
  }
  #header-brand-name {
    font-size: 1.05rem;
  }

  /* 히어로 배너 버튼 전체 너비 및 중앙 정렬 */
  .hero-draggable-btn-box {
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 300px !important;
    margin: 10px auto 0 !important;
    align-items: center !important;
  }
  .hero-draggable-btn-box .btn,
  .hero-content-overlay .btn-lg {
    width: 100% !important;
    max-width: 300px !important;
    margin: 0 auto 6px !important;
    text-align: center !important;
  }

  .hero-multi-img-layer {
    max-width: 88% !important;
    max-height: 44% !important;
  }

  /* 상세 페이지 컨테이너 및 옵션 여백 */
  .smartstore-detail-container {
    margin: 16px auto 50px !important;
    padding: 0 12px !important;
  }

  .detail-top-wrapper {
    gap: 16px !important;
  }

  /* 인-페이지 견적문의 폼 1열 */
  .inq-grid-2col {
    grid-template-columns: 1fr !important;
  }

  /* 상품 상세 탭 가로 스크롤 대응 */
  .smartstore-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .smartstore-tabs .tab-item {
    padding: 10px 16px !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
  }
}

/* Container Query: 소형 모바일 (520px 이하) */
@container (max-width: 520px) {
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  #showcase-items-grid {
    grid-template-columns: 1fr !important;
  }

  .hero-draggable-btn-box {
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 300px !important;
    margin: 10px auto 0 !important;
    align-items: center !important;
  }
  .hero-draggable-btn-box .btn {
    width: 100% !important;
    max-width: 300px !important;
    margin: 0 auto 6px !important;
    text-align: center !important;
  }

  .hero-multi-img-layer {
    max-width: 88% !important;
    max-height: 44% !important;
  }

  .detail-top-wrapper {
    gap: 16px !important;
  }

  .inq-grid-2col {
    grid-template-columns: 1fr !important;
  }
}
