/*
 * BesCool homepage responsive enhancement.
 * Scope: current homepage only, 320px-1023px. Desktop styles remain untouched.
 */

@media (max-width: 1023px) {
    body.home {
        --mobile-green: #127439;
        --mobile-green-dark: #07552f;
        --mobile-ink: #0f172a;
        --mobile-muted: #5f6f82;
        --mobile-line: #e4ece7;
        --mobile-gutter: 20px;
        --mobile-bottom-bar-height: 64px;
        --mobile-bottom-bar-gap: 16px;
    }

    /* Tablet/mobile header controls are injected from existing links. */
    body.home .nav-sticky {
        z-index: 3000;
    }

    body.home .nav-sticky > div {
        height: 68px;
        padding-left: var(--mobile-gutter);
        padding-right: var(--mobile-gutter);
    }

    body.home .nav-sticky > div > a:first-child span {
        font-size: 24px;
        line-height: 1;
    }

    body.home .nav-sticky > div > .hidden.lg\:flex,
    body.home .nav-sticky > div > .btn-primary {
        display: none !important;
    }

    .bescool-mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .bescool-mobile-icon-button {
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--mobile-green-dark);
        cursor: pointer;
    }

    .bescool-mobile-icon-button svg {
        width: 22px;
        height: 22px;
    }

    .bescool-mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 3010;
        border: 0;
        background: rgba(15, 23, 42, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease;
    }

    .bescool-mobile-menu {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 3020;
        width: min(88vw, 360px);
        padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
        background: #ffffff;
        box-shadow: -18px 0 48px rgba(15, 23, 42, 0.16);
        transform: translateX(105%);
        transition: transform 220ms ease;
        overflow-y: auto;
    }

    .bescool-mobile-menu.is-open {
        transform: translateX(0);
    }

    .bescool-mobile-menu-backdrop.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    .bescool-mobile-menu__top {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--mobile-line);
    }

    .bescool-mobile-menu__brand {
        color: var(--mobile-green-dark);
        font-size: 22px;
        font-weight: 900;
    }

    .bescool-mobile-menu__links {
        display: grid;
        margin-top: 18px;
    }

    .bescool-mobile-menu__links a {
        min-height: 50px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid var(--mobile-line);
        color: var(--mobile-ink);
        font-size: 15px;
        font-weight: 800;
    }

    .bescool-mobile-menu__contact {
        display: grid;
        gap: 10px;
        margin-top: 24px;
        padding: 16px;
        border-radius: 8px;
        background: #f4faf6;
    }

    .bescool-mobile-menu__contact a {
        overflow-wrap: anywhere;
        color: var(--mobile-green-dark);
        font-size: 13px;
        font-weight: 700;
    }

    body.bescool-mobile-menu-open {
        overflow: hidden;
    }

    /* Shared tablet spacing and stable media sizing. */
    body.home .bescool-home-section img,
    body.home .swiper-hero img {
        max-width: 100%;
    }

    body.home .bescool-home-section iframe,
    body.home .bescool-home-section table,
    body.home .bescool-home-section input,
    body.home .bescool-home-section select,
    body.home .bescool-home-section textarea {
        max-width: 100%;
    }

    /* Keep tablet product cards in a useful two-column layout. */
    body.home .bescool-section-products .bescool-products-grid,
    body.home .bescool-section-applications .bescool-applications-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.home footer > div:first-child {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    body.home.bescool-mobile-home {
        padding-bottom: calc(
            var(--mobile-bottom-bar-height) + var(--mobile-bottom-bar-gap) + env(safe-area-inset-bottom)
        );
        scroll-padding-bottom: calc(
            var(--mobile-bottom-bar-height) + var(--mobile-bottom-bar-gap) + env(safe-area-inset-bottom)
        );
    }

    /* Keep one mobile WhatsApp action: the fixed conversion bar. */
    body.home .top-bar,
    body.home .sticky-contact,
    body.home .chat-launcher,
    body.home .chat-panel,
    body.home .language-panel,
    body.home .bescool-mobile-header-actions > a[href*="wa.me"] {
        display: none !important;
    }

    /* Hero becomes content-first instead of a fixed desktop overlay. */
    body.home .swiper-hero {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
        background: #f4faf6;
    }

    body.home .swiper-hero .swiper-wrapper {
        display: contents;
        height: auto;
        transform: none !important;
    }

    body.home .swiper-hero .swiper-slide {
        position: relative;
        inset: auto;
        display: none;
        height: auto;
        min-height: 0;
        opacity: 1;
        pointer-events: auto;
        background: #f4faf6;
        transition: none;
    }

    body.home .swiper-hero .swiper-slide:first-child {
        display: contents;
    }

    body.home .swiper-hero .swiper-slide:first-child > img {
        position: relative;
        inset: auto;
        order: 3;
        display: block !important;
        width: calc(100% - 40px);
        height: auto;
        aspect-ratio: 4 / 3;
        margin: 0 20px 26px;
        border-radius: 8px;
        object-fit: cover;
        object-position: 22% 50%;
    }

    body.home .swiper-hero .swiper-slide:first-child > .absolute.inset-0 {
        display: none;
    }

    body.home .swiper-hero .swiper-slide:first-child > .max-w-7xl {
        order: 1;
        padding: 30px var(--mobile-gutter) 20px;
    }

    body.home .swiper-hero .swiper-slide:first-child .max-w-2xl {
        max-width: none;
        color: var(--mobile-ink);
    }

    body.home .swiper-hero .swiper-slide:first-child .inline-flex {
        border-color: #cce2d4;
        background: #e9f5ed;
        color: var(--mobile-green-dark);
    }

    body.home .swiper-hero h1 {
        margin: 18px 0 0;
        color: var(--mobile-ink);
        font-size: 38px;
        line-height: 1.1;
    }

    body.home .swiper-hero h1 span {
        color: var(--mobile-green);
    }

    body.home .swiper-hero .swiper-slide:first-child p {
        margin-top: 16px;
        color: var(--mobile-muted);
        font-size: 16px;
        line-height: 1.68;
    }

    body.home .swiper-hero .swiper-pagination,
    body.home .swiper-hero .swiper-button-next,
    body.home .swiper-hero .swiper-button-prev {
        display: none !important;
    }

    body.home .swiper-hero > .absolute.bottom-0 {
        position: relative;
        inset: auto;
        order: 2;
        padding: 0 var(--mobile-gutter) 20px;
        background: transparent;
    }

    body.home .swiper-hero > .absolute.bottom-0 > .max-w-7xl {
        padding: 0;
    }

    body.home .swiper-hero > .absolute.bottom-0 .mb-6 {
        display: none;
    }

    body.home .swiper-hero > .absolute.bottom-0 .gap-4 {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    body.home .swiper-hero > .absolute.bottom-0 .gap-4 a {
        min-height: 50px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 10px 12px;
        border: 1px solid var(--mobile-green);
        border-radius: 6px;
        background: #ffffff;
        color: var(--mobile-green-dark);
        font-size: 13px;
        font-weight: 900;
        text-align: center;
    }

    body.home .swiper-hero > .absolute.bottom-0 .gap-4 a:first-child {
        background: var(--mobile-green);
        color: #ffffff;
    }

    /* Factual data stays complete; the fifth metric spans the last row. */
    body.home .bescool-section-stats {
        padding: 26px 0;
    }

    body.home .bescool-section-stats .max-w-7xl {
        padding: 0 var(--mobile-gutter);
    }

    body.home .bescool-section-stats .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
    }

    body.home .bescool-section-stats .grid > div {
        min-height: 102px;
        padding: 14px 8px;
        border-right: 1px solid var(--mobile-line);
        border-bottom: 1px solid var(--mobile-line);
    }

    body.home .bescool-section-stats .grid > div:nth-child(2n) {
        border-right: 0;
    }

    body.home .bescool-section-stats .grid > div:last-child {
        grid-column: 1 / -1;
        min-height: 86px;
        border-right: 0;
        border-bottom: 0;
    }

    body.home .bescool-section-stats svg {
        width: 20px;
        height: 20px;
    }

    body.home .bescool-section-stats .text-3xl {
        font-size: 28px;
        line-height: 1.1;
    }

    body.home .bescool-section-stats .text-\[10px\] {
        font-size: 12px;
        letter-spacing: 0.06em;
    }

    body.home .bescool-home-certificates {
        padding: 14px var(--mobile-gutter);
    }

    body.home .bescool-home-certificates > div {
        gap: 8px 12px;
        padding: 0;
    }

    body.home .bescool-home-certificates span {
        display: none;
    }

    /* Consistent section rhythm without removing any page copy. */
    body.home .bescool-home-section:not(.bescool-section-stats) {
        padding-top: 48px;
        padding-bottom: 48px;
    }

    body.home .bescool-home-section > .max-w-7xl {
        padding-left: var(--mobile-gutter);
        padding-right: var(--mobile-gutter);
    }

    body.home .bescool-home-section h2.text-sm {
        font-size: 11px;
        letter-spacing: 0.18em;
    }

    body.home .bescool-home-section h3,
    body.home .bescool-home-section h2.text-4xl {
        font-size: 28px;
        line-height: 1.18;
    }

    body.home .bescool-section-intro > div {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    body.home .bescool-section-intro .space-y-4 {
        font-size: 15px;
        line-height: 1.75;
    }

    /* Products: manual horizontal scroll with a visible next-card cue. */
    body.home .bescool-section-products > div > .flex:first-child {
        margin-bottom: 28px;
        align-items: flex-start;
    }

    body.home .bescool-section-products .bescool-products-grid {
        display: flex;
        gap: 12px;
        margin-right: calc(var(--mobile-gutter) * -1);
        padding-right: 32px;
        padding-bottom: 10px;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scroll-snap-type: inline mandatory;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    body.home .bescool-section-products .bescool-products-grid::-webkit-scrollbar {
        display: none;
    }

    body.home .bescool-section-products .product-card {
        flex: 0 0 85vw;
        max-width: 360px;
        scroll-snap-align: start;
        border: 1px solid var(--mobile-line);
        border-radius: 8px;
        background: #ffffff;
        overflow: hidden;
    }

    body.home .bescool-section-products .product-card > div:first-child {
        aspect-ratio: 4 / 3;
    }

    body.home .bescool-section-products .product-card > div:last-child {
        padding: 18px;
    }

    /* Why Choose keeps all four reasons in a compact two-column field. */
    body.home .bescool-section-why {
        background: var(--mobile-green-dark);
        color: #ffffff;
    }

    body.home .bescool-section-why .text-center {
        margin-bottom: 28px;
        text-align: left;
    }

    body.home .bescool-section-why h2,
    body.home .bescool-section-why h3,
    body.home .bescool-section-why p,
    body.home .bescool-section-why strong {
        color: #ffffff;
    }

    body.home .bescool-section-why .grid.lg\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    body.home .bescool-section-why .grid.grid-cols-1 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    body.home .bescool-section-why .grid.grid-cols-1 > div {
        padding: 16px 14px;
        border-color: rgba(255, 255, 255, 0.14);
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.07);
        box-shadow: none;
    }

    body.home .bescool-section-why .grid.grid-cols-1 > div > div:first-child {
        margin-bottom: 10px;
    }

    /* Current version uses icons rather than application photos; keep them. */
    body.home .bescool-section-applications .text-center.mb-16 {
        margin-bottom: 28px;
    }

    body.home .bescool-section-applications .bescool-applications-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    body.home .bescool-section-applications .bescool-applications-grid > div {
        min-width: 0;
        padding: 16px 12px;
        border: 1px solid var(--mobile-line);
        border-radius: 7px;
    }

    body.home .bescool-section-applications .bescool-applications-grid > div > div:first-child {
        width: 44px;
        height: 44px;
        margin-bottom: 12px;
    }

    body.home .bescool-section-applications h4 {
        display: -webkit-box;
        min-height: 42px;
        overflow: hidden;
        font-size: 14px;
        line-height: 1.45;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    body.home .bescool-section-applications p {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    /* Existing process becomes a connected mobile timeline. */
    body.home .bescool-section-process .grid.lg\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 36px;
    }

    body.home .bescool-section-process .space-y-6 {
        position: relative;
    }

    body.home .bescool-section-process .space-y-6::before {
        content: "";
        position: absolute;
        top: 20px;
        bottom: 20px;
        left: 19px;
        width: 1px;
        background: #9bc8aa;
    }

    body.home .bescool-section-process .space-y-6 > .flex {
        position: relative;
        z-index: 1;
        gap: 14px;
    }

    body.home .bescool-section-process .space-y-6 > .flex > div:first-child {
        width: 40px;
        height: 40px;
        border: 4px solid #f8fafc;
    }

    body.home .bescool-section-process .aspect-\[4\/5\] {
        aspect-ratio: 4 / 3;
        border-radius: 8px;
        box-shadow: none;
    }

    /* Global reach uses full-width map and one-line metric row. */
    body.home .bescool-section-global .grid.lg\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    body.home .bescool-section-global .space-y-8 {
        display: flex;
        flex-direction: column;
        gap: 18px;
    }

    body.home .bescool-section-global .space-y-8 > * {
        margin-top: 0;
        margin-bottom: 0;
    }

    body.home .bescool-section-global .space-y-8 > .flex:last-child {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 16px 0;
        border-top: 1px solid var(--mobile-line);
        border-bottom: 1px solid var(--mobile-line);
        text-align: center;
    }

    body.home .bescool-section-global .space-y-8 > .flex:last-child .text-2xl {
        font-size: 22px;
    }

    body.home .bescool-section-global .relative.flex.justify-center {
        min-height: 230px;
        align-items: center;
    }

    body.home .bescool-section-global img {
        width: 100%;
        max-width: none;
        height: 230px;
        object-fit: contain;
        opacity: 0.28;
    }

    /* Quality cards become a numbered, separated list. */
    body.home .bescool-section-quality .text-center.mb-16 {
        margin-bottom: 24px;
        text-align: left;
    }

    body.home .bescool-section-quality .grid.md\:grid-cols-3 {
        display: block;
    }

    body.home .bescool-section-quality .grid.md\:grid-cols-3 > div {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 2px 14px;
        padding: 20px 0;
        border-bottom: 1px solid var(--mobile-line);
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        text-align: left;
    }

    body.home .bescool-section-quality .grid.md\:grid-cols-3 > div > div:first-child {
        grid-row: 1 / span 2;
        grid-column: 1;
        margin: 0;
    }

    body.home .bescool-section-quality .grid.md\:grid-cols-3 h4,
    body.home .bescool-section-quality .grid.md\:grid-cols-3 p {
        grid-column: 2;
    }

    /* Final conversion band stays concise; WhatsApp remains in the bottom bar. */
    body.home .bescool-section-cta {
        padding: 28px 0;
        background-color: var(--mobile-green-dark);
    }

    body.home .bescool-section-cta h2 {
        font-size: 29px;
        line-height: 1.15;
    }

    body.home .bescool-section-cta .flex {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    body.home .bescool-section-cta .flex a {
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 10px 16px;
        font-size: 15px;
    }

    body.home .bescool-section-cta .flex a:nth-child(3) {
        display: none;
    }

    /* Mobile footer: identity stays visible, remaining existing groups fold. */
    body.home footer {
        padding: 38px 0 24px;
    }

    body.home footer > div:first-child {
        display: block;
        padding-left: var(--mobile-gutter);
        padding-right: var(--mobile-gutter);
    }

    body.home footer > div:first-child > div:first-child {
        margin-bottom: 24px;
    }

    body.home footer > div:first-child > div:first-child > div:first-child {
        margin-bottom: 14px;
    }

    body.home footer > div:first-child > div:first-child p {
        margin-bottom: 18px;
    }

    .bescool-mobile-footer-primary-contact {
        display: grid;
        gap: 8px;
        margin-bottom: 18px;
    }

    .bescool-mobile-footer-primary-contact a {
        width: fit-content;
        max-width: 100%;
        color: #d1fae5;
        font-size: 13px;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

    .bescool-mobile-footer-group {
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .bescool-mobile-footer-group:last-child {
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .bescool-mobile-footer-group summary {
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #ffffff;
        font-size: 13px;
        font-weight: 900;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        cursor: pointer;
        list-style: none;
    }

    .bescool-mobile-footer-group summary::-webkit-details-marker {
        display: none;
    }

    .bescool-mobile-footer-group summary::after {
        content: "+";
        font-size: 20px;
        font-weight: 400;
    }

    .bescool-mobile-footer-group[open] summary::after {
        content: "-";
    }

    .bescool-mobile-footer-group__content {
        padding: 4px 0 20px;
    }

    body.home footer > div:last-of-type {
        margin-top: 28px;
        padding-top: 20px;
        text-align: center;
    }

    body.home footer > div:last-of-type > div {
        display: none;
    }

    /* Fixed conversion bar uses existing, verified URLs and hides at footer. */
    .bescool-mobile-bottom-bar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 2990;
        box-sizing: border-box;
        width: 100%;
        height: calc(var(--mobile-bottom-bar-height) + env(safe-area-inset-bottom));
        min-height: calc(var(--mobile-bottom-bar-height) + env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
        border-top: 1px solid #dce7df;
        background: #ffffff;
        box-shadow: 0 -8px 26px rgba(15, 23, 42, 0.09);
        transition: transform 180ms ease, opacity 180ms ease, visibility 180ms ease;
    }

    .bescool-mobile-bottom-bar.is-footer-visible,
    .bescool-mobile-bottom-bar.is-intro-visible {
        transform: translateY(100%);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .bescool-mobile-bottom-bar a {
        position: static;
        inset: auto;
        width: auto;
        height: auto;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 0 12px;
        border: 0;
        box-shadow: none;
        color: var(--mobile-green-dark);
        font-size: 13px;
        font-weight: 900;
    }

    .bescool-mobile-bottom-bar a:last-child {
        border-radius: 6px;
        background: var(--mobile-green);
        color: #ffffff;
    }
}

@media (max-width: 359px) {
    body.home.bescool-mobile-home {
        --mobile-gutter: 16px;
    }

    body.home .swiper-hero h1 {
        font-size: 34px;
    }

    body.home .swiper-hero .swiper-slide:first-child > img {
        width: calc(100% - 32px);
        margin-right: 16px;
        margin-left: 16px;
    }

    body.home .swiper-hero > .absolute.bottom-0 .gap-4 a {
        font-size: 12px;
    }

}

@media (min-width: 768px) and (max-width: 1023px) {
    body.home .top-bar {
        display: block;
    }

    body.home footer > div:first-child {
        gap: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bescool-mobile-menu,
    .bescool-mobile-menu-backdrop,
    .bescool-mobile-bottom-bar {
        transition: none;
    }
}
