.case-study-page main {
  overflow: clip;
}

.case-study-page .reveal {
  opacity: 1;
  transform: none;
}

.js .case-study-page .reveal {
  opacity: 0;
  transform: translateY(26px);
}

.js .case-study-page .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.case-index,
.case-back,
.story-number,
.story-progress,
.case-pagination small {
  font-family: var(--mono);
  text-transform: uppercase;
}

.case-index {
  margin: 0;
  color: var(--project-accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.case-back {
  display: inline-flex;
  width: max-content;
  margin-bottom: clamp(44px, 6vh, 74px);
  color: var(--text-secondary);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 180ms ease;
}

.case-section {
  padding-block: clamp(120px, 12vw, 190px);
}

.case-section-heading {
  display: grid;
  grid-template-columns: minmax(190px, 0.32fr) minmax(0, 0.68fr);
  column-gap: clamp(40px, 6vw, 96px);
  align-items: start;
  padding-bottom: clamp(52px, 7vw, 90px);
  border-bottom: 1px solid var(--border);
}

.case-section-heading .case-index {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.case-section-heading h2,
.story-header h2 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(3.3rem, 6.4vw, 6.6rem);
  font-weight: 520;
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.case-section-heading > p:not(.case-index) {
  grid-column: 2;
  max-width: 680px;
  margin: clamp(28px, 3vw, 44px) 0 0;
  color: var(--text-secondary);
  font-size: 1.08rem;
  line-height: 1.75;
}

.case-laptop,
.case-phone,
.case-app-window {
  position: relative;
  display: block;
  overflow: hidden;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #0c1112;
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.42);
}

.case-laptop img,
.case-phone img,
.case-app-window img {
  display: block;
  width: 100%;
  height: auto;
}

.case-app-window {
  border-radius: 18px;
}

.case-app-window > img {
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.case-device-bar {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 22px;
  padding-inline: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #171b1f;
}

.case-device-bar i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4b525a;
}

.case-phone {
  border-width: 6px;
  border-radius: 28px;
}

.case-phone-speaker {
  position: absolute;
  z-index: 3;
  top: 7px;
  left: 50%;
  width: 36%;
  height: 12px;
  border-radius: 99px;
  background: #090c10;
  transform: translateX(-50%);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.case-enter {
  opacity: 1;
}

.js .case-enter {
  opacity: 0;
  animation: case-enter 760ms cubic-bezier(.2, .7, .2, 1) forwards;
  animation-delay: var(--delay);
}

@keyframes case-enter {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.story-header {
  display: grid;
  grid-template-columns: minmax(190px, 0.32fr) minmax(0, 0.68fr);
  column-gap: clamp(40px, 6vw, 96px);
  padding-bottom: clamp(70px, 8vw, 120px);
}

.story-header .case-index {
  grid-row: 1 / span 2;
}

.story-header > p:last-child {
  grid-column: 2;
  max-width: 620px;
  margin: 30px 0 0;
  color: var(--text-secondary);
  font-size: 1.06rem;
}

.story-layout {
  display: block;
}

.story-step {
  padding-block: 56px;
  border-top: 1px solid var(--border);
}

.story-step:last-child {
  border-bottom: 1px solid var(--border);
}

.story-number {
  margin: 0 0 24px;
  color: var(--project-accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
}

.story-step h3 {
  max-width: 460px;
  margin: 0 0 24px;
  font-size: clamp(1.75rem, 3vw, 3rem);
  font-weight: 520;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.story-step > p:last-of-type {
  max-width: 470px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 1.04rem;
  line-height: 1.75;
}

.story-step-visual {
  margin-top: 38px;
}

.story-media {
  display: none;
}

@media (min-width: 769px) {
  .js .story-layout {
    display: grid;
    grid-template-columns: minmax(300px, 0.37fr) minmax(0, 0.63fr);
    gap: clamp(42px, 5vw, 78px);
    align-items: start;
  }

  .js .story-step {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 76vh;
    min-height: 76svh;
    opacity: 0.36;
    transition: opacity 420ms ease;
  }

  .js .story-step.is-active {
    opacity: 1;
  }

  .js .story-step-visual {
    display: none;
  }

  .js .story-media {
    position: sticky;
    top: calc(var(--header-height) + 50px);
    display: block;
    align-self: start;
    padding-top: 1px;
  }
}

.story-screen-stack {
  position: relative;
  aspect-ratio: 390 / 844;
  overflow: hidden;
  background: #0c1112;
}

.story-screen-stack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  object-fit: cover;
  transform: translateY(4px);
  transition: opacity 560ms ease, transform 560ms cubic-bezier(.2, .7, .2, 1);
}

.story-screen-stack img.is-active {
  z-index: 1;
  opacity: 1;
  transform: translateY(0);
}

.story-progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.story-progress i {
  position: relative;
  height: 1px;
  overflow: hidden;
  background: var(--border-bright);
}

.story-progress b {
  position: absolute;
  inset: 0;
  background: var(--project-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 560ms cubic-bezier(.2, .7, .2, 1);
}

.case-pagination {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-top: clamp(74px, 9vw, 130px);
  border-top: 1px solid var(--border-bright);
}

.case-pagination a {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 20px;
  align-items: center;
  min-height: 132px;
  padding: 24px 30px;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  transition: color 180ms ease, background 180ms ease;
}

.case-pagination a + a {
  grid-template-columns: 1fr auto;
  text-align: right;
  border-left: 1px solid var(--border-bright);
}

.case-pagination small {
  grid-column: 2;
  color: var(--text-secondary);
  font-size: 0.64rem;
  letter-spacing: 0.09em;
}

.case-pagination a + a small {
  grid-column: 1;
}

.case-pagination span {
  grid-row: 1 / span 2;
  color: var(--project-accent);
}

.case-pagination a + a span {
  grid-column: 2;
}

@media (hover: hover) and (pointer: fine) {
  .case-back:hover {
    color: var(--text);
  }

  .case-pagination a:hover {
    color: var(--bg);
    background: var(--text);
  }

  .case-pagination a:hover small,
  .case-pagination a:hover span {
    color: var(--bg);
  }
}

@media (max-width: 900px) {
  .case-section {
    padding-block: 120px;
  }

  .case-section-heading,
  .story-header {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .case-section-heading .case-index,
  .story-header .case-index,
  .case-section-heading h2,
  .case-section-heading > p:not(.case-index),
  .story-header > p:last-child {
    grid-column: 1;
    grid-row: auto;
  }

  .case-section-heading h2,
  .story-header h2 {
    font-size: clamp(3.3rem, 8vw, 5rem);
  }

  .case-section-heading > p:not(.case-index),
  .story-header > p:last-child {
    margin-top: 0;
  }
}

@media (max-width: 768px) {
  .story-media {
    display: none !important;
  }

  .story-step {
    min-height: 0 !important;
    opacity: 1 !important;
  }

  .story-step-visual {
    display: block !important;
  }
}

@media (max-width: 600px) {
  .case-section {
    padding-block: 96px;
  }

  .case-section-heading {
    padding-bottom: 46px;
  }

  .case-section-heading h2,
  .story-header h2 {
    font-size: clamp(2.8rem, 13vw, 4.2rem);
  }

  .case-back {
    margin-bottom: 36px;
  }

  .story-header {
    padding-bottom: 52px;
  }

  .story-step {
    padding-block: 64px;
  }

  .story-step h3 {
    font-size: clamp(1.8rem, 9vw, 2.55rem);
  }

  .story-step-visual {
    margin-top: 34px;
  }

  .case-pagination {
    grid-template-columns: 1fr;
    margin-top: 74px;
  }

  .case-pagination a {
    min-height: 110px;
    padding-inline: 8px;
    border-bottom: 1px solid var(--border-bright);
  }

  .case-pagination a + a {
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .case-enter,
  .js .case-enter,
  .story-screen-stack img {
    opacity: 1;
    animation: none;
    transform: none;
  }

  .story-screen-stack img:not(.is-active) {
    opacity: 0;
  }
}
