/* =====================================================================
   beanarella Custom Mobile Menu — v13c
   Dynamische Header-Höhe + Failsafe (Porto nur versteckt wenn JS lädt)
   ===================================================================== */

/* Desktop: alles versteckt */
.ba-mm,
.ba-mm-toggle {
  display: none;
}

/* ===================================================================
   MOBILE ONLY (≤ 991px)
   =================================================================== */
@media (max-width: 991px) {

  /* Porto's Mobile-Menü komplett ausblenden */
  html.ba-mm-ready .nav-toggle,
  html.ba-mm-ready .nav-sections,
  html.ba-mm-ready .nav-sections-item-title,
  html.ba-mm-ready .nav-sections-item-content {
    display: none !important;
  }

  /* Header: Links 64px Platz für Hamburger reservieren */
  .page-header .header.content,
  .header.content {
    padding-left: 64px !important;
  }

  .page-header .logo {
    margin-left: 0 !important;
  }

  /* ── Hamburger-Button ──────────────────────────────────────────── */
  button.ba-mm-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 12px;
    top: var(--ba-mm-toggle-top, 16px);
    transform: none;
    z-index: 10001;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }

  /* ── CSS Hamburger-Striche (3 Linien → X) ──────────────────────── */
  .ba-mm-toggle__icon {
    position: relative;
    display: block;
    width: 22px;
    height: 2px;
    background: #282D3B;
    border-radius: 2px;
    transition: background 0.15s linear;
  }

  .ba-mm-toggle__icon::before,
  .ba-mm-toggle__icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    background: #282D3B;
    border-radius: 2px;
    transition: transform 0.15s linear, top 0.15s linear;
  }

  .ba-mm-toggle__icon::before { top: -6px; }
  .ba-mm-toggle__icon::after  { top: 6px; }

  .ba-mm-toggle[aria-expanded="true"] .ba-mm-toggle__icon {
    background: transparent;
  }

  .ba-mm-toggle[aria-expanded="true"] .ba-mm-toggle__icon::before {
    top: 0;
    transform: rotate(45deg);
  }

  .ba-mm-toggle[aria-expanded="true"] .ba-mm-toggle__icon::after {
    top: 0;
    transform: rotate(-45deg);
  }

  /* ── Menü-Panel ────────────────────────────────────────────────── */
  .ba-mm {
    display: block;
    position: fixed;
    top: var(--ba-mm-panel-top, 77px);
    left: 0;
    width: 100%;
    max-width: 400px;
    height: calc(100vh - var(--ba-mm-panel-top, 77px));
    height: calc(100dvh - var(--ba-mm-panel-top, 77px));
    background: #fff;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.15s linear, visibility 0s linear 0.15s;
    z-index: 9998;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }

  .ba-mm.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.15s linear, visibility 0s linear 0s;
  }

  body.ba-mm-noscroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
  }

  /* ── Sprach-Grid oben ──────────────────────────────────────────── */
  .ba-mm__top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1px;
    background: #282D3B;
    padding: 1px;
  }

  .ba-mm__top-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: #353A48;
    color: #fff !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    transition: background 0.15s;
  }

  .ba-mm__top-btn:hover,
  .ba-mm__top-btn:focus {
    background: #454B5A;
    color: #fff !important;
    text-decoration: none;
  }

  .ba-mm__top-btn--active {
    background: #fff;
    color: #282D3B !important;
  }

  .ba-mm__top-btn img {
    width: 20px;
    height: 14px;
    border-radius: 2px;
  }

  /* ── Kacheln (2×2 Grid) ────────────────────────────────────────── */
  .ba-mm__tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #282D3B;
    padding: 1px;
    padding-top: 0;
  }

  .ba-mm__tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px 10px;
    background: #353A48;
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    text-align: center;
    line-height: 1.3;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .ba-mm__tile:visited,
  .ba-mm__tile:link {
    color: #fff !important;
  }

  .ba-mm__tile:hover,
  .ba-mm__tile:focus {
    background: #454B5A;
    color: #fff !important;
    text-decoration: none !important;
  }

  .ba-mm__tile svg {
    stroke: #fff;
    flex-shrink: 0;
  }

  .ba-mm__tile span {
    color: #fff !important;
  }

  /* ── Navigation ────────────────────────────────────────────────── */
  .ba-mm__nav {
    padding: 0;
  }

  .ba-mm__list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  /* ── Hauptpunkte (Level 1) ─────────────────────────────────────── */
  .ba-mm__item {
    border-bottom: 1px solid #ced4da;
  }

  .ba-mm__list > .ba-mm__item:last-child {
    border-bottom: none;
  }

  .ba-mm__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    font-size: 15px;
    font-weight: 700;
    color: #282D3B;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }

  .ba-mm__link:hover,
  .ba-mm__link:focus {
    color: #282D3B;
    text-decoration: none;
    background: #f8f8f8;
  }

  .ba-mm__link-text {
    flex: 1;
  }

  /* ── Toggle (+/−) ──────────────────────────────────────────────── */
  .ba-mm__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .ba-mm__toggle svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: #282D3B;
    stroke-width: 2.5;
    overflow: visible;
    pointer-events: none;
  }

  .ba-mm__icon-minus { display: none; }
  .ba-mm__icon-plus  { display: block; }

  .ba-mm__item--expanded > .ba-mm__link--toggle .ba-mm__icon-plus,
  .ba-mm__item--expanded > .ba-mm__link .ba-mm__icon-plus  { display: none; }
  .ba-mm__item--expanded > .ba-mm__link--toggle .ba-mm__icon-minus,
  .ba-mm__item--expanded > .ba-mm__link .ba-mm__icon-minus { display: block; }

  /* ── Unterpunkte (Level 2) ─────────────────────────────────────── */
  .ba-mm__sub {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .ba-mm__item--expanded > .ba-mm__sub {
    max-height: 2000px;
  }

  .ba-mm__sublink {
    display: block;
    padding: 14px 24px 14px 40px;
    font-size: 14px;
    font-weight: 400;
    color: #282D3B;
    text-decoration: none;
    border-bottom: 1px solid #e9ecef;
    -webkit-tap-highlight-color: transparent;
  }

  .ba-mm__sublink:hover,
  .ba-mm__sublink:focus {
    color: #282D3B;
    text-decoration: none;
    background: #f8f8f8;
  }

  .ba-mm__sub li:last-child .ba-mm__sublink {
    border-bottom: none;
  }

  .ba-mm__sublink--overview {
    font-weight: 600;
    color: #282D3B;
  }

  /* ── Verschachtelte Accordions (Level 2) ─────────────────────── */
  .ba-mm__sub .ba-mm__item--expandable {
    border-bottom: 1px solid #e9ecef;
  }

  .ba-mm__sub .ba-mm__item--expandable:last-child {
    border-bottom: none;
  }

  .ba-mm__link--sub {
    padding: 0 24px 0 40px;
    height: 48px;
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
  }

  .ba-mm__sub .ba-mm__sub .ba-mm__sublink {
    padding-left: 56px;
    font-size: 13px;
  }

  /* ── Footer-Links (dunkler Abschluss) ────────────────────────── */
  .ba-mm__footer {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    margin-top: 8px;
    background: #353A48;
    border-top: none;
  }

  .ba-mm__footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #fff !important;
    text-decoration: none;
  }

  .ba-mm__footer-link:hover,
  .ba-mm__footer-link:focus {
    color: #fff !important;
    text-decoration: none;
    background: #454B5A;
  }

  .ba-mm__footer-link svg {
    flex-shrink: 0;
    color: #fff;
    stroke: #fff;
  }

}

/* ===================================================================
   Mobile: Filter-Button + Layered Nav ausblenden (nur Kategorieseiten)
   + Subcategory Chips
   =================================================================== */

/* Hidden by default (desktop) */
.subcats-mobile {
    display: none;
}

@media (max-width: 991px) {
    .sidebar-main .block.block-category-list,
    .filter-options-item[attribute="cat"],
    .sidebar-main .filter-options-item[attribute="cat"],
    .layered-filter-block-container .filter-options-item[attribute="cat"] {
        display: none !important;
    }

    body.catalog-category-view .porto-product-filters-toggle.sidebar-toggle,
    body.catalog-category-view .toolbar-products a.filter-toggle {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        position: absolute !important;
        clip: rect(0, 0, 0, 0) !important;
    }

    body.catalog-category-view .sidebar-main #layered-filter-block,
    body.catalog-category-view #layered-filter-block,
    body.catalog-category-view .layered-filter-block-container .block.filter {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }
}

@media (max-width: 767px) {
    .subcats-mobile {
        display: block;
        margin: 0 0 15px 0;
        overflow: hidden;
    }

    .subcats-mobile__scroll {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0 12px 0;
        scrollbar-width: none;
    }

    .subcats-mobile__scroll::-webkit-scrollbar {
        display: none;
    }

    .subcats-mobile__chip {
        display: inline-flex;
        align-items: center;
        white-space: nowrap;
        padding: 6px 14px;
        border: 1px solid #ddd;
        border-radius: 999px;
        background: #fff;
        color: #333;
        font-size: 12px;
        font-weight: 500;
        text-decoration: none;
        flex-shrink: 0;
        transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    }

    .subcats-mobile__chip:hover,
    .subcats-mobile__chip:focus,
    .subcats-mobile__chip.active {
        background: #333;
        color: #fff;
        border-color: #333;
        text-decoration: none;
    }
}
