/* Case study pages */

.case-study-main > section {
  padding: var(--space-2xl) 0;
  border-bottom: 1px solid var(--line);
}

.case-study-main h1 {
  max-width: none;
  font-size: clamp(2.75rem, 5.5vw, 4rem);
}

.case-intro-grid__gap {
  margin-top: 1rem;
}

/* Browser frame */

.browser-frame {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.browser-frame__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.browser-frame__bar--dark {
  background: #1a1d28;
  border-bottom-color: #2a2f3d;
}

.browser-frame__bar--light {
  background: #fff;
  border-bottom-color: var(--line);
}

.browser-frame__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c7c7cb;
}

.browser-frame__bar--dark .browser-frame__dot {
  background: #4a5060;
}

.browser-frame__bar--dark .browser-frame__dot:first-child {
  background: #5c6378;
}

.browser-frame__viewport img {
  width: 100%;
  aspect-ratio: 1024 / 640;
  object-fit: cover;
  object-position: top;
  background: var(--bg-soft);
}

/* Hero */

.case-study-main > section.case-hero {
  padding-top: calc(var(--header-height) + var(--space-2xl));
  padding-bottom: 0;
  background: var(--bg-soft);
  overflow: visible;
}

.case-hero__grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-xl);
  align-items: stretch;
}

.case-hero__copy {
  max-width: 34rem;
  align-self: start;
  padding-bottom: var(--space-2xl);
}

.case-hero__visual {
  display: flex;
  align-items: flex-end;
  overflow: visible;
}

.case-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: var(--text-label);
  font-weight: 700;
  color: var(--muted);
}

/* Intro */

.case-study-main > section.case-intro {
  background: var(--bg);
}

.case-intro-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 76px;
  align-items: start;
}

.case-fact-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-top: 42px;
}

.case-fact {
  padding: var(--work-card-pad);
  padding-top: calc(var(--work-card-pad) + 4px);
  border: 0;
  border-radius: var(--radius-md);
  border-top: 3px solid var(--purple);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.case-fact strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.case-fact span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Gallery */

.case-study-main > section.case-gallery {
  background: var(--bg-highlight);
}

.case-gallery-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: end;
  margin-bottom: 30px;
}

.case-gallery-head .section-lede {
  max-width: 32rem;
  margin-bottom: 4px;
}

.case-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  align-items: start;
}

.case-gallery-thumb .case-media-frame {
  border: 1px solid #eee;
}

.case-gallery-thumb .browser-frame {
  box-shadow: var(--shadow-sm);
}

.case-gallery-thumb--large .browser-frame__viewport img {
  aspect-ratio: 1024 / 640;
}

.case-gallery-thumb:not(.case-gallery-thumb--large) .browser-frame__viewport img {
  aspect-ratio: 4 / 3;
}

.case-gallery-caption {
  margin: 12px 0 0;
  font-size: var(--text-label-md);
  line-height: 1.45;
  color: var(--muted);
}

/* Outcome */

.case-study-main > section.case-outcome {
  background: var(--bg-soft);
}

.case-outcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: start;
}

.case-quote {
  margin: 0;
  padding: var(--space-md);
  border: 0;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--purple);
}

.case-quote strong {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
}

.case-quote p {
  margin: 0 0 1rem;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.45;
  color: var(--ink);
}

.case-quote footer {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

/* Next — matches homepage final CTA */

.case-study-main > section.case-next {
  background: var(--purple);
  color: #fff;
  border-bottom: 0;
}

.case-next .eyebrow {
  color: var(--purple-hover);
}

.case-next h2 {
  max-width: 44rem;
  color: #fff;
}

.case-next__copy {
  max-width: 40rem;
  margin-bottom: var(--space-md);
  color: rgba(255, 255, 255, 0.88);
}

.case-next .actions {
  justify-content: flex-start;
}

/* Bare hero image (no frame or stage) */

.case-hero-shot {
  margin: 0;
  width: 100%;
}

.case-hero-shot img {
  display: block;
  width: 100%;
  height: auto;
  transform: scale(1.2);
  transform-origin: center bottom;
}

/* Device stage (game case studies) */

.device-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 22rem;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--bg-soft), var(--bg-highlight));
  box-shadow: var(--shadow-md);
}

.device-stage__desktop {
  width: min(76%, 36rem);
  overflow: hidden;
  border: 8px solid #151515;
  border-bottom-width: 14px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.device-stage__desktop img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
}

.device-stage__phone {
  position: absolute;
  right: 6%;
  bottom: 8%;
  width: 22%;
  min-width: 5.5rem;
  overflow: hidden;
  border: 6px solid #151515;
  border-radius: 1.4rem;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.device-stage__phone img {
  width: 100%;
  aspect-ratio: 9 / 19.5;
  object-fit: cover;
  object-position: top;
}

/* Showcase grid */

.case-study-main > section.case-showcase {
  background: var(--bg-highlight);
}

.case-showcase-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: var(--space-sm);
  align-items: start;
}

.case-showcase-stack {
  display: grid;
  gap: var(--space-sm);
}

.case-showcase-grid--split {
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.52fr);
  gap: var(--space-md);
  align-items: start;
}

.case-showcase-copy {
  display: grid;
  gap: 20px;
  align-content: start;
}

.case-showcase-shots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.case-showcase-shot {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: var(--radius-sm);
}

.case-showcase-cell {
  min-width: 0;
}

.case-showcase-summary {
  margin: 0;
  color: #414348;
  font-size: calc(0.875rem * 1.3);
  line-height: 1.55;
}

/* Phone-framed inline video (case study showcase) */

.case-phone-stage {
  --case-phone-w: 1036;
  --case-phone-h: 2060;
  --case-screen-x: 42;
  --case-screen-y: 29;
  --case-screen-w: 953;
  --case-screen-h: 2004;
  position: relative;
  width: 100%;
  aspect-ratio: var(--case-phone-w) / var(--case-phone-h);
  filter: drop-shadow(0 14px 28px rgba(16, 20, 37, 0.14));
}

.case-phone-stage__screen {
  position: absolute;
  left: calc(var(--case-screen-x) / var(--case-phone-w) * 100%);
  top: calc(var(--case-screen-y) / var(--case-phone-h) * 100%);
  width: calc(var(--case-screen-w) / var(--case-phone-w) * 100%);
  height: calc(var(--case-screen-h) / var(--case-phone-h) * 100%);
  overflow: hidden;
  background: #000;
  -webkit-mask-image: url("../assets/case-studies/phone-mask.svg");
  mask-image: url("../assets/case-studies/phone-mask.svg");
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.case-phone-stage__video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  background: #000;
}

.case-phone-stage__toggle {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
}

.case-phone-stage__dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
}

.case-phone-stage__play {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 280ms ease, transform 280ms ease;
  pointer-events: none;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
}

.case-phone-stage__play-icon {
  width: 3.5rem;
  height: 3.5rem;
}

.case-phone-stage__screen.is-paused .case-phone-stage__dim,
.case-phone-stage__screen.is-paused .case-phone-stage__play {
  opacity: 1;
}

.case-phone-stage__screen.is-paused .case-phone-stage__play {
  transform: scale(1);
}

.case-phone-stage__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  pointer-events: none;
  user-select: none;
  z-index: 2;
}

@media (prefers-reduced-motion: reduce) {
  .case-phone-stage__dim,
  .case-phone-stage__play {
    transition: none;
  }
}

.case-media-frame {
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.case-media-frame img {
  width: 100%;
  aspect-ratio: 1024 / 640;
  object-fit: cover;
  object-position: top;
}

.case-media-frame--compact img,
.case-media-frame--mobile img {
  aspect-ratio: 4 / 3;
}

.case-media-frame--mobile {
  max-width: 16rem;
  margin-inline: auto;
}

/* Process section */

.case-study-main > section.case-process {
  background: var(--bg-highlight);
}

.case-visual-row {
  display: grid;
  grid-template-columns: 1.45fr 0.55fr;
  gap: var(--space-sm);
  margin-top: 46px;
}

.case-visual-row--75-25 {
  grid-template-columns: 68fr 32fr;
  align-items: start;
  gap: var(--space-md);
}

.case-visual-row__copy {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.case-visual-row__phone {
  min-width: 0;
}

.case-visual-row__summary {
  margin: 0;
  max-width: 42rem;
  color: #414348;
  font-size: calc(0.875rem * 1.3);
  line-height: 1.55;
}

.case-visual-shot {
  display: block;
  width: 100%;
  height: auto;
}

.case-visual-shot--desktop {
  border: 1px solid #eee;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.case-visual-shot--phone {
  max-width: 100%;
}

/* Soundtrack */

.case-study-main > section.case-soundtrack {
  background: var(--bg);
}

.case-soundtrack__grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 60px;
  align-items: start;
}

.case-soundtrack__copy .section-lede {
  max-width: none;
}

.case-soundtrack__lede-gap {
  margin-bottom: 1rem;
}

.case-soundtrack__album {
  display: grid;
  grid-template-columns: minmax(0, 11.5rem) minmax(0, 1fr);
  gap: var(--space-md);
  align-items: start;
  margin-bottom: var(--space-md);
}

.case-soundtrack__cover {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #eee;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.case-soundtrack__album-title {
  margin: 0 0 12px;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.case-soundtrack__album-copy {
  margin: 0;
  color: #414348;
  font-size: 0.875rem;
  line-height: 1.55;
}

.case-soundtrack__cta {
  display: flex;
  justify-content: flex-start;
  margin-top: 18px;
}

.case-soundtrack__bandcamp {
  gap: 0.55rem;
}

.case-soundtrack__bandcamp-icon {
  flex: 0 0 auto;
  color: var(--purple);
}

.cs-preview-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.cs-preview-card {
  display: grid;
  grid-template-columns: minmax(11rem, 34%) minmax(0, 1fr);
  gap: var(--space-sm);
  align-items: center;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.cs-preview-card:last-child {
  border-bottom: 0;
}

.cs-preview-card__info {
  min-width: 0;
}

.cs-preview-card__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.15rem;
}

.cs-preview-card__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.3;
}

.cs-preview-card__label {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}

.cs-preview-card__duration {
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-soft);
  font-size: 0.66rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.cs-preview-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.65rem 0.75rem;
  align-items: center;
  min-width: 0;
  width: 100%;
}

.cs-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  border: 1px solid var(--purple);
  border-radius: 50%;
  background: #fff;
  color: var(--purple);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cs-preview-btn:hover,
.cs-preview-btn:focus-visible {
  border-color: var(--purple-hover);
  background: var(--bg-highlight);
  color: var(--purple);
  outline: none;
}

.cs-preview-btn[aria-pressed="true"] {
  border-color: var(--purple);
  background: var(--purple);
  color: #fff;
}

.cs-preview-btn__pause {
  display: none;
}

.cs-preview-btn[aria-pressed="true"] .cs-preview-btn__play {
  display: none;
}

.cs-preview-btn[aria-pressed="true"] .cs-preview-btn__pause {
  display: block;
}

.cs-preview-wave {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
}

.cs-preview-wave:focus-visible {
  outline: 2px solid var(--purple-hover);
  outline-offset: 2px;
}

.cs-preview-card.is-loading .cs-preview-wave::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(57, 62, 126, 0.08), transparent);
  pointer-events: none;
}

.cs-preview-status {
  grid-column: 1 / -1;
  margin: 0.15rem 0 0;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.cs-preview-status[hidden] {
  display: none !important;
}

.cs-preview-player__time {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.28rem;
  margin: 0;
  min-width: 4.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.cs-preview-player__time-sep {
  opacity: 0.7;
}

/* Responsive */

@media (max-width: 980px) {
  .case-hero__grid,
  .case-intro-grid,
  .case-outcome-grid,
  .case-soundtrack__grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .case-fact-strip,
  .case-gallery-grid,
  .case-showcase-grid,
  .case-showcase-grid--split,
  .case-visual-row,
  .case-visual-row--75-25 {
    grid-template-columns: 1fr;
  }

  .case-showcase-shots {
    grid-template-columns: 1fr;
  }

  .case-soundtrack__album {
    grid-template-columns: minmax(0, 10rem) minmax(0, 1fr);
    gap: var(--space-sm);
  }

  .case-gallery-head {
    flex-direction: column;
    align-items: start;
  }

  .case-hero__visual {
    order: -1;
  }

  .cs-preview-card {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .cs-preview-player {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "btn wave"
      ". time";
  }

  .cs-preview-btn {
    grid-area: btn;
  }

  .cs-preview-wave {
    grid-area: wave;
  }

  .cs-preview-player__time {
    grid-area: time;
    justify-self: end;
  }

  .device-stage__phone {
    width: 27%;
    right: 4%;
  }
}

@media (max-width: 640px) {
  .case-soundtrack__album {
    grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
  }
}
