/* ============================================
   chips.css: .bl-chip (owner A1, see .claude/md files/redesign-spec.md section 3)

   Toggle:  <button type="button" class="bl-chip" aria-pressed="false">Pool</button>
   Link:    <a class="bl-chip" href="…" aria-current="page">Couples</a>
   Tile:    <button type="button" class="bl-chip bl-chip--tile" aria-pressed="false">
              <svg aria-hidden="true">…</svg><span>Chalet</span>
            </button>
   Input:   <label class="bl-chip"><input type="checkbox" class="visually-hidden" name="x" value="y">
              <span>Pool</span></label>   (radio works too; for form filters that submit without JS.
              Checked looks selected, keyboard focus on the input rings the chip; also with --tile)
   Row:     <div class="bl-chips">…chips…</div>  (wraps; add .bl-chips--scroll for one swipeable line)
            <div class="bl-chips bl-chips--tiles">…tiles…</div>  (responsive tile grid)

   Selected = aria-pressed="true", aria-current (links) or .is-active.
   ============================================ */

.bl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.bl-chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  /* Let the focus ring and shadows breathe inside the scroller. */
  padding: var(--space-1);
  margin: calc(var(--space-1) * -1);
}

.bl-chips--scroll::-webkit-scrollbar {
  display: none;
}

.bl-chips--scroll > .bl-chip {
  flex: none;
  scroll-snap-align: start;
}

.bl-chips--tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-2);
}

@media (min-width: 576px) {
  .bl-chips--tiles {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: var(--space-3);
  }
}

/* --- Chip --- */
.bl-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background-color: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    scale var(--press-duration) var(--press-ease);
}

.bl-chip:hover {
  color: var(--color-ink);
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .bl-chip:hover {
    border-color: var(--color-ink);
  }
}

.bl-chip:focus-visible,
.bl-chip:has(> input:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.bl-chip:active {
  scale: 0.97;
}

.bl-chip svg,
.bl-chip img {
  flex: none;
  width: 18px;
  height: 18px;
}

/* Round photo inside a chip ("Batroun" with a thumbnail). */
.bl-chip img {
  width: 28px;
  height: 28px;
  margin-left: calc(var(--space-2) * -1);
  border-radius: 50%;
  object-fit: cover;
}

.bl-chip[aria-pressed="true"],
.bl-chip[aria-current]:not([aria-current="false"]),
.bl-chip.is-active,
.bl-chip:has(> input:checked) {
  background-color: var(--green-50);
  border-color: var(--green-600);
  color: var(--green-800);
  font-weight: 600;
}

.bl-chip[aria-pressed="true"] svg,
.bl-chip.is-active svg {
  color: var(--green-700);
}

.bl-chip:disabled,
.bl-chip[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
  scale: none;
}

/* Small count bubble: <span class="bl-chip__count">3</span> */
.bl-chip__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background-color: var(--color-ink);
  color: var(--color-surface);
  font-size: 12px;
  font-weight: 600;
}

/* --- Tile: icon above label (property types, essentials) --- */
.bl-chip--tile {
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 88px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 14px;
  text-align: left;
  white-space: normal;
}

.bl-chip--tile svg,
.bl-chip--tile img {
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 0;
  color: var(--color-ink);
}

.bl-chip--tile[aria-pressed="true"],
.bl-chip--tile[aria-current]:not([aria-current="false"]),
.bl-chip--tile.is-active,
.bl-chip--tile:has(> input:checked) {
  /* 2px border; padding gives back the extra pixel so the content never moves. */
  border-width: 2px;
  padding: calc(var(--space-3) - 1px) calc(var(--space-4) - 1px);
}

@media (min-width: 576px) {
  .bl-chip--tile {
    min-height: 96px;
    padding: var(--space-4);
  }

  .bl-chip--tile[aria-pressed="true"],
  .bl-chip--tile[aria-current]:not([aria-current="false"]),
  .bl-chip--tile.is-active,
  .bl-chip--tile:has(> input:checked) {
    padding: calc(var(--space-4) - 1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bl-chip {
    transition:
      background-color var(--duration-fast) var(--ease-out),
      border-color var(--duration-fast) var(--ease-out),
      color var(--duration-fast) var(--ease-out);
  }

  .bl-chip:active {
    scale: none;
  }
}
