/*
 * Brightly phone layout (viewports up to 768px, tested targets 320-430px).
 *
 * Loaded after style.css. Everything except the first rule sits inside a
 * media query, so the desktop presentation is untouched.
 *
 * Two things here are deliberate and easy to "tidy away" by mistake:
 *  - Selectors start with `body` so they outrank the page-level <style>
 *    blocks that templates print later in the document.
 *  - `!important` appears only where a template sets the same property in an
 *    inline style="" attribute, which nothing else can override.
 */

/* Phones enlarge text on pages they think are wider than the screen. The
   layout below no longer overflows, so keep text at its authored size. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 768px) {
    /* ---------------------------------------------------------------- page */
    body .container { padding-left: 16px; padding-right: 16px; }

    /* ------------------------------------------------- promotional banner */
    body #psleStickyBanner { padding: 4px 4px 4px 12px !important; }
    body #psleStickyBanner .container { flex-wrap: nowrap !important; gap: 8px !important; padding: 0 !important; justify-content: space-between !important; }
    body #psleStickyBanner .psle-left { gap: 10px !important; min-width: 0; }
    body #psleStickyBanner .icon-box { width: 30px !important; height: 30px !important; min-width: 30px; flex: 0 0 30px; font-size: .9rem !important; }
    body #psleStickyBanner .psle-subtitle { display: none; }
    body #psleStickyBanner strong { font-size: .875rem !important; line-height: 1.25; margin: 0 !important; }
    body #psleStickyBanner .psle-right { gap: 0 !important; flex: 0 0 auto; }
    /* A 32px pill with a 44px touch area (the ::after extends the hit box). */
    body #psleStickyBanner .btn-signup { position: relative; display: inline-flex !important; align-items: center; min-height: 32px; padding: 0 14px !important; font-size: .8125rem !important; }
    body #psleStickyBanner .btn-signup::after { content: ""; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; }
    body #psleStickyBanner .btn-close { width: 44px; height: 44px; justify-content: center; padding: 0 !important; font-size: 1.1rem !important; }

    /* -------------------------------------------------------------- header */
    body .header-inner { height: 60px; }
    body .logo img { height: 34px !important; width: auto; }
    body .mobile-menu-toggle { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin-right: -10px; }
    /* The menu hangs from the bottom of the header whatever its height, and
       scrolls inside itself on short screens instead of running off the page. */
    body .navigation ul { top: 100%; left: -16px; width: calc(100% + 32px); padding: 14px 16px 18px; gap: 6px; max-height: calc(100vh - 130px); max-height: calc(100dvh - 130px); overflow-y: auto; overscroll-behavior: contain; }
    body .navigation ul li a, body .mobile-subject-item a { min-height: 44px; display: flex; align-items: center; }
    body .navigation ul li a.btn-primary { justify-content: center; }

    /* ------------------------------------------------------ homepage hero */
    /* The heading carries an inline desktop size (2.5rem). On phones it scales
       with the screen so "Find Primary School Tuition / Centres in
       Singapore!" always sits on two lines; 5.8vw leaves the longer line
       about 7% spare at every width from 320px up. Capped at the desktop
       size, so tablets never get a larger heading than desktop. */
    body .hero h1 { font-size: min(5.8vw, 2.5rem) !important; line-height: 1.25 !important; text-wrap: balance; margin-bottom: 18px; }
    /* Desktop keeps its 100px/80px hero padding; phones do not have the height to spare. */
    body .hero { padding: 32px 0 40px; }

    /* ------------------------------------------------- listings directory */
    body .listing-card-horizontal {
        display: grid;
        grid-template-columns: 112px minmax(0, 1fr);
        grid-template-areas: "media content" "media actions";
        column-gap: 12px;
        row-gap: 0;
        align-items: start;
        width: 100%;
        height: auto;
        min-height: 0;
        margin: 0 0 12px !important;
        padding: 10px;
        border-radius: 12px;
    }
    /* 4:3 photo. The picture fills the box absolutely, so the photo is cropped
       to the shape instead of stretching it; the grey shows if a photo fails. */
    body .listing-card-horizontal .listing-img { grid-area: media; width: 112px; height: 84px; aspect-ratio: 4 / 3; border-radius: 8px; background-color: #e2e8f0; }
    body .listing-card-horizontal .listing-img picture { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
    body .listing-card-horizontal .listing-img picture img { width: 100%; height: 100%; object-fit: cover; }
    body .listing-card-horizontal .listing-logo { left: 4px !important; bottom: 4px !important; width: 40px !important; height: 28px !important; padding: 2px !important; border-radius: 5px !important; object-fit: contain; }
    body .listing-card-horizontal .listing-content { grid-area: content; padding: 0; gap: 4px; min-width: 0; justify-content: flex-start; }
    body .listing-card-horizontal .listing-title { font-size: 1.125rem; line-height: 1.3; min-height: 0; margin: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
    body .listing-card-horizontal .listing-address { font-size: .8125rem; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
    body .listing-card-horizontal .listing-rating { font-size: .8125rem; margin-top: 0; }
    body .listing-card-horizontal .listing-price { font-size: .875rem; margin-top: 0; flex-wrap: wrap; gap: 2px 12px !important; }
    /* Favourite and claim controls sit in a row under the text, not in a
       separate tall column. */
    body .listing-card-horizontal .listing-actions { grid-area: actions; width: auto; flex-direction: row !important; justify-content: flex-end; gap: 4px !important; padding: 0 !important; border: 0; margin: 2px -4px -4px 0; }
    body .listing-card-horizontal .fav-btn, body .listing-card-horizontal .listing-actions a { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
    body .listing-card-horizontal .fav-btn { background: transparent; }
    body .brightly-pagination a, body .brightly-pagination span[aria-current] { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

    /* --------------------------------------------------- centre profile */
    body .detail-container { padding: 0 16px; margin: 16px auto 24px; }
    body .detail-tags { gap: 6px; margin-bottom: 12px; }
    body .detail-tags span { font-size: .75rem; padding: 3px 9px; }
    body .detail-top { gap: 12px; margin-bottom: 14px; }
    body .detail-heading { gap: 12px !important; }
    body .detail-logo { width: 64px !important; height: 48px !important; padding: 5px !important; object-fit: contain; }
    body .detail-title { font-size: clamp(1.75rem, 7vw, 2.125rem); line-height: 1.2; overflow-wrap: anywhere; }
    body .detail-address { align-items: flex-start; font-size: .9375rem; line-height: 1.45; }
    body .detail-container h2 { font-size: clamp(1.5rem, 6vw, 1.75rem); line-height: 1.25; }
    body .detail-container h3 { font-size: 1.125rem; line-height: 1.3; }
    body .detail-description { font-size: 1rem !important; line-height: 1.6 !important; }
    body .bookmark-btn { min-height: 44px; align-self: flex-start; }

    /* Hero photo keeps one shape at every width; thumbnails form a contained
       strip that scrolls sideways if it ever needs to. */
    body .main-photo { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 12px; background-color: #e2e8f0; }
    body .detail-thumbs { gap: 8px !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-bottom: 4px; }
    body .detail-thumbs > * { flex: 0 0 calc(25% - 6px); width: auto !important; min-width: 68px; height: auto !important; aspect-ratio: 4 / 3; scroll-snap-align: start; }

    /* These sit in a column up to 768px (stated here because the page's own rule
       only starts at 576px, which left a sideways scroll in between). Their
       desktop flex-basis (300px) would otherwise become a 300px minimum height. */
    body .side-widgets { flex-direction: column; margin-top: 20px; gap: 14px; }
    body .review-widget, body .map-widget { flex: 0 0 auto; }
    body .map-widget { height: 180px; }

    body .features-grid { margin-bottom: 28px; }
    body .schedule-section { padding: 18px 14px; margin-bottom: 28px; }
    body .schedule-pickers { gap: 16px !important; }
    body .schedule-level-picker, body .schedule-subject-picker { min-width: 0 !important; flex: 1 1 100% !important; width: 100%; }
    body .schedule-tab { padding: 10px 14px !important; min-height: 44px; }
    body .schedule-table th, body .schedule-table td { padding: 12px !important; }
    body .pricing-grid { margin-bottom: 28px; }
    body .pricing-header, body .pricing-body, body .pricing-footer { padding: 18px; }
    body .btn-whatsapp { min-height: 44px; }

    /* -------------------------------------------------- footer and sheets */
    /* style.css reserves 120-160px under the footer for a bottom banner that
       no longer exists. */
    body .main-footer { padding-bottom: 24px; }
    /* The filter sheet is fixed to the bottom edge: keep its last control
       clear of the phone's home indicator. */
    body .sidebar { padding-bottom: env(safe-area-inset-bottom); }
}

/* Very narrow phones: the listing card stacks, photo on top. */
@media (max-width: 359px) {
    body .listing-card-horizontal { grid-template-columns: minmax(0, 1fr); grid-template-areas: "media" "content" "actions"; row-gap: 8px; }
    body .listing-card-horizontal .listing-img { width: 100%; height: auto; aspect-ratio: 16 / 9; }
    body #psleStickyBanner .icon-box { display: none !important; }
}

/* Phones held sideways have very little height: let the banner and header
   scroll away instead of pinning them over a third of the screen. */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 932px) {
    body .global-header-wrapper { position: static !important; }
}
