/* =========================================================
   CoreanLab Mobile Fix Pack (Blocksy)
   목표: (1) 가로 튐 제거 (2) 모바일 폭/여백 정상화 (3) 썸네일 규격 통일
   ========================================================= */

/* 0) 가로 스크롤 방지 + 미디어 기본 안전장치 */
html, body {
  overflow-x: hidden !important;
  width: 100%;
}

img, video, iframe {
  max-width: 100% !important;
}

figure, .wp-block-image, .wp-block-embed, .wp-block-table {
  max-width: 100% !important;
}

/* 1) 모바일 컨텐츠 좌우 여백: "한 군데에서만" 통제 */
@media (max-width: 768px) {

  /* Blocksy 컨테이너/콘텐츠 영역을 풀폭에 가깝게 */
  .ct-container,
  .site-content,
  .content-area,
  .entry-content,
  .ct-content {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ✅ 핵심: 좌우 여백을 과도하게 쌓지 말고 16px로 통일 */
  .ct-container,
  .site-content,
  .content-area {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Gutenberg 'constrained' 때문에 쪼그라드는 현상 방지 */
  .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width: 100% !important;
  }

  /* Alignwide/Alignfull이 이상하게 튀면 이것도 */
  .alignwide, .alignfull {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* 2) 카드(글 리스트) 여백/가독성 */
  .ct-post-card {
    margin-bottom: 26px !important;
  }

  .ct-post-card .entry-title,
  .ct-post-card .ct-entry-title {
    font-size: 20px !important;
    line-height: 1.28 !important;
    word-break: keep-all !important;
    overflow-wrap: anywhere !important; /* 긴 영문 제목 안전장치 */
  }

  /* 3) ✅ 썸네일 규격 통일 (추천: 4:5) */
  .ct-post-card .ct-image-container {
    width: 100% !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    aspect-ratio: 4 / 5;
  }

  .ct-post-card .ct-image-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
  }

  /* 4) 테이블/코드가 가로를 뚫는 대표 원인들 */
  .wp-block-table {
    overflow-x: auto !important;
  }

  pre, code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
  }

  /* 5) 광고(최소 안전장치): 모바일 폭 넘침 방지 */
  ins.adsbygoogle {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  .adsbygoogle iframe,
  iframe[id^="google_ads_iframe_"] {
    max-width: 100% !important;
  }
}

/* =========================================================
   옵션: 썸네일을 16:9로 하고 싶으면 위 4:5를 아래로 교체
   .ct-post-card .ct-image-container { aspect-ratio: 16 / 9; }
   ========================================================= */

/* Fix: homepage post grid touching screen edges (Blocksy) */
@media (max-width: 768px){
  body.home .ct-container,
  body.home .content-area,
  body.home .ct-content,
  body.home .entry-content {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Prevent any block from causing horizontal overflow */
  body.home .ct-content > * {
    max-width: 100% !important;
  }
}

/* Global safety: kill horizontal scroll */
html, body { overflow-x: hidden !important; }
/* 1) Prevent ads from breaking layout */
ins.adsbygoogle,
.adsbygoogle {
  max-width: 100% !important;
  width: 100% !important;
  display: block !important;
  overflow: hidden !important;
}

/* 2) If any ad iframe tries to be wider than the screen */
.adsbygoogle iframe,
ins.adsbygoogle iframe,
iframe[src*="ads"],
iframe[id^="google_ads_iframe"] {
  max-width: 100% !important;
}

/* 3) Safety: stop horizontal overflow caused by ads */
html, body {
  overflow-x: hidden !important;
}