/*
 * Best Lift — responsive.css
 * Purpose: Fixes the responsive gaps found in the audit of main.css, index.css,
 *          products.css, quote-builder.css, forms.css, admin.css, animations.css.
 *          Existing files are NOT touched; every rule here only adds to them.
 *
 * Load order: must come AFTER every page stylesheet (index.css, products.css,
 *             projects.css, quote-builder.css are linked per page, below
 *             header.php), so link it in footer.php right before the <script>
 *             tags — NOT in header.php, where it would load too early and lose.
 *             Also link it in admin_shell.php after admin.css (section 6).
 *
 * Breakpoints used (same as variables.css):
 *   Mobile  <= 767px | Tablet 768-1023px | Desktop >= 1024px | Ultra-wide >= 1600px
 *
 * Index:
 *   0. Sideways-scroll guard + Projects / Gallery / Blog stat tiles in one row (phones)
 *   1. Ultra-wide screens (>= 1600px): hero / banner / footer line up with the header
 *   2. Very narrow phones (<= 479px): grids that could overflow
 *   3. iOS Safari: stop the auto-zoom when a form field is tapped
 *   4. Touch devices: 44px minimum tap targets
 *   5. Phones with a notch / home bar: safe-area spacing for the floating widget
 *   6. Admin panel: dynamic viewport height, mobile table + form comfort
 *   7. Short landscape phones (drawer + lightboxes scroll)
 *   8. Header current-page label on phones + tablets (Home / Projects ...)
 */


/* ---------------------------------------------------------------------
 * 0. Sideways-scroll guard (phones / tablets)
 * main.css only sets overflow-x:clip on <body>. Glow orbs, drifting blobs
 * and anything absolutely positioned against the viewport can still widen
 * the PAGE, so on a phone the whole site (sticky header included) can be
 * dragged left, leaving an empty strip on the right.
 * html gets the clip too (body keeps its own, so position:sticky still works),
 * and .hs-products, whose glow orbs stick out at right:-8% with no clipping
 * container, is clipped at the source.
 * ------------------------------------------------------------------- */
html {
    overflow-x: hidden;
}

.hs-products {
    overflow-x: clip;
}

/* <main> wraps every page's content (opened in header.php, closed in
   footer.php). Clipping it sideways means nothing inside any page can widen
   the document, whichever element is the culprit. clip (not hidden) does not
   create a scroll container, so sticky/fixed children keep working. */
main {
    overflow-x: clip;
}

/* Products page: single-column grids written as `1fr` can grow past the screen
   when one child (a long word, a nowrap button row) has a big min-content width.
   minmax(0,1fr) lets the column shrink to the screen instead. */
@media (max-width: 899px) {
    .pp-list,
    .pp-product,
    .pp-svclist,
    .pp-svc {
        grid-template-columns: minmax(0, 1fr);
    }

    .pp-product__media,
    .pp-product__body,
    .pp-svc > * {
        min-width: 0;
    }

    .pp-product__body h2,
    .pp-product__desc {
        overflow-wrap: anywhere;
    }
}


/* ---------------------------------------------------------------------
 * 0b. Stat tiles (.pj-stats — Projects hero): all three in ONE row on phones
 * projects.css forces 2 columns under 520px, which pushed the 3rd tile onto
 * its own row. Three equal columns now, with tighter padding / type so
 * "Completed projects", "Major projects" and "Ongoing projects" fit.
 * (The old "centre the odd last tile" rule was removed: with 3 columns it
 * would have made the 3rd tile span the whole row again.)
 * ------------------------------------------------------------------- */
@media (max-width: 520px) {
    .pj-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .pj-stat {
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0.75rem 0.3rem 0.65rem;
        border-radius: 16px;
    }

    .pj-stat__num {
        font-size: 1.55rem;
    }

    /* dot sits above the text so a two-line label stays centred */
    .pj-stat__label {
        flex-direction: column;
        gap: 0.3rem;
        font-size: 0.72rem;
        line-height: 1.25;
        text-align: center;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 359px) {
    .pj-stat__num {
        font-size: 1.3rem;
    }

    .pj-stat__label {
        font-size: 0.66rem;
    }
}


/* ---------------------------------------------------------------------
 * 0c. Gallery + Blog stat tiles (.gl-stats / .bh-stats): one row on phones
 * gallery.php and blog.php style these in their own <style> blocks (flex-wrap,
 * li min-width:112px), so 3 tiles wrapped onto two rows. Under 520px they stay
 * on ONE row and share the width equally (flex:1 1 0, min-width:0).
 * The Project / Product tiles only exist when there are such photos, so this
 * also works when only 1 or 2 tiles are shown.
 * ------------------------------------------------------------------- */
@media (max-width: 520px) {
    .gl-stats,
    .bh-stats {
        flex-wrap: nowrap;
        gap: 0.45rem;
        margin-top: 1.25rem;
    }

    .gl-stats li,
    .bh-stats li {
        flex: 1 1 0;
        min-width: 0;
        padding: 0.7rem 0.3rem;
        border-radius: 14px;
    }

    .gl-stats b,
    .bh-stats b {
        font-size: 1.45rem;
    }

    .gl-stats span,
    .bh-stats span {
        display: block;
        font-size: 0.72rem;
        line-height: 1.25;
        letter-spacing: 0;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 359px) {
    .gl-stats b,
    .bh-stats b {
        font-size: 1.25rem;
    }

    .gl-stats span,
    .bh-stats span {
        font-size: 0.66rem;
    }
}


/* ---------------------------------------------------------------------
 * 1. Ultra-wide screens
 * The header is capped at --header-max-width (1480px, 1720px on the home
 * page), but .hero, .consultation-banner, .site-footer, .gallery-hero and
 * .pp-hero only use the gutter margin, so on a 1920px+ monitor they keep
 * stretching while the header stays centred. Same cap + same centring here.
 * min(100% - 2*gutter, cap) keeps the normal gutter below the cap.
 * ------------------------------------------------------------------- */
@media (min-width: 1600px) {
    .hero,
    .consultation-banner,
    .site-footer,
    .gallery-hero,
    .pp-hero {
        width: min(100% - 2 * var(--bl-gutter, 1rem), var(--header-max-width, 1480px));
        max-width: none;
        margin-left: auto;
        margin-right: auto;
    }
}


/* ---------------------------------------------------------------------
 * 2. Very narrow phones (Galaxy Fold folded, small Androids: 280-479px)
 * repeat(auto-fit, minmax(260-280px, 1fr)) forces a column wider than the
 * screen when less than ~300px is available. min(100%, Npx) lets the
 * column shrink to the container instead of overflowing sideways.
 * ------------------------------------------------------------------- */
@media (max-width: 479px) {
    .hs-products .hs-pstrip__list {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    }

    .hs-bento--grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    }

    .contact-people__grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    }

    .admin-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    }

    /* Long words / emails / Bangla compounds must wrap instead of pushing the page */
    .pp-hero h1,
    .pp-card__body h3,
    .contact-cards a,
    .contact-people__grid a {
        overflow-wrap: anywhere;
    }
}


/* ---------------------------------------------------------------------
 * 3. iOS Safari form zoom
 * --font-size-base is 15px. iOS zooms the whole page in when a field with
 * a font-size under 16px is focused, and does not zoom back out. Public
 * forms (Request A Quote, Quote Builder, Contact) and the admin forms
 * are all affected. 16px on touch screens only; desktop keeps 15px.
 * Selectors mirror the originals so specificity is equal and load order wins.
 * ------------------------------------------------------------------- */
@media (max-width: 1023px) and (pointer: coarse) {
    .form-field input[type="text"],
    .form-field input[type="email"],
    .form-field input[type="tel"],
    .form-field input[type="number"],
    .form-field select,
    .form-field textarea,
    .contact-form .form-field input,
    .contact-form .form-field select,
    .contact-form .form-field textarea,
    .quote-builder .form-field select,
    .quote-builder .form-field input[type="text"],
    .quote-builder .form-field input[type="email"],
    .quote-builder .form-field input[type="tel"],
    .quote-builder .form-field input[type="number"],
    .qb-stepper input[type="number"],
    .admin-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
    .admin-content select,
    .admin-content textarea,
    .pm-stage-table select,
    .pm-stage-table input[type="date"] {
        font-size: 16px;
    }
}


/* ---------------------------------------------------------------------
 * 4. Touch targets (phones and tablets, any width)
 * Apple/Google guidance is ~44px. Only the controls that were visibly
 * smaller are raised; layout is unchanged because they are inline/flex.
 * ------------------------------------------------------------------- */
@media (pointer: coarse) {
    .qb-stepper__btn {
        min-width: 44px;
        min-height: 44px;
    }

    .pp-filter .product-filter__link,
    .product-filter__link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .pp-link {
        min-height: 44px;
    }

    .admin-row-actions a,
    td.admin-row-actions a {
        display: inline-block;
        padding: 0.55rem 0.25rem;
    }
}


/* ---------------------------------------------------------------------
 * 5. Floating widget position (phones + tablets) / notch phones
 * The floor control panel was removed from header.php, but main.css still
 * lifts .emergency-widget 56px on screens under 1024px to clear that bar,
 * so the WhatsApp button floats too high with nothing under it. Back to the
 * normal corner offset, plus the home-indicator height on notch phones.
 * (The safe-area part needs viewport-fit=cover in header.php's viewport meta.)
 * ------------------------------------------------------------------- */
@media (max-width: 1023px) {
    .emergency-widget {
        bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
        right: calc(var(--space-sm) + env(safe-area-inset-right, 0px));
    }
}


/* ---------------------------------------------------------------------
 * 6. Admin panel
 * ------------------------------------------------------------------- */

/* 100vh is taller than the visible area on mobile browsers (address bar),
   which leaves the login card off-centre and adds a pointless scrollbar. */
@supports (min-height: 100dvh) {
    .admin-shell,
    .admin-auth-page {
        min-height: 100dvh;
    }
}

@media (max-width: 767px) {
    /* Tables scroll inside their card (.admin-card is overflow-x:auto);
       a min-width stops columns collapsing to a few letters first. */
    .admin-data-table {
        min-width: 560px;
    }

    .admin-data-table th,
    .admin-data-table td {
        padding: 0.7rem 0.75rem;
    }

    .admin-log-message {
        max-width: 240px;
    }

    .adm-person {
        min-width: 180px;
    }

    /* Session-timeout modal (injected by admin.js): fit small screens */
    .session-warning-modal {
        width: calc(100% - 2rem);
        max-width: 360px;
    }
}

/* Tablet admin: sidebar is a drawer below 900px; keep the 2-up stat grid
   readable between 768px and 899px instead of squeezing a third column in. */
@media (min-width: 768px) and (max-width: 899px) {
    .admin-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* ---------------------------------------------------------------------
 * 7. Short landscape phones (e.g. 667x375, 844x390)
 * Full-height hero / preloader / drawer content can be taller than the
 * screen. Let them scroll and stop forcing tall minimums.
 * ------------------------------------------------------------------- */
@media (max-height: 480px) and (orientation: landscape) {
    .site-nav {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .gallery-lightbox,
    .hm-lb {
        overflow-y: auto;
    }
}


/* ---------------------------------------------------------------------
 * 8. Header: current page name on phones + tablets
 * The nav links are inside the hamburger drawer below 1024px, so the header
 * bar had an empty middle. header.php now prints a .site-header__page span
 * holding only the label of the page the visitor is on (Home on the home
 * page, Projects on Projects ...). It is hidden on desktop, where the full
 * nav is visible. .site-header__actions keeps margin-left:auto, so the
 * hamburger stays at the far right.
 * ------------------------------------------------------------------- */
.site-header__page {
    display: none;
}

@media (max-width: 1023px) {
    .site-header__page {
        display: block;
        flex: 1 1 0;
        min-width: 0;
        margin: 0 0.5rem;
        overflow: hidden;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--color-primary);
        font-size: 0.9rem;
        font-weight: 800;
        line-height: 1.2;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        pointer-events: none;
    }

    .site-header__page::before {
        content: "";
        display: inline-block;
        width: 7px;
        height: 7px;
        margin-right: 0.45rem;
        border-radius: 50%;
        background: var(--color-accent);
        vertical-align: 0.08em;
    }

    body.lang-bn .site-header__page {
        letter-spacing: 0;
        text-transform: none;
    }
}

@media (max-width: 359px) {
    .site-header__page {
        font-size: 0.78rem;
        letter-spacing: 0.03em;
    }
}


/* ---------------------------------------------------------------------
 * 9. Home hero slider: shorter on phones
 * main.css (last mobile block, ~line 4577) gives the slider
 * clamp(380px, 72vh, 520px), which on a tall phone is always the 520px cap.
 * Lowered to about 400px. min-height (not height), so a longer Bangla
 * headline can still grow the slide instead of being clipped.
 * To tune: change the 400px cap (smaller = shorter slider).
 * ------------------------------------------------------------------- */
@media (max-width: 767px) {
    .hero__slider,
    .hero > .hero__slide {
        min-height: clamp(360px, 46vh, 400px);
    }
}


/* ---------------------------------------------------------------------
 * 10. Home hero "365 Days Zero-Cost Preventive Maintenance..." pill
 * Text a little bigger and a little bolder (not heavy). main.css has it at
 * 0.9rem desktop / 0.82rem phones, normal weight. Only font-size and weight
 * change; padding, shape and position are untouched.
 * To tune: font-size (bigger number = bigger text), font-weight 500 -> 600.
 * ------------------------------------------------------------------- */
.hero__maintenance-badge {
    font-size: 1rem;
    font-weight: 500;
}

.hero__maintenance-badge strong {
    font-weight: 800;
}

@media (max-width: 767px) {
    .hero__maintenance-badge {
        font-size: 0.9rem;
    }
}

/* ---------------------------------------------------------------------
 * 11. Home hero slider: slimmer on phones (v2)
 * Section 9 only sets min-height, but on a phone the slide's own CONTENT
 * decided the height (big headline + 3-line text + 2rem top padding +
 * 5rem bottom padding for the dots), so it stayed tall. This tightens the
 * spacing and type size on phones only; desktop/tablet are untouched.
 * To tune: min-height (smaller = shorter), padding-bottom (room for dots),
 * h1 / p font-size. min-height, not height, so a long Bangla headline can
 * still grow the slide instead of being clipped.
 * ------------------------------------------------------------------- */
@media (max-width: 767px) {
    .hero .hero__slider,
    .hero > .hero__slide {
        min-height: 300px;
    }

    .hero .hero__slider .hero__slide-content,
    .hero > .hero__slide .hero__slide-content {
        padding-top: 1.25rem;
        padding-bottom: 3.1rem;   /* keeps clear of the progress dots */
    }

    .hero .hero__slide-content h1,
    .hero .hero__slide-content h2 {
        margin-bottom: 0.5rem;
        font-size: clamp(1.45rem, 6.4vw, 1.75rem);
        line-height: 1.15;
    }

    .hero .hero__slide-content h1::before,
    .hero .hero__slide-content h2::before {
        width: 44px;
        height: 3px;
        margin-bottom: 0.6rem;
    }

    .hero .hero__slide-content p {
        margin-bottom: 0.85rem;
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .hero .hero__slide-content .btn {
        padding: 0.65rem 1.3rem;
        font-size: 0.8rem;
    }

    .hero .hero__controls {
        bottom: 12px;
    }
}


/* ---------------------------------------------------------------------
 * 12. Home hero card: rounded corners clip properly (v2)
 * The hero photo is scaled / translated on its own GPU layer (zoom +
 * parallax, will-change, backface-visibility). Chrome does not always
 * clip such a layer to the parent's border-radius, so the card's corners
 * showed square patches of the photo / slide. clip-path clips everything
 * inside, including composited layers, so the corners stay clean.
 * Keep the radius equal to the card's border-radius (32px; 28px on phones).
 * ------------------------------------------------------------------- */
.hero .hero__slider,
.hero > .hero__slide {
    isolation: isolate;
    clip-path: inset(0 round var(--bl-radius-xl, 32px));
}

.hero .hero__slider .hero__slide {
    border-radius: inherit;
    overflow: hidden;
}

@media (max-width: 767px) {
    .hero .hero__slider,
    .hero > .hero__slide {
        clip-path: inset(0 round 28px);
    }
}


/* ---------------------------------------------------------------------
 * 13. Home hero buttons — cleaner design (v2)
 * Before: the green button used the purple->green gradient, whose purple
 * end melted into the purple photo, and BOTH buttons carried a 4px white
 * ring on top of their own border, so the outlines looked doubled/messy.
 * Now: primary = solid green pill with an arrow (stands out on purple, white
 * text stays readable); secondary = clear glass pill with one thin white
 * border. Same height, no extra ring, soft shadow, calm hover.
 * To tune: green colours in the first gradient, padding, border opacity.
 * ------------------------------------------------------------------- */
.hero .hero__slide-content .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 52px;
    margin: 0 0.75rem 0.6rem 0;
    padding: 0.8rem 1.7rem;
    border: 1.5px solid transparent;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.005em;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.hero .hero__slide-content .btn + .btn {
    margin-left: 0;
}

/* primary */
.hero .hero__slide-content .btn.btn--accent {
    background: linear-gradient(135deg, #14A262 0%, #0B6B3A 100%);
    border-color: rgba(255, 255, 255, 0.22);
    color: #FFFFFF;
    box-shadow: 0 10px 24px rgba(8, 90, 48, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.hero .hero__slide-content .btn.btn--accent::after {
    content: "\2192";
    font-size: 1.15em;
    line-height: 1;
    transition: transform 0.2s ease;
}

.hero .hero__slide-content .btn.btn--accent:hover,
.hero .hero__slide-content .btn.btn--accent:focus-visible {
    background: linear-gradient(135deg, #19B86F 0%, #0E7A42 100%);
    box-shadow: 0 14px 30px rgba(8, 90, 48, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.hero .hero__slide-content .btn.btn--accent:hover::after,
.hero .hero__slide-content .btn.btn--accent:focus-visible::after {
    transform: translateX(4px);
}

/* secondary */
.hero .hero__slide-content .btn.btn--ghost {
    background: rgba(255, 255, 255, 0.10);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-color: rgba(255, 255, 255, 0.7);
    color: #FFFFFF;
    box-shadow: 0 8px 20px rgba(13, 2, 26, 0.25);
}

.hero .hero__slide-content .btn.btn--ghost:hover,
.hero .hero__slide-content .btn.btn--ghost:focus-visible {
    background: #FFFFFF;
    border-color: #FFFFFF;
    color: var(--color-primary, #4B0072);
    box-shadow: 0 14px 28px rgba(13, 2, 26, 0.35);
}

.hero .hero__slide-content .btn:hover,
.hero .hero__slide-content .btn:focus-visible {
    transform: translateY(-2px);
}

.hero .hero__slide-content .btn:focus-visible {
    outline: 3px solid #FFFFFF;
    outline-offset: 3px;
}

/* a little more air between the paragraph and the buttons */
.hero .hero__slide-content p {
    margin-bottom: 1.4rem;
}

@media (max-width: 767px) {
    .hero .hero__slide-content .btn {
        min-height: 44px;
        margin: 0 0.5rem 0.5rem 0;
        padding: 0.6rem 1.2rem;
        font-size: 0.88rem;
    }

    .hero .hero__slide-content p {
        margin-bottom: 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero .hero__slide-content .btn,
    .hero .hero__slide-content .btn::after {
        transition: none;
    }
}