/* ============================================================
   case-study.css — overlay case study layout
   ============================================================ */

body.case-study-open {
  overflow: hidden;
}

.case-study-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.case-study-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  animation: cs-backdrop-in 280ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@media (prefers-color-scheme: dark) {
  .case-study-backdrop {
    background: rgba(0, 0, 0, 0.55);
  }
}

@keyframes cs-backdrop-in {
  to { opacity: 1; }
}

.case-study {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 320ms cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.case-study.is-open {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .case-study-backdrop { animation: none; opacity: 1; }
  .case-study { transition: none; opacity: 1; transform: none; }
}

.case-study__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 28px 80px;
}

@media (max-width: 600px) {
  .case-study__inner { padding: 28px 20px 56px; }
}

.case-study__back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 40px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--t);
}

.case-study__back:hover { color: var(--ink); }

.cs-page-title {
  font-size: clamp(36px, 6vw, 52px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 24px;
}

.cs-intro {
  margin-bottom: 8px;
}

/* ---- Sections ---- */
.cs-section {
  margin-top: 72px;
}

.cs-section--compact {
  margin-top: 56px;
}

/* ---- Scroll reveal ---- */
.cs-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 560ms cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 560ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.cs-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .cs-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---- Placeholders ---- */
.cs-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--t), transform var(--t);
}

@media (hover: hover) {
  .cs-ph:hover {
    border-color: var(--ink-3);
    transform: translateY(-2px);
  }
}

.cs-ph__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  user-select: none;
}

.cs-ph--challenge { aspect-ratio: 3 / 4; width: 100%; min-height: 320px; }
.cs-ph--gallery { aspect-ratio: 16 / 10; width: 100%; }

/* ---- Split (challenge) ---- */
.cs-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

@media (max-width: 768px) {
  .cs-split { grid-template-columns: 1fr; gap: 28px; }
}

.cs-split__media {
  overflow: hidden;
  aspect-ratio: 3 / 4;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t), transform var(--t);
}

.cs-split__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

@media (hover: hover) {
  .cs-split__media:hover {
    border-color: var(--ink-3);
    transform: translateY(-2px);
  }
}

.cs-prose {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

.cs-prose + .cs-prose {
  margin-top: 16px;
}

/* ---- Role cards ---- */
.cs-role-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 80px;
  gap: 12px;
}

@media (max-width: 768px) {
  .cs-role-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .cs-role-grid { grid-template-columns: 1fr; }
}

.cs-role-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  min-height: 80px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--t);
}

.cs-role-card--primary {
  grid-column: span 2;
}

@media (max-width: 768px) {
  .cs-role-card--primary { grid-column: span 2; }
}

@media (max-width: 420px) {
  .cs-role-card--primary { grid-column: span 1; }
}

.cs-role-card__icon {
  display: flex;
  color: var(--ink-3);
}

.cs-role-card__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
}

.cs-role-card--primary .cs-role-card__title {
  font-size: 16px;
  font-weight: 600;
}

.cs-role-card--result {
  justify-content: center;
}

.cs-role-card__value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.cs-role-card__label {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.3;
}

@media (max-width: 600px) {
  .cs-role-card__value {
    font-size: 22px;
  }
}

.cs-role-card--link {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #111111;
  border-color: #111111;
  color: #ffffff;
  text-decoration: none;
  transition: opacity var(--t);
}

@media (hover: hover) {
  .cs-role-card--link:hover {
    opacity: 0.82;
  }
}

.cs-role-card__link-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-role-card__link-arrow {
  flex: none;
  display: flex;
  line-height: 0;
}

/* ---- Problems ---- */
.cs-problems {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

@media (max-width: 768px) {
  .cs-problems { grid-template-columns: 1fr; }
}

.cs-problem {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cs-problem__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cs-problem__body {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ---- Process ---- */
.cs-process {
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.cs-process__step {
  width: 100%;
}

.cs-process__label {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .cs-process { gap: 40px; }
  .cs-process__label { font-size: 19px; }
}

.cs-ph--process {
  aspect-ratio: 16 / 9;
  width: 100%;
}

.cs-process__media,
.cs-process__video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t), transform var(--t);
}

.cs-process__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

@media (hover: hover) {
  .cs-process__media:hover {
    border-color: var(--ink-3);
    transform: translateY(-2px);
  }
}

.cs-process__video-wrap {
  display: grid;
}

.cs-process__video-poster,
.cs-process__video {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.cs-process__video {
  opacity: 0;
  transition: opacity 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.cs-process__video-wrap.is-ready .cs-process__video {
  opacity: 1;
}

.cs-process__video-wrap.is-ready .cs-process__video-poster {
  visibility: hidden;
}

.cs-process__video-wrap.is-ready .cs-process__video-loader {
  opacity: 0;
  pointer-events: none;
}

.cs-process__video-loader {
  position: absolute;
  z-index: 2;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 280ms var(--t);
}

.cs-process__video-loader-track {
  flex: 1;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  overflow: hidden;
}

.cs-process__video-loader-bar {
  height: 100%;
  width: 0%;
  background: var(--ink);
  border-radius: 1px;
  transition: width 140ms linear;
}

.cs-process__video-loader-pct {
  flex: none;
  min-width: 2.5em;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-align: right;
}

@media (hover: hover) {
  .cs-process__video-wrap:hover {
    border-color: var(--ink-3);
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-process__video {
    transition: none;
  }

  .cs-process__video-wrap.is-loading .cs-process__video {
    opacity: 0;
  }

  .cs-process__video-wrap.is-ready .cs-process__video {
    opacity: 1;
  }
}

/* ---- Decisions ---- */
.cs-decisions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cs-decision {
  display: flex;
  gap: 16px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.cs-decision:last-child {
  border-bottom: 1px solid var(--line);
}

.cs-decision__icon {
  flex: none;
  display: flex;
  margin-top: 2px;
  color: var(--ink-3);
}

.cs-decision__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cs-decision__text {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* ---- Outcome ---- */
.cs-outcome__metrics {
  margin-top: 0;
}

.cs-outcome__text {
  margin-top: 28px;
  max-width: 62ch;
}

/* ---- Gallery ---- */
.cs-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.cs-gallery__item {
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t), transform var(--t);
}

.cs-gallery__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

@media (hover: hover) {
  .cs-gallery__item:hover {
    border-color: var(--ink-3);
    transform: translateY(-2px);
  }

  .cs-gallery__item:hover .cs-gallery__img {
    transform: scale(1.02);
  }
}

.cs-gallery__img {
  transition: transform var(--t);
}

@media (max-width: 768px) {
  .cs-gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .cs-gallery { grid-template-columns: 1fr; }
}

/* ---- Learnings ---- */
.cs-learnings .cs-prose + .cs-prose {
  margin-top: 14px;
}

.cs-learnings {
  max-width: 62ch;
}

/* ---- Prev / Next nav ---- */
.cs-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.cs-nav__spacer {
  flex: 1;
}

.cs-nav__link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--ink-3);
  transition: color var(--t);
  max-width: 45%;
}

.cs-nav__link:hover { color: var(--ink); }

.cs-nav__link--next {
  text-align: right;
  align-items: flex-end;
  margin-left: auto;
}

.cs-nav__project {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.cs-nav__link:hover .cs-nav__project {
  color: var(--ink);
}

/* ---- Stamp ---- */
.cs-stamp {
  display: flex;
  justify-content: center;
  margin-top: 48px;
}

.cs-stamp__img {
  display: block;
  height: 96px;
  width: auto;
  opacity: 1;
  pointer-events: none;
  user-select: none;
}

.cs-stamp__img--dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .cs-stamp__img--light {
    display: none;
  }

  .cs-stamp__img--dark {
    display: block;
  }
}
