.tutorful-case {
  --case-ink: #203858;
  --case-header-stroke: #8191aa32;
  --case-header-shadow: 0 3px 12px #7888a217;
  --case-line: #d9dce7;
  --case-accent: #555879;
  --case-section-padding: clamp(48px, 8vw, 104px);
  color: var(--case-ink);
  background: white;
  line-height: 1.55;
}

.case-section { padding-block: var(--case-section-padding); }
.case-wrap { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.case-overview { position: relative; isolation: isolate; overflow: hidden; background: #ececf4; }
.case-overview .case-wrap { position: relative; z-index: 1; }
.case-section h1,
.case-section h2 {
  margin: 0 0 18px;
  color: #263c5d;
  background: linear-gradient(110deg, #233954, #666189 75%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.045em;
}
.case-section h1 { font-size: clamp(56px, 10vw, 112px); }
.case-section h2 { font-size: clamp(37px, 6vw, 62px); }
.case-section .case-overview-label { font-size: clamp(22px, 3vw, 32px); letter-spacing: -.025em; }
.case-section h3 { margin: 0 0 10px; color: var(--case-ink); font-size: 22px; line-height: 1.2; }
.case-section p { margin: 0 0 16px; }
.case-lead { max-width: 65ch; font-size: clamp(18px, 2.4vw, 23px); }
.case-pills { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 24px 0 32px; list-style: none; }
.case-pills li,
.case-status { padding: 5px 12px; border: 1px solid #b9b9cd; border-radius: 999px; background: #ffffffe0; font-size: 14px; }
.case-meta, .case-metrics { display: grid; gap: 16px; margin: 0; }
.case-meta-band {
  position: relative;
  z-index: 3;
  background: #fff;
  border-bottom: 1px solid var(--case-header-stroke);
  box-shadow: var(--case-header-shadow);
}
.case-meta { grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); padding-block: 18px; margin-inline: auto; }
.case-meta dt, .case-metrics dt { font-weight: 700; }
.case-meta dd, .case-metrics dd { margin: 4px 0 0; }
.case-meta a { color: inherit; text-decoration: underline; }
.case-research-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-block: 32px; }
.case-research-grid article { padding-top: 16px; border-top: 1px solid var(--case-line); }
.case-example { max-width: 72ch; border-left: 3px solid #8b8eac; padding-left: 16px; }
.case-created { background: #f5f5f6; }
.case-projects { display: grid; grid-template-columns: minmax(218px, 1fr) minmax(0, 2.65fr); border: 1px solid var(--case-line); border-radius: 24px; overflow: hidden; background: white; }
.case-project-list { display: grid; align-content: start; gap: 5px; padding: 16px; border-right: 1px solid var(--case-line); background: #fafafe; }
.case-project-list a { border-radius: 12px; color: var(--case-ink); padding: 12px; text-decoration: none; line-height: 1.3; }
.case-project-list a:hover { background: #f0eef7; }
.case-project-list a[aria-selected="true"] { background: #e3e5f2; font-weight: 700; }
.case-project-list a:focus-visible, .case-meta a:focus-visible { outline: 2px solid #555879; outline-offset: 2px; }
.case-project-content { min-width: 0; padding: clamp(18px, 3.5vw, 36px); }
.case-project + .case-project { margin-top: 32px; }
.case-project[role="tabpanel"] { margin-top: 0; }
.case-status { display: inline-block; margin-bottom: 12px; background: #f4f2fa; }
.case-visual { overflow: hidden; margin: 20px 0 0; border-radius: 16px; background: linear-gradient(145deg, #e9ebf4, #d8dcec); }
.case-wizard-visual { display: grid; gap: 1px; border: 1px solid var(--case-line); }
.case-wizard-visual > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 12px 16px; background: #ffffffe8; }
.case-wizard-visual figcaption { padding: 8px 16px; font-size: 14px; }
.case-device { position: relative; isolation: isolate; aspect-ratio: 16 / 9; }
.case-device canvas, .case-device .device-still { position: absolute; inset: 0; width: 100%; height: 100%; }
.case-device canvas { opacity: 0; transition: opacity 320ms ease-out; }
.case-device.is-rendered canvas { opacity: 1; }
.case-device.is-rendered .device-still { visibility: hidden; transition: visibility 0s 320ms; }
.case-device .device-still { overflow: hidden; display: grid; place-items: center; }
.case-device img { width: 100%; height: 100%; object-fit: contain; }
.case-visual--phone .device-still { inset-inline: 35%; width: auto; }
.case-impact-headline { font-size: clamp(20px, 3vw, 32px); }
.case-impact-headline strong { color: var(--story-blue, #265b82); font-size: clamp(52px, 8vw, 92px); line-height: 1; letter-spacing: -.05em; }
.case-chart { background: #f8f8fc; border: 1px solid var(--case-line); border-radius: 20px; margin: 24px 0; padding: clamp(16px, 4vw, 32px); }
.case-chart figcaption { font-weight: 700; }
.case-chart ul { display: grid; gap: 16px; padding: 0; margin: 18px 0 0; list-style: none; }
.case-chart li { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; }
.case-chart-track { grid-column: 1 / -1; height: 12px; border-radius: 999px; background: #e6e8f1; overflow: hidden; }
.case-chart-track i { display: block; width: var(--bar); height: 100%; border-radius: inherit; background: #8188ab; }
.case-chart li:last-child i { background: #46577d; }
.case-metrics { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.case-metrics > div { padding: 16px; border: 1px solid var(--case-line); border-radius: 16px; background: linear-gradient(150deg, #fff, #f0eef7); }
.case-metrics dd { font-size: clamp(19px, 3vw, 28px); font-weight: 700; }
.case-section .case-impact-note { max-width: 72ch; margin-top: 20px; }
.case-skip { position: absolute; z-index: 999; left: 12px; top: 12px; transform: translateY(-200%); background: white; padding: 10px; }
.case-skip:focus { transform: none; }

@media (max-width: 720px) {
  .case-research-grid, .case-projects { grid-template-columns: 1fr; }
  .case-research-grid { gap: 16px; }
  .case-project-list { border-right: 0; border-bottom: 1px solid var(--case-line); }
}

@media (prefers-reduced-motion: reduce) {
  .case-device canvas, .case-device.is-rendered .device-still { transition: none; }
}

/* Section layout uses the previous case study's type and glass treatments. */
.story.tutorful-case { font-family: var(--font-body, system-ui, sans-serif); }
.story.tutorful-case h1.name-copy { font-size: clamp(36px, 5vw, 72px); }
.story.tutorful-case .case-section h2 { font-size: clamp(28px, 3.7vw, 48px); }
.story.tutorful-case .case-section .case-overview-label { font-size: clamp(20px, 2.5vw, 27px); }
.story.tutorful-case .case-section h3 { font-family: var(--font-heading, system-ui, sans-serif); }
.story.tutorful-case .case-wrap { position: relative; z-index: 2; }
.case-research-grid .story-liquid { padding: 20px; }
.tutorful-case .case-overview { background: #f7f9fc; min-height: auto; }
.case-overview #particles-js { position: absolute; inset: 0; pointer-events: none; }
.case-research, .case-impact { position: relative; overflow: hidden; background: #eeedf5; }
.case-project[hidden] { display: none; }
.case-project-list { background: #fff; }
.case-project-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.case-project-list a::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-inline-end: 4px;
  flex: 0 0 6px;
  border: solid currentColor;
  border-width: 1px 1px 0 0;
  transform: rotate(45deg);
}

.case-device .device-still img {
  width: 78%;
  height: auto;
  max-height: 98%;
  object-fit: cover;
  object-position: top;
  border: 5px solid #45475e;
  border-radius: 10px;
  box-shadow: 0 12px 22px #262b4c34;
  transform: rotate(-5deg);
}
.case-visual--phone .device-still img { width: auto; max-width: 90%; border-radius: 14px; transform: rotate(-9deg); }

.case-hero { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: center; gap: clamp(20px, 5vw, 56px); }
.case-pills li {
  border-color: #a8aec63f;
  background:
    radial-gradient(ellipse at 25% 0%, #fff 0%, transparent 76%),
    linear-gradient(135deg, #ffffff90, #e2e3f0a6);
  box-shadow: inset 0 1px 1px #fff, inset 0 -1px 2px #777a9b29, 0 3px 10px #61678716;
  backdrop-filter: blur(12px) saturate(130%);
}
.case-projects {
  border-color: var(--case-header-stroke);
  box-shadow: var(--case-header-shadow);
}
.case-project-list {
  gap: 8px;
  padding: clamp(14px, 2vw, 22px);
  background: linear-gradient(150deg, #f9f9fd, #f2f3f9);
}
.case-project-list a { min-height: 44px; padding-inline: 14px; }
.case-project-list a[aria-selected="true"] {
  background: linear-gradient(145deg, #ffffffea, #e3e4f2);
  box-shadow: inset 0 0 0 1px var(--case-header-stroke), inset 0 1px 1px #fff, var(--case-header-shadow);
}
.case-project-content { background: linear-gradient(157deg, #fff 45%, #f8f8fc); }
.case-project > p { max-width: 64ch; }
.case-project-demo {
  margin-top: 16px;
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(14px, 3vw, 32px);
}
.case-project-demo .case-visual, .case-hero-device { margin: 0; }
.case-project-demo .case-wizard-visual {
  border-color: #d5d9e6;
  background: #edeef6;
}
.case-project-demo .case-wizard-visual > div { display: grid; gap: 3px; }
.case-project-demo .case-wizard-visual span { font-size: 13px; }
.story .case-visual:has(.case-device),
.story .case-visual .case-device { background: transparent; }
.story .case-visual .case-device[data-device="laptop"] { aspect-ratio: 1.65; }
.story .case-visual--phone .case-device { aspect-ratio: 1; max-height: 420px; }
.story .case-visual--phone .device-still { inset-inline: 24%; }
.story .case-device .device-still { box-shadow: none; }
.story .case-device canvas { pointer-events: none; }

@media (max-width: 720px) {
  .case-hero { grid-template-columns: minmax(0, 1fr); }
  .case-hero-device { max-width: 520px; width: 100%; justify-self: center; }
}
@media (max-width: 425px) {
  .case-project-demo { grid-template-columns: minmax(0, 1fr); }
}

.story .case-hero-device .case-device[data-device="laptop"] { aspect-ratio: 1.35; }

.case-reading-width { max-width: 72ch; }
.story .case-section .case-subsection { margin-top: clamp(26px, 4vw, 42px); }
.case-research-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.case-research-grid h4 { margin: 0 0 8px; font: inherit; font-weight: 700; color: var(--case-ink); }
.case-research-grid article p { margin-bottom: 0; }
.case-findings { display: grid; gap: 8px; margin: 0 0 22px; padding-inline-start: 1.3rem; }
.case-metric-icon { flex: none; color: var(--story-violet); }
.case-chart figcaption, .case-metrics dt { display: flex; align-items: center; gap: 8px; }
.case-metrics .case-metric-detail { font-size: .875rem; font-weight: 400; line-height: 1.5; }
@media (max-width: 720px) {
  .case-research-grid { grid-template-columns: minmax(0, 1fr); }
}

.story.tutorful-case .case-section :is(h1.name-copy, h2) {
  width: fit-content;
  background-image: linear-gradient(90deg, #23213b, #4b4d69 17%, #8ab5d0 61%, #d8315b);
}

/* Keep the CSS shadow visible while the glass renderer pauses on scroll. */
.story.tutorful-case[data-css-card-shadows] .story-liquid {
  box-shadow: 0 8px 24px #41497420, 0 2px 5px #41497412;
}

.story.tutorful-case :is(.case-research-grid h4, .case-project h3, .case-chart figcaption, .case-metrics dt) {
  color: var(--case-ink);
}

/* The section index sits outside the reading column from desktop widths. */
.case-reading { position: relative; }
.story.tutorful-case :is(.case-section, #team-results, .case-projects) {
  scroll-margin-top: calc(var(--case-header-height, 80px) + 16px);
}
.case-index-rail {
  z-index: 4;
  background: #f7f9fc;
  border-bottom: 1px solid var(--case-header-stroke);
}
.case-index {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
  padding-block: 12px;
  font-size: .875rem;
}
.story .case-index p {
  margin: 0 0 5px;
  color: var(--case-ink);
  font-weight: 650;
}
.case-index ul {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.story .case-index a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 6px 4px 12px;
  color: #525c75;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}
.story .case-index a:hover { color: var(--case-ink); text-decoration: underline; }
.story .case-index a[aria-current="location"] {
  color: #4a4774;
  font-weight: 650;
}
.case-index a[aria-current="location"]::before {
  content: "";
  position: absolute;
  inset-inline-start: 1px;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: currentColor;
}

@media (min-width: 960px) {
  .story.tutorful-case {
    --case-page-gutter: clamp(24px, 3vw, 44px);
    --case-index-width: 174px;
    --case-index-gap: clamp(20px, 3vw, 44px);
    --case-layout-width: calc(1120px + var(--case-index-width) + var(--case-index-gap));
    --case-layout-start: max(var(--case-page-gutter), calc((100% - var(--case-layout-width)) / 2));
  }
  .case-index-rail {
    position: absolute;
    inset-block: 0;
    inset-inline-start: max(16px, calc(var(--case-layout-start) - clamp(36px, 5vw, 80px)));
    width: var(--case-index-width);
    padding-block-start: var(--case-section-padding);
    background: transparent;
    border-bottom: 0;
  }
  .case-index {
    position: sticky;
    top: max(calc(var(--case-header-height, 80px) + 16px), min(22vh, 176px));
    width: 100%;
    padding-block: 0;
  }
  .case-index ul { display: block; }
  .story.tutorful-case .case-wrap {
    width: min(1120px, calc(100% - 2 * var(--case-page-gutter) - var(--case-index-width) - var(--case-index-gap)));
    margin-inline-start: calc(var(--case-layout-start) + var(--case-index-width) + var(--case-index-gap));
    margin-inline-end: auto;
  }
}
