/* ==========================================================================
   Mobile categories nav (Scripts/cfg-catnav.js) - Chiltern Food Group
   Header compact/sticky, category drawer, shop chip bar, breadcrumb.
   Desktop (>= 1058px) keeps the hover menu and the pill grid untouched.
   ========================================================================== */
:root { --cfg-blue: #0E76BC; --cfg-red: #9F2228; --cfg-bar-h: 64px; }

/* the page wrapper's overflow:hidden stopped position:sticky from working; clip keeps the
   "no sideways scroll" behaviour without creating a scroll container */
@supports (overflow: clip) {
    .over-flow-stopper { overflow: visible; overflow-x: clip; }
}

/* ---------- desktop pill grid (now real buttons) ---------- */
#widget-inner .categorybutton { background: #fff; font: inherit; font-size: 13px; line-height: 1.4; margin: 2px 0; }
#widget-inner .categorybutton:hover, #widget-inner .categorybutton.activated { background: var(--cfg-red); color: #fff; }
#widget-inner .categorybutton:focus-visible, #widget-inner .cfg-pill-prev:focus-visible { outline: 3px solid var(--cfg-blue); outline-offset: 2px; }

/* ---------- breadcrumb (all widths) ---------- */
.cfg-crumbs { max-width: 1140px; margin: 0 auto; padding: 10px 15px 0; }
.cfg-crumbs[hidden] { display: none; }
.cfg-crumbs__list { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; list-style: none; margin: 0; padding: 0; font-size: 13px; color: #555; }
.cfg-crumbs__item { display: inline-flex; align-items: center; }
.cfg-crumbs__item + .cfg-crumbs__item::before { content: "\203A"; margin: 0 8px; color: #999; }
.cfg-crumbs .cfg-crumbs__link { display: inline-flex; align-items: center; min-height: 32px; padding: 0; border: 0; background: none; color: var(--cfg-blue); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; white-space: normal; }
.cfg-crumbs .cfg-crumbs__link:hover { color: #0a5a90; }
.cfg-crumbs [aria-current="page"] { color: #222; font-weight: 600; }

/* chips are mobile only */
.cfg-chipbar, .cfg-subchips { display: none; }

/* ---------- category drawer ---------- */
.cfg-drawer-backdrop { position: fixed; inset: 0; z-index: 1990; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s ease; }
.cfg-drawer-backdrop.is-open { opacity: 1; }
.cfg-drawer-backdrop[hidden], .cfg-drawer[hidden] { display: none; }
.cfg-drawer {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 2000;
    width: min(88vw, 360px); max-width: 100%;
    display: flex; flex-direction: column;
    background: #fff; color: #222; box-shadow: 4px 0 24px rgba(0, 0, 0, .2);
    transform: translateX(-100%); transition: transform .22s ease;
    font-family: 'Poppins', sans-serif;
}
.cfg-drawer.is-open { transform: none; }
@media (prefers-reduced-motion: reduce) { .cfg-drawer, .cfg-drawer-backdrop { transition: none; } }
html.cfg-drawer-open, html.cfg-drawer-open body { overflow: hidden; }
.cfg-drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 3px solid var(--cfg-blue); }
.cfg-drawer__title { margin: 0; font-size: 18px; font-weight: 600; color: #222; letter-spacing: 0; text-transform: none; }
.cfg-drawer__close { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; color: #333; cursor: pointer; }
.cfg-drawer__close:hover { background: #f1f4f7; }
.cfg-drawer__body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 0 24px; }
.cfg-drawer__all { display: flex; align-items: center; min-height: 48px; padding: 0 16px; font-weight: 600; color: var(--cfg-blue); border-bottom: 1px solid #eee; text-decoration: none; }
.cfg-drawer__list, .cfg-drawer__sub { list-style: none; margin: 0; padding: 0; }
.cfg-drawer__sub[hidden] { display: none; }
.cfg-drawer__item { border-bottom: 1px solid #eee; margin: 0; }
.cfg-drawer__sub .cfg-drawer__item { border-bottom: 0; }
.cfg-drawer__toggle, .cfg-drawer__link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; min-height: 48px; padding: 10px 16px; margin: 0;
    border: 0; background: transparent; color: #222; font: inherit; font-size: 15px; line-height: 1.3; text-align: left; text-decoration: none; cursor: pointer;
}
.cfg-drawer__toggle:hover, .cfg-drawer__link:hover { background: #f4f8fb; color: #222; }
.cfg-drawer__toggle.is-active { color: var(--cfg-blue); font-weight: 600; }
.cfg-drawer__chev { flex: 0 0 auto; color: #666; transition: transform .2s ease; }
.cfg-drawer__toggle[aria-expanded="true"] .cfg-drawer__chev { transform: rotate(180deg); color: var(--cfg-blue); }
.cfg-drawer__sub { background: #f7f9fb; padding: 4px 0; }
.cfg-drawer__sub .cfg-drawer__toggle, .cfg-drawer__sub .cfg-drawer__link { padding-left: 28px; font-size: 14px; min-height: 44px; }
.cfg-drawer__sub .cfg-drawer__sub { background: #eef3f7; }
.cfg-drawer__sub .cfg-drawer__sub .cfg-drawer__link { padding-left: 40px; }
.cfg-drawer__viewall { color: var(--cfg-blue); font-weight: 600; }
.cfg-drawer__link.is-current { color: var(--cfg-red); font-weight: 600; box-shadow: inset 3px 0 0 var(--cfg-red); }
.cfg-drawer__msg { padding: 16px; color: #555; }
.cfg-drawer a:focus-visible, .cfg-drawer button:focus-visible { outline: 3px solid var(--cfg-blue); outline-offset: -3px; }

/* ==========================================================================
   <= 1057px: compact sticky header, chip bar, pill grid hidden
   ========================================================================== */
@media (max-width: 1057px) {
    /* the Navbar wrapper (.container) was only as tall as the header, so sticky had nowhere to stick;
       on small screens let its children sit directly in the page */
    .cfg-nav-shell { display: contents; }
    /* header: account/search rows scroll away, the menu/logo/cart row stays (top is set by cfg-catnav.js) */
    .mobile-navbar {
        position: -webkit-sticky; position: sticky; top: var(--cfg-mh-stick, -110px);
        height: auto; transition: none; z-index: 1000;
        display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
        grid-template-areas: "dl dl dl" "srch srch srch" "menu logo cart" "nav nav nav";
        box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    }
    .mobile-order-deadline-header { grid-area: dl; }
    .mobile-navbar__search { grid-area: srch; display: flex; flex-direction: column; padding: 6px 12px 4px; min-width: 0; }
    .mobile-navbar__search .info-account {
        order: -1; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px;
        float: none; position: static; top: auto; margin: 0 0 6px; padding: 0 4px;
    }
    .mobile-navbar__search .info-account form { display: contents; }
    .mobile-navbar__search .info-account li { position: static; top: auto; left: auto; width: auto; height: auto; overflow: visible; margin: 0; padding: 0; }
    .mobile-navbar__search .info-account a { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; font-size: 14px; cursor: pointer; }
    .mobile-navbar__search .block-search { position: relative; top: auto; float: none; width: 100%; max-width: 640px; margin: 0 auto; padding: 0; }
    .mobile-navbar__search .block-search .block-content input { height: 44px; line-height: 44px; }

    .mobile-navbar__toggle {
        grid-area: menu; position: static; top: auto; transform: none;
        width: 48px; height: 48px; margin-left: 8px; padding: 0;
        display: inline-flex; align-items: center; justify-content: center;
        border: 0; border-radius: 10px; background: transparent; color: #333; font-size: 0; line-height: 1; cursor: pointer;
    }
    .mobile-navbar__toggle:focus-visible { outline: 3px solid var(--cfg-blue); outline-offset: 2px; }
    .mobile-navbar__toggle--open { background: #f1f4f7; }
    .cfg-burger { position: relative; display: block; width: 24px; height: 18px; }
    .cfg-burger span { position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px; background: currentColor; transition: transform .2s ease, opacity .2s ease, top .2s ease; }
    .cfg-burger span:nth-child(1) { top: 0; }
    .cfg-burger span:nth-child(2) { top: 8px; }
    .cfg-burger span:nth-child(3) { top: 16px; }
    .mobile-navbar__toggle--open .cfg-burger span:nth-child(1) { top: 8px; transform: rotate(45deg); }
    .mobile-navbar__toggle--open .cfg-burger span:nth-child(2) { opacity: 0; }
    .mobile-navbar__toggle--open .cfg-burger span:nth-child(3) { top: 8px; transform: rotate(-45deg); }

    .mobile-navbar__logo { grid-area: logo; position: static; top: auto; left: auto; justify-self: center; height: 64px; display: flex; align-items: center; }
    .mobile-navbar__logo img { height: 54px; width: auto; }
    .mobile-navbar__cart-info { grid-area: cart; position: relative; top: auto; right: auto; justify-self: end; width: 64px; height: 64px; line-height: 64px; }
    /* the slide menu panel is position:fixed; its 100vh wrapper must not push the page down */
    .mobile-navbar__menu { grid-area: nav; height: 0; overflow: visible; }

    /* chip bar sticks right under the compact header */
    .cfg-chipbar {
        display: block; position: -webkit-sticky; position: sticky; top: var(--cfg-bar-h, 64px); z-index: 990;
        background: #fff; border-bottom: 1px solid #e6e6e6; box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
    }
    .cfg-chipbar__track, .cfg-subchips {
        display: flex; align-items: center; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; scrollbar-width: none; padding: 8px 12px;
    }
    .cfg-chipbar__track::-webkit-scrollbar, .cfg-subchips::-webkit-scrollbar { display: none; }
    .cfg-chipbar__items { display: contents; }
    .cfg-subchips { background: #f7f9fb; border-bottom: 1px solid #e6e6e6; padding-top: 6px; padding-bottom: 6px; }
    .cfg-subchips[hidden] { display: none; }
    .cfg-chip {
        flex: 0 0 auto; scroll-snap-align: start;
        display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; margin: 0;
        border: 1px solid #cfd8e0; border-radius: 999px; background: #fff; color: #333;
        font: inherit; font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
    }
    .cfg-chip:hover { border-color: var(--cfg-blue); color: var(--cfg-blue); text-decoration: none; }
    .cfg-chip.is-active, .cfg-chip.is-active:hover { background: var(--cfg-blue); border-color: var(--cfg-blue); color: #fff; }
    .cfg-chip:focus-visible { outline: 3px solid var(--cfg-blue); outline-offset: 2px; }
    .cfg-chip--menu { background: var(--cfg-red); border-color: var(--cfg-red); color: #fff; font-weight: 600; }
    .cfg-chip--menu:hover { background: #861c21; border-color: #861c21; color: #fff; }
    .cfg-chip--sub { min-height: 40px; font-size: 13px; }
    .cfg-crumbs .cfg-crumbs__link { min-height: 44px; }

    /* the 376px pill block is replaced by the chip bar + drawer on small screens */
    .product-container-row > .cfg-cat-col { display: none; }
    .product-container-row > .product-table { flex: 0 0 100%; max-width: 100%; width: 100%; }
    /* cart sidebar was squeezed into 25% at 768px: put it under the products, full width */
    .product-container-row > .cfg-cart-col { flex: 0 0 100%; max-width: 100%; width: 100%; }
    .product-container-row > .cfg-cart-col .follow-scroll { position: static; top: 0 !important; }
    #parentcontainer.ftco-section { padding-top: 16px; }
}

/* ---------- page heading band (.hero-wrap.hero-bread) under the fixed desktop header ----------
   The desktop header is position:fixed (110px), so a heading band that starts at the top of the page
   (Products, single product) must start below it. Pages that already sit in a padded .blob wrapper
   (basket, checkout) keep their own spacing. */
@media (min-width: 1058px) {
    .hero-wrap.hero-bread { padding-top: calc(110px + 2.5em); }
    .blob .hero-wrap.hero-bread { padding-top: 2.5em; }
}
/* keep anchored / scrolled-to list tops clear of the stuck header (JS uses cfgScrollToContent, this covers #hash jumps) */
#products-row, .cfg-crumbs { scroll-margin-top: 126px; }
@media (max-width: 1057px) { #products-row, .cfg-crumbs { scroll-margin-top: calc(var(--cfg-bar-h, 64px) + 72px); } }
