/* ══════════════════════════════════════
   EXPAND OVERLAY (about, principles, sites, tools)
   The card grows from its own rect into a centred panel.
══════════════════════════════════════ */
.xp-wrap { position: relative; width: 100%; height: 100%; }
.xp-wrap > .bento-card { width: 100%; height: 100%; }
.xp-card--ghost { opacity: 0; pointer-events: none; }
.xp-card--was-open { animation: none; }

.xp-backdrop,
.cs-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-backdrop);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  animation: backdrop-in 0.3s ease forwards;
  touch-action: none;
}
.xp-backdrop--out,
.cs-backdrop--out { animation: backdrop-out 0.45s ease forwards; }
@keyframes backdrop-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { from { opacity: 1; } to { opacity: 0; } }

.xp-expanded {
  position: fixed;
  background: var(--color-surface-card);
  border-radius: 32px;
  border: 1px solid var(--color-border-card);
  box-shadow:
    0 2px 200px var(--color-shadow-card-expanded),
    inset 0 1px 0 var(--color-card-inset-top),
    inset 0 -1px 0 var(--color-card-inset-bottom);
  z-index: 300;
  overflow: hidden;
  isolation: isolate;
  transition: background 0.5s ease, border-color 0.3s ease;
}
.xp-expanded::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--card-grain-image);
  background-size: 180px 180px;
  opacity: var(--card-grain-opacity);
  pointer-events: none;
  z-index: 0;
}
.xp-expanded--settled {
  transition:
    left   0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    top    0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    width  0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    height 0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    background 0.5s ease,
    border-color 0.3s ease;
}

.xp-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 40px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  scrollbar-width: thin;
}
.xp-inner--center { justify-content: center; padding: 40px 56px; }

.xp-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.xp-expanded--settled .xp-content { transition: opacity 0.3s ease 0.38s; opacity: 1; }
.xp-expanded--closing .xp-content { opacity: 0; transition: opacity 0.1s ease; }

.xp-shrink-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: var(--color-surface-card-white);
  border: none;
  border-radius: 100px;
  box-shadow: 0 2px 40px var(--color-shadow-action-icon);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.xp-shrink-btn img { filter: var(--filter-action-icon); }

/* The flying avatar travels between the card and the panel */
.xp-fly {
  position: fixed;
  object-fit: cover;
  z-index: 400;
  pointer-events: none;
}

/* ══════════════════════════════════════
   CASE STUDY OVERLAY
   Card → fullscreen, its media flies to the hero slot.
══════════════════════════════════════ */
.cs-card-wrapper { position: relative; width: 100%; height: 100%; }
.cs-card-wrapper > .bento-card { width: 100%; height: 100%; }
.cs-card--ghost { opacity: 0; pointer-events: none; }
.cs-card--was-open { animation: none; }

.cs-expanded {
  position: fixed;
  background: var(--color-bg-body);
  border-radius: 32px;
  z-index: 300;
  overflow: hidden;
  transition: background 0.5s ease;
}
.cs-expanded--settled {
  border-radius: 0;
  transition:
    left          0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    top           0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    width         0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    height        0.7s cubic-bezier(0.34, 1.1, 0.64, 1),
    border-radius 0.7s cubic-bezier(0.34, 1.1, 0.64, 1);
}

.cs-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 36px;
  z-index: 40;
  pointer-events: none;
}
.cs-back-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--color-border-card);
  background: color-mix(in srgb, var(--color-surface-nav) 62%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  color: var(--color-text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, background 0.2s ease;
}
.cs-back-btn:hover {
  border-color: var(--color-primary);
  transform: translateX(-2px);
}
.cs-header-close {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  background: var(--color-surface-card-white);
  border: 1px solid var(--color-border-card);
  border-radius: 100px;
  box-shadow: 0 6px 24px -8px var(--color-shadow-card-expanded);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}
.cs-header-close:hover { transform: scale(1.06); }
.cs-header-close img { filter: var(--filter-action-icon); }

.cs-expanded-inner {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.cs-expanded-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  opacity: 0;
  transition: opacity 0.25s ease;
  padding-bottom: 120px;
}
.cs-expanded--settled .cs-expanded-content { transition: opacity 0.3s ease 0.38s; opacity: 1; }
.cs-expanded--closing .cs-expanded-content { opacity: 0; transition: opacity 0.1s ease; }

.cs-hero-video {
  display: block;
  border-radius: 32px;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 40px;
  background: var(--color-surface-card-dark);
  transition: opacity 0.2s ease;
}

.cs-back-to-top {
  position: absolute;
  bottom: 32px;
  right: 32px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: 100px;
  border: none;
  background: var(--color-surface-action-icon);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 40px var(--color-shadow-action-icon);
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.5s ease;
  cursor: pointer;
}
.cs-back-to-top--visible { opacity: 1; transform: scale(1); pointer-events: auto; }
.cs-back-to-top:hover  { transform: scale(1.08); }
.cs-back-to-top:active { transform: scale(0.95); }

.cs-video-fly {
  position: fixed;
  object-fit: cover;
  z-index: 400;
  pointer-events: none;
  background: var(--color-surface-card-dark);
}

/* ── Reading row: Detailed / TL;DR ── */
.cs-readbar {
  position: sticky;
  top: 40px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 8px;
  width: fit-content;
}
.tldr-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 100px;
  background: var(--color-surface-nav-blur);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: fit-content;
  transition: background 0.5s ease;
}
.tldr-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 6px);
  border-radius: 100px;
  background: var(--color-surface-nav);
  box-shadow: 0 0 40px var(--color-shadow-nav);
  pointer-events: none;
  transition: transform 0.62s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tldr-bar--tldr .tldr-indicator { transform: translateX(calc(100% + 4px)); }
.tldr-pill {
  position: relative;
  z-index: 1;
  padding: 8px 24px;
  border-radius: 100px;
  border: none;
  background: transparent;
  font-size: var(--action-size);
  font-weight: var(--action-weight);
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}
.tldr-pill:not(.tldr-pill--active):hover { color: var(--color-primary); }

.tldr-collapsible {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 0.55s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}
.tldr-collapsible > * { overflow: hidden; }
.tldr-collapsible--hidden { grid-template-rows: 0fr; opacity: 0; }

@media (min-width: 769px) {
  .cs-header-close { display: none; }
  .cs-expanded .cs-readbar {
    top: 25px;
    z-index: 355;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
  }
  body.nav-hidden .cs-expanded .cs-readbar {
    transform: translateY(-140%);
    opacity: 0;
    pointer-events: none;
  }
}

/* ── Case study body ── */
.cs-body {
  max-width: var(--cs-column);
  width: 100%;
  padding: 0 24px;
  margin-top: 56px;
}
.cs-kicker {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-ultra);
  text-transform: uppercase;
  color: var(--color-text-primary);
  opacity: 0.4;
  margin-bottom: 12px;
}
.cs-title {
  font-size: var(--cs-title-size);
  font-weight: var(--weight-bold);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  margin: 0 0 24px;
  transition: color 0.5s ease;
}
.cs-section-title {
  font-size: var(--cs-section-size);
  font-weight: var(--weight-bold);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  margin: 72px 0 8px;
  transition: color 0.5s ease;
}
.cs-section-kicker {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-ultra);
  text-transform: uppercase;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 72px;
  width: fit-content;
}
.cs-section-kicker + .cs-section-title { margin-top: 6px; }
.cs-body-text {
  font-size: var(--cs-body-size);
  line-height: var(--leading-relaxed);
  color: var(--color-text-body);
  margin: 4px 0 24px;
  transition: color 0.5s ease;
}
.cs-body-list {
  padding-left: 24px;
  margin: 0 0 24px;
  font-size: var(--cs-body-size);
  line-height: var(--leading-relaxed);
  color: var(--color-text-body);
}
.cs-body-list li { margin: 0 0 6px; }

/* Numbered pipeline stages */
.cs-stages {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 24px 0 8px;
  counter-reset: stage;
}
.cs-stage {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 4px 16px;
  padding: 20px 24px;
  border-radius: 20px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-card);
  counter-increment: stage;
  transition: background 0.5s ease;
}
.cs-stage::before {
  content: counter(stage, decimal-leading-zero);
  grid-row: span 2;
  font-weight: var(--weight-bold);
  font-size: var(--text-4xl);
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.cs-stage b {
  -webkit-text-fill-color: currentColor;
  background: none;
  font-weight: var(--weight-bold);
  font-size: var(--text-3xl);
}
.cs-stage span { font-size: var(--text-xl); line-height: var(--leading-relaxed); opacity: 0.75; }

/* Stat row */
.cs-stat-row {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  padding: 32px 0 24px;
}
.cs-stat-item { padding-right: 28px; }
.cs-stat-item + .cs-stat-item {
  padding-left: 28px;
  padding-right: 0;
  border-left: 1px solid var(--color-text-muted);
}
.cs-stat-num {
  font-size: var(--text-9xl);
  font-weight: var(--weight-bold);
  line-height: 1.1;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.cs-stat-lbl { font-size: var(--text-base); color: var(--color-text-body); line-height: var(--leading-normal); }

.cs-link {
  color: var(--color-text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}
.cs-link:hover { opacity: 0.6; }

/* Media: a wide film-strip grid at the column's edge, each item its true shape */
.cs-media {
  width: min(1040px, calc(100vw - 48px));
  margin-top: 32px;
  columns: 3 280px;
  column-gap: 16px;
}
.cs-media--single { columns: 1; width: min(720px, calc(100vw - 48px)); }
.cs-media--pair   { columns: 2 280px; width: min(860px, calc(100vw - 48px)); }
/* a lone portrait piece is held to 80% of the screen's height, centred */
.cs-media--single .cs-media-item { max-width: min(100%, calc(80vh * var(--r, 1.78))); margin-inline: auto; }
.cs-media-item {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  background: var(--color-surface-skeleton);
}
.cs-media-item video,
.cs-media-item img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}
.cs-media-cap {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  padding: 6px 12px;
  border-radius: 100px;
  width: fit-content;
  max-width: calc(100% - 24px);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  background: rgba(14, 14, 24, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
a.cs-media-item { display: block; }

/* Scroll reveal for anything drawn into the case study */
.cs-expanded-content .cs-reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}
.cs-expanded-content .cs-reveal.cs-img-visible { opacity: 1; transform: translateY(0); }

.cs-cta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cs-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: var(--action-size);
  font-weight: var(--action-weight);
  color: var(--color-text-primary);
  text-decoration: none;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-card);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.5s ease;
}
.cs-cta:hover { transform: translateY(-2px); }
.cs-cta:active { transform: scale(0.95); }
.cs-cta img { width: 14px; height: 14px; filter: var(--filter-action-icon); }

@media (max-width: 600px) {
  .cs-stat-row { grid-template-columns: 1fr; }
  .cs-stat-item { padding-right: 0; padding-bottom: 24px; }
  .cs-stat-item + .cs-stat-item {
    padding-left: 0;
    padding-top: 24px;
    border-left: none;
    border-top: 1px solid var(--color-text-muted);
  }
}
