.card-carousel {
  isolation: isolate;
  /* Shared hover/focus timing (fill, image rise/tilt, height, body collapse). */
  --cc-duration: 0.45s;
  --cc-ease: cubic-bezier(0.4, 0, 0.2, 1);
  /* Desktop card heights: resting cards are tall; the focus card is shorter, so
     the image sits mostly ABOVE it (the green only reaches just under the image). */
  --cc-card-h: 30rem;
  --cc-card-h-focus: 21rem;
  --cc-img-max-h: 210px;
  /* The focus image's bottom sits this far below the card top — small, so the
     image only slightly overlaps the card and pokes well above it. */
  --cc-img-anchor: 2.5rem;
  --cc-tilt: 4deg;
}

/* FOUC guard for the JS entrance (card-carousel.js): hide the cards while the
   reveal engine's `reveal-pending` is on (motion only). reveal.js drops the class
   on init, in the same task the carousel JS sets the GSAP from-state, so the cards
   stay hidden until the stagger plays — no flash. Reduced-motion never gets the
   class, so the cards show immediately. */
@media (prefers-reduced-motion: no-preference) {
  html.reveal-pending .card-carousel__card {
    opacity: 0;
  }
}

/* ── Carousel / slides ───────────────────────────────────────────── */
/* Clip the LEFT edge flush to the container, but let the row bleed off the RIGHT
   (a peek of the next card, per Figma) and let the focus image poke ABOVE.
   `overflow` can't clip a single side, so override Swiper's `.swiper { overflow:
   hidden }` (scoped 0,2,0) and clip with `clip-path: inset(top right bottom left)`
   — only the left inset is 0; top/right are pushed far out so nothing there is
   trimmed. Horizontal bleed past the viewport is clipped at the page root
   (body.css `overflow-x: clip`), so there's no sideways scroll. */
.card-carousel .card-carousel__swiper {
  overflow: visible;
  clip-path: inset(-12rem -100vw -2rem 0);
  /* Mobile headroom for the popped focus image. The desktop 5rem over-inflated the
     arrows-to-card gap (BugHerd #102), but 0 let the tallest images pop up and
     overlap the arrows; ~2rem lands the tallest image at a Figma-like ~20px gap and
     shorter images sit a little lower (their natural height). */
  padding-top: 2rem;
}

/* Desktop: resting cards are tall, so the focus image pops above the whole slide and
   needs the larger 5rem headroom. */
@media (min-width: 60rem) {
  .card-carousel .card-carousel__swiper {
    padding-top: 5rem;
  }
}

.card-carousel__swiper .swiper-wrapper {
  align-items: stretch;
}

/* Fixed-height slides are a STABLE hover target AND the frame the focus image pops
   within: the focus card shrinks (`--cc-card-h-focus`) bottom-aligned inside its
   slide, so hovering never reshapes the row (no jitter) and the popped image mostly
   sits in the empty space above the shrunk card — only a little pokes past the slide
   top, which the padding-top + clip-path absorb. Works the same on mobile (just a
   narrower slide). Scoped 0,2,0 to beat Swiper's base `.swiper-slide` sizing. */
.card-carousel__swiper .card-carousel__slide {
  flex-shrink: 0;
  width: 85%; /* mobile peek — the next card edge shows */
  height: var(--cc-card-h);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

@media (min-width: 60rem) {
  /* Three cards in view with the 24px swiper gap between them. */
  .card-carousel__swiper .card-carousel__slide {
    width: calc((100% - 48px) / 3);
  }
}

/* ── Card ────────────────────────────────────────────────────────── */
.card-carousel__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: var(--cc-card-h);
  padding: 1rem;
  color: var(--color-charcoal);
  background-color: transparent;
  border: 1px solid var(--color-charcoal);
  transition:
    height var(--cc-duration) var(--cc-ease),
    padding var(--cc-duration) var(--cc-ease),
    background-color var(--cc-duration) var(--cc-ease),
    border-color var(--cc-duration) var(--cc-ease),
    color var(--cc-duration) var(--cc-ease);
}

/* The focus look — accent fill + the green shrinking — at ALL breakpoints. Applies
   to the card whose SLIDE is hovered/focused, OR to the centred (active) card when NO
   slide is hovered (so on desktop hovering moves the focus and the centre reverts;
   releasing returns it). Mobile has no hover, so it's purely the active slide. Hover
   is read on the fixed-height SLIDE so the card shrinks inside it without jitter. The
   centred branch is gated behind `.cc-revealed` so it kicks in after the entrance. */
.card-carousel:not(.card-carousel--text-cards) .card-carousel__slide:hover .card-carousel__card,
.card-carousel:not(.card-carousel--text-cards) .card-carousel__slide:focus-within .card-carousel__card,
.card-carousel:not(.card-carousel--text-cards) .cc-revealed .card-carousel__swiper:not(:has(.card-carousel__slide:is(:hover, :focus-within))) .swiper-slide-active .card-carousel__card {
  height: var(--cc-card-h-focus);
  padding-top: calc(var(--cc-img-anchor) + 1.5rem);
  background-color: var(--cc-accent);
  border-color: transparent;
  color: var(--color-off-white);
}

/* ── Featured image — flexible aspect ratio, capped at 210px tall ──── */
/* Natural proportions (object-contain, never cropped), never taller than 210px
   (Figma: "Flexible aspect ratio · Max Height of Image: 210px"). Shown only on the
   focus card, popped above it (rest cards have no image) — same on mobile + desktop. */
.card-carousel__frame {
  margin: 0;
  width: 100%;
}

.card-carousel__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: var(--cc-img-max-h);
  object-fit: contain;
}

/* The image is the focus card's flourish — positioned above the card, hidden until
   the card is the focus, then it fades/slides DOWN in, tilted. (Decorative +
   aria-hidden.) Absolute, so rest cards reflow without it. */
.card-carousel__media {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(100% - var(--cc-img-anchor));
  opacity: 0;
  pointer-events: none;
  /* Starts ABOVE its resting spot so it slides DOWN into place ("from the top"). */
  translate: 0 -2.5rem;
  rotate: 0deg;
  transition:
    opacity var(--cc-duration) var(--cc-ease),
    translate var(--cc-duration) var(--cc-ease),
    rotate var(--cc-duration) var(--cc-ease);
}

/* Image fades/slides DOWN in for the focus card: the hovered/focused slide, or the
   centred slide when nothing is hovered. The `transition-delay` makes it wait for
   the green to finish shrinking first (so focus reads as "shrink, THEN image" — on
   hover and on the entrance alike). On the way out it's instant (the base media
   rule above has no delay), so un-hovering doesn't lag. */
.card-carousel:not(.card-carousel--text-cards) .card-carousel__slide:hover .card-carousel__media,
.card-carousel:not(.card-carousel--text-cards) .card-carousel__slide:focus-within .card-carousel__media,
.card-carousel:not(.card-carousel--text-cards) .cc-revealed .card-carousel__swiper:not(:has(.card-carousel__slide:is(:hover, :focus-within))) .swiper-slide-active .card-carousel__media {
  opacity: 1;
  translate: 0 0;
  rotate: var(--cc-tilt);
  transition-delay: var(--cc-duration);
}

/* ── Content ─────────────────────────────────────────────────────── */
.card-carousel__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2rem;
  min-height: 0;
}

.card-carousel__top {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

/* ── Tags ────────────────────────────────────────────────────────── */
.card-carousel__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Chips take the LIGHT counterpart of the accent (set per instance as
   `--cc-accent-light` in the view), with charcoal text — readable on every light
   tint and on the accent-filled focus card. */
.card-carousel__tag {
  padding: 0.25rem 0.5rem;
  background-color: var(--cc-accent-light, var(--color-light-green));
  color: var(--color-charcoal);
  line-height: 1;
}

/* ── Title ───────────────────────────────────────────────────────── */
/* Mobile: 24px headline (text-header-6); desktop keeps text-header-5 / 32px. */
@media (max-width: 59.999rem) {
  .card-carousel .card-carousel__title {
    font-size: var(--text-header-6);
  }
}

/* ── Body ────────────────────────────────────────────────────────── */
/* Clamp the excerpt and end it with an ellipsis when it runs out of room. The
   line cap is the upper bound; a long title eats into it first (the body can
   still shrink) so the card never overflows. */
.card-carousel__body {
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

/* The body collapses out on the focus card (hovered/focused slide, or the centred
   slide when nothing is hovered) — with the shrink. */
.card-carousel:not(.card-carousel--text-cards) .card-carousel__slide:hover .card-carousel__body,
.card-carousel:not(.card-carousel--text-cards) .card-carousel__slide:focus-within .card-carousel__body,
.card-carousel:not(.card-carousel--text-cards) .cc-revealed .card-carousel__swiper:not(:has(.card-carousel__slide:is(:hover, :focus-within))) .swiper-slide-active .card-carousel__body {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--cc-duration) var(--cc-ease),
    visibility 0s linear var(--cc-duration);
}

/* Mobile shows one card at a time with no hover, so drop the description (#135):
   image, title and Learn More only. */
@media (max-width: 59.999rem) {
  .card-carousel__body {
    display: none;
  }
}

/* ── Learn More link ─────────────────────────────────────────────── */
.card-carousel__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin-top: auto;
  color: inherit;
  text-transform: uppercase;
  text-underline-offset: 3px;
  transition: none;
  text-decoration: none;
}

.card-carousel__link > span:first-child,
.card-carousel__file-link > span:first-child {
  text-decoration: underline;
  text-decoration-color: currentColor;
  transition: text-decoration-color var(--cc-duration) var(--cc-ease);
}

/* Hover/focus drops the underline on both link kinds: the stretched link reacts to
   the whole card, a file link to itself. */
.card-carousel__slide:hover .card-carousel__link > span:first-child,
.card-carousel__slide:focus-within .card-carousel__link > span:first-child,
.card-carousel__file-link:hover > span:first-child,
.card-carousel__file-link:focus-visible > span:first-child {
  text-decoration-color: transparent;
}

/* Stretched link — the whole card is clickable (::after resolves to the card,
   its nearest positioned ancestor). */
.card-carousel__card--link {
  position: relative;
}

.card-carousel__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Arrow points straight right for in-site links; up-right (↗) only when the link
   leaves the site (`--external`). */
.card-carousel__link svg {
  flex: none;
  transform: rotate(var(--cc-arrow, 0deg));
  transition: transform var(--cc-duration) var(--cc-ease);
}

.card-carousel__link--external {
  --cc-arrow: -45deg;
}

/* Nudge the arrow along its pointing direction on hover/focus. */
.card-carousel__slide:hover .card-carousel__link svg,
.card-carousel__slide:focus-within .card-carousel__link svg {
  transform: rotate(var(--cc-arrow, 0deg)) translateX(2px);
}

/* ── File / download links ───────────────────────────────────────── */
/* A card with file links is NOT a stretched link; the links stack at the
   bottom, each an inline link with its own download / arrow icon. */
.card-carousel__files {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  margin-top: auto;
  padding: 0;
  list-style: none;
}

.card-carousel__file-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  color: inherit;
  text-transform: uppercase;
  text-underline-offset: 3px;
  text-decoration: none;
}

.card-carousel__file-link svg {
  flex: none;
  transition: transform var(--cc-duration) var(--cc-ease);
}

/* Same 2px nudge as the stretched link's icon (along the arrow when it's tilted). */
.card-carousel__file-link:hover svg,
.card-carousel__file-link:focus-visible svg {
  transform: translateX(2px);
}

.card-carousel__file-arrow--external {
  rotate: -45deg;
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .card-carousel__card,
  .card-carousel__media,
  .card-carousel__body,
  .card-carousel__link svg {
    transition:
      background-color var(--cc-duration) var(--cc-ease),
      color var(--cc-duration) var(--cc-ease),
      border-color var(--cc-duration) var(--cc-ease);
  }

  .card-carousel__slide:hover .card-carousel__media,
  .card-carousel__slide:focus-within .card-carousel__media,
  .cc-revealed .card-carousel__swiper:not(:has(.card-carousel__slide:is(:hover, :focus-within))) .swiper-slide-active .card-carousel__media {
    rotate: 0deg;
    translate: 0 0;
  }

  .card-carousel__slide:hover .card-carousel__link svg,
  .card-carousel__slide:focus-within .card-carousel__link svg {
    transform: rotate(var(--cc-arrow, 0deg));
  }

  .card-carousel__link > span:first-child,
  .card-carousel__file-link > span:first-child,
  .card-carousel__file-link svg {
    transition: none;
  }

  .card-carousel__file-link:hover svg,
  .card-carousel__file-link:focus-visible svg {
    transform: none;
  }
}

/* Pagination dots + prev/next buttons are shared chrome — see
   resources/css/main/carousel.css (.carousel-dots / .carousel-dot /
   .carousel-nav__btn). */

/* ── Text cards (BugHerd #229) ───────────────────────────────────── */
/* No featured image, so the row needs no headroom for one to pop into. */
.card-carousel--text-cards .card-carousel__swiper {
  padding-top: 0;
}
