/* ============================================================
   Case Study Slider
   Replicates the DMA homepage case study module as a
   Gutenberg block.  GSAP drives all transitions; this file
   handles layout, typography, and static visual state only.
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────── */
.dma-cs-block {
  --dma-cs-accent:   #e4002b;
  --dma-cs-teal:     #007d8a;
  --dma-cs-charcoal: #646569;
  --dma-cs-dark:     #383838;
  --dma-cs-img-ar:   53.9%;   /* image aspect ratio (original: height 0; padding-top 53.9%) */
}

/* ── Block shell ─────────────────────────────────────────────── */
.dma-cs-block {
  overflow: hidden;
  position: relative;
  /*
   * Explicit stacking: markets-services-slider's triangle watermark
   * (see .dma-ms-block__triangle) deliberately bleeds down past its
   * own block's bottom edge into whatever section follows, relying on
   * that section's own background to cover it. This block's own
   * background was removed on request, so instead of leaning on
   * implicit DOM-order painting (both blocks were z-index:auto — fine
   * until either one gains its own stacking context and flips the
   * order), give this block an explicit higher stacking level so its
   * content always paints above that bleed-through. `isolation: isolate`
   * forces a new stacking context unconditionally (belt-and-suspenders
   * alongside position+z-index, which already does this per spec) so
   * nothing inside this block can ever be reached from outside it.
   */
  isolation: isolate;
  z-index: 2;
}
.wp-block-pro-design-case-study-slider.alignfull,
.dma-cs-block.alignfull {
  margin-left:  calc(-1 * var(--wp--style--root--padding-left,  0px));
  margin-right: calc(-1 * var(--wp--style--root--padding-right, 0px));
  max-width: none;
  width: 100%;
}

/* ── Inner container ─────────────────────────────────────────── */
/*
 * padding-top: leaves room for the number that bleeds ~96px above the image.
 * padding-right: accommodates the tab buttons pushed outside the right edge.
 */
.dma-cs-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 130px 80px 80px 60px;
}

/* ── Main wrapper (positioning context for the tab anchor) ───── */
.dma-cs-main {
  position: relative;
}

/* ── Slides — CSS grid stacking ──────────────────────────────── */
/*
 * All slides occupy the same grid cell; GSAP controls opacity.
 * The grid naturally sizes to the tallest slide, keeping layout stable
 * throughout crossfade transitions (all posts share an identical template).
 */
.dma-cs-slides {
  display: grid;
  grid-template-columns: 1fr;
  position: relative;
  overflow: visible;
}
.dma-cs-slide {
  grid-area: 1 / 1;
  opacity: 0;           /* GSAP reveals on enter-viewport */
  pointer-events: none;
  position: relative;
}
.dma-cs-slide.is-active {
  pointer-events: auto;
}

/* ── Large outlined number ───────────────────────────────────── */
/*
 * Wrapper div is absolutely positioned to bleed above and left of
 * the image frame. clip-path: inset(0 100% 0 0) hides it off-right;
 * GSAP animates to inset(0 0% 0 0) for the wipe-in reveal.
 * The inner SVG uses fill:none / stroke:currentColor for the outline.
 */
.dma-cs-num {
  position: absolute;
  top: -96px;
  left: -40px;
  z-index: 2;
  width: clamp(180px, 26vw, 340px);
  pointer-events: none;
  user-select: none;
  /*
   * Original site renders these at opacity:0.14 with black stroke.
   * Using rgba(0,0,0,0.35) gives the same subtlety but reads
   * more clearly on the white block background.
   */
  color: rgba(0, 0, 0, 0.35);
  clip-path: inset(0 100% 0 0);  /* GSAP animates to inset(0 0% 0 0) */
}
.dma-cs-num svg,
.dma-cs-num img {
  display: block;
  width: 100%;
  height: auto;
}
/* CSS text-stroke fallback when SVG file is missing */
.dma-cs-num__fallback {
  display: block;
  font-size: clamp(100px, 14vw, 210px);
  font-weight: 900;
  font-family: 'mr-eaves-modern', Arial Black, sans-serif;
  color: transparent;
  -webkit-text-stroke: 2px var(--dma-cs-charcoal);
  text-stroke: 2px var(--dma-cs-charcoal);
  line-height: 1;
}

/* ── Image frame ─────────────────────────────────────────────── */
/*
 * Intrinsic aspect-ratio box: height:0 + padding-top creates a container
 * that is always (--dma-cs-img-ar) tall relative to its own width.
 * overflow: visible so the title and number can bleed outside.
 */
.dma-cs-img-frame {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: var(--dma-cs-img-ar);
  overflow: visible;
  /*
   * Solid backing for the dimmed image below (see .dma-cs-img's
   * opacity:0.3) — without this, whatever sits behind the frame shows
   * straight through the see-through photo. That used to always be
   * .dma-cs-block's own opaque white fill; now that the block itself
   * is deliberately transparent (so markets-services-slider's
   * parallax triangle can bleed through the surrounding empty space),
   * the frame needs its own backing so the triangle doesn't wash
   * across the photo itself — it should still show through everywhere
   * OUTSIDE this frame.
   */
  background: #fff;
}

/* ── Featured image ──────────────────────────────────────────── */
.dma-cs-img {
  position: absolute;
  inset: 0;
  background: no-repeat center / cover;
  opacity: 0.3;
  filter: grayscale(100%);
}
.dma-cs-img--placeholder {
  background-color: #c8c9ca;
}

/* ── Progress bar ────────────────────────────────────────────── */
/*
 * A 5 px strip on the far right edge of the image.
 * Track (dark underlay) is always full-height.
 * Red bar fills TOP-to-BOTTOM: transform-origin is top center,
 * GSAP animates scaleY 0 → 1 over autoplaySpeed seconds.
 */
.dma-cs-bar-track {
  position: absolute;
  right: 0; top: 0;
  width: 5px; height: 100%;
  background: var(--dma-cs-dark);
  z-index: 2;
}
.dma-cs-bar {
  position: absolute;
  right: 0; top: 0;
  width: 5px; height: 100%;
  background: var(--dma-cs-accent);
  transform: scaleY(0);
  transform-origin: top center;
  z-index: 3;
}

/* ── Body — title + excerpt + button as one connected block ──── */
/*
 * Negative margin-top pulls the entire body up over the image bottom.
 * -41px matches the original DMA site's title overlap value.
 * Tweak this per breakpoint below as needed.
 */
.dma-cs-body {
  position: relative;
  z-index: 1;
  margin-top: -41px;
}

.dma-cs-title {
  font-size: clamp(28px, 4.5vw, 62px);
  line-height: 1.05;
  font-weight: 700;
  color: var(--dma-cs-teal);
  margin: 0 0 0.25em;
  padding: 0 16px;
}
.dma-cs-title a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.dma-cs-title a:hover,
.dma-cs-title a:focus {
  color: inherit;
  text-decoration: none;
}

/* ── Excerpt + CTA row ───────────────────────────────────────── */
.dma-cs-foot {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 16px;
}
.dma-cs-excerpt {
  flex: 1;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.4;
  color: var(--dma-cs-charcoal);
  margin: 0;
}
.dma-cs-cta {
  flex-shrink: 0;
}

/* ── Read More button ────────────────────────────────────────── */
/*
 * Two-tone hover: gradient-fill slides up from bottom on hover
 * (background-position technique — no height change, no reflow).
 * border-bottom: 7px matches the original DMA button aesthetic.
 */
.dma-cs-btn {
  display: inline-block;
  flex-shrink: 0;
  border: 2px solid var(--dma-cs-accent);
  border-bottom-width: 7px;
  border-radius: 3px;
  padding: 4px 24px;
  font-weight: 700;
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1.4;
  color: #007b8a !important;
  text-decoration: none !important;
  background-image: linear-gradient(to bottom, #fff 50%, var(--dma-cs-accent) 50%);
  background-size: 100% 200%;
  background-position: 0 0;
  transition: background-position 0.35s ease, color 0.35s ease;
  white-space: nowrap;
}
.dma-cs-btn:hover {
  background-position: 0 100%;
  color: #fff !important;
}
.dma-cs-btn:focus-visible {
  outline: 2px solid var(--dma-cs-accent);
  outline-offset: 3px;
}

/* ── Tab anchor ghost box ────────────────────────────────────── */
/*
 * padding-top mirrors the image aspect ratio, giving the ghost box
 * the same computed height as the image frame.  The tabs are then
 * absolutely positioned inside it at top:50%, pushed outside the
 * right edge of .dma-cs-main via translateX(100%).
 *
 * On desktop this is position:absolute (out of flow, overlays slides).
 * On mobile it becomes position:static so tabs appear below the slides.
 */
.dma-cs-tab-anchor {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 0;
  padding-top: var(--dma-cs-img-ar);
  pointer-events: none;
}
.dma-cs-tabs {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateX(100%) translateY(-50%);
  width: 60px;
  display: flex;
  flex-direction: column;
  pointer-events: all;
}
.dma-cs-tab {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  border-radius: 0 !important;
  padding: 10px 0 10px 16px;
  font-family: 'space-mono', 'Space Mono', monospace;
  font-size: clamp(16px, 2vw, 26px);
  line-height: 1.2;
  color: var(--dma-cs-charcoal);
  cursor: pointer;
  text-align: left;
  transition: color 0.2s;
  white-space: nowrap;
}
.dma-cs-tab:hover,
.dma-cs-tab:focus:not(:focus-visible) {
  color: #555659; /* charcoal #646569 darkened 15% */
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
}
.dma-cs-tab.is-active,
.dma-cs-tab.is-active:hover {
  color: var(--dma-cs-accent);
  font-weight: 700;
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
}
.dma-cs-tab:focus-visible {
  outline: 2px solid var(--dma-cs-accent);
  outline-offset: 2px;
  background: none !important;
}

/* ── Empty state ─────────────────────────────────────────────── */
.dma-cs-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--dma-cs-charcoal);
  font-size: 16px;
}
.dma-cs-empty a {
  color: var(--dma-cs-accent);
  text-decoration: underline;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991px) {
  .dma-cs-inner {
    padding: 90px 20px 60px;
  }
  /* Tab anchor collapses; tabs reflow below the slides */
  .dma-cs-tab-anchor {
    position: static;
    height: auto;
    padding-top: 0;
    pointer-events: all;
  }
  .dma-cs-tabs {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: center;
    gap: 24px;
    width: auto;
    padding: 20px 0 0;
  }
  .dma-cs-tab {
    padding: 6px 8px;
  }
  .dma-cs-num {
    width: clamp(120px, 22vw, 200px);
    top: -56px;
    left: -20px;
  }
}
@media (max-width: 767px) {
  .dma-cs-inner {
    padding: 80px 16px 48px;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .dma-cs-btn { transition: none; }
  .dma-cs-tab { transition: none; }
  .dma-cs-bar { transition: none; }
}
