/* ==========================================================================
   Filter Products — premium modal for the Kaayko store.
   Scoped to .store-v2 so it inherits the page's light/dark design tokens
   (defined in storestyle.css). No global :root pollution.
   ========================================================================== */

/*-----------------------------------------------------------------------------
  Backdrop
-----------------------------------------------------------------------------*/
.store-v2 .filter-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(8, 8, 8, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 220ms ease;
}
.store-v2 .filter-overlay.active {
  display: flex;
  opacity: 1;
}

html.dark-theme .store-v2 .filter-overlay {
  background: rgba(0, 0, 0, 0.55);
}

/*-----------------------------------------------------------------------------
  Panel
-----------------------------------------------------------------------------*/
.store-v2 .filter-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  /* dvh, not vh: mobile browser chrome otherwise makes the panel taller than
     the visible viewport and pushes the actions off-screen. */
  max-height: min(82vh, 720px);
  max-height: min(82dvh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 24px 60px rgba(0, 0, 0, 0.35),
    0 4px 16px rgba(0, 0, 0, 0.18);
  /* The panel scrolls. It used to clip: with wrapped chips the content ran past
     max-height and the Apply button became unreachable on small screens. */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  font-family: 'Josefin Sans', 'Josefin_Light', Arial, sans-serif;
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 200ms ease;
}
.store-v2 .filter-overlay.active .filter-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/*-----------------------------------------------------------------------------
  Header
-----------------------------------------------------------------------------*/
.store-v2 .filter-panel h2 {
  flex: 0 0 auto;
  margin: 0;
  padding: 22px 24px 18px;
  font-family: 'Josefin_Bold', 'Josefin Sans', Arial, sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg);
  border-bottom: 1px solid var(--line);
}

/*-----------------------------------------------------------------------------
  Close button
-----------------------------------------------------------------------------*/
.store-v2 .filter-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Material Icons';
  font-size: 20px;
  line-height: 1;
  transition: background-color 160ms ease, color 160ms ease;
}
.store-v2 .filter-close:hover {
  background: var(--line);
  color: var(--fg);
}
.store-v2 .filter-close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/*-----------------------------------------------------------------------------
  Sections (scrollable)
-----------------------------------------------------------------------------*/
.store-v2 .filter-panel > .filter-section:first-of-type {
  padding-top: 22px;
}
.store-v2 .filter-section {
  flex: 0 0 auto;
  padding: 18px 24px;
  overflow-y: auto;
}
.store-v2 .filter-panel > .filter-section + .filter-section {
  border-top: 1px solid var(--line);
}

.store-v2 .filter-section strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Josefin_Bold', 'Josefin Sans', Arial, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.store-v2 .filter-section .filter-section-count {
  font-family: 'Josefin_Light', 'Josefin Sans', Arial, sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--muted);
}
.store-v2 .filter-section .filter-section-count[data-count="0"] {
  visibility: hidden;
}

/*-----------------------------------------------------------------------------
  Chips
-----------------------------------------------------------------------------*/
.store-v2 .chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.store-v2 .chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font-family: 'Josefin_Medium', 'Josefin Sans', Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.store-v2 .chip:hover {
  border-color: var(--muted);
  background: var(--line);
}
.store-v2 .chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.store-v2 .chip.selected {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--surface-2);
}
.store-v2 .chip.selected:hover {
  background: var(--fg);
  border-color: var(--fg);
}
.store-v2 .chip.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Empty-state message when no tags exist in catalog */
.store-v2 .filter-empty {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/*-----------------------------------------------------------------------------
  Note under the facets
-----------------------------------------------------------------------------*/
.store-v2 .filter-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px 24px 18px;
  font-family: 'Josefin_Light', 'Josefin Sans', Arial, sans-serif;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/*-----------------------------------------------------------------------------
  Footer actions (sticky bottom)
-----------------------------------------------------------------------------*/
.store-v2 .filter-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.store-v2 .filter-actions button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 22px;
  font-family: 'Josefin_Medium', 'Josefin Sans', Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.store-v2 .filter-actions #filter-reset {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}
.store-v2 .filter-actions #filter-reset:hover {
  color: var(--fg);
  background: var(--line);
}
.store-v2 .filter-actions #filter-apply {
  flex: 1 1 auto;
  background: var(--fg);
  border: 1px solid var(--fg);
  color: var(--surface-2);
}
.store-v2 .filter-actions #filter-apply:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  color: var(--surface-2);
}
.store-v2 .filter-actions button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/*-----------------------------------------------------------------------------
  Mobile bottom-sheet
-----------------------------------------------------------------------------*/
@media (max-width: 640px) {
  .store-v2 .filter-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .store-v2 .filter-panel {
    max-width: none;
    max-height: 86vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(20px);
  }
  .store-v2 .filter-overlay.active .filter-panel {
    transform: translateY(0);
  }
  .store-v2 .filter-panel h2 {
    padding: 24px 22px 16px;
    text-align: left;
  }
  .store-v2 .filter-panel h2::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
  }
  .store-v2 .filter-section { padding: 16px 22px; }
  .store-v2 .filter-actions { padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); }
}

/*-----------------------------------------------------------------------------
  Reduce motion
-----------------------------------------------------------------------------*/
@media (prefers-reduced-motion: reduce) {
  .store-v2 .filter-overlay,
  .store-v2 .filter-panel,
  .store-v2 .chip,
  .store-v2 .filter-actions button {
    transition: none;
  }
}

/* Actions stay reachable at the foot of the scroll, clear of the home indicator. */
.store-v2 .filter-panel > .filter-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

/* Inner sections must not create their own scrollers, or a drag started inside
   one never reaches the panel and the sheet feels stuck. */
.store-v2 .filter-panel > .filter-section { overflow: visible; }

/* Dark mode: unselected chips carry a gentle gold tint; selected stays solid. */
html.dark-theme .store-v2 .chip:not(.selected) {
  border-color: rgba(212, 182, 132, 0.34);
  color: var(--gold);
}
html.dark-theme .store-v2 .chip:not(.selected):hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}
html.dark-theme .store-v2 #filter-reset {
  border-color: rgba(212, 182, 132, 0.34);
  color: var(--gold);
}

