/* ============================================================
   hsk.xuexi.kr — mobile responsive layer (added 2026-11-21)
   Loaded last in <head> so these rules win on small screens.
   Desktop layout is untouched: everything lives under 768px,
   except the CJK line-break fix which only affects .zh-text.
   ============================================================ */

/* Chinese essay text must break between characters.
   The site-wide Korean `word-break: keep-all` otherwise makes
   long Chinese sentences overflow their cards on any screen. */
.zh-text {
  word-break: break-all;
  line-break: anywhere;
  overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  /* Safety net: nothing may push the page sideways. */
  html, body { overflow-x: hidden; }
  img, video, iframe { max-width: 100%; }

  /* Flex children must be allowed to shrink below content size,
     otherwise cards inherit the widest line inside them. */
  .apple-card .flex > *, main .flex > * { min-width: 0; }

  /* Essay cards: tighter padding, slightly smaller type,
     so the model essays fit a phone screen. */
  .apple-card { padding: 20px 16px !important; border-radius: 20px; }
  .zh-text { font-size: 16.5px !important; line-height: 2.0 !important; }
  .zh-pinyin { font-size: 11.5px; }

  /* Shorts player: centred, never wider than the screen. */
  .shorts-container {
    max-width: min(280px, 82vw) !important;
    margin-left: auto;
    margin-right: auto;
  }
  .shorts-container iframe { width: 100% !important; height: 100% !important; }

  /* Long unbreakable words in body copy wrap instead of
     nudging a card wider than the screen. */
  main p, main li { overflow-wrap: break-word; }

  /* Category filter tabs: one line per tab, sized to the label,
     in a sideways-scrolling strip. They must never be squeezed
     into narrow multi-line pills. */
  .filter-btn {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }

  /* Full-width buttons inside essay cards: slightly smaller,
     tighter tracking so long labels stay on one line. */
  .apple-card a[class~="w-full"],
  .apple-card button[class~="w-full"] {
    font-size: 13px;
    letter-spacing: -0.03em;
    padding-left: 14px;
    padding-right: 14px;
  }

  /* Data tables (scores etc.): scroll sideways inside the page
     instead of stretching it. */
  main table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Category / filter tab rows: smooth touch scrolling,
     no visible scrollbar, soft fade handled by padding. */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .overflow-x-auto::-webkit-scrollbar { display: none; }

  /* Sticky bottom CTA bars & fixed bottom nav:
     respect the iPhone home-indicator area and slim down. */
  aside.sticky.bottom-0, .fixed.bottom-0 {
    padding-bottom: env(safe-area-inset-bottom);
  }
  aside.sticky.bottom-0 .text-base { font-size: 14px; }
  aside.sticky.bottom-0 .text-sm { font-size: 12.5px; }

  /* Header rows: let the two pill buttons share the width
     instead of squeezing each other off-screen. */
  header .whitespace-nowrap { white-space: normal; }
  header a, header button { min-height: 40px; }

  /* Forms: 16px inputs stop iOS Safari auto-zoom on focus. */
  input, select, textarea { font-size: 16px !important; }

  /* Long Korean/English words in headings wrap instead of clipping. */
  h1, h2, h3 { overflow-wrap: break-word; }
}

@media (max-width: 380px) {
  /* Very small phones (Galaxy Fold class, older iPhones). */
  .zh-text { font-size: 15.5px !important; }
  .apple-card { padding: 16px 13px !important; }
}
