/* Listing page header row (title + count + filter toggle + search pill) and
   the chip-based filter system: chips, chip-group, more-filters expander.
   The filter form itself is always present; layout.css controls where it sits
   (sidebar on desktop, dropdown sheet on mobile). */

/* Compact page header — keeps title + count + search inline above the carousel. */
.page-header { display: flex; align-items: baseline; gap: 0.85rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.page-header h1 { font-size: 1.25rem; }
.page-header .count { font-size: 0.85rem; color: var(--muted); }

/* Filter toggle button — visible only on mobile, same height as the search pill. */
.filter-toggle {
  display: none;
  align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.filter-toggle:hover { background: #fff; }
.filter-toggle:active { transform: scale(0.97); }
.filter-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-toggle svg { width: 16px; height: 16px; }

/* Sort dropdown — same pill shape as the filter-toggle so it sits
   naturally alongside the Grid / Filters buttons in the page header.
   The native <select> keeps mobile-friendly behaviour for free. */
.sort-control {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem 0.3rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.sort-control:hover { background: #fff; }
.sort-control svg { width: 14px; height: 14px; color: var(--muted); }
.sort-control select {
  border: 0; background: transparent;
  font: inherit; font-size: 0.85rem; color: var(--fg);
  padding: 0.1rem 0.2rem;
  cursor: pointer;
}
.sort-control select:focus { outline: none; }

/* Desktop view switch (Grid / Carousel) — a segmented pill that sits to the
   left of the search bar in the page header. margin-left:auto pushes it (and
   the search pill that follows) to the right edge. Mobile uses the single-icon
   .view-toggle instead, so this is hidden ≤980px. */
.view-seg {
  margin-left: auto;
  display: inline-flex; align-items: center;
  padding: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.view-seg input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.view-seg-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem; font-weight: 600;
  color: var(--muted);
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.view-seg-btn svg { width: 14px; height: 14px; }
.view-seg-btn:hover { color: var(--fg); }
.view-seg input:checked + .view-seg-btn { background: var(--accent); color: #fff; }
.view-seg input:focus-visible + .view-seg-btn { box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.25); }

/* Pill-shaped search input with inline magnifier icon + optional clear (×). */
.page-search-wrap {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 0.45rem;
  flex: 0 1 300px;
  padding: 0.4rem 0.85rem 0.4rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  min-width: 0;
}
.page-search-wrap:hover { background: #fff; }
.page-search-wrap:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.14);
}
.page-search-wrap .search-icon { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.page-search-wrap:focus-within .search-icon { color: var(--accent); }
.page-search {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font: inherit; font-size: 0.9rem;
  color: var(--fg);
  padding: 0;
}
.page-search::placeholder { color: var(--muted); }
.page-search::-webkit-search-cancel-button { display: none; }   /* using our own × */
.search-clear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 0.95rem; line-height: 1;
  background: #e5e1d5; color: var(--muted);
  text-decoration: none;
}
.search-clear:hover { background: var(--bad); color: #fff; text-decoration: none; }

/* Mobile: collapse to just the magnifier icon. Tap to expand into a full-width
   search bar with autofocus. */
@media (max-width: 680px) {
  .page-search-wrap { flex: 0 0 auto; padding: 0.5rem; background: var(--card); }
  .page-search-wrap .page-search,
  .page-search-wrap .search-clear { display: none; }
  .page-search-wrap.expanded { flex: 1 1 100%; padding: 0.4rem 0.85rem 0.4rem 0.75rem; }
  .page-search-wrap.expanded .page-search,
  .page-search-wrap.expanded .search-clear { display: inline-flex; }
}

/* The filter form container itself. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.65rem 1.1rem;
  margin: 1rem 0 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.filters select, .filters input[type=text] {
  padding: 0.4rem 0.55rem; border: 1px solid var(--line); border-radius: 5px; font-size: 0.9rem;
}

/* Chip system — radio/checkbox inputs hidden, labels become pills. */
.chip-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  flex: 0 0 auto;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.chip-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.chip-group input[type=radio],
.chip-group input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem; font-weight: 600;
  color: #4a4538;
  background: #f0eadd;       /* warm tan, no border — softer than white pills */
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer; user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
  white-space: nowrap;
  line-height: 1;
}
.chip:hover { background: #e6dfce; color: var(--fg); }
.chip:active { transform: scale(0.96); }
.chip svg { width: 13px; height: 13px; flex-shrink: 0; }
.chip-group input:checked + .chip {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.chip-group input:focus-visible + .chip { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.disabled { opacity: 0.4; cursor: not-allowed; }
.chip.disabled:hover { border-color: var(--line); }

/* Icon-only chips (square, no text). Currently unused since all chips have text. */
.chip.chip-icon {
  width: 32px; height: 32px;
  padding: 0; justify-content: center;
  border-radius: 50%;
}
.chip.chip-icon svg { width: 16px; height: 16px; }

.chip-link { font-size: 0.8rem; color: var(--muted); text-decoration: underline; }
.chip-link:hover { color: var(--accent); }
.reset-all { align-self: center; padding: 0.2rem 0.5rem; }

/* "More filters" expander wraps the secondary filter groups so the default
   view stays uncluttered. Auto-opens when any contained filter is active. */
.more-filters { width: 100%; }
.more-filters summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
  list-style: none;
  user-select: none;
}
.more-filters summary::-webkit-details-marker { display: none; }
.more-filters summary::before { content: "+ "; }
.more-filters[open] summary::before { content: "− "; }
.more-filters summary:hover { background: #f0eadd; }
.more-grid {
  display: flex; flex-wrap: wrap; gap: 0.65rem 1.1rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}
.breed-row input[type=text] { flex: 1; min-width: 160px; max-width: 240px; padding: 0.35rem 0.5rem; }
.actions { margin-top: 0.2rem; }

@media (max-width: 680px) {
  .filters { gap: 0.5rem 0.85rem; padding: 0.7rem 0.85rem; }
  .chip-label { font-size: 0.62rem; }
  .chip { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
  .chip.chip-icon { width: 32px; height: 32px; }
  .chip.chip-icon svg { width: 14px; height: 14px; }
}
