/* Mobile shop controls enhance the existing category shortcode; desktop stays native. */
.smd-shop-dock,
.smd-shop-sheet,
.smd-shop-heading {
  --smd-shop-cream: var(--awb-color1, #fffdf9);
  --smd-shop-coral: var(--awb-color4, #f75a45);
  --smd-shop-red: var(--awb-color5, #f2354b);
  --smd-shop-green: var(--awb-custom_color_1, #0f3d32);
  --smd-shop-line: var(--awb-color3, #ede6df);
  font-family: var(--awb-typography4-font-family, "Montserrat", Arial, sans-serif);
}

.smd-shop-dock,
.smd-shop-heading,
.smd-shop-branch-toggle,
.smd-shop-sheet:not([open]),
.smd-shop-sheet [hidden],
.smd-shop-dock[hidden] {
  display: none;
}

@media (max-width: 800px) {
  /* Head-loaded styles + opt-in bootstrap prevent the old list flashing.
     Without JavaScript (or if initialization fails), the native list stays usable. */
  html.smd-shop-preparing .woocommerce.archive .smd-product-categories { display: none; }
  body.smd-shop-mobile { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
  body.smd-shop-sheet-open { overflow: hidden; }
  body.smd-mobile-menu-open .smd-shop-dock { visibility: hidden; }
  body.smd-shop-mobile #toTop { bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }

  .smd-shop-section { padding: 24px 16px 40px !important; }
  .smd-shop-layout-row { width: 100% !important; max-width: 100% !important; margin: 0 !important; }
  .smd-shop-sidebar-column,
  .smd-shop-products-column {
    width: 100% !important;
    margin: 0 !important;
    flex: 0 0 100% !important;
    position: static !important;
    top: auto !important;
  }
  .smd-shop-sidebar-column > .fusion-column-wrapper,
  .smd-shop-products-column > .fusion-column-wrapper { margin: 0 !important; padding: 0 !important; }
  .smd-shop-sidebar-column .fusion-search-element { margin-bottom: 16px !important; }
  .smd-shop-sidebar-column:has(.fusion-column-wrapper:empty) { display: none; }
  .smd-shop-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
  .smd-shop-heading__label { margin: 0; color: var(--smd-shop-green); font-size: 18px; font-weight: 700; line-height: 1.35; }
  .smd-shop-heading__count { flex-shrink: 0; color: var(--awb-color6, #6b6b6b); font-size: 11px; }

  .smd-shop-dock {
    position: fixed;
    z-index: 9990;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    box-sizing: border-box;
    gap: 6px;
    width: min(440px, calc(100% - 24px));
    padding: 6px;
    border: 2px solid color-mix(in srgb, var(--smd-shop-green) 18%, var(--smd-shop-cream));
    border-radius: 22px;
    background: var(--smd-shop-cream);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(15, 61, 50, 0.24), 0 -3px 14px rgba(15, 61, 50, 0.1);
  }
  .smd-shop-dock__button {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--smd-shop-green);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
  }
  .smd-shop-dock__button--categories { background: var(--smd-shop-green); color: var(--smd-shop-cream); }
  .smd-shop-dock__button--categories:hover { background: color-mix(in srgb, var(--smd-shop-green) 90%, #000); }
  .smd-shop-dock__button--sorting { flex: 0 0 66px; flex-direction: column; gap: 3px; border: 1px solid var(--smd-shop-line); font-size: 12px; }
  .smd-shop-dock svg,
  .smd-shop-sheet svg { width: 21px; height: 21px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

  .smd-shop-sheet {
    position: fixed;
    inset: auto 0 0;
    width: min(100%, 540px);
    max-width: 100%;
    max-height: min(84dvh, 780px);
    margin: 0 auto;
    padding: 0 0 env(safe-area-inset-bottom, 0px);
    overflow: hidden;
    border: 1px solid var(--smd-shop-line);
    border-bottom: 0;
    border-radius: 28px 28px 0 0;
    background: var(--smd-shop-cream);
    color: var(--smd-shop-green);
    box-shadow: 0 -12px 50px rgba(15, 61, 50, 0.15);
  }
  .smd-shop-sheet[open] { display: flex; flex-direction: column; animation: smd-shop-sheet-in 240ms cubic-bezier(.22,1,.36,1); }
  .smd-shop-sheet::backdrop { background: rgba(9, 29, 24, 0.48); backdrop-filter: blur(3px); }
  .smd-shop-sheet__header { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-shrink: 0; padding: 22px 20px 18px; border-bottom: 1px solid var(--smd-shop-line); }
  .smd-shop-sheet__eyebrow { margin: 0 0 4px; color: var(--smd-shop-coral); font-size: 10px; font-weight: 700; letter-spacing: .09em; }
  .smd-shop-sheet .smd-shop-sheet__title { margin: 0; color: var(--smd-shop-green); font: inherit; font-size: 20px; font-weight: 700; line-height: 1.3; text-transform: none; }
  .smd-shop-sheet__close {
    display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px;
    padding: 0; border: 0; border-radius: 50%; color: var(--smd-shop-cream);
    background: linear-gradient(125deg, var(--smd-shop-coral), var(--smd-shop-red) 65%);
    cursor: pointer;
  }
  .smd-shop-sheet__body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 10px 16px 20px; scrollbar-width: thin; }
  .smd-shop-sheet__all { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 8px 16px; color: var(--smd-shop-green); font-size: 13px; font-weight: 700; }
  .smd-shop-sheet__all svg { color: var(--smd-shop-coral); }
  .smd-shop-sheet .smd-product-categories { padding: 0; border: 0; background: transparent; box-shadow: none; }
  .smd-shop-sheet .smd-product-categories__title { display: none; }
  .smd-shop-sheet .smd-product-categories__list { max-height: none; overflow: visible; padding: 0 !important; gap: 10px; }
  .smd-shop-sheet .smd-product-categories__item--master,
  .smd-shop-sheet .smd-product-categories__group--standalone { position: relative; border: 1px solid var(--smd-shop-line); border-radius: 16px; background: transparent; box-shadow: none; }
  .smd-shop-sheet .smd-product-categories__item--master > .smd-product-categories__link {
    min-height: 56px; padding: 14px 58px 14px 14px; border: 0;
    background: transparent; color: var(--smd-shop-green); box-shadow: none;
    font-size: 14px; font-weight: 700; transform: none;
  }
  .smd-shop-sheet .smd-product-categories__item--master > .smd-product-categories__link::after { display: none; }
  .smd-shop-sheet .smd-product-categories__children { padding: 2px 8px 8px; }
  .smd-shop-sheet .smd-product-categories__children[hidden] { display: none !important; }
  .smd-shop-sheet .smd-product-categories__link { min-height: 44px; font-size: 13px; transform: none; }
  .smd-shop-sheet .smd-product-categories__item.is-active > .smd-product-categories__link { color: var(--smd-shop-green); background: color-mix(in srgb, var(--smd-shop-coral) 10%, var(--smd-shop-cream)); box-shadow: none; }
  .smd-shop-sheet .smd-shop-branch-toggle {
    position: absolute; top: 6px; right: 6px; display: grid; place-items: center;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
    background: color-mix(in srgb, var(--smd-shop-green) 5%, var(--smd-shop-cream)); color: var(--smd-shop-green); cursor: pointer;
  }
  .smd-shop-branch-toggle svg { transition: transform 180ms ease; }
  .smd-shop-branch-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .smd-shop-sort-link { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; padding: 14px 10px; border-bottom: 1px solid var(--smd-shop-line); color: var(--smd-shop-green); font-size: 14px; line-height: 1.4; }
  .smd-shop-sort-check { flex: 0 0 20px; height: 20px; border: 1px solid var(--smd-shop-line); border-radius: 50%; }
  .smd-shop-sort-link[aria-current] { font-weight: 700; }
  .smd-shop-sort-link[aria-current] .smd-shop-sort-check { border-color: var(--smd-shop-red); background: var(--smd-shop-red); box-shadow: inset 0 0 0 5px var(--smd-shop-cream); }
  .smd-shop-dock button:focus-visible,
  .smd-shop-sheet button:focus-visible,
  .smd-shop-sheet a:focus-visible { outline: 2px solid var(--smd-shop-coral); outline-offset: 2px; }
}

@keyframes smd-shop-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .smd-shop-sheet[open] { animation: none; }
  .smd-shop-branch-toggle svg { transition: none; }
}
