/**
 * Page-scoped layout fixes for /hong-kong-ai-courses/ and /faq/ only.
 * Does not change global chat, typography, or other templates.
 */

/* ——— 香港 AI 課程專頁 ———
   Cause: .aia-page-hero--rich h1 uses word-break:keep-all + line-break:strict,
   so the last clause「按你的業務帶做並帶走成品」cannot wrap. CSS Grid
   min-width:auto then expands the page past the viewport (horizontal scroll),
   and .aia-page-hero { overflow:hidden } clips the last glyphs.
*/
body.page-template-page-hong-kong-ai-courses .aia-page-hero__grid,
body.page-template-page-hong-kong-ai-courses .aia-page-hero__grid > *,
body.page-template-page-hong-kong-ai-courses .aia-hub-choose,
body.page-template-page-hong-kong-ai-courses .aia-hub-table,
body.page-template-page-hong-kong-ai-courses .aia-wrap {
  min-width: 0;
  max-width: 100%;
}

body.page-template-page-hong-kong-ai-courses .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.page-template-page-hong-kong-ai-courses .aia-page-hero--rich h1 {
    font-size: clamp(1.7rem, 7.2vw, 2rem);
    line-height: 1.28;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-h2 .aia-nobr {
    white-space: normal;
  }

  /*
    Table remains a real 4-column table (7 rows). main.css stacks at 720px
    (display:block + data-label), but unscoped nth-child width 24/32/22/22%
    (0,2,1) beats the stacked width:100%/auto (0,1,1), so cells stay narrow
    columns. The previous overflow-wrap:anywhere then split Latin words
    (YouT/ube). Prefer contained horizontal scroll; do not mid-break words.
  */
  body.page-template-page-hong-kong-ai-courses .aia-hub-table {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table::before {
    content: "可左右滑動查看";
    display: block;
    position: sticky;
    left: 0;
    z-index: 1;
    padding: 0.55rem 1.15rem 0.2rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    background: #fff;
    white-space: nowrap;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table table {
    display: table;
    table-layout: auto;
    width: max-content;
    min-width: 40rem;
    max-width: none;
    word-break: normal;
    overflow-wrap: normal;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table thead {
    display: table-header-group;
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table tbody {
    display: table-row-group;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table tr {
    display: table-row;
    padding: 0;
    border: 0;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table caption {
    display: table-caption;
    white-space: normal;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table th,
  body.page-template-page-hong-kong-ai-courses .aia-hub-table td,
  body.page-template-page-hong-kong-ai-courses .aia-hub-table th:nth-child(n),
  body.page-template-page-hong-kong-ai-courses .aia-hub-table td:nth-child(n),
  body.page-template-page-hong-kong-ai-courses .aia-hub-table__price {
    display: table-cell;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--line);
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    line-break: auto;
    text-align: left;
    vertical-align: middle;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table th {
    padding: 0.85rem 1.15rem 0.95rem;
    border-top: 0;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table td {
    padding: 1.05rem 1.15rem;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table th:nth-child(4),
  body.page-template-page-hong-kong-ai-courses .aia-hub-table td:nth-child(4),
  body.page-template-page-hong-kong-ai-courses .aia-hub-table__price {
    text-align: right;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table td::before {
    content: none;
    display: none;
  }

  body.page-template-page-hong-kong-ai-courses .aia-hub-table a {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    max-width: none;
  }
}

/* ——— 常見問題 ———
   Ask MISA stays in the corner and remains usable. Reserve gutters so
   question/answer text is not covered at 390px or 1280px.
*/
body.page-id-33.aia-page-faq .aia-ask {
  padding-bottom: 5.75rem;
}

@media (max-width: 767px) {
  body.page-id-33.aia-page-faq .aia-ask__list {
    padding-right: 4.5rem;
    padding-bottom: 2.25rem;
  }

  body.page-id-33.aia-page-faq .aia-ask__item:last-child {
    margin-bottom: 2.5rem;
  }

  body.page-id-33.aia-page-faq .aia-ask__q {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (min-width: 768px) {
  body.page-id-33.aia-page-faq .aia-ask__list {
    padding-right: 12.5rem;
    padding-bottom: 2rem;
  }

  body.page-id-33.aia-page-faq .aia-ask {
    padding-bottom: 6.5rem;
  }

  body.page-id-33.aia-page-faq .aia-ask__a {
    box-sizing: border-box;
    max-width: 100%;
  }
}
