/**
 * JSMT responsive layout — mobile & tablet support.
 * Matches Elementor breakpoints: tablet <=1024px, mobile <=767px.
 */

/* ── Base ── */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.jsmt-site {
    overflow-x: hidden;
    max-width: 100%;
}

.jsmt-page,
#page {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.elementor {
    width: 100%;
    max-width: 100%;
}

.e-con,
.e-con-inner {
    max-width: 100%;
}

img.e-image-base,
.elementor img,
.gallery img,
.ectbe-calendar-wrapper img {
    max-width: 100%;
    height: auto;
}

/* ── Tablet (<=1024px) ── */
@media (max-width: 1024px) {
    #masthead .e-con-boxed > .e-con-inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    .e-con-boxed > .e-con-inner {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* ── Compact header bar (tablet & mobile) ── */
    #masthead {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #000;
        border-bottom: 1px solid rgba(183, 160, 102, 0.28);
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
    }

    .elementor-259 .elementor-element-638e667,
    .elementor-508 .elementor-element-638e667 {
        --padding-top: 8px;
        --padding-bottom: 8px;
        --padding-left: 0px;
        --padding-right: 0px;
    }

    .elementor-259 .elementor-element-638e667 > .e-con-inner,
    .elementor-508 .elementor-element-638e667 > .e-con-inner {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 34px 34px 42px !important;
        grid-template-rows: auto !important;
        align-items: center !important;
        column-gap: 8px !important;
        row-gap: 0 !important;
        padding: 8px 12px !important;
        width: 100% !important;
        position: relative;
    }

    .elementor-259 .elementor-element-638e667 > .e-con-inner > .e-con.e-child,
    .elementor-508 .elementor-element-638e667 > .e-con-inner > .e-con.e-child {
        --display: block !important;
        display: block !important;
        width: auto !important;
        --width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        flex: unset !important;
        flex-basis: auto !important;
        flex-shrink: 0 !important;
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .elementor-259 .elementor-element-7f8fd7e,
    .elementor-508 .elementor-element-7f8fd7e {
        grid-column: 1 !important;
        grid-row: 1 !important;
        --width: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex-shrink: 1 !important;
        overflow: hidden !important;
    }

    .elementor-259 .elementor-element-317a0c9,
    .elementor-508 .elementor-element-317a0c9 {
        grid-column: 2 !important;
        grid-row: 1 !important;
        --width: 34px !important;
        width: 34px !important;
        max-width: 34px !important;
        justify-self: center !important;
    }

    .elementor-259 .elementor-element-ba0edd8,
    .elementor-508 .elementor-element-ba0edd8 {
        grid-column: 3 !important;
        grid-row: 1 !important;
        --width: 34px !important;
        width: 34px !important;
        max-width: 34px !important;
        justify-self: center !important;
    }

    .elementor-259 .elementor-element-0b9b9c1,
    .elementor-508 .elementor-element-0b9b9c1 {
        grid-column: 4 !important;
        grid-row: 1 !important;
        --width: 42px !important;
        width: 42px !important;
        max-width: 42px !important;
        justify-self: end !important;
        overflow: visible !important;
    }

    .elementor-259 .elementor-element-7f8fd7e .e-image-link-base,
    .elementor-508 .elementor-element-7f8fd7e .e-image-link-base {
        display: block !important;
        max-width: 100% !important;
        width: auto !important;
    }

    .elementor-259 .elementor-element-7f8fd7e img,
    .elementor-508 .elementor-element-7f8fd7e img {
        max-height: 42px;
        width: auto;
        max-width: 100% !important;
        margin: 0;
        display: block;
        object-fit: contain;
        object-position: left center;
    }

    .elementor-259 .elementor-element-317a0c9 a,
    .elementor-259 .elementor-element-ba0edd8 a,
    .elementor-508 .elementor-element-317a0c9 a,
    .elementor-508 .elementor-element-ba0edd8 a {
        display: block !important;
        width: 36px !important;
        height: 24px !important;
        line-height: 0;
    }

    .elementor-259 .elementor-element-317a0c9 img,
    .elementor-259 .elementor-element-ba0edd8 img,
    .elementor-508 .elementor-element-317a0c9 img,
    .elementor-508 .elementor-element-ba0edd8 img {
        width: 32px !important;
        height: 22px !important;
        max-width: 32px !important;
        max-height: 22px !important;
        object-fit: cover;
        border-radius: 3px;
        border: 1px solid rgba(183, 160, 102, 0.45);
        display: block;
    }

    .elementor-259 .elementor-element-0b9b9c1 .elementor-widget-container,
    .elementor-508 .elementor-element-0b9b9c1 .elementor-widget-container {
        width: 42px !important;
        max-width: 42px !important;
    }

    /* จำกัดเฉพาะ wrapper ของ toggle — ไม่ใช่ ul.hfe-nav-menu ใน dropdown */
    .elementor-259 .elementor-element-0b9b9c1 .elementor-widget-container > .hfe-nav-menu.hfe-layout-horizontal,
    .elementor-508 .elementor-element-0b9b9c1 .elementor-widget-container > .hfe-nav-menu.hfe-layout-horizontal {
        display: block !important;
        width: 42px !important;
        max-width: 42px !important;
        text-align: center;
    }

    /* เอา nav ออกจาก layout ตอนปิด — แก้ทับซ้อน */
    .elementor-259 .elementor-element-0b9b9c1 nav.hfe-nav-menu__layout-horizontal,
    .elementor-508 .elementor-element-0b9b9c1 nav.hfe-nav-menu__layout-horizontal {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        top: var(--jsmt-header-h, 58px) !important;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 9999 !important;
        pointer-events: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    .elementor-259 .elementor-element-b220782 .hfe-nav-menu__toggle,
    .elementor-508 .elementor-element-b220782 .hfe-nav-menu__toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        margin: 0;
        padding: 0;
        border: 1px solid rgba(183, 160, 102, 0.55);
        border-radius: 8px;
        background: rgba(183, 160, 102, 0.08);
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease;
    }

    .elementor-259 .elementor-element-b220782 .hfe-nav-menu__toggle:hover,
    .elementor-259 .elementor-element-b220782 .hfe-active-menu.hfe-nav-menu__toggle,
    .elementor-508 .elementor-element-b220782 .hfe-nav-menu__toggle:hover,
    .elementor-508 .elementor-element-b220782 .hfe-active-menu.hfe-nav-menu__toggle {
        background: rgba(183, 160, 102, 0.2);
        border-color: rgba(183, 160, 102, 0.85);
    }

    .elementor-259 .elementor-element-b220782 .hfe-nav-menu-icon,
    .elementor-508 .elementor-element-b220782 .hfe-nav-menu-icon {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .elementor-259 .elementor-element-b220782 .hfe-nav-menu-icon svg,
    .elementor-508 .elementor-element-b220782 .hfe-nav-menu-icon svg {
        width: 22px !important;
        height: 22px !important;
    }

    /* Full-width dropdown panel — menu widget only */
    .elementor-259 .elementor-element-0b9b9c1 .elementor-widget-container,
    .elementor-508 .elementor-element-0b9b9c1 .elementor-widget-container {
        overflow: visible;
        position: relative;
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal {
        pointer-events: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        overflow-y: auto !important;
        background: #080808 !important;
        border-bottom: 1px solid rgba(183, 160, 102, 0.35);
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
        max-height: calc(100dvh - var(--jsmt-header-h, 58px));
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal ul.hfe-nav-menu,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal ul.hfe-nav-menu {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        list-style: none !important;
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal ul.hfe-nav-menu > li,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal ul.hfe-nav-menu > li {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        float: none !important;
        margin: 0 !important;
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal ul.hfe-nav-menu > li > a.hfe-menu-item,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal ul.hfe-nav-menu > li > a.hfe-menu-item {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    body.jsmt-menu-open::before {
        content: "";
        position: fixed;
        inset: var(--jsmt-header-h, 62px) 0 0 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 9998;
        pointer-events: none;
    }

    body.jsmt-menu-open {
        overflow: hidden;
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal .hfe-nav-menu,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal .hfe-nav-menu {
        padding: 6px 0 10px;
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal .hfe-nav-menu li a.hfe-menu-item,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal .hfe-nav-menu li a.hfe-menu-item {
        padding: 13px 20px !important;
        font-size: 13px !important;
        letter-spacing: 0.05em;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
        text-align: left;
    }

    .elementor-259 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal .hfe-nav-menu li:last-child a.hfe-menu-item,
    .elementor-508 .hfe-nav-menu__breakpoint-tablet .hfe-active-menu + .hfe-nav-menu__layout-horizontal .hfe-nav-menu li:last-child a.hfe-menu-item {
        border-bottom: none;
    }

    /* Calendar + contact side-by-side blocks → stack on tablet */
    .elementor-element-c556cac.e-flex > .e-con-inner {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }

    .elementor-element-803973b,
    .elementor-element-914c175 {
        width: 100% !important;
        --width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Footer two columns */
    .elementor-448 .elementor-element-186ac91 > .e-con-inner,
    .elementor-506 .elementor-element-186ac91 > .e-con-inner {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        gap: 24px;
    }

    .elementor-448 .elementor-element-45f2df5,
    .elementor-448 .elementor-element-b97cd71,
    .elementor-506 .elementor-element-45f2df5,
    .elementor-506 .elementor-element-b97cd71 {
        width: 100% !important;
        --width: 100% !important;
        flex: 0 0 100% !important;
    }

    .elementor .Head_footer,
    .elementor .Head_footer2,
    .elementor .Head_footer3,
    .elementor .Head_footer4 {
        text-align: start !important;
        align-self: start !important;
    }

    /* Image galleries */
    .elementor-image-gallery .gallery {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px;
    }

    .elementor-image-gallery .gallery-item {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Calendar toolbar */
    .fc .fc-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        row-gap: 10px;
    }

    .fc .fc-toolbar-title {
        font-size: 1.1rem;
    }
}

/* ── Mobile (<=767px) ── */
@media (max-width: 767px) {
    .e-con-boxed > .e-con-inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Section headings from desktop-only CSS */
    .elementor .e-d2295b0-60e98fc,
    .elementor .e-78599ef-36a5505,
    .elementor .e-01fc7ad-cdd35fc,
    .elementor .e-4fbaec3-617759d,
    .elementor .e-heading-base.e-d2295b0-60e98fc,
    .elementor .e-heading-base.e-78599ef-36a5505,
    .elementor .e-heading-base.e-01fc7ad-cdd35fc,
    .elementor .e-heading-base.e-4fbaec3-617759d {
        font-size: clamp(16px, 4.8vw, 22px) !important;
        line-height: 1.35 !important;
        text-align: center;
        word-break: break-word;
    }

    .elementor .Head_footer {
        font-size: clamp(18px, 5vw, 24px) !important;
        line-height: 1.3 !important;
    }

    .elementor .Head_footer2,
    .elementor .Head_footer3,
    .elementor .Head_footer4 {
        font-size: clamp(14px, 3.8vw, 18px) !important;
        line-height: 1.4 !important;
    }

    .elementor .Text_footer2,
    .elementor .Text_footer {
        font-size: 14px;
        line-height: 1.6;
    }

    /* Hero / banner images */
    .elementor-element-0adc4d1 img,
    .elementor-element-918bac7 + .elementor-element img {
        width: 100%;
    }

    /* Galleries: 2 columns on phone */
    .elementor-image-gallery .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    /* Row containers in page content → single column */
    .elementor-54 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-385 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-477 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-285 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-287 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-289 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-291 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-293 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-295 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-297 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-394 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-402 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-407 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-415 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-421 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-429 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-436 .e-con.e-flex > .e-con-inner > .e-con.e-child,
    .elementor-443 .e-con.e-flex > .e-con-inner > .e-con.e-child {
        flex: 0 0 100% !important;
        width: 100% !important;
        --width: 100% !important;
        max-width: 100% !important;
    }

    /* Header flags — keep compact (rules in tablet section) */

    /* Mobile nav items */
    .hfe-nav-menu__layout-horizontal .hfe-nav-menu .menu-item a.hfe-menu-item {
        font-size: 14px;
        padding: 12px 16px;
        word-break: break-word;
    }

    /* Calendar */
    .ectbe-calendar-wrapper,
    .ectbe-event-calendar-cls,
    .fc {
        width: 100% !important;
        max-width: 100%;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .fc .fc-button {
        font-size: 12px;
        padding: 4px 8px;
    }

    .fc .fc-daygrid-day-number {
        font-size: 12px;
    }

    /* Contact / long text */
    .elementor .e-paragraph-base,
    .elementor-widget-text-editor {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* Footer logo */
    .elementor .logo_footer {
        width: 100px !important;
        max-width: 40vw;
    }
}

/* Mobile header fine-tuning */
@media (max-width: 767px) {
    .elementor-259 .elementor-element-638e667 > .e-con-inner,
    .elementor-508 .elementor-element-638e667 > .e-con-inner {
        column-gap: 8px;
        padding: 6px 12px !important;
    }

    .elementor-259 .elementor-element-7f8fd7e img,
    .elementor-508 .elementor-element-7f8fd7e img {
        max-height: 40px;
        max-width: calc(100vw - 150px);
    }

    .elementor-259 .elementor-element-317a0c9 img,
    .elementor-259 .elementor-element-ba0edd8 img,
    .elementor-508 .elementor-element-317a0c9 img,
    .elementor-508 .elementor-element-ba0edd8 img {
        width: 30px;
        height: 20px;
        max-width: 30px;
        max-height: 20px;
    }

    .elementor-259 .elementor-element-b220782 .hfe-nav-menu__toggle,
    .elementor-508 .elementor-element-b220782 .hfe-nav-menu__toggle {
        width: 40px;
        height: 40px;
    }
}

/* ── Small phones (<=480px) ── */
@media (max-width: 480px) {
    .elementor-image-gallery .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .fc .fc-toolbar-title {
        font-size: 1rem;
    }

    .fc .fc-button-group .fc-button {
        font-size: 11px;
        padding: 3px 6px;
    }
}
