/* ==========================================================================
   ISE Garden & Forest Equipment — phone / tablet UI
   Loaded AFTER modern.css (see the AppAsset.php of each theme). Uses the --ise tokens defined there.

     1. Header (phone + tablet, up to 1199px)
     2. Basket side panel (all screen sizes)
     3. "You may also like" carousel (product page)
     4. Small fixes
   ========================================================================== */

/* ---------- 1. Header ---------------------------------------------------- */

/* the extra header controls only exist for phones / tablets */
.mhd-icon, .mhd-menu-text { display: none; }

/* the category panel opens from "Shop by category" in the menu drawer. It sits in this plain wrapper (no overflow, no
   transform): iPhones clip a fixed panel that lives inside a scrolling or clipping parent, which showed a blank screen. */
.header-categories-host { display: none; }

@media (max-width: 1199px) {
    .header .header-bottom { background: #fff; }
    .header .header-bottom > .container,
    .header .header-bottom .container { padding-left: 0; padding-right: 0; }

    /* row 1: menu | logo ........ search  account  basket */
    .header .header-content-wrapper {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        height: 60px;
        padding: 0 8px 0 6px;
        gap: 2px;
    }
    .header .header-content-right { display: contents; }

    .header .hamburger-menu,
    .header .mhd-icon,
    .header .basket-button {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 46px;
        height: 46px;
        padding: 0;
        margin: 0;
        border: 0;
        border-radius: 14px;
        background: transparent;
        color: var(--ise-ink);
        flex: 0 0 auto;
        cursor: pointer;
        transition: background-color .15s var(--ise-ease), color .15s;
    }
    /* the menu button: icon + the word "Menu" in a soft pill */
    .header .hamburger-menu {
        order: 0;
        width: auto;
        height: 44px;
        padding: 0 14px 0 11px;
        gap: 8px;
        margin-right: 4px;
        background: var(--ise-green-50);
        border-radius: 14px;
    }
    .header .hamburger-menu .mhd-menu-text {
        display: block;
        font-family: var(--ise-font-semibold);
        font-size: 15px;
        line-height: 1;
        letter-spacing: .01em;
        color: var(--ise-ink);
    }
    .header .header-content-left { order: 1; flex: 1 1 auto; min-width: 0; width: auto; }
    .header .mhd-search-toggle { order: 2; }
    .header .mhd-account { order: 3; }
    .header .basket-button { order: 4; }

    .header .hamburger-menu:active { background: var(--ise-green-100); }
    .header .mhd-icon:active,
    .header .basket-button:active { background: var(--ise-green-50); }
    .header .mhd-icon svg { display: block; width: 24px; height: 24px; }
    .header .hamburger-menu .icon svg { display: block; width: 22px; height: 22px; }
    .header .hamburger-menu .icon,
    .header .basket-button .icon { display: flex; align-items: center; justify-content: center; }
    .header .hamburger-menu .icon svg path { fill: none; stroke: currentColor; }

    .header .basket-button .icon svg { display: block; width: 25px; height: 23px; }
    .header .basket-button svg path { fill: currentColor; }
    .header .basket-button .basket-label { display: none; }
    .header .basket-button .count {
        position: absolute;
        top: 2px;
        right: 0;
        left: auto;
        min-width: 19px;
        height: 19px;
        padding: 0 5px;
        margin: 0;
        font-size: 11px;
        line-height: 19px;
        font-weight: 700;
        text-align: center;
        box-shadow: 0 0 0 2px #fff;
    }
    .header .basket-button .count.is-empty { display: none; }

    .header .header-logo-link { height: 60px; padding: 0 4px; align-items: center; justify-content: flex-start; }
    .header .header-logo-link img { max-height: 36px; width: auto; margin: 0; }

    /* row 2: search */
    .header .mobile-search-wrapper { display: block; padding: 0 12px 10px; }
    .header .mobile-search-wrapper .search-form { position: relative; display: block; margin: 0; padding: 0; width: auto; }
    .header .mobile-search-wrapper .search-form input[type="search"] {
        display: block;
        width: 100%;
        height: 46px;
        padding: 0 16px 0 46px;
        border: 1px solid var(--ise-line);
        border-radius: 999px;
        background: var(--ise-bg);
        color: var(--ise-ink);
        font-size: 16px; /* 16px keeps iOS from zooming in on focus */
        -webkit-appearance: none;
        appearance: none;
    }
    .header .mobile-search-wrapper .search-form input[type="search"]::placeholder { color: var(--ise-muted); opacity: 1; }
    .header .mobile-search-wrapper .search-form input[type="search"]:focus { background: #fff; border-color: var(--ise-green-600); box-shadow: var(--ise-focus); }
    .header .mobile-search-wrapper .search-form button[type="submit"] {
        position: absolute;
        left: 6px;
        top: 50%;
        transform: translateY(-50%);
        width: 36px;
        height: 36px;
        padding: 0;
        border: 0;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .header .mobile-search-wrapper .search-form button[type="submit"] svg { width: 18px; height: 18px; }

    /* the category panel is parked off-screen: its shadow must not leak onto the page (pale fade on the right edge) */
    .header .header-categories-menu-wrapper { box-shadow: none; }
    .header.open-categories .header-categories-menu-wrapper { box-shadow: -16px 0 40px rgba(16, 40, 28, .18); }

    /* the wrapper of the category panel is only a place for the fixed panel: it takes no room on the page */
    .header .header-categories-host { display: block; height: 0; margin: 0; padding: 0; }

    /* once the page is scrolled the bar shrinks to the top row; search opens from its icon (no more 164px pinned to the top) */

    /* when scrolled, the bar is a fixed layer of its own (z-index 100), which trapped the menu drawer / category panel
       under the dark backdrop (z-index 990). While one of them is open the bar is lifted above the backdrop. */
    .header.open-menu .header-bottom,
    .header.open-categories .header-bottom { z-index: 1002; }
    .header.fixed .mhd-search-toggle { display: flex; }
    .header:not(.fixed) .mhd-search-toggle { display: none; }
    .header.fixed .mobile-search-wrapper {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        padding: 8px 12px 12px;
        background: #fff;
        box-shadow: 0 14px 24px rgba(16, 40, 28, .14);
        z-index: 5;
    }
    .header.fixed.mhd-search-open .mobile-search-wrapper { display: block; }
    .header.fixed.mhd-search-open .mhd-search-toggle { background: var(--ise-green-50); color: var(--ise-green-700); }
    .header.fixed .header-bottom { box-shadow: 0 6px 18px rgba(16, 40, 28, .12) !important; }

    /* icons are visible on phones / tablets only */
    .header .mhd-icon { display: flex; }
}

@media (max-width: 380px) {
    .header .mhd-icon, .header .basket-button { width: 42px; height: 42px; }
    .header .hamburger-menu { height: 42px; padding: 0 12px 0 9px; gap: 6px; }
    .header .hamburger-menu .mhd-menu-text { font-size: 14px; }
    .header .header-logo-link img { max-height: 32px; }
    .header .header-content-wrapper { padding-left: 2px; padding-right: 4px; }
}
/* very narrow phones (320px): only the icon, there is no room for the word */
@media (max-width: 345px) {
    .header .hamburger-menu { width: 42px; padding: 0; }
    .header .hamburger-menu .mhd-menu-text { display: none; }
}

/* ---------- 2. Basket side panel ------------------------------------------ */

/* above the sticky "Choose option" bar (z-index 900), the header (1000/1001) and the category panel */
.basket-popup {
    z-index: 1300;
    background: rgba(11, 42, 28, .58);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
html.basket-open .pdp-sticky,
html.basket-open .btn-wrapper.popup-btn,
html.basket-open .cart-toast { display: none !important; }
/* the live-chat bubble (Chatra, always on top) must not sit on the buttons while a panel is open */
html.mui-overlay #chatra { visibility: hidden !important; pointer-events: none !important; }

.basket-popup .basket-content {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -18px 0 50px rgba(0, 0, 0, .22);
    transform: translateX(28px);
    opacity: 0;
    transition: transform .32s var(--ise-ease), opacity .25s ease;
}
.basket-popup.open-popup .basket-content { transform: none; opacity: 1; }

/* the theme's custom scrollbar plugin is neutralised: the list scrolls natively and the footer stays put */
.basket-popup .basket-content .mCustomScrollBox,
.basket-popup .basket-content .mCSB_container {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    top: 0 !important;
    width: 100%;
}
.basket-popup .basket-content .mCSB_scrollTools { display: none !important; }

.basket-popup .basket-list-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    padding: 0;
}
.basket-popup .basket-title {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 18px 70px 14px 20px;
    border-bottom: 1px solid var(--ise-line);
    font-family: var(--ise-font-head);
    font-size: 24px;
    line-height: 1.15;
    letter-spacing: .01em;
    color: var(--ise-ink);
}
.basket-popup .basket-title__count {
    font-family: var(--ise-font-medium);
    font-size: 13px;
    letter-spacing: 0;
    color: var(--ise-muted);
}
.basket-popup .close-popup-button {
    display: flex;
    align-items: center;
    justify-content: center;
    top: 10px;
    right: 10px;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--ise-bg);
    z-index: 3;
}
.basket-popup .close-popup-button svg { width: 16px; height: 16px; }
.basket-popup .close-popup-button svg path { fill: var(--ise-ink); }

.basket-popup .basket-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 4px 16px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.basket-popup .basket-list__item { position: static; padding: 14px 0; border-bottom: 1px solid var(--ise-line); }
.basket-popup .basket-list__item:last-child { border-bottom: 0; }

.basket-popup .basket-list__item-content-wrapper {
    padding: 0; /* the base theme pads this 30px 80px 30px 20px */
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    grid-template-areas:
        "img text text"
        "img qty  price"
        "img upd  upd";
    gap: 8px 12px;
    align-items: start;
    position: relative;
}
.basket-popup .basket-list__item-content,
.basket-popup .basket-qty-form,
.basket-popup .basket-list__item-count-wrapper { display: contents; }

.basket-popup .basket-list__item-img {
    grid-area: img;
    display: block;
    width: 76px;
    height: 76px;
    padding: 4px;
    border: 1px solid var(--ise-line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.basket-popup .basket-list__item-img a { display: block; width: 100%; height: 100%; }
.basket-popup .basket-list__item-img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.basket-popup .basket-list__item-text-wrapper { grid-area: text; display: block; min-width: 0; padding: 0 30px 0 0; margin: 0; }
.basket-popup .basket-list__item-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    font-family: var(--ise-font-semibold);
    font-size: 15px;
    line-height: 1.3;
    color: var(--ise-ink);
    text-decoration: none;
    word-break: break-word;
}
.basket-popup .basket-list__item-subtitle { margin-top: 3px; font-size: 13px; line-height: 1.3; color: var(--ise-muted); }

.basket-popup .input-count-wrapper {
    grid-area: qty;
    display: inline-flex;
    align-items: center;
    justify-self: start;
    width: auto;
    height: 38px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--ise-line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}
.basket-popup .input-count-wrapper .input-count-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    font-size: 20px;
    line-height: 1;
    color: var(--ise-ink);
    text-decoration: none;
    background: transparent;
}
.basket-popup .input-count-wrapper .input-count-link:active { background: var(--ise-green-50); }
.basket-popup .input-count-wrapper .input-field { display: block; width: 40px; }
.basket-popup .input-count-wrapper .input {
    display: block;
    width: 100%;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    text-align: center;
    font-size: 16px;
    color: var(--ise-ink);
    -moz-appearance: textfield;
}
.basket-popup .basket-list__item-count-wrapper .price {
    grid-area: price;
    align-self: center;
    justify-self: end;
    padding: 0;
    text-align: right;
    font-family: var(--ise-font-semibold);
    font-size: 17px;
    line-height: 1.2;
    color: var(--ise-ink);
    white-space: nowrap;
}
.basket-popup .basket-list__item-count-wrapper .price small { display: block; margin-top: 2px; font-family: var(--ise-font); font-size: 12px; color: var(--ise-muted); }
.basket-popup .basket-list__item-count-wrapper .button-wrapper { grid-area: upd; display: block; padding: 0; margin: 2px 0 0; }
.basket-popup .basket-list__item-count-wrapper .button-wrapper .button { height: 38px; min-width: 0; width: 100%; margin: 0; padding: 0 16px; border-radius: 10px; font-size: 14px; }
/* "update" only appears after the quantity was changed (js/mobile-ui.js adds .mui to <html>) */
html.mui .basket-popup .basket-list__item:not(.is-dirty) .button-wrapper { display: none; }

.basket-popup .basket-list__item-remove-link {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    border-radius: 10px;
}
.basket-popup .basket-list__item-remove-link svg { width: 14px; height: 14px; }
.basket-popup .basket-list__item-remove-link svg path { fill: var(--ise-muted); }
.basket-popup .basket-list__item-remove-link:active { background: var(--ise-bg); }

.basket-popup .basket-popup-bottom {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch; /* the base theme right-aligns this block */
    align-items: stretch;
    gap: 10px;
    margin: 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--ise-line);
    background: #fff;
    box-shadow: 0 -12px 28px rgba(16, 40, 28, .08);
}
.basket-popup .basket-popup-bottom .total-price {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
    padding: 0 2px;
}
.basket-popup .basket-popup-bottom .total-price .title { font-family: var(--ise-font-semibold); font-size: 15px; color: var(--ise-ink-2); }
.basket-popup .basket-popup-bottom .total-price .count { font-family: var(--ise-font-head); font-size: 28px; line-height: 1.1; color: var(--ise-ink); }
.basket-popup .basket-popup-bottom .button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    height: 54px;
    margin: 0;
    border-radius: 14px;
    font-size: 16px;
}
/* the cart icon sits inline next to the label instead of in a dark box at the end of the button */
.basket-popup .basket-popup-bottom .add-to-card-button { gap: 10px; }
.basket-popup .basket-popup-bottom .add-to-card-button .text { padding: 0; margin: 0; }
.basket-popup .basket-popup-bottom .add-to-card-button .icon {
    position: static;
    display: inline-flex;
    align-items: center;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    background: none !important;
}
.basket-popup .basket-popup-bottom .add-to-card-button .icon svg { width: 22px; height: 20px; }
.basket-popup .basket-popup-bottom .add-to-card-button .icon svg path { fill: #fff; }
.basket-popup .basket-popup-continue {
    display: block;
    padding: 4px 0 0;
    text-align: center;
    font-family: var(--ise-font-semibold);
    font-size: 14px;
    color: var(--ise-green-700);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.basket-popup .basket-empty {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 24px;
    text-align: center;
}
.basket-popup .basket-empty__text { margin: 0; font-size: 17px; color: var(--ise-ink-2); }
.basket-popup .basket-empty__link {
    display: inline-flex;
    align-items: center;
    height: 46px;
    padding: 0 22px;
    border-radius: 12px;
    background: var(--ise-green-800);
    color: #fff;
    font-family: var(--ise-font-semibold);
    text-decoration: none;
}

/* ---------- 3. "You may also like" --------------------------------------- */

.rel { padding: 44px 0 56px; background: var(--ise-bg); border-top: 1px solid var(--ise-line); }
.rel__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.rel__eyebrow {
    display: block;
    margin-bottom: 6px;
    font-family: var(--ise-font-semibold);
    font-size: 12px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ise-orange-600);
}
.rel__title {
    margin: 0;
    font-family: var(--ise-font-head);
    font-weight: normal;
    font-size: clamp(28px, 4.4vw, 40px);
    line-height: 1.02;
    letter-spacing: .01em;
    text-transform: uppercase;
    color: var(--ise-ink);
}
.rel__title::after { content: ""; display: block; width: 56px; height: 4px; margin-top: 12px; border-radius: 2px; background: var(--ise-orange-400); }
.rel__controls { display: none; gap: 10px; flex: 0 0 auto; }
.rel__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--ise-line);
    border-radius: 50%;
    background: #fff;
    color: var(--ise-ink);
    cursor: pointer;
    box-shadow: var(--ise-shadow-sm);
    transition: background-color .2s, color .2s, border-color .2s, opacity .2s;
}
.rel__arrow:hover:not(:disabled) { background: var(--ise-green-800); border-color: var(--ise-green-800); color: #fff; }
.rel__arrow:disabled { opacity: .35; cursor: default; box-shadow: none; }

.rel__track {
    display: flex;
    gap: 14px;
    margin: 0 -16px;
    padding: 4px 16px 20px;
    list-style: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.rel__track::-webkit-scrollbar { display: none; }
.rel__item { flex: 0 0 calc((100% - 32px - 14px) / 2.15); min-width: 0; scroll-snap-align: start; }

.rel .pcard {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 0;
    padding: 0; /* the base card reserves 80px at the bottom for its old absolute button */
    border: 1px solid var(--ise-line);
    border-radius: 18px;
    background: #fff;
    box-shadow: none;
    overflow: hidden;
    transition: transform .25s var(--ise-ease), box-shadow .25s var(--ise-ease), border-color .25s;
}
.rel .pcard__media {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    padding: 14px;
    border: 0;
    background: #fff;
}
.rel .pcard__media img { width: 100%; height: 100%; object-fit: contain; }
.rel .category-list__item-labels { top: 10px; left: 10px; z-index: 2; pointer-events: none; }
.rel .pcard__body { display: flex; flex-direction: column; flex: 1 1 auto; gap: 6px; padding: 4px 14px 14px; border: 0; background: transparent; }
.rel .pcard__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
    margin: 0;
    font-family: var(--ise-font-semibold);
    font-size: 15px;
    line-height: 1.3;
    color: var(--ise-ink);
    text-decoration: none;
}
/* the whole card is one big tap target */
.rel .pcard__title::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.rel .pcard__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: auto; padding-top: 4px; }
.rel .pcard__price .price { font-family: var(--ise-font-head); font-size: 22px; line-height: 1.1; color: var(--ise-ink); }
.rel .pcard__price .price.is-sale { color: var(--ise-sale); }
.rel .pcard__price .discount { font-size: 13px; color: var(--ise-muted); text-decoration: line-through; }
.rel .pcard__meta { font-size: 12.5px; color: var(--ise-muted); }
.rel .pcard__cta {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    margin: 8px 0 0;
    padding: 0 14px;
    border: 1.5px solid var(--ise-green-100);
    border-radius: 12px;
    background: var(--ise-green-50) !important;
    color: var(--ise-green-700) !important;
    font-size: 13.5px;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    box-shadow: none;
    transition: background-color .2s, color .2s, border-color .2s;
}
.rel .pcard__cta .text { padding: 0; margin: 0; white-space: nowrap; }
.rel .pcard__cta svg { width: 16px; height: 16px; fill: currentColor; flex: 0 0 auto; transition: transform .2s var(--ise-ease); }
.rel .pcard__cta .icon { display: none; }

@media (hover: hover) {
    .rel .pcard:hover { transform: translateY(-4px); border-color: transparent; box-shadow: var(--ise-shadow); }
    .rel .pcard:hover .pcard__cta { background: var(--ise-green-800) !important; border-color: var(--ise-green-800); color: #fff !important; }
    .rel .pcard:hover .pcard__cta svg { transform: translateX(3px); }
}
.rel .pcard:focus-within { box-shadow: var(--ise-focus); }

@media (min-width: 480px) { .rel__item { flex-basis: calc((100% - 32px - 28px) / 3.15); } }
@media (min-width: 768px) {
    .rel { padding: 56px 0 72px; }
    .rel__controls { display: flex; }
    .rel__track { margin: 0 -2px; padding: 6px 2px 22px; gap: 18px; scroll-padding: 0; }
    .rel__item { flex-basis: calc((100% - 36px) / 3); }
}
@media (min-width: 1024px) { .rel__item { flex-basis: calc((100% - 54px) / 4); } }

@media (prefers-reduced-motion: reduce) {
    .rel .pcard, .rel .pcard__cta svg, .basket-popup .basket-content { transition: none; }
}

/* ---------- 4. Small fixes ------------------------------------------------ */

/* long product names in the sticky purchase bar never push the button out */
.pdp-sticky__info { min-width: 0; }
.pdp-sticky__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rel__controls[hidden] { display: none !important; }
