/**
 * Narrow mobile layout fixes for /courses/ and single aia_course pages.
 * Does not change the global Ask MISA widget, typography scale, or other templates.
 */

/* ——— 課程目錄 /courses/ ———
   Same cause as the 2026-11-13 hub QA fix: .aia-page-hero--rich h1 uses
   word-break:keep-all + line-break:strict, and .aia-page-hero { overflow:hidden }
   clips the last glyphs of「一對一直接預約」at 390px.
*/
body.post-type-archive-aia_course .aia-page-hero__grid,
body.post-type-archive-aia_course .aia-page-hero__grid > *,
body.post-type-archive-aia_course .aia-wrap {
  min-width: 0;
  max-width: 100%;
}

body.post-type-archive-aia_course .aia-page-hero--courses h1,
body.post-type-archive-aia_course .aia-page-hero--rich h1 {
  max-width: min(12em, 100%);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-break: auto;
  text-wrap: pretty;
}

@media (max-width: 720px) {
  body.post-type-archive-aia_course .aia-page-hero--courses h1,
  body.post-type-archive-aia_course .aia-page-hero--rich h1 {
    font-size: clamp(1.7rem, 7.2vw, 2rem);
    line-height: 1.28;
  }
}

/* ——— 課程頁 Ask MISA 避讓（≤767px）———
   Do not pad individual paragraphs or cards. At 390px the content column
   (.aia-wrap is calc(100% - 2.5rem)) only leaves 1.25rem on the right, while
   the icon launcher is ~3.25rem + 0.85rem inset, so mid-page cards sit under it.
   Reserve one right rail on main + footer, and compact the launcher into that
   rail. Chat stays tappable; header / 立即報名 is unchanged.
*/
@media (max-width: 767px) {
  body.single-aia_course,
  body.post-type-archive-aia_course {
    --aia-misa-safe: 2.5rem;
  }

  body.single-aia_course .aia-main,
  body.single-aia_course .aia-footer,
  body.post-type-archive-aia_course .aia-main,
  body.post-type-archive-aia_course .aia-footer {
    padding-right: var(--aia-misa-safe);
    box-sizing: border-box;
  }

  body.single-aia_course .aia-chat,
  body.post-type-archive-aia_course .aia-chat {
    right: 0.5rem;
    bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
  }

  body.single-aia_course .aia-chat:not(.is-open) .aia-chat__launcher,
  body.post-type-archive-aia_course .aia-chat:not(.is-open) .aia-chat__launcher {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.2rem;
    gap: 0;
    justify-content: center;
  }

  body.single-aia_course .aia-chat:not(.is-open) .aia-chat__launcher-pfp,
  body.post-type-archive-aia_course .aia-chat:not(.is-open) .aia-chat__launcher-pfp {
    width: 2.35rem;
    height: 2.35rem;
  }

  body.single-aia_course .aia-chat:not(.is-open) .aia-chat__launcher-glow,
  body.post-type-archive-aia_course .aia-chat:not(.is-open) .aia-chat__launcher-glow {
    display: none;
  }
}
