/* ============================================================
   Case Studies page (/case-studies) — layout CSS.

   Reuses the shared design system from ec-styles.css in full: --green/
   --white/--black/--mid/--dark/--gray, --serif/--sans/--mono, .wrap,
   .eyebrow, h1-h4, p/p.lead, .priv-note, .btn/.btn.ghost,
   .reveal/.reveal-stagger, .magnetic-cta, .progress-bar, .nav, .footer.
   This file only adds the case-studies-specific layout: the intro, the
   horizontal carousel, the compact card face, and the expanded editorial
   card (video column + 3-column results grid). No new color or font
   tokens are introduced. Breakpoints mirror the values already used
   throughout ec-styles.css (1180 / 1080 / 1000 / 900 / 820 / 560 / 480).
   ============================================================ */

.cs-app { padding-top: 0; }

/* ---------------- INTRO ---------------- */
.cs-intro {
  padding: clamp(120px, 12vw, 168px) 0 clamp(56px, 6vw, 84px);
  background: linear-gradient(180deg, #050505 0%, #000 100%);
}
.cs-intro-inner { max-width: 760px; }
.cs-intro-inner h1 { margin: 18px 0 22px; font-size: clamp(44px, 6.4vw, 84px); }
.cs-intro-inner h1 em { font-style: italic; color: var(--green); }
.cs-intro-inner .lead { margin-bottom: 22px; color: #d6d6d6; }
.cs-disclaimer { margin: 0; }

/* ---------------- CAROUSEL SHELL ---------------- */
.cs-carousel-section {
  position: relative;
  padding: 0 0 clamp(64px, 7vw, 108px);
  overflow: visible;
}
/* Positioning context for the prev/next arrow buttons. They sit as
   SIBLINGS of .cs-carousel-viewport (not inside it) so the viewport's
   own edge-fade mask-image never clips them. */
.cs-carousel-viewport-wrap { position: relative; }
.cs-carousel-viewport {
  overflow: hidden;
  /* Soft edge fade so cards feel like they drift in/out rather than
     hard-clipping at the viewport edge. */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%);
  padding: 12px 0 28px;
}
.cs-carousel-track {
  display: flex;
  align-items: stretch;
  gap: 28px;
  width: max-content;
  padding-left: var(--edge);
  will-change: transform;
  cursor: grab;
  touch-action: pan-y; /* let vertical page-scroll pass through; only horizontal drags are captured for carousel nav */
}
/* The ambient drift + arrow/drag navigation are all driven from
   case-studies.js via a single requestAnimationFrame loop writing an
   inline `transform: translateX()` (an unbounded offset rendered modulo
   one full copy of the card set, so the doubled/cloned content below
   always wraps seamlessly in either direction, forever — no CSS
   @keyframes animation is used, since a CSS animation and a JS-driven
   inline transform can't both authoritatively own `transform` at once,
   and only the JS model supports infinite arrow-driven wraparound and
   resuming the drift mid-position after a pause). */
.cs-carousel-track.is-dragging { cursor: grabbing; }
.cs-carousel-track img { -webkit-user-drag: none; user-select: none; }
.cs-carousel-hint {
  text-align: center;
  color: var(--gray);
  font-size: 12px;
  letter-spacing: 0.14em;
  margin-top: -8px;
}

/* Prev/next arrows: reuse the shared .scroll-arrow-btn component from
   ec-styles.css (same look as the homepage persona-section arrows).
   Pulled slightly further in from the true edge than the persona
   version since this section has no .wrap side padding of its own. */
.cs-carousel-viewport-wrap .scroll-arrow-btn.prev { left: 4px; }
.cs-carousel-viewport-wrap .scroll-arrow-btn.next { right: 4px; }
@media (max-width: 560px) {
  /* Edge-fade mask already signals more content off-screen, and the
     track remains fully drag/swipe-scrollable without the arrows. */
  .cs-carousel-viewport-wrap .scroll-arrow-btn { display: none; }
}

/* ---------------- COMPACT CARD FACE ---------------- */
.cs-card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(300px, 27vw, 372px);
}
.cs-card-clone { pointer-events: none; }

.cs-card-toggle {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 22px;
  overflow: hidden;
  background: #0d0f11;
  border: 1px solid rgba(255,255,255,0.08);
  transition: transform .5s cubic-bezier(.2,.7,.2,1), opacity .4s ease, border-color .3s ease;
  cursor: pointer;
}
.cs-card-toggle:hover,
.cs-card-toggle:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(90,185,54,0.4);
}
.cs-card-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* Cards other than the one being expanded recede/fade while a case
   study is open (spec: "other cards recede or fade"). */
.cs-carousel-section.has-active .cs-card:not(.is-active) .cs-card-toggle {
  opacity: 0.28;
  transform: scale(0.96);
  filter: blur(1px);
}
.cs-card.is-active .cs-card-toggle { visibility: hidden; }

.cs-card-face-media {
  position: relative;
  aspect-ratio: 9 / 13;
  background: #000;
  overflow: hidden;
}
.cs-card-face-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cs-card-play-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  backdrop-filter: blur(4px);
}
.cs-card-play-badge svg { width: 18px; height: 18px; }
.cs-card-num {
  position: absolute;
  top: 14px; left: 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--white);
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 4px 10px;
}
.cs-card-face-body { padding: 18px 20px 22px; }
.cs-card-face-category {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
  /* Some category labels (e.g. "Business Turnaround & Market Penetration")
     wrap to 2 lines on narrower cards while shorter ones fit on 1;
     reserve room for 2 so this doesn't reintroduce height variance. */
  line-height: 1.35;
  min-height: calc(1.35em * 2);
}
.cs-card-face-headline {
  font-family: var(--serif);
  font-size: clamp(21px, 2vw, 25px);
  line-height: 1.14;
  color: var(--white);
  margin-bottom: 14px;
  /* Reserve room for 2 lines (the longest of the 6 headlines wraps to 2;
     shorter ones only use 1) so every compact card renders at the same
     total height regardless of how many lines its own headline needs. */
  min-height: calc(1.14em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.cs-card-face-metric { display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.cs-card-face-metric-value { font-family: var(--serif); font-size: 22px; color: var(--white); }
.cs-card-face-metric-label {
  font-size: 12.5px;
  color: var(--gray);
  line-height: 1.4;
  /* Same reasoning as .cs-card-face-headline above: the longest metric
     label (Case Study 06) wraps to 2 lines while shorter ones fit on 1,
     so reserve room for 2 lines on every card to keep heights equal. */
  min-height: calc(1.4em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* ---------------- EXPANDED PANEL (shared by all 6) ---------------- */
/* Rendered in normal flow (not display:none) so all copy stays crawlable
   at all times, per the SEO requirement. Visually collapsed by default
   via height:0/opacity:0/pointer-events:none; JS toggles `.is-open` +
   moves the node into the fixed-position stage for the FLIP animation. */
.cs-card-panel {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 94vw;
  max-width: 1320px;
  max-height: 88vh;
  background: #0a0b0c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 26px;
  box-shadow: 0 60px 140px -30px rgba(0,0,0,0.75);
  display: flex;
  overflow: hidden;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0) scale(1);
  will-change: transform, opacity;
  transition: opacity .32s ease;
}
.cs-card-panel.is-open {
  opacity: 1;
  pointer-events: auto;
}
/* When not open and not currently mid-animation, keep fully out of the
   way visually + from screen-reader focus order without removing the
   text nodes from the document (still indexable). */
.cs-card-panel:not(.is-open):not(.is-animating) {
  position: static;
  width: 100%;
  max-width: none;
  max-height: 0;
  height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  margin: 0;
}

.cs-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(3px);
  z-index: 390;
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s ease;
}
.cs-backdrop.is-visible { opacity: 1; pointer-events: auto; }

/* Left: video column, ~28-30% width */
.cs-card-media {
  flex: 0 0 29%;
  max-width: 29%;
  position: relative;
  background: #000;
  border-radius: 26px 0 0 26px;
  overflow: hidden;
}
.cs-video, .cs-media-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cs-media-placeholder img { width: 100%; height: 100%; object-fit: cover; }

/* Fullscreen: switch from "cover" (crops to fill the card's box) to
   "contain" (letterboxed, nothing cropped) so the entire 9:16 video is
   visible instead of being cut off top/bottom against a 16:9 screen.
   IMPORTANT: these must be four SEPARATE rules, not one comma-separated
   selector list. A browser that doesn't recognize one of the vendor-
   prefixed pseudo-classes (e.g. Chromium doesn't know :-moz-full-screen)
   treats the ENTIRE selector list as invalid and drops the whole rule
   per the CSS spec -- which was silently defeating this fix even in
   browsers that DO support the standard :fullscreen. */
.cs-video:fullscreen {
  object-fit: contain;
  background: #000;
  width: 100%;
  height: 100%;
}
.cs-video:-webkit-full-screen {
  object-fit: contain;
  background: #000;
  width: 100%;
  height: 100%;
}
.cs-video:-moz-full-screen {
  object-fit: contain;
  background: #000;
  width: 100%;
  height: 100%;
}
.cs-video:-ms-fullscreen {
  object-fit: contain;
  background: #000;
  width: 100%;
  height: 100%;
}

/* Right: info column, ~70-72% width */
.cs-card-info {
  flex: 1 1 auto;
  min-width: 0;
  padding: clamp(28px, 3.4vw, 44px) clamp(28px, 3.6vw, 48px);
  overflow-y: auto;
  position: relative;
}

.cs-close-btn {
  position: absolute;
  top: 18px; right: 18px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.4);
  transition: border-color .25s, color .25s;
  z-index: 5;
}
.cs-close-btn span[aria-hidden] { font-size: 18px; line-height: 1; }
.cs-close-btn:hover, .cs-close-btn:focus-visible { border-color: var(--green); color: var(--green); }

.cs-info-category {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 10px;
  padding-right: 90px;
}
.cs-info-headline {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.08;
  color: var(--white);
  margin-bottom: 22px;
  max-width: 44ch;
}

/* Results-at-a-glance band */
.cs-results-panel {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 18px 20px 20px;
  margin-bottom: 28px;
}
.cs-results-heading {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 14px;
}
.cs-results-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}
.cs-metric {
  padding: 4px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 1px solid rgba(255,255,255,0.12);
}
.cs-metric:first-child { border-left: none; padding-left: 4px; }
.cs-metric-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--green);
  color: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.cs-metric-icon svg { width: 16px; height: 16px; }
.cs-metric-value { font-family: var(--serif); font-size: clamp(19px, 1.8vw, 24px); color: var(--white); line-height: 1.15; }
.cs-metric-label { font-size: 12.5px; color: var(--gray); line-height: 1.4; }

/* 3-column editorial grid */
.cs-editorial-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 clamp(20px, 2.6vw, 36px);
}
.cs-col { border-left: 1px solid rgba(255,255,255,0.08); padding-left: clamp(20px, 2.6vw, 36px); display: flex; flex-direction: column; gap: 22px; }
.cs-col-1 { border-left: none; padding-left: 0; }

.cs-block-heading {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white);
  margin-bottom: 8px;
}
.cs-block-icon { color: var(--green); display: inline-flex; }
.cs-block-icon svg { width: 15px; height: 15px; }
.cs-block p { font-size: 14.5px; line-height: 1.6; color: #b9b9b9; max-width: none; margin-bottom: 8px; }
.cs-block p:last-child { margin-bottom: 0; }

.cs-snap-row { font-size: 14px; margin-bottom: 4px; color: #b9b9b9; }
.cs-snap-label { color: var(--gray); }

.cs-bullets { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.cs-bullets li {
  font-size: 14px;
  line-height: 1.5;
  color: #c7c7c7;
  padding-left: 16px;
  position: relative;
}
.cs-bullets li::before {
  content: '';
  position: absolute;
  left: 0; top: 8px;
  width: 6px; height: 1px;
  background: var(--green);
}

.cs-block-special { padding: 14px 16px; background: rgba(90,185,54,0.06); border: 1px solid rgba(90,185,54,0.18); border-radius: 12px; }

.cs-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.cs-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green);
  border: 1px solid rgba(90,185,54,0.4);
  border-radius: 999px;
  padding: 5px 12px;
}

.cs-cta { margin-top: auto; align-self: flex-start; }

/* ---------------- RESPONSIVE ---------------- */
/* Large laptop: ~2.5-3 visible */
@media (max-width: 1180px) {
  .cs-editorial-grid { gap: 0 22px; }
  .cs-card { width: clamp(280px, 30vw, 340px); }
}

/* Tablet ~2 visible + editorial grid collapses to a readable 2-col */
@media (max-width: 1000px) {
  .cs-card-panel { flex-direction: column; max-height: 92vh; }
  .cs-card-media { flex: 0 0 260px; max-width: none; width: 100%; height: 260px; border-radius: 26px 26px 0 0; }
  .cs-card-info { padding: 24px 24px 32px; }
  .cs-info-category { padding-right: 0; margin-top: 44px; }
  .cs-editorial-grid { grid-template-columns: 1fr 1fr; }
  .cs-col-3 { grid-column: 1 / -1; border-left: none; padding-left: 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.08); }
}

@media (max-width: 900px) {
  .cs-card { width: clamp(260px, 62vw, 320px); }
  .cs-carousel-track { gap: 20px; }
}

/* Mobile ~1 visible, single-column editorial grid, order per spec */
@media (max-width: 560px) {
  .cs-card { width: 78vw; max-width: 320px; }
  .cs-card-panel { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; top: 0; left: 0; right: 0; bottom: 0; margin: 0; }
  .cs-card-media { height: 220px; border-radius: 0; }
  .cs-editorial-grid { grid-template-columns: 1fr; }
  .cs-col { border-left: none; padding-left: 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.08); }
  .cs-col-1 { padding-top: 0; border-top: none; }
  .cs-close-btn { top: 12px; right: 12px; }
  .cs-info-category { margin-top: 40px; }
  .cs-results-row { grid-template-columns: 1fr; gap: 14px; }
  .cs-metric { border-left: none; padding-left: 4px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.1); }
  .cs-metric:first-child { border-top: none; padding-top: 4px; }
}

@media (max-width: 480px) {
  .cs-intro-inner h1 { font-size: clamp(36px, 9vw, 48px); }
}

/* ---------------- REDUCED MOTION ---------------- */
/* Ambient drift itself is disabled in JS (case-studies.js checks
   prefers-reduced-motion and sets driftPxPerMs = 0), not here. */
@media (prefers-reduced-motion: reduce) {
  .cs-card-toggle, .cs-card-panel, .cs-backdrop { transition-duration: .12s !important; }
  .cs-card-toggle:hover, .cs-card-toggle:focus-visible { transform: none; }
  .cs-carousel-section.has-active .cs-card:not(.is-active) .cs-card-toggle { transform: none; filter: none; }
}

/* Fixed-position stage that hosts an open card's panel (see
   case-studies.js openCard/closeCard) — invisible/inert while empty. */
#csStage { position: relative; z-index: 400; }
