/*
 * Gupy redesign v2 — Home v2 filter bar (html/redesign/home/filter-bar.php,
 * behaviour in js/redesign/gupy-v2-refiner.js). Loaded after gupy-v2.css, which
 * already holds the mockup base rules (.gv2-filter-bar__row / __group / __pill /
 * __services-group / __filters-btn / __panel / __dropdown, from scss/_hero.scss).
 * This file adds the states the static mockup does not have (sticky, OK, badge,
 * panes, chips, ranges) and the responsive behaviour.
 *
 * Every rule is scoped under .gv2-filter-bar: nothing here reaches the legacy
 * refiner (#vrd_refiner_holder) or any v1 page.
 * Breakpoints (mockup): 480 / 768 / 1024 / 1600.
 */

/* --------------------------------------------------------------------------
   Shell + sticky
   -------------------------------------------------------------------------- */

.gv2-filter-bar {
  position: relative;
  z-index: 20;
  padding-block: 40px;
  box-sizing: border-box;
}

.gv2-filter-bar *,
.gv2-filter-bar *::before,
.gv2-filter-bar *::after {
  box-sizing: border-box;
}

.gv2-filter-bar__sticky {
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* position:fixed while scrolled past (JS sets top = real header bottom + side paddings). */
.gv2-filter-bar.is-stuck .gv2-filter-bar__sticky {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 998;
  padding-block: 10px;
  background: rgba(var(--gv2-bg-rgb), 0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gv2-border);
  box-shadow: var(--gv2-shadow);
}

.gv2-filter-bar.is-stuck .gv2-filter-bar__panel-inner {
  max-height: var(--gv2r-panel-max, 70vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.gv2-filter-bar.is-loading {
  pointer-events: none;
}

.gv2-filter-bar.is-loading .gv2-filter-bar__row {
  opacity: 0.6;
}

/* --------------------------------------------------------------------------
   Row
   -------------------------------------------------------------------------- */

.gv2-filter-bar__row {
  font-family: var(--gv2-font-body);
}

.gv2-filter-bar__group {
  min-width: 0;
}

.gv2-filter-bar__pill {
  line-height: 1.2;
}

.gv2-filter-bar__pill:not(.is-active):hover {
  color: var(--gv2-text);
}

.gv2-filter-bar__pill i {
  font-size: 12px;
}

/* Selected services: a button opening the Services pane. */
.gv2-filter-bar__services-group {
  appearance: none;
  cursor: pointer;
  font: inherit;
  color: var(--gv2-text-muted);
  min-width: 0;
  flex-shrink: 0;
  transition: border-color 0.2s ease;
}

.gv2-filter-bar__services-group:hover {
  border-color: var(--vrd-primary);
}

.gv2-filter-bar__services-group:focus-visible {
  outline: 2px solid var(--vrd-primary);
  outline-offset: 2px;
}

.gv2-filter-bar__services-group img,
.gv2-filter-bar__services-group .gv2-filter-bar__logo-fallback {
  flex-shrink: 0;
}

.gv2-filter-bar__services-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-inline: 5px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.gv2-filter-bar__logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--gv2-surface-alt);
  color: var(--gv2-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

/* OK: pending changes only, right before "Filtres". */
.gv2-filter-bar__ok {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--gv2-font-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  padding: 10px 20px;
  background: var(--vrd-primary);
  color: #fff;
  flex-shrink: 0;
  transition: background 0.2s ease;
  animation: gv2r-pop 0.2s ease;
}

.gv2-filter-bar__ok[hidden] {
  display: none;
}

.gv2-filter-bar__ok:hover {
  background: var(--vrd-primary-dark);
}

.gv2-filter-bar__ok:focus-visible {
  outline: 2px solid var(--gv2-text);
  outline-offset: 2px;
}

@keyframes gv2r-pop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.gv2-filter-bar__filters-btn {
  flex-shrink: 0;
}

.gv2-filter-bar__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding-inline: 5px;
  border-radius: 999px;
  background: var(--vrd-primary);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.gv2-filter-bar__badge[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Panel (collapsible box under the row)
   -------------------------------------------------------------------------- */

.gv2-filter-bar__panel {
  max-width: 100%;
  visibility: hidden;
  transition: grid-template-rows 0.25s ease, opacity 0.2s ease, visibility 0s linear 0.25s;
}

.gv2-filter-bar__panel.is-open {
  visibility: visible;
  transition: grid-template-rows 0.25s ease, opacity 0.2s ease, visibility 0s;
}

/* The filters box always takes the full row width (it used to be a box
   aligned right, 920px max once a pane was open). */
.gv2-filter-bar__panel,
.gv2-filter-bar.has-pane .gv2-filter-bar__panel {
  width: 100%;
  max-width: none;
  margin-left: 0;
}

.gv2-filter-bar__panel-inner {
  min-height: 0;
}

.gv2-filter-bar__dropdowns {
  align-items: center;
}

.gv2-filter-bar__dropdown {
  line-height: 1.2;
}

.gv2-filter-bar__dropdown:hover,
.gv2-filter-bar__dropdown.is-active {
  border-color: var(--vrd-primary);
}

.gv2-filter-bar__dropdown.has-value {
  border-color: rgba(219, 53, 117, 0.6);
}

.gv2-filter-bar__dropdown i {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.gv2-filter-bar__dropdown.is-active i {
  transform: rotate(180deg);
}

.gv2-filter-bar__dropdown-value:empty {
  display: none;
}

.gv2-filter-bar__dropdown-value {
  color: var(--vrd-primary);
  font-weight: 900;
}

.gv2-filter-bar__reset {
  appearance: none;
  cursor: pointer;
  font-family: var(--gv2-font-body);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--gv2-text-muted);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.gv2-filter-bar__reset:hover {
  color: var(--gv2-text);
  border-color: var(--gv2-border);
}

.gv2-filter-bar__reset:focus-visible,
.gv2-filter-bar__dropdown:focus-visible,
.gv2-filter-bar__chip:focus-visible,
.gv2-filter-bar__logo:focus-visible,
.gv2-filter-bar__link:focus-visible {
  outline: 2px solid var(--vrd-primary);
  outline-offset: 2px;
}

/* Panes */
.gv2-filter-bar__pane {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(109, 79, 163, 0.5);
}

.gv2-filter-bar__pane[hidden] {
  display: none;
}

.gv2-filter-bar__pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.gv2-filter-bar__pane-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.gv2-filter-bar__search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 220px;
  max-width: 320px;
  margin: 0;
}

.gv2-filter-bar__search i {
  position: absolute;
  left: 12px;
  color: var(--gv2-text-muted);
  font-size: 13px;
  pointer-events: none;
}

.gv2-filter-bar .gv2-filter-bar__search input[type=search] {
  width: 100%;
  height: 38px;
  margin: 0;
  padding: 0 12px 0 34px;
  border: 1px solid var(--gv2-border);
  border-radius: 5px;
  background: var(--gv2-surface);
  color: var(--gv2-text);
  font: 13px var(--gv2-font-body);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.gv2-filter-bar .gv2-filter-bar__search input[type=search]:focus {
  outline: none;
  border-color: var(--vrd-primary);
}

.gv2-filter-bar__link {
  appearance: none;
  border: none;
  background: none;
  padding: 5px;
  cursor: pointer;
  color: var(--gv2-text-muted);
  font: 700 13px var(--gv2-font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.gv2-filter-bar__link:hover {
  color: var(--gv2-text);
}

/* Provider logos grid */
.gv2-filter-bar__logos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding: 3px;
  scrollbar-width: thin;
}

.gv2-filter-bar__logo {
  position: relative;
  appearance: none;
  border: 2px solid transparent;
  border-radius: 7px;
  padding: 0;
  background: var(--gv2-surface);
  cursor: pointer;
  aspect-ratio: 1;
  overflow: hidden;
  opacity: 0.55;
  transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.gv2-filter-bar__logo[hidden] {
  display: none;
}

.gv2-filter-bar__logo:hover {
  opacity: 1;
}

.gv2-filter-bar__logo.is-active {
  opacity: 1;
  border-color: var(--vrd-primary);
}

.gv2-filter-bar__logo img,
.gv2-filter-bar__logo .gv2-filter-bar__logo-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
}

.gv2-filter-bar__logo-check {
  position: absolute;
  top: 3px;
  right: 3px;
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--vrd-primary);
  color: #fff;
  font-size: 9px;
  line-height: 16px;
  text-align: center;
}

.gv2-filter-bar__logo.is-active .gv2-filter-bar__logo-check {
  display: block;
}

.gv2-filter-bar__empty {
  margin: 10px 0 0;
  color: var(--gv2-text-muted);
  font-size: 13px;
}

.gv2-filter-bar__empty[hidden] {
  display: none;
}

/* Chips (genres, offers, "My services") */
.gv2-filter-bar__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gv2-filter-bar__chip {
  appearance: none;
  cursor: pointer;
  font-family: var(--gv2-font-body);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  padding: 8px 14px;
  background: var(--gv2-surface);
  border: 1px solid var(--gv2-border);
  color: var(--gv2-text-muted);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.gv2-filter-bar__chip:hover {
  color: var(--gv2-text);
  border-color: var(--vrd-primary);
}

.gv2-filter-bar__chip.is-active {
  background: var(--vrd-primary);
  border-color: var(--vrd-primary);
  color: #fff;
}

/* Dual range (two native range inputs over one track) */
.gv2-filter-bar__range {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 640px;
}

.gv2-filter-bar__range-val {
  min-width: 42px;
  color: var(--gv2-text);
  font: 700 15px var(--gv2-font-body);
  text-align: center;
}

.gv2-filter-bar__range-track {
  --gv2r-from: 0%;
  --gv2r-to: 100%;
  position: relative;
  flex: 1;
  height: 28px;
}

.gv2-filter-bar__range-track::before,
.gv2-filter-bar__range-track::after {
  content: "";
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
}

.gv2-filter-bar__range-track::before {
  left: 0;
  right: 0;
  background: var(--gv2-border);
}

.gv2-filter-bar__range-track::after {
  left: var(--gv2r-from);
  right: calc(100% - var(--gv2r-to));
  background: var(--vrd-primary);
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]:focus {
  outline: none;
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]::-webkit-slider-runnable-track {
  background: transparent;
  border: 0;
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]::-moz-range-track {
  background: transparent;
  border: 0;
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]::-webkit-slider-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--vrd-primary);
  cursor: grab;
  -webkit-appearance: none;
  appearance: none;
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--vrd-primary);
  cursor: grab;
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(219, 53, 117, 0.45);
}

.gv2-filter-bar .gv2-filter-bar__range-track input[type=range]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(219, 53, 117, 0.45);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Laptop */
@media (max-width: 1024px) {
  .gv2-filter-bar {
    padding-block: 20px;
  }

  .gv2-filter-bar__row {
    gap: 10px;
  }

  .gv2-filter-bar__pill,
  .gv2-filter-bar__filters-btn,
  .gv2-filter-bar__ok,
  .gv2-filter-bar__dropdown,
  .gv2-filter-bar__reset {
    padding: 10px 14px;
  }
}

/* Tablet and below: one line; pills + services scroll horizontally, Filtres/OK stay put. */
@media (max-width: 768px) {
  .gv2-filter-bar__row {
    flex-wrap: nowrap;
  }

  .gv2-filter-bar__group {
    flex: 0 1 auto;
  }

  .gv2-filter-bar__services-group {
    flex: 0 1 auto;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .gv2-filter-bar__services-group::-webkit-scrollbar {
    display: none;
  }

  .gv2-filter-bar__spacer {
    flex: 1 0 0;
    min-width: 0;
  }

  .gv2-filter-bar__panel,
  .gv2-filter-bar.has-pane .gv2-filter-bar__panel {
    width: 100%;
    max-width: none;
    margin-left: 0;
  }

  .gv2-filter-bar__panel-box {
    padding: 10px;
  }

  /* Pane tabs + reset: one scrollable line. */
  .gv2-filter-bar__dropdowns {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin: -3px;
    padding: 3px;
  }

  .gv2-filter-bar__dropdowns::-webkit-scrollbar {
    display: none;
  }

  .gv2-filter-bar__dropdown,
  .gv2-filter-bar__reset {
    flex-shrink: 0;
  }

  .gv2-filter-bar__reset {
    margin-left: auto;
  }

  .gv2-filter-bar__pane {
    margin-top: 10px;
    padding-top: 10px;
  }

  .gv2-filter-bar__pane-head {
    margin-bottom: 10px;
  }

  .gv2-filter-bar__search {
    max-width: none;
  }

  .gv2-filter-bar__logos {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    max-height: 45vh;
  }

  .gv2-filter-bar__range {
    gap: 10px;
    flex-wrap: wrap;
  }

  .gv2-filter-bar__range-track {
    flex: 1 1 160px;
  }
}

/* Mobile: compact buttons, icon-only "Filtres" (badge still visible). */
@media (max-width: 480px) {
  .gv2-filter-bar {
    padding-block: 10px;
  }

  .gv2-filter-bar__row {
    gap: 5px;
  }

  .gv2-filter-bar__group {
    padding: 3px;
  }

  .gv2-filter-bar__pill {
    padding: 8px 10px;
    font-size: 12px;
  }

  .gv2-filter-bar__services-group {
    padding: 3px 5px;
  }

  .gv2-filter-bar__services-group img,
  .gv2-filter-bar__services-group .gv2-filter-bar__logo-fallback {
    width: 24px;
    height: 24px;
  }

  .gv2-filter-bar__services-all {
    font-size: 12px;
  }

  .gv2-filter-bar__filters-btn,
  .gv2-filter-bar__ok {
    padding: 8px 10px;
  }

  .gv2-filter-bar__filters-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .gv2-filter-bar__chip {
    padding: 6px 10px;
    font-size: 12px;
  }

  .gv2-filter-bar.is-stuck .gv2-filter-bar__sticky {
    padding-block: 5px;
  }
}

/* ---- Counters: "+X" after 4 logos (wide) / as the 4th cell of the grid (small) ---- */
.gv2-filter-bar__services-more--grid {
  display: none;
}

/* ---- Filters panel: its content wraps (tabs + reset, chips) instead of scrolling ---- */
.gv2-filter-bar__dropdowns {
  flex-wrap: wrap;
  overflow: visible;
}
.gv2-filter-bar__dropdown,
.gv2-filter-bar__reset {
  flex-shrink: 1;
  min-width: 0;
}
.gv2-filter-bar__pane-head,
.gv2-filter-bar__pane-actions,
.gv2-filter-bar__chips {
  flex-wrap: wrap;
}

/* ---- Small screens: the row must hold on one line without squashing ------------- */
@media (max-width: 560px) {
  /* Tous / Films / Séries: labels only. */
  .gv2-filter-bar__pill i {
    display: none;
  }
  .gv2-filter-bar__pill {
    padding: 8px 10px;
  }

  /* Selected services: a square 2x2 grid — 3 logos + "+X" as the 4th cell. */
  .gv2-filter-bar__services-group.has-logos,
  .gv2-filter-bar__services-group:has(> img),
  .gv2-filter-bar__services-group:has(> .gv2-filter-bar__logo-fallback) {
    display: grid;
    grid-template-columns: repeat(2, 16px);
    grid-auto-rows: 16px;
    gap: 2px;
    padding: 4px;
    flex: 0 0 auto;
    overflow: visible;
  }
  .gv2-filter-bar__services-group img,
  .gv2-filter-bar__services-group .gv2-filter-bar__logo-fallback {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    font-size: 7px;
  }
  .gv2-filter-bar__services-group .is-4th,
  .gv2-filter-bar__services-more--wide {
    display: none;
  }
  .gv2-filter-bar__services-more--grid {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    border-radius: 3px;
    background: rgba(var(--gv2-fg-rgb), 0.12);
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
  }

  /* No service selected: the icon alone. */
  .gv2-filter-bar__services-all-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .gv2-filter-bar__services-group {
    flex: 0 0 auto;
  }
}
