/* ===========================================================================
   3D SWIPE CAROUSEL — MOBILE AND TABLET ONLY
   ---------------------------------------------------------------------------
   On a laptop or desktop these sections stay exactly as they were designed:
   a grid, every card visible at once. There is room for all of them there, and
   a carousel only adds a step. Below 900px the same cards become a swipeable
   track with a depth effect, because that is where the grid turns into a long
   scroll.

   Everything that converts the grid into a track lives inside the media query
   below, so above the breakpoint none of it applies and the original grid
   rules in styles.css are left untouched. js/carousel.js watches the same
   breakpoint and switches its own behaviour off in step.

   The scrolling itself is native CSS scroll-snap, not JavaScript — that gives
   real touch momentum and correct accessibility for free, so if the script
   never runs the section is still a working swipeable row.
   =========================================================================== */

.carousel-shell{ position: relative; }

/* The controls belong to the carousel, so they only exist with it. */
.carousel-nav{ display: none; }

@media (max-width: 900px){

  [data-carousel]{
    display: flex;
    gap: clamp(14px, 3vw, 22px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    perspective: 1200px;
    padding: 22px 0 26px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: grab;
    /* a grid parent may have set these; a flex track must not inherit them */
    grid-template-columns: none;
    background: transparent;
    border: 0;
  }
  [data-carousel]::-webkit-scrollbar{ display: none; }
  [data-carousel].is-dragging{ cursor: grabbing; scroll-behavior: auto; scroll-snap-type: none; }

  /* Half a track width of space either side lets the first and last card
     reach the centre of the viewport. */
  [data-carousel]::before,
  [data-carousel]::after{
    content: '';
    flex: 0 0 max(0px, calc(50% - (var(--card-w) / 2)));
  }

  [data-carousel] > *{
    flex: 0 0 var(--card-w);
    scroll-snap-align: center;
    transform-style: preserve-3d;
    transition: transform .45s cubic-bezier(.2,.7,.2,1), opacity .45s ease;
    will-change: transform;
    backface-visibility: hidden;
  }

  /* Set by the script from each card's distance to the centre of the track. */
  [data-carousel] > .is-side{ opacity: .55; }

  /* One card at a time on a phone, with the neighbours just showing. */
  [data-carousel]{ --card-w: min(78vw, 340px); }
  @media (min-width: 620px){
    [data-carousel]{ --card-w: min(56vw, 380px); }
  }

  [data-carousel] > .lp-scene{ min-height: 400px; }

  /* The why-cards drew their borders from the grid's background showing
     through the gaps, which a flex track does not provide. */
  [data-carousel] > .why-card{
    border: 1px solid var(--line);
    background: var(--surface);
  }

  /* ---- controls ---- */
  .carousel-nav{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 2px;
  }
  .carousel-btn{
    width: 42px; height: 42px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 50%;
    transition: background .25s ease, color .25s ease, opacity .25s ease;
  }
  .carousel-btn:hover:not(:disabled){ background: var(--line-strong); color: var(--canvas); }
  .carousel-btn:disabled{ opacity: .3; cursor: default; }
  .carousel-btn svg{ width: 18px; height: 18px; }

  .carousel-dots{ display: flex; gap: 0; }
  /* 24px tap area around an 8px dot, so the dots are easy to hit on a phone */
  .carousel-dot{
    width: 24px; height: 24px; padding: 0;
    border: 0; background: none; color: inherit;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
  }
  .carousel-dot::before{
    content: ''; width: 8px; height: 8px; border-radius: 50%;
    background: currentColor; opacity: .25;
    transition: opacity .25s ease, transform .25s ease;
  }
  .carousel-dot.is-active::before{ opacity: 1; transform: scale(1.4); }

  /* On the dark landing bands the controls sit on navy. */
  .lp-section--dark .carousel-btn,
  .lp-section--flush .carousel-btn{ border-color: rgba(255,255,255,.35); }
  .lp-section--dark .carousel-btn:hover:not(:disabled),
  .lp-section--flush .carousel-btn:hover:not(:disabled){ background: #fff; color: var(--lp-ink, #0e2a63); }

  /* Someone who has asked for less motion gets a plain snap, no rotation. */
  @media (prefers-reduced-motion: reduce){
    [data-carousel]{ scroll-behavior: auto; }
    [data-carousel] > *{ transition: none; transform: none !important; }
    [data-carousel] > .is-side{ opacity: 1; }
  }
}

/* ---------------------------------------------------------------------------
   The line under the section heading describes how to read the cards, and the
   answer differs by width: hover on a laptop, swipe on a phone.
   ------------------------------------------------------------------------- */
.hint-swipe{ display: none; }
@media (max-width: 900px){
  .hint-hover{ display: none; }
  .hint-swipe{ display: inline; }
}
