/* ==========================================================================
   Page: Expertise — hero · expertise carousel · contact

   The carousel has THREE visual states, in three blocks below:

   1. SHARED      — skeleton + typography used by every state.
   2. MOBILE+TABLET — (<= 1024px) the scroll-driven fade carousel: pinned view
                    with title + ONE card + the category list below (unchanged
                    design; tablets use it too — the diagonal needs a roomier
                    screen). Under "reduce motion" it still runs: the scroll-
                    tied crossfade IS the low-motion variant.
   3. DESKTOP     — (>= 1025px) the diagonal scroll carousel. Everything
                    animated is scoped to .is-dcx, which diagonal-carousel.js
                    adds only when the viewport is wide enough AND motion is
                    allowed — phones/tablets are never affected.
   4. FALLBACK    — desktop without JS or with "reduce motion": a plain
                    stacked list, no pinning, no animation.

   Tuning the desktop motion (speed, dwell, card size…) happens in the CFG
   block at the top of assets/js/diagonal-carousel.js — not here.

   NOTE: position:sticky breaks silently if any ancestor of the carousel gets
   overflow:hidden/auto — use overflow-x:clip instead (html/body already do,
   see tokens.css).
   ========================================================================== */

/* ── 1. SHARED ──────────────────────────────────────────────────────────── */

.expertise-carousel {
  background: var(--bg-primary);
  padding-inline: var(--margin-primary);
}
.expertise-carousel__pin { position: relative; }  /* the tall scroll "timeline" */
.expertise-carousel__sticky {
  display: flex;
  align-items: center;
  justify-content: center;
}
.expertise-carousel__frame { position: relative; width: 100%; }

/* Cards — an <a> wrapping the image; the scrim dims non-active cards (desktop). */
.expertise-carousel__card {
  position: absolute;
  margin: 0;
  display: block;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-image);
  overflow: hidden;
  background: #dfe2f0;
}
.expertise-carousel__media { position: absolute; inset: 0; transform-origin: center; }
.expertise-carousel__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.expertise-carousel__scrim {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  opacity: 0;
  pointer-events: none;
}

/* Title — used by BOTH the mobile info items and the desktop head. */
.expertise-carousel__title {
  margin: 0 0 24px;
  font-size: var(--title-md);
  line-height: var(--title-md-lh);
  letter-spacing: var(--title-md-ls);
  font-weight: 400;
  color: var(--text-title);
}

/* Category nav buttons (right list on desktop, below the card on mobile). */
.expertise-carousel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.expertise-carousel__navbtn {
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: right;
  font-size: var(--body-sm);
  line-height: var(--body-sm-lh);
  color: var(--text-body);
  opacity: 0.55;
  transition: opacity 0.2s ease, color 0.2s ease;
}
.expertise-carousel__navbtn:hover,
.expertise-carousel__navbtn.is-active { opacity: 1; color: var(--text-title); }

/* Desktop-only elements — hidden until the .is-dcx engine turns them on. */
.expertise-carousel__head-wrap,
.expertise-carousel__meta { display: none; }

/* Visually hidden live region — announces the active card to screen readers. */
.expertise-carousel__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ── 2. MOBILE + TABLET (<= 1024px) — scroll-driven fade carousel ─────────
   1024.98 (not 1024) so fractional zoom widths between 1024 and the JS
   breakpoint 1025 can never fall between the CSS and the engine. */

@media (max-width: 1024.98px) {
  /* ~70vh of page scroll per card; --exp-count is set inline by the template. */
  .expertise-carousel__pin { height: calc((var(--exp-count, 1) + 1) * 70vh); }
  .expertise-carousel__sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;                        /* mobile browser chrome-safe */
    overflow: hidden;
    /* Reusable section padding from tokens.css (--section-pt/--section-pb).
       --header-h is added on top only because this section is PINNED at
       top:0 and sits under the fixed header — normal in-flow sections use
       the tokens directly: padding-block: var(--section-pt) var(--section-pb) */
    padding-block: calc(var(--header-h) + var(--section-pt)) var(--section-pb);
  }

  .expertise-carousel__frame {
    height: 100%;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 24px;
  }

  /* Title + Read more: one block per card, cross-faded by the script.
     The items are absolute — the wrapper keeps a sized box (fits 4-line taglines). */
  .expertise-carousel__info {
    position: relative;
    width: 100%;
    min-height: 100px;
    flex: none;
    z-index: 20;
  }
  .expertise-carousel__info-item {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    transform: translateX(60px);
    /* Only the no-JS/initial state — the script kills this transition inline
       and scrubs opacity/transform straight from the scroll position. */
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    will-change: transform, opacity;
  }
  .expertise-carousel__info-item.is-active { opacity: 1; transform: translateX(0); pointer-events: auto; }
  .expertise-carousel__title { margin-bottom: 20px; }

  /* ONE card slot: cards stacked on top of each other; the script swaps them
     with a sequential fade from the scroll position. */
  .expertise-carousel__stage { position: relative; flex: 1; min-height: 0; z-index: 10; }
  .expertise-carousel__track { position: absolute; inset: 0; }
  .expertise-carousel__card {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 420px;      /* cap the card/image height (mobile + tablet) — tweak freely */
    opacity: 0;
    will-change: transform, opacity;   /* the fade engine scrubs these per frame */
  }
  .expertise-carousel__card:first-child { opacity: 1; }   /* no-JS fallback */

  /* Category list below the card — right-aligned. */
  .expertise-carousel__aside {
    position: relative;
    align-self: flex-end;
    flex: none;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .expertise-carousel__list { gap: 8px; }
}

@media (max-width: 1024.98px) and (prefers-reduced-motion: reduce) {
  .expertise-carousel__info-item { transition: opacity 0.3s ease; transform: none; }
  .expertise-carousel__card { transition: opacity 0.3s ease; }
}

/* Short windows in the fade band (e.g. a 900×600 browser window): shrink the
   fixed chrome so the card keeps a usable height inside the 100svh sticky. */
@media (max-width: 1024.98px) and (max-height: 700px) {
  .expertise-carousel__sticky { padding-block: calc(var(--header-h) + 16px) 24px; }
}

/* ── 3. DESKTOP (>= 1025px) — diagonal scroll carousel, scoped to .is-dcx ──
   The script sizes and moves the cards (width/height/transform/shadow/z-index
   are inline styles); this block only places the fixed pieces around them. */

.expertise-carousel.is-dcx {
  padding-inline: 0;          /* full-bleed stage — the engine positions in vw */
  isolation: isolate;         /* keep card z-indexes below the site header */
  /* Content edge shared with the rest of the site: --margin-primary from the
     viewport edge, or the centred .container column once the viewport is
     wider than --container-max — head, nav and meta all align to it. */
  --exp-edge: max(var(--margin-primary), calc((100vw - var(--container-max)) / 2 + var(--margin-primary)));
}

/* The fixed header slides out of the way while the carousel is pinned and
   returns once you scroll past the section. diagonal-carousel.js toggles the
   body class (desktop engine only); header.css transitions the transform. */
body.expertise-carousel-pinned .site-header {
  transform: translateY(-100%);
  pointer-events: none;
}
/* Pin height is set inline by the script: 100vh + one "step" per card switch. */
.expertise-carousel.is-dcx .expertise-carousel__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.expertise-carousel.is-dcx .expertise-carousel__frame { position: absolute; inset: 0; }

/* The mobile per-card text blocks are replaced by ONE head whose content the
   script swaps as the active card changes. */
.expertise-carousel.is-dcx .expertise-carousel__info { display: none; }
.expertise-carousel.is-dcx .expertise-carousel__head-wrap {
  display: block;
  position: absolute;
  left: var(--exp-edge);
  top: 50%;
  transform: translateY(-50%);
  /* Never let the head cross the big card's left edge (50vw − card half-width
     − 24px air). min(20vw, 28.46vh) mirrors the card sizing in the JS CFG:
     W/2 = min(cardW/2 · vw, cardMaxH/ratio/2 · vh) — update it if you change
     cardW (0.40), cardMaxH (0.74) or ratio (1.3). */
  max-width: min(26vw, calc(50vw - var(--exp-edge) - min(20vw, 28.46vh) - 24px));
  z-index: 400;
  pointer-events: none;       /* let scroll pass through; the link re-enables */
}
.expertise-carousel.is-dcx .expertise-carousel__head { will-change: transform, opacity; }
.expertise-carousel.is-dcx .expertise-carousel__head .small-link { pointer-events: auto; margin-top: 2px; }
.expertise-carousel__kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-body);
  opacity: 0.6;
  margin-bottom: 18px;
}
.expertise-carousel__head-body {
  margin: 0 0 24px;
  font-size: var(--body-sm);
  line-height: var(--body-sm-lh);
  font-weight: 300;
  color: var(--text-body);
  max-width: 30ch;
}

.expertise-carousel.is-dcx .expertise-carousel__card {
  left: 50%;
  top: 50%;
  will-change: transform;
  backface-visibility: hidden;
}
.expertise-carousel.is-dcx .expertise-carousel__media { will-change: transform; }

/* Right: category nav. The script glides opacity/position per frame, so the
   opacity transition is dropped here (it would lag one step behind). */
.expertise-carousel.is-dcx .expertise-carousel__aside {
  position: absolute;
  right: var(--exp-edge);
  top: 50%;
  transform: translateY(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.expertise-carousel.is-dcx .expertise-carousel__list {
  gap: 14px;
  align-items: flex-end;   /* every label flush against the same right edge */
}
.expertise-carousel.is-dcx .expertise-carousel__navbtn { padding: 2px 0; transition: color 0.2s ease; }
.expertise-carousel.is-dcx .expertise-carousel__navbtn:focus-visible {
  outline: 2px solid var(--text-title);
  outline-offset: 5px;
  border-radius: 3px;
}

/* Bottom left: "01 / 04" + progress bar. */
.expertise-carousel.is-dcx .expertise-carousel__meta {
  display: flex;
  position: absolute;
  left: var(--exp-edge);
  bottom: var(--margin-primary);   /* corner-symmetric with the left edge */
  z-index: 400;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-body);
}
.expertise-carousel__count { opacity: 0.7; }
.expertise-carousel__bar {
  display: block;
  width: 120px;
  height: 1px;
  background: var(--text-muted);
  position: relative;
  overflow: hidden;
}
.expertise-carousel__bar span {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: var(--text-title);
}

/* ── 4. FALLBACK (>= 1025px, no JS or "reduce motion") — static stacked list ── */

@media (min-width: 1025px) {
  .expertise-carousel:not(.is-dcx) { padding-block: 60px; }
  .expertise-carousel:not(.is-dcx) .expertise-carousel__info {
    max-width: 660px;
    margin-inline: auto;
  }
  .expertise-carousel:not(.is-dcx) .expertise-carousel__info-item { margin-bottom: 40px; }
  .expertise-carousel:not(.is-dcx) .expertise-carousel__track {
    display: grid;
    gap: 40px;
    justify-items: center;
  }
  .expertise-carousel:not(.is-dcx) .expertise-carousel__card {
    position: relative;
    width: min(660px, 100%);
    aspect-ratio: 660 / 850;
  }
  .expertise-carousel:not(.is-dcx) .expertise-carousel__aside { display: none; }
}
