/* ════════════════════════════════════════════════════════════════════════
   APP MODE: the phone layout.

   Everything here sits inside max-width:720px (the same breakpoint the tab bar
   uses), so desktop and tablet never see it. The aim is an app, not a long
   web page: long card grids become swipeable rails, long copy folds behind
   "Read more", course pages get a sticky section switcher, and the four
   floating buttons collapse into one "Talk" tab. Nothing is removed from the
   HTML, so search engines still read the whole page.

   Paired with assets/js/app-mobile.js, which adds the rail dots, folds, the
   section chips and the Talk / More sheets. Without JS the rails still swipe.
   ════════════════════════════════════════════════════════════════════════ */

@media (max-width: 720px) {

  /* Full-bleed rails use 100vw, which can round a pixel past the screen */
  html.app-on, html.app-on body { overflow-x: clip; }

  /* ── Rhythm: app screens are denser than web pages ─────────────────── */
  .section { padding: 40px 0; }
  .section-heading { margin-bottom: 20px; }
  .section-heading h2, .section h2 { font-size: clamp(26px, 7.4vw, 32px); line-height: 1.12; }
  .section-heading p { font-size: 15px; }
  .hero { min-height: 0; }
  .hero-inner { padding: 28px 18px 18px; }
  .hero h1 { font-size: clamp(30px, 8.6vw, 38px); }
  .hero .eyebrow { font-size: 11px; }

  /* ── Rails: long card grids become horizontal swipe lists ──────────── */
  .why-grid,
  .ttc-grid,
  body:not(.app-listing) .course-grid,
  .steps-grid,
  .post-grid,
  .cert-assurance,
  .bjy-fee-cards,
  .course-gallery,
  .special-sessions-grid,
  .exc-grid,
  .apply-steps,
  .intl-grid,
  .dl-plan,
  #sec-accommodation [data-lb-group="Accommodation"],
  .app-rail {
    display: flex !important;
    flex-wrap: nowrap !important;
    grid-template-columns: none !important;
    gap: 12px !important;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;
    width: 100vw !important;
    max-width: none !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
    padding: 4px 16px 14px !important;
    box-sizing: border-box;
    max-height: none !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .why-grid::-webkit-scrollbar,
  .ttc-grid::-webkit-scrollbar,
  .course-grid::-webkit-scrollbar,
  .steps-grid::-webkit-scrollbar,
  .post-grid::-webkit-scrollbar,
  .cert-assurance::-webkit-scrollbar,
  .bjy-fee-cards::-webkit-scrollbar,
  .course-gallery::-webkit-scrollbar,
  .special-sessions-grid::-webkit-scrollbar,
  .exc-grid::-webkit-scrollbar,
  .apply-steps::-webkit-scrollbar,
  .intl-grid::-webkit-scrollbar,
  .dl-plan::-webkit-scrollbar,
  #sec-accommodation [data-lb-group="Accommodation"]::-webkit-scrollbar,
  .app-rail::-webkit-scrollbar { display: none; }

  .why-grid > *,
  .ttc-grid > *,
  body:not(.app-listing) .course-grid > *,
  .steps-grid > *,
  .post-grid > *,
  .cert-assurance > *,
  .bjy-fee-cards > *,
  .special-sessions-grid > *,
  .exc-grid > *,
  .apply-steps > *,
  .intl-grid > *,
  .dl-plan > *,
  .app-rail > * {
    flex: 0 0 84% !important;
    max-width: 84% !important;
    min-width: 0;
    margin: 0 !important;
    scroll-snap-align: start;
  }
  /* Short cards: show more of the next one so the swipe is obvious */
  .why-grid > *, .steps-grid > *, .apply-steps > *, .intl-grid > * {
    flex-basis: 72% !important; max-width: 72% !important;
  }
  /* The "show all countries" toggle means nothing once the grid is a rail */
  .intl-grid--collapsed > * { display: block !important; }
  .intl-more-wrap { display: none !important; }

  /* Photo rails: fixed-height frames so the rail doesn't jump */
  .course-gallery > *,
  #sec-accommodation [data-lb-group="Accommodation"] > * {
    flex: 0 0 78% !important;
    max-width: 78% !important;
    height: 230px !important;
    margin: 0 !important;
    scroll-snap-align: start;
    border-radius: 14px;
    overflow: hidden;
    grid-column: auto !important; grid-row: auto !important;
  }
  .course-gallery > * img,
  #sec-accommodation [data-lb-group="Accommodation"] > * img {
    width: 100% !important; height: 100% !important; object-fit: cover;
  }

  /* Rail position dots (added by app-mobile.js) */
  .app-dots {
    display: flex; justify-content: center; gap: 6px;
    margin: 2px 0 6px; pointer-events: none;
  }
  .app-dots span {
    width: 6px; height: 6px; border-radius: 99px;
    background: color-mix(in srgb, var(--maroon) 25%, transparent);
    transition: width .2s, background .2s;
  }
  .app-dots span.on { width: 18px; background: var(--maroon); }
  .app-rail-count {
    display: block; text-align: right; margin: -4px 0 6px;
    font-size: 12px; font-weight: 600; color: var(--muted);
  }

  /* ── Folds: long copy collapses behind "Read more" ─────────────────── */
  .app-fold {
    position: relative;
    max-height: var(--fold-h, 300px);
    overflow: hidden;
  }
  .app-fold::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 90px;
    background: linear-gradient(to bottom, transparent, var(--fold-bg, var(--cream)));
    pointer-events: none;
  }
  .app-fold.is-open { max-height: none; }
  .app-fold.is-open::after { display: none; }
  .app-fold-btn {
    display: inline-flex; align-items: center; gap: 6px;
    margin: 10px 0 4px; padding: 9px 16px;
    border: 1px solid var(--border); border-radius: 99px;
    background: var(--white); color: var(--maroon-dark);
    font: 600 14px/1 var(--sans); cursor: pointer;
  }
  .app-fold-btn svg { transition: transform .2s; }
  .app-fold-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

  /* ── Course page: sticky section chips replace the floating menu ───── */
  .app-chips {
    position: sticky; top: var(--app-head, 68px); z-index: 45;
    display: flex; gap: 8px; overflow-x: auto;
    padding: 10px 16px;
    background: rgba(253, 249, 245, .97);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .app-chips::-webkit-scrollbar { display: none; }
  .app-chips a {
    flex: 0 0 auto; padding: 8px 14px; border-radius: 99px;
    border: 1px solid var(--border); background: var(--white);
    color: var(--ink); font: 600 13px/1 var(--sans); text-decoration: none;
    white-space: nowrap;
  }
  .app-chips a.on { background: var(--maroon-dark); border-color: var(--maroon-dark); color: #fff; }
  body.has-app-chips .page-toc { display: none !important; }
  body.has-app-chips [id^="sec-"] { scroll-margin-top: calc(var(--app-head, 68px) + 58px); }

  /* ── /courses: compact list rows instead of full-height cards ───────── */
  body.app-listing .course-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  body.app-listing .course-grid > .course-card {
    display: grid !important; grid-template-columns: 116px 1fr !important; align-items: stretch;
    flex-direction: row !important;
    border-radius: 14px; overflow: hidden; min-height: 0 !important;
  }
  body.app-listing .course-grid > .course-card .cc-image-wrap {
    position: relative; height: auto !important; min-height: 150px; aspect-ratio: auto !important; margin: 0 !important;
  }
  body.app-listing .course-grid > .course-card .cc-image-wrap img {
    position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: cover;
  }
  body.app-listing .course-grid > .course-card .cc-body { min-width: 0; justify-content: flex-start !important; }
  body.app-listing .course-card .cc-cat-badge { display: none; }
  body.app-listing .course-card .cc-duration-badge { font-size: 10px; padding: 3px 7px; left: 6px; bottom: 6px; top: auto; }
  body.app-listing .course-card .cc-body { padding: 12px 12px 12px 14px; gap: 6px; }
  body.app-listing .course-card .cc-title { font-size: 17px; line-height: 1.2; margin: 0; }
  body.app-listing .course-card .cc-summary,
  body.app-listing .course-card .cc-points,
  body.app-listing .course-card .cc-meta > span:nth-child(2) { display: none; }
  body.app-listing .course-card .cc-seal { transform: scale(.62); transform-origin: bottom right; }
  body.app-listing .course-card .cc-meta { margin: 0; padding: 0; border: 0; font-size: 13px; }
  body.app-listing .course-card .cc-from { margin: 0; font-size: 14px; }
  body.app-listing .course-card .cc-actions .cc-reserve-link { font-size: 12.5px; }
  body.app-listing .course-card .cc-info-rows { gap: 2px; margin: 0; }
  body.app-listing .course-card .cc-info-row:not(.cc-info-row--highlight) { display: none; }
  body.app-listing .course-card .cc-info-row { font-size: 12.5px; padding: 0; border: 0; }
  body.app-listing .course-card .cc-price-block { margin: 2px 0 0; padding: 0; }
  body.app-listing .course-card .cc-price-amount { font-size: 18px; }
  body.app-listing .course-card .cc-actions { gap: 6px; margin-top: 4px; }
  body.app-listing .course-card .cc-actions .btn { padding: 8px 10px; font-size: 12.5px; flex: 1; min-height: 0; }

  /* Course cards inside rails: a teaser, the full story is one tap away */
  body:not(.app-listing) .course-grid .cc-summary {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  body:not(.app-listing) .course-grid .cc-points li:nth-child(n+4) { display: none; }
  .ttc-card .ov-body { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }

  /* Long lists: first five, then "See all" (app-mobile.js) */
  .app-cut > *:nth-child(n+6):not(.app-fold-btn) { display: none !important; }

  /* Newsletter: the email box grew to ~140px tall when the row stacked */
  .nl-row { flex-direction: column; }
  .nl-row input[type="email"] { flex: 0 0 auto !important; height: 48px; }
  .nl-btn { width: 100%; }

  /* ── Homepage batches: first three rows, "See all" reveals the rest ── */
  .batch-table-wrap.app-short > .batch-row:nth-of-type(n+4) { display: none; }

  /* ── Footer: link columns become tap-to-open rows ──────────────────── */
  .footer-inner > div:not(.footer-brand) { border-top: 1px solid rgba(255,255,255,.12); }
  .footer-inner > div:not(.footer-brand) > h3 {
    display: flex; justify-content: space-between; align-items: center;
    margin: 0; padding: 14px 0; cursor: pointer;
  }
  .footer-inner > div:not(.footer-brand) > h3::after {
    content: "+"; font: 400 22px/1 var(--sans); opacity: .7;
  }
  .footer-inner > div.is-open > h3::after { content: "–"; }
  .footer-inner > div:not(.footer-brand) > ul { display: none; padding-bottom: 12px; }
  .footer-inner > div.is-open > ul { display: block; }
  .footer-inner { gap: 0 !important; }
  .footer-brand { padding-bottom: 18px; }
  .footer-brand p { font-size: 14px; }

  /* ── One floating thing, not four ───────────────────────────────────── */
  html.app-on .wa-widget,
  html.app-on .share-fab,
  html.app-on .oyc-launch,
  html.app-on .oyc-tab,
  html.app-on .oyc-invite { display: none !important; }
  /* The chat panel still opens full-screen from the Talk tab */
  html.app-on .oyc { left: 0; right: 0; bottom: 0; }

  /* ── Tab bar: Home · Courses · [Talk] · Reviews · More ─────────────── */
  html.app-on .mobile-tabbar { height: calc(62px + env(safe-area-inset-bottom, 0px)); }
  html.app-on .tabbar-item { flex: 1 1 0; min-width: 0; font-size: 10.5px; position: relative; background: none; border: 0; font-family: var(--sans); cursor: pointer; }
  html.app-on .tabbar-item--talk { color: var(--maroon-dark); }
  html.app-on .tabbar-item--talk .talk-bubble {
    width: 46px; height: 30px; border-radius: 99px;
    display: grid; place-items: center;
    background: var(--maroon-dark); color: #fff;
  }
  html.app-on .tabbar-item--talk .talk-bubble svg { opacity: 1; }
  html.app-on .tabbar-item .app-dot {
    position: absolute; top: 4px; right: calc(50% - 20px);
    width: 9px; height: 9px; border-radius: 50%;
    background: #25d366; box-shadow: 0 0 0 2px var(--cream);
  }
  html.app-on .tabbar-item--talk .app-dot { top: 3px; right: calc(50% - 26px); }

  /* ── Course page booking bar: price + Book + WhatsApp, one strip ───── */
  html.app-on .mobile-book-bar { padding: 10px 14px; gap: 10px; }
  html.app-on .mobile-book-bar .mbb-price { min-width: 0; flex: 1 1 auto; }
  html.app-on .mobile-book-bar .mbb-btn { flex: 0 0 auto; padding-inline: 16px; white-space: nowrap; }
  html.app-on .mobile-book-bar .mbb-wa {
    flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; background: #25d366; color: #fff;
  }
  html.app-on .mobile-book-bar .mbb-wa svg { width: 24px; height: 24px; fill: #fff; }

  /* ── Bottom sheets (Talk / More / Install) ──────────────────────────── */
  .app-sheet-scrim {
    position: fixed; inset: 0; z-index: 990;
    background: rgba(24,10,0,.42);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .app-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 991;
    max-height: 86vh; overflow-y: auto;
    background: var(--cream); color: var(--ink);
    border-radius: 22px 22px 0 0;
    padding: 10px 18px calc(22px + env(safe-area-inset-bottom, 0px));
    transform: translateY(105%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  }
  .app-sheet.is-open { transform: none; }
  .app-sheet.is-open + .app-sheet-scrim, .app-sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
  .app-sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 14px; }
  .app-sheet h3 { font-size: 22px; margin: 0 0 4px; }
  .app-sheet .app-sheet-sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
  .app-sheet-list { display: grid; gap: 8px; }
  .app-sheet-list a, .app-sheet-list button {
    display: flex; align-items: center; gap: 14px; width: 100%;
    padding: 13px 14px; border-radius: 14px;
    background: var(--white); border: 1px solid var(--border);
    color: var(--ink); text-decoration: none; text-align: left;
    font: 600 15px/1.25 var(--sans); cursor: pointer;
  }
  .app-sheet-list small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
  .app-sheet-list .ico {
    flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center; font-size: 19px;
    background: var(--light-bg); color: var(--maroon-dark);
  }
  .app-sheet-list .ico--wa { background: #25d366; color: #fff; }
  .app-sheet-list .ico svg { width: 20px; height: 20px; }
  .app-sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .app-sheet-grid a, .app-sheet-grid button {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 6px; border-radius: 14px;
    background: var(--white); border: 1px solid var(--border);
    color: var(--ink); text-decoration: none;
    font: 600 12.5px/1.2 var(--sans); text-align: center; cursor: pointer;
  }
  .app-sheet-grid .ico { font-size: 22px; line-height: 1; }
  .app-sheet-section { margin: 18px 0 8px; font: 700 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .app-install-card {
    display: flex; align-items: center; gap: 12px; margin-top: 16px;
    padding: 14px; border-radius: 16px;
    background: var(--maroon-dark); color: #fff;
  }
  .app-install-card img { width: 44px; height: 44px; border-radius: 12px; background: #fff; }
  .app-install-card strong { display: block; font-size: 15px; color: #fff; }
  .app-install-card span { font-size: 12.5px; opacity: .85; color: #fff; }
  .app-install-card button {
    margin-left: auto; padding: 9px 14px; border-radius: 99px; border: 0;
    background: #fff; color: var(--maroon-dark); font: 700 13px/1 var(--sans); cursor: pointer;
  }
  .app-ios-steps { margin: 6px 0 0; padding-left: 20px; font-size: 15px; line-height: 1.7; }
}

/* ── Installed app (standalone PWA): no browser chrome to make room for ─ */
@media (display-mode: standalone) {
  .top-strip { display: none !important; }
  .site-header { padding-top: env(safe-area-inset-top, 0px); }
}

/* App-only pieces never show on larger screens, even after a resize */
@media (min-width: 721px) {
  .app-chips, .app-dots, .app-rail-count, .app-fold-btn,
  .app-sheet, .app-sheet-scrim, .mbb-wa, .tabbar-item--talk, .tabbar-item--more { display: none !important; }
  .app-fold { max-height: none !important; }
  .app-fold::after { display: none !important; }
}
