/* ARRØ shop — collection filters as a right-hand "Filter and sort" drawer on mobile/tablet (<= 849px).
 * Desktop keeps the sidebar. Markup: inc/arro-shop-view.php. Behaviour: js/arro-shop-drawer.js.
 * Layout: centred title + result count, one row per filter (tap = opens that filter's options with a back arrow),
 * Sort by select, footer with "Remove all" + black "Apply". Filters still apply live behind the overlay. */

/* hidden on desktop */
.arro-filters-backdrop,
.arro-drawer-close,
.arro-drawer-title,
.arro-drawer-sort,
.arro-drawer-foot {
  display: none;
}

@media (max-width: 849px) {
  html.arro-drawer-open,
  html.arro-drawer-open body {
    overflow: hidden;
  }

  /* sort lives in the drawer on mobile (collection pages with a filter panel) */
  .arro-shop__wrap:has(aside#arro-filters) .arro-toolbar__right {
    display: none;
  }

  .arro-filters-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
    z-index: 100000;
  }

  html.arro-drawer-open .arro-filters-backdrop {
    opacity: 1;
    visibility: visible;
  }

  /* panel */
  html body .arro-filters {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(400px, 84vw);
    margin: 0;
    padding: 0;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .3s ease, visibility .3s ease;
    z-index: 100001;
  }

  html body .arro-filters.is-open {
    display: flex; /* beats arro-shop.css `.arro-filters.is-open { display: block }` */
    transform: translateX(0);
    visibility: visible;
  }

  /* header */
  html body .arro-filters .arro-filters__head {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-height: 72px;
    padding: 14px 56px;
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    flex: 0 0 auto;
  }

  html body .arro-filters .arro-filters__head > svg,
  html body .arro-filters .arro-filters__head > h2 {
    display: none;
  }

  html body .arro-filters .arro-drawer-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  html body .arro-filters .arro-drawer-title strong {
    font-family: var(--font-text-bold, "text_bold", sans-serif);
    font-size: 17px;
    line-height: 24px;
    font-weight: 700;
    color: #000;
  }

  html body .arro-filters .arro-drawer-title span {
    font-family: var(--font-text-medium, "text_medium", sans-serif);
    font-size: 14px;
    line-height: 20px;
    color: #555;
  }

  html body .arro-filters .arro-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 16px;
    right: 14px;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #00a1e9;
    cursor: pointer;
    min-height: 0;
    line-height: 1;
  }

  /* scrolling area (filter rows + sort) — a facet's options open as a panel over it */
  html body .arro-filters .arro-drawer-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  html body .arro-filters .arro-drawer-body:has(.arro-facet[open]) {
    overflow: hidden;
  }

  html body .arro-filters .arro-active {
    padding: 16px 24px 0;
  }

  /* one row per filter */
  html body .arro-filters .arro-facet {
    padding: 0;
    border: 0;
  }

  html body .arro-filters .arro-facet > summary {
    box-sizing: border-box;
    height: 56px;
    padding: 0 24px;
    font-family: var(--font-text-medium, "text_medium", sans-serif);
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    color: #121212;
  }

  html body .arro-filters .arro-facet > summary .arro-facet__icon {
    display: none;
  }

  html body .arro-filters .arro-facet > summary::after {
    content: "";
    flex: 0 0 auto;
    width: 16px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12' fill='none' stroke='%23121212' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 6h13M9.5 1.5L14 6l-4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  /* opened filter = sub-panel: header with back arrow + its options */
  html body .arro-filters .arro-facet[open] > summary {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    justify-content: flex-start;
    gap: 14px;
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    font-family: var(--font-text-bold, "text_bold", sans-serif);
    font-weight: 700;
    color: #000;
  }

  html body .arro-filters .arro-facet[open] > summary::before {
    content: "";
    flex: 0 0 auto;
    width: 16px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12' fill='none' stroke='%23121212' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 6H2M6.5 1.5L2 6l4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  html body .arro-filters .arro-facet[open] > summary::after {
    display: none;
  }

  html body .arro-filters .arro-facet[open] > .arro-facet__body {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 8px 24px 24px;
    background: #fff;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* sort by */
  html body .arro-filters .arro-drawer-sort {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 24px 28px;
  }

  html body .arro-filters .arro-drawer-sort label {
    margin: 0;
    font-family: var(--font-text-bold, "text_bold", sans-serif);
    font-size: 15px;
    line-height: 22px;
    font-weight: 700;
    color: #121212;
    white-space: nowrap;
  }

  html body .arro-filters .arro-drawer-sort__select {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    margin: 0;
    padding: 0 12px;
    border: 0;
    border-radius: 0;
    background-color: #f5f5f5;
    font-family: var(--font-text-medium, "text_medium", sans-serif);
    font-size: 14px;
    color: #121212;
    box-shadow: none;
  }

  /* footer */
  html body .arro-filters .arro-drawer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex: 0 0 auto;
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #e6e6e6;
  }

  html body .arro-filters .arro-drawer-foot .arro-drawer-clear {
    flex: 0 0 auto;
    margin: 0;
    font-family: var(--font-text-bold, "text_bold", sans-serif);
    font-size: 15px;
    line-height: 22px;
    font-weight: 700;
    text-decoration: underline;
    color: #000;
    white-space: nowrap;
  }

  html body .arro-filters .arro-drawer-apply {
    flex: 1 1 auto;
    height: 52px;
    margin: 0;
    padding: 0 20px;
    border: 0;
    border-radius: 40px;
    background: #000;
    color: #fff;
    cursor: pointer;
    font-family: var(--font-text-bold, "text_bold", sans-serif);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: none;
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .arro-filters,
  .arro-filters-backdrop {
    transition: none;
  }
}
