/* ==========================================================================
   CoverflowCarousel — reusable 3D coverflow slider
   --------------------------------------------------------------------------
   Markup:
     <div class="cf-carousel" id="myCarousel" tabindex="0">
       <div class="cf-stage" data-cf-stage></div>
       <button class="cf-arrow cf-arrow--prev" data-cf-prev>…</button>
       <button class="cf-arrow cf-arrow--next" data-cf-next>…</button>
       <div class="cf-dots" data-cf-dots></div>
     </div>

   Theme hooks (override on the .cf-carousel or a parent):
     --cf-card-w   card width            --cf-step   horizontal distance (card-width %)
     --cf-ratio    card aspect ratio     --cf-dur    transition duration
     --cf-ink      arrow / dot colour

   The only JS-controlled properties are --d (offset), --s (scale),
   --r (rotation) and --y (vertical nudge). Everything else is CSS.
   ========================================================================== */

.cf-carousel {
  --cf-card-w: min(50vw, 1300px);
  --cf-step: 66%;
  --cf-ratio: 0.5625;              /* 16:9 */
  --cf-dur: 700ms;
  --cf-ease: cubic-bezier(.22, .61, .36, 1);
  --cf-ink: #26221C;
  --cf-paper: #F7F3EC;
  position: relative;
  width: 100%;
  padding: 0 0 40px;
  overflow: hidden;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
}

.cf-carousel:focus-visible {
  outline: 2px solid #6E7D5F;
  outline-offset: 6px;
}

/* The perspective lives on the stage so each slide gets true 3D depth. */
.cf-stage {
  position: relative;
  width: 100%;
  height: calc(var(--cf-card-w) * var(--cf-ratio));
  perspective: 1400px;
  perspective-origin: 50% 44%;
}

.cf-slide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--cf-card-w);
  aspect-ratio: 16 / 9;
  margin: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #E9E1D3;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform:
    translate(calc(-50% + var(--cf-step) * var(--d, 0)), -50%)
    translateY(var(--y, 0px))
    scale(var(--s, 1))
    rotateY(var(--r, 0deg));
  transition:
    transform var(--cf-dur) var(--cf-ease),
    opacity var(--cf-dur) ease,
    box-shadow var(--cf-dur) ease;
  will-change: transform, opacity;
}

.cf-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  filter: sepia(.06) saturate(.92);
  transition: filter var(--cf-dur) ease;
}

.cf-slide:not(.is-active) img {
  filter: sepia(.06) saturate(.88) brightness(1.06);
}

/* Active card gets the strongest lift; side cards sit back. */
.cf-slide.is-active {
  box-shadow:
    0 26px 54px -32px rgba(38, 34, 28, .26),
    0 6px 14px -10px rgba(38, 34, 28, .08);
}

.cf-slide:not(.is-active) {
  box-shadow: none;
}

/* A warm veil fades the side cards. Using a veil instead of opacity keeps
   every card opaque, so the card behind it never shows through mid-swipe. */
.cf-veil {
  position: absolute;
  inset: 0;
  background: rgba(250, 246, 239, .40);
  opacity: 0;
  transition: opacity var(--cf-dur) ease;
  pointer-events: none;
}

.cf-slide:not(.is-active) .cf-veil {
  opacity: 1;
}

/* Broken image fallback — keeps the geometry intact. */
.cf-slide.is-broken img { display: none; }

.cf-slide.is-broken::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #EFE8DC 0%, #E2D8C6 100%);
}

.cf-slide.is-broken::after {
  content: "Photo unavailable";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Jost', 'Segoe UI', system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #8B8173;
}

/* Instant positioning (first paint / no animation) */
.cf-carousel.is-instant .cf-slide { transition: none !important; }

/* ---------------------------------------------------------------- arrows */
.cf-arrow {
  position: absolute;
  top: calc(var(--cf-card-w) * var(--cf-ratio) / 2);
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(38, 34, 28, .07);
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  color: var(--cf-ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 30;
  box-shadow: 0 10px 26px -10px rgba(38, 34, 28, .35);
  transition: background .3s ease, color .3s ease, transform .3s ease;
}

.cf-arrow:hover {
  background: var(--cf-ink);
  color: var(--cf-paper);
}

.cf-arrow:active { transform: translateY(-50%) scale(.94); }

.cf-arrow--prev { left: clamp(10px, 2.6vw, 38px); }
.cf-arrow--next { right: clamp(10px, 2.6vw, 38px); }

/* ------------------------------------------------------------------ dots */
.cf-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  z-index: 30;
}

.cf-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(38, 34, 28, .22);
  cursor: pointer;
  transition: width .35s ease, background .35s ease, transform .35s ease;
}

.cf-dot:hover { background: rgba(38, 34, 28, .45); }

.cf-dot.is-active {
  width: 24px;
  border-radius: 4px;
  background: #6E7D5F;
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .cf-carousel {
    --cf-card-w: 82vw;
    --cf-step: 53%;
    padding-bottom: 40px;
  }
  .cf-arrow {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }
  .cf-arrow--prev { left: 4px; }
  .cf-arrow--next { right: 4px; }
  .cf-dots { bottom: 6px; gap: 8px; }
  .cf-dot { width: 6px; height: 6px; }
  .cf-dot.is-active { width: 20px; }
}

@media (max-width: 520px) {
  .cf-carousel {
    --cf-card-w: 80vw;
    --cf-step: 56%;
  }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  .cf-slide {
    transition-duration: 1ms;
  }
}
