/* ============================================================================
   WrightHaven Homes — Pasture Edge "Collection" grid
   ----------------------------------------------------------------------------
   Styles for the filterable model grid rendered by assets/wh-collection.js
   into <div data-wh-collection> on the Pasture Edge community page.

   Sits on the site's dark #141414 background. Uses the sitewide tokens
   (--wh-*) and the established dark-card treatment shared with
   wh-homes-street.css / wh-siteplan.css:
     card bg #1d1e1e, hover #232424, hairlines rgba(192,181,155,0.18–0.32)

   Layout: 232px filter sidebar (count, Sort By, filter checkboxes) + 2-up
   card grid on desktop; slide-in filter drawer + single-column grid on
   mobile, opened via a small meta row (count + Filters toggle) above the
   grid — no more full-width white toolbar.
   ========================================================================== */

.wh-collection {
  --wh-col-line: rgba(192, 181, 155, 0.32);
  --wh-col-line-soft: rgba(192, 181, 155, 0.18);
  --wh-col-card-bg: #1d1e1e;
  --wh-col-card-bg-hover: #232424;
  --wh-col-text: rgba(255, 255, 255, 0.92);
  --wh-col-text-dim: rgba(255, 255, 255, 0.6);
  --wh-col-ease: cubic-bezier(0.22, 0.72, 0.22, 1);

  position: relative;
  width: 100%;        /* Elementor flex columns otherwise shrink-wrap it */
  box-sizing: border-box;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px 96px;
  font-family: var(--wh-font-body, "Poppins", sans-serif);
  color: var(--wh-col-text);
}

/* ---------------------------------------------------------------------------
   1. Meta row — mobile-only: live count + Filters toggle. No more white
      toolbar bar; sort chips now live inside the filter sidebar (below).
   ------------------------------------------------------------------------- */
.wh-collection__meta {
  /* "Sticky" is emulated in JS (wh-collection.js toggles .is-pinned):
     the Elementor pages' overflow-x:hidden html/body breaks real
     position:sticky at page level. */
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 0 0 20px;
  padding: 0;
}

/* JS-emulated sticky state for the meta row (see wh-collection.js) */
.wh-collection__meta.is-pinned {
  position: fixed;
  top: var(--wh-ribbon-h, 46px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 12px max(24px, calc((100vw - 1112px) / 2));
  background: rgba(20, 20, 20, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--wh-col-line-soft);
}

.wh-collection__count,
.wh-collection__sidebar-count {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wh-col-text-dim);
}

.wh-collection__meta .wh-collection__count {
  margin-right: auto;
}

.wh-collection__sidebar-count {
  margin: 0 0 18px;
  font-size: 12px;
}

.wh-collection__count strong,
.wh-collection__sidebar-count strong {
  color: var(--wh-gold, #9a8c57);
  font-weight: 600;
}

.wh-collection__sorts {
  display: flex;
  gap: 8px;
}

.wh-collection .wh-collection__sort,
.wh-collection .wh-collection__filters-toggle {
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--wh-col-line);
  border-radius: 999px;
  background: transparent;
  color: var(--wh-col-text-dim);
  font-family: var(--wh-font-body, "Poppins", sans-serif);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.wh-collection .wh-collection__sort:hover,
.wh-collection .wh-collection__filters-toggle:hover {
  color: var(--wh-col-text);
  border-color: var(--wh-gold, #9a8c57);
}

.wh-collection .wh-collection__sort.is-active {
  color: var(--wh-ink, #141414);
  background: var(--wh-gold, #9a8c57);
  border-color: var(--wh-gold, #9a8c57);
  font-weight: 600;
}

.wh-collection .wh-collection__sort:focus-visible,
.wh-collection .wh-collection__filters-toggle:focus-visible {
  outline: 2px solid var(--wh-gold, #9a8c57);
  outline-offset: 2px;
}

/* Filters toggle only exists visually on mobile */
.wh-collection .wh-collection__filters-toggle {
  display: none;
}

/* Sort group sits first in the sidebar, above the checkbox filter groups */
.wh-collection__group--sort {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.wh-collection__group--sort .wh-collection__group-label {
  display: block;
}

.wh-collection__filters-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--wh-gold, #9a8c57);
  color: var(--wh-ink, #141414);
  font-size: 11px;
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   2. Layout: sidebar + grid
   ------------------------------------------------------------------------- */
.wh-collection__layout {
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

.wh-collection__filters {
  flex: 0 0 232px;
  padding: 20px;
  background: var(--wh-col-card-bg);
  border: 1px solid var(--wh-col-line-soft);
  border-radius: var(--wh-radius, 3px);
}

.wh-collection__filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.wh-collection__filters-title {
  margin: 0;
  font-family: var(--wh-font-heading, "Lato", sans-serif);
  font-weight: 300;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wh-col-text);
}

.wh-collection .wh-collection__filters-close {
  display: none;
  appearance: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--wh-col-text-dim);
  font-size: 26px;
  line-height: 1;
  padding: 4px 8px;
}

.wh-collection__group {
  margin: 18px 0 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 1px solid var(--wh-col-line-soft);
}

.wh-collection__group-label {
  padding: 0;
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wh-gold, #9a8c57);
}

.wh-collection__check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--wh-col-text-dim);
  transition: color 0.15s;
}

.wh-collection__check:hover {
  color: var(--wh-col-text);
}

.wh-collection__check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wh-collection__check-box {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 1px solid var(--wh-col-line);
  border-radius: 2px;
  position: relative;
  transition: background-color 0.15s, border-color 0.15s;
}

.wh-collection__check input:checked + .wh-collection__check-box {
  background: var(--wh-gold, #9a8c57);
  border-color: var(--wh-gold, #9a8c57);
}

.wh-collection__check input:checked + .wh-collection__check-box::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid var(--wh-ink, #141414);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.wh-collection__check input:focus-visible + .wh-collection__check-box {
  outline: 2px solid var(--wh-gold, #9a8c57);
  outline-offset: 2px;
}

.wh-collection__check input:checked ~ .wh-collection__check-text {
  color: var(--wh-col-text);
}

.wh-collection__check-count {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.wh-collection .wh-collection__clear {
  appearance: none;
  cursor: pointer;
  visibility: hidden;
  margin-top: 18px;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--wh-col-line);
  border-radius: var(--wh-radius, 3px);
  background: transparent;
  color: var(--wh-col-text-dim);
  font-family: var(--wh-font-body, "Poppins", sans-serif);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s, border-color 0.2s;
}

.wh-collection .wh-collection__clear.is-visible {
  visibility: visible;
}

.wh-collection__empty .wh-collection__clear {
  visibility: visible;
  width: auto;
}

.wh-collection .wh-collection__clear:hover {
  color: var(--wh-white, #ffffff);
  border-color: var(--wh-gold, #9a8c57);
}

/* ---------------------------------------------------------------------------
   3. The grid + cards
   ------------------------------------------------------------------------- */
.wh-collection__grid {
  flex: 1;
  min-width: 0;
  display: grid;
  /* 2-up (not 3): reviewer feedback — bigger cards you can actually see */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.wh-collection__empty {
  flex: 1;
  padding: 64px 24px;
  text-align: center;
  color: var(--wh-col-text-dim);
  border: 1px dashed var(--wh-col-line-soft);
  border-radius: var(--wh-radius, 3px);
}

.wh-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--wh-col-card-bg);
  border: 1px solid var(--wh-col-line-soft);
  border-radius: var(--wh-radius, 3px);
  overflow: hidden;
  cursor: pointer;
  transition: background-color 0.25s, border-color 0.25s, transform 0.25s var(--wh-col-ease);
}

.wh-card:hover {
  background: var(--wh-col-card-bg-hover);
  border-color: var(--wh-col-line);
  transform: translateY(-2px);
}

/* --- media / mini carousel --- */
.wh-card__media {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #101111;
}

.wh-card__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.wh-card__slide.is-active {
  opacity: 1;
}

.wh-card__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Floor plans are wide technical drawings — NEVER crop-fill them. */
.wh-card__slide--plan {
  background: #ffffff;
}

.wh-card__slide--plan img {
  object-fit: contain;
  padding: 10px;
  box-sizing: border-box;
}

.wh-collection .wh-card__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  appearance: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border: 1px solid var(--wh-col-line);
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.72);
  color: var(--wh-white, #ffffff);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
  opacity: 0;
  transition: opacity 0.2s, border-color 0.2s, background-color 0.2s;
}

.wh-collection .wh-card__arrow--prev { left: 10px; }
.wh-collection .wh-card__arrow--next { right: 10px; }

.wh-card:hover .wh-card__arrow,
.wh-collection .wh-card__arrow:focus-visible {
  opacity: 1;
}

.wh-collection .wh-card__arrow:hover {
  border-color: var(--wh-gold, #9a8c57);
  background: rgba(20, 20, 20, 0.9);
}

/* Touch devices have no hover — arrows stay visible. */
@media (hover: none) {
  .wh-collection .wh-card__arrow { opacity: 1; }
}

.wh-card__dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 6px;
}

.wh-collection .wh-card__dot {
  appearance: none;
  cursor: pointer;
  width: 8px;
  height: 8px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.2s, border-color 0.2s;
}

.wh-collection .wh-card__dot.is-active {
  background: var(--wh-gold, #9a8c57);
  border-color: var(--wh-gold, #9a8c57);
}

.wh-card__tag {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.72);
  color: var(--wh-tan, #c0b59b);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* --- overlays: sqft badge + compare --- */
.wh-card__sqft {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.78);
  border: 1px solid var(--wh-col-line-soft);
  color: var(--wh-gold, #9a8c57);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wh-card__compare {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.78);
  border: 1px solid var(--wh-col-line-soft);
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.wh-card__compare:hover {
  border-color: var(--wh-gold, #9a8c57);
  color: var(--wh-white, #ffffff);
}

.wh-card__compare input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wh-card__compare-box {
  width: 13px;
  height: 13px;
  border: 1px solid var(--wh-col-line);
  border-radius: 2px;
  position: relative;
  transition: background-color 0.15s, border-color 0.15s;
}

.wh-card__compare input:checked + .wh-card__compare-box {
  background: var(--wh-gold, #9a8c57);
  border-color: var(--wh-gold, #9a8c57);
}

.wh-card__compare input:checked + .wh-card__compare-box::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 8px;
  border: solid var(--wh-ink, #141414);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.wh-card__compare input:focus-visible + .wh-card__compare-box {
  outline: 2px solid var(--wh-gold, #9a8c57);
  outline-offset: 2px;
}

@keyframes wh-card-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.wh-card__compare.is-full {
  animation: wh-card-shake 0.3s ease;
  border-color: #b0563e;
}

/* --- body --- */
.wh-card__body {
  padding: 16px 18px 18px;
}

.wh-card__title {
  margin: 0 0 6px;
  font-family: var(--wh-font-heading, "Lato", sans-serif);
  font-weight: 300;
  font-size: 22px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.wh-card__price {
  margin: 0 0 8px;
  font-family: var(--wh-font-heading, "Lato", sans-serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--wh-gold, #9a8c57);
}

.wh-card__link {
  color: var(--wh-col-text);
  text-decoration: none;
}

.wh-card__link:hover {
  color: var(--wh-gold, #9a8c57);
}

.wh-card__link:focus-visible {
  outline: 2px solid var(--wh-gold, #9a8c57);
  outline-offset: 3px;
}

.wh-card__specs {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--wh-col-text-dim);
}

.wh-card__cta {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wh-gold, #9a8c57);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s, transform 0.2s var(--wh-col-ease);
  display: inline-block;
}

.wh-card:hover .wh-card__cta {
  opacity: 1;
  transform: translateX(0);
}

@media (hover: none) {
  .wh-card__cta { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------------
   4. Responsive
   ------------------------------------------------------------------------- */

@media (max-width: 880px) {
  /* Sidebar becomes a slide-in drawer */
  .wh-collection .wh-collection__filters-toggle {
    display: inline-flex;
  }

  .wh-collection__filters {
    position: fixed;
    inset: 0 auto 0 0;
    top: 0;
    width: min(320px, 86vw);
    max-height: none;
    height: 100%;
    z-index: 200;
    border-radius: 0;
    border-right: 1px solid var(--wh-col-line);
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.28s var(--wh-col-ease);
  }

  .wh-collection__filters.is-open {
    transform: translateX(0);
  }

  .wh-collection .wh-collection__filters-close {
    display: block;
  }

  .wh-collection__scrim {
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.25s;
  }

  .wh-collection__scrim.is-visible {
    opacity: 1;
  }

  body.wh-modal-open {
    overflow: hidden;
  }
}

@media (max-width: 720px) {
  /* The Elementor section already pads the page edges 25px on mobile —
     don't stack our own 16px on top of it; give that width to the cards. */
  .wh-collection {
    padding: 0 0 64px;
  }

  /* small screens are overwhelmingly touch — keep carousel arrows visible */
  .wh-collection .wh-card__arrow {
    opacity: 1;
  }

  .wh-collection__meta {
    margin: 0 0 20px;
  }

  .wh-collection__grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wh-card,
  .wh-card__slide,
  .wh-card__cta,
  .wh-collection__filters,
  .wh-collection__scrim {
    transition: none;
  }

  .wh-card__compare.is-full {
    animation: none;
  }
}
