/* ==========================================================================
   Why Somerset County — centre-focused carousel
   --------------------------------------------------------------------------
   One slide held large in the middle with its neighbours stepped down and back
   on either side. Every position is a transform on the same box, so the whole
   thing animates itself when main.js re-assigns them — no per-frame work.

   Comp geometry at 1440 (WhySomerset_Website_2026_Life.pdf, page 2), all the
   slides sharing one vertical centre:
     centre   506   x 376.5  offset    0
     +/- 1    430.1 x 320    offset  254.2   scale .851
     +/- 2    344.1 x 256    offset  469.4   scale .682
   The run spans 77 - 1363, wider than the 1240 column the copy sits in.
   ========================================================================== */

.coverflow {
  --slide-w: 39.35%;          /* 506 of the 1286 the run spans */
  --step-1: 50.24%;           /* 254.2 as a share of a slide's own width */
  --step-2: 92.77%;           /* 469.4 likewise */
  --scale-1: .851;
  --scale-2: .682;
  position: relative;
  /* The wrap around this already applies the page gutters; taking them off
     again here would shrink the run below the comp. */
  width: min(100%, 1286px);
  margin-inline: auto;
}

.coverflow__viewport {
  position: relative;
  /* The centre slide sets the height; the rest are scaled down inside it. */
  aspect-ratio: 1286 / 376.5;
  /* A carousel like this always has slides reaching past its edges — the ones
     waiting off stage, and at narrow widths the outermost visible pair too.
     Without this they push the page sideways. */
  overflow: hidden;
}

.coverflow__slide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--slide-w);
  margin: 0;
  opacity: 0;
  pointer-events: none;
  /* Off-stage slides sit under the centre one and scaled away, so a carousel
     with more pictures than positions has somewhere to come from and go to. */
  transform: translate(-50%, -50%) scale(var(--scale-2));
  transition: transform .55s var(--ws-ease), opacity .45s var(--ws-ease);
}
.coverflow__slide img {
  display: block;
  width: 100%;
  aspect-ratio: 506 / 376.5;
  object-fit: cover;
  border-radius: clamp(4px, .42vw, 6px);
}

/* Translate first, then scale, so the step between positions is measured on
   the full-size box and does not shrink with the slide. */
.coverflow__slide[data-pos="0"] {
  transform: translate(-50%, -50%);
  opacity: 1;
  z-index: 3;
  pointer-events: auto;
}
.coverflow__slide[data-pos="-1"],
.coverflow__slide[data-pos="1"] { opacity: 1; z-index: 2; pointer-events: auto; cursor: pointer; }
.coverflow__slide[data-pos="-2"],
.coverflow__slide[data-pos="2"] { opacity: 1; z-index: 1; pointer-events: auto; cursor: pointer; }

.coverflow__slide[data-pos="-1"] { transform: translate(-50%, -50%) translateX(calc(-1 * var(--step-1))) scale(var(--scale-1)); }
.coverflow__slide[data-pos="1"]  { transform: translate(-50%, -50%) translateX(var(--step-1))            scale(var(--scale-1)); }
.coverflow__slide[data-pos="-2"] { transform: translate(-50%, -50%) translateX(calc(-1 * var(--step-2))) scale(var(--scale-2)); }
.coverflow__slide[data-pos="2"]  { transform: translate(-50%, -50%) translateX(var(--step-2))            scale(var(--scale-2)); }

/* --------------------------------------------------------------------------
   Chevrons — the same mark and stroke weight as the Outdoors gallery, but in
   white with a shadow rather than that gallery's grey. This carousel runs to
   the full width of its block, so there is no white margin to stand them in
   and they sit over the outermost photographs; grey-on-photo disappeared
   completely against the darker ones.
   They live inside the viewport so they centre on the pictures rather than on
   the block, which also holds the caption.
   -------------------------------------------------------------------------- */
.coverflow__arrow {
  position: absolute;
  top: 50%;
  z-index: 4;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: clamp(38px, 4.5vw, 64px);
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  transition: opacity .25s var(--ws-ease), transform .25s var(--ws-ease);
  opacity: .85;
}
.coverflow__arrow--prev { left: 0; }
.coverflow__arrow--next { right: 0; }
.coverflow__arrow svg {
  width: clamp(20px, 2.15vw, 31px);
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .6));
}
.coverflow__arrow:hover { opacity: 1; }
.coverflow__arrow--prev:hover { transform: translateY(-50%) translateX(-3px); }
.coverflow__arrow--next:hover { transform: translateY(-50%) translateX(3px); }
.coverflow__arrow:focus-visible { outline: 3px solid var(--ws-green); outline-offset: 3px; }
.coverflow__arrow[disabled] { opacity: .25; cursor: default; transform: translateY(-50%); }

/* --------------------------------------------------------------------------
   Caption — the active slide's line and its credit, centred under the run
   -------------------------------------------------------------------------- */
.coverflow__caption {
  margin: clamp(10px, 1.04vw, 15px) auto 0;
  /* Its own measure, not the wrap's: this block's wrap is 1286 wide and a
     centred caption stretched that far is unreadable. */
  max-width: min(100%, 720px);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ws-ink);
  text-align: center;
}
.coverflow__credit { display: block; }

/* --------------------------------------------------------------------------
   Responsive
   The stepped-back neighbours need room; on a phone the centre slide takes the
   width on its own and the rest sit off stage.
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .coverflow {
    --slide-w: 62%;
    --step-1: 68%;
    --step-2: 122%;
    --scale-1: .8;
    --scale-2: .64;
  }
  .coverflow__viewport { aspect-ratio: 1286 / 430; }
}
