/*
 * Single case study page (site/templates/casestudy.php and
 * site/snippets/casestudy/*; docs/design/components.md, "Case study page").
 * Linked by the template only, so no other page loads it.
 *
 * Every class here is cs-* and only the case study page prints them. Shared
 * pieces keep their own styles: the section nav (.casestudy-nav, site.css),
 * the figures (.metrics, site.css, with the count-up hooks), the "From
 * Christina" note (.casestudy-note), FAQs, the closing band (.cta-band) and
 * the shared button. Colors, type and spacing come from tokens.css.
 *
 * Density rule: a frame is never drawn wider than half its file
 * (--shot-max, set per figure from the file's width), so every capture is
 * 2x or better on retina screens and nothing is upscaled.
 *
 * Motion: none of its own in CSS. The shared layer reveals each .section >
 * .container and runs the hero entrance (.hero-enter); nothing here hides
 * anything, so ?fx=off, reduced motion and print show the whole page. The
 * whole-page captures scroll inside their frames (.cs-frame__screen--scroll);
 * their slow scroll on hover is public/assets/js/cs-scroll.js (key devices).
 */

@layer templates {
  .template-casestudy main {
    counter-reset: cs-step;
  }

  /* Anchor targets land below the sticky header and the section nav */
  .cs-target {
    scroll-margin-top: calc(var(--header-height) + 3.75rem);
  }

  /* ---------- Showcase (snippets/casestudy/showcase.php) ---------- */

  /* Solid ink, as the hero. Under 1024 px: the panel, then a swipe row */
  .cs-showcase {
    padding-block: var(--space-2) var(--space-5);
    background: var(--color-ink);
    color: var(--color-white);
  }

  .cs-showcase__inner {
    display: grid;
    gap: var(--space-4);
  }

  .cs-showcase__panel {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    min-width: 0;
  }

  .cs-showcase__panel p,
  .cs-showcase__panel dl {
    margin: 0;
  }

  .cs-showcase .breadcrumb {
    padding-block: 0;
    background: transparent;
  }

  .cs-showcase .breadcrumb .container {
    width: auto;
    max-width: none;
    margin: 0;
    padding-inline: 0;
  }

  .cs-showcase .breadcrumb__item + .breadcrumb__item::before {
    color: var(--color-on-ink-label);
  }

  .cs-showcase__eyebrow {
    color: var(--color-brand);
  }

  .cs-showcase__title {
    margin: 0;
    font-size: clamp(2.5rem, 2rem + 1.6vw, 3.25rem);
    font-weight: var(--weight-display);
    line-height: 1.06;
    overflow-wrap: break-word;
  }

  .cs-showcase__title em {
    color: var(--color-brand);
  }

  .cs-showcase__line {
    color: var(--color-on-ink-text-strong);
    font-size: var(--text-body);
    line-height: 1.7;
  }

  .cs-showcase__proof {
    padding-block: 0.75rem;
    border-block: 1px solid var(--color-on-ink-line);
  }

  .cs-showcase__claim {
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading-sm);
    line-height: 1.3;
  }

  .cs-showcase__figure {
    display: block;
    color: var(--color-brand);
    font-size: clamp(2.75rem, 2rem + 1.6vw, 3.25rem);
    font-weight: var(--weight-display);
    line-height: 1.05;
  }

  .cs-showcase__source {
    margin-top: var(--space-1);
    color: var(--color-on-ink-label);
    font-size: var(--step--1);
  }

  /* the facts sit after the button on phones: the call stays in the first screen */
  .cs-showcase__facts {
    display: grid;
    order: 2;
  }

  .cs-showcase__fact {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    gap: var(--space-2);
    padding-block: 0.5rem;
    border-bottom: 1px solid var(--color-on-ink-border-faint);
  }

  .cs-showcase__factlabel {
    color: var(--color-on-ink-label);
    font-size: var(--step--1);
  }

  .cs-showcase__factvalue {
    margin: 0;
    font-size: var(--step--1);
    line-height: 1.6;
  }

  .cs-showcase__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    order: 1;
  }

  .cs-showcase__site {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-2);
  }

  .cs-showcase__site .caps-label {
    color: var(--color-brand);
  }

  .cs-showcase__media {
    min-width: 0;
  }

  .cs-showcase__list {
    display: flex;
    gap: var(--space-2);
    margin: 0 calc(var(--gutter) * -1);
    padding: 0 var(--gutter);
    overflow-x: auto;
    list-style: none;
    scroll-padding-inline: var(--gutter);
    scroll-snap-type: x mandatory;
    scrollbar-color: var(--color-on-ink-scrollbar) transparent;
    scrollbar-width: thin;
  }

  .cs-showcase__item {
    flex: 0 0 85%;
    min-width: 0;
    scroll-snap-align: start;
  }

  .cs-showcase__figurebox {
    margin: 0;
  }

  /* a very tall comp shows its top in the swipe row, whole in the stack */
  .cs-showcase__img {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(78svh, 135vw);
    object-fit: cover;
    object-position: top;
  }

  .cs-showcase__item--capture .cs-showcase__img {
    border: 1px solid var(--color-paper);
    border-radius: var(--radius-sm);
  }

  .cs-showcase__note {
    margin-top: var(--space-1);
    color: var(--color-paper);
    font-size: var(--step--1);
    opacity: 0.7;
  }

  .cs-showcase__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-2);
    visibility: hidden;
  }

  .cs-showcase__controls.is-ready {
    visibility: visible;
  }

  .cs-showcase__controls .btn {
    color: var(--color-white);
  }

  .cs-showcase__controls .btn:disabled {
    color: var(--color-on-ink-label);
  }

  .cs-showcase__count {
    margin: 0;
    font-size: var(--step--1);
    font-variant-numeric: tabular-nums;
  }

  @media (min-width: 64rem) {
    .cs-showcase {
      padding-block: var(--space-4) var(--space-6);
    }

    .cs-showcase__inner {
      grid-template-columns: minmax(0, 58fr) minmax(0, 42fr);
      gap: var(--space-6);
      align-items: start;
    }

    /* Pinned beside the stack; a tall panel scrolls on its own, never cut off */
    .cs-showcase__panel {
      position: sticky;
      top: calc(var(--header-height) + var(--space-3));
      grid-area: 1 / 2;
      max-height: calc(100vh - var(--header-height) - 2 * var(--space-3));
      overflow: auto;
      scrollbar-color: var(--color-on-ink-scrollbar) transparent;
      scrollbar-width: thin;
    }

    .cs-showcase__facts,
    .cs-showcase__actions {
      order: 0;
    }

    .cs-showcase__media {
      grid-area: 1 / 1;
    }

    .cs-showcase__list {
      display: grid;
      gap: var(--space-4);
      margin: 0;
      padding: 0;
      overflow: visible;
    }

    .cs-showcase__img {
      max-height: none;
    }

    .cs-showcase__controls {
      display: none;
    }
  }

  /* ---------- Hero ---------- */

  /* The breadcrumb joins the ink hero: white on black, so the page does not
     open with two white bands under the header (design review 2026-10-22) */
  .template-casestudy .breadcrumb {
    --focus-ring: var(--color-white);
    border-bottom: 0;
    background: var(--color-ink);
    color: var(--color-white);
  }

  .template-casestudy :is(.breadcrumb__item[aria-current="page"], .breadcrumb__item + .breadcrumb__item::before) {
    color: var(--color-on-ink-text);
  }

  /* Solid ink, no glow or gradient (hero rule, 2026-10-26; design review #73) */
  .cs-hero {
    --focus-ring: var(--color-white);
    position: relative;
    overflow: hidden;
    padding-block: var(--space-5) var(--space-6);
    background: var(--color-ink);
    color: var(--color-white);
  }

  .cs-hero__inner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    align-items: center;
  }

  .cs-hero__body > * {
    margin: 0;
  }

  .cs-hero__body > * + * {
    margin-top: var(--space-3);
  }

  .cs-hero__eyebrow {
    color: var(--color-brand);
  }

  .cs-hero__title {
    font-size: clamp(2.75rem, 1.5rem + 4.4vw, 4.75rem);
    font-weight: var(--weight-display);
    line-height: 1.04;
    overflow-wrap: break-word;
  }

  .cs-hero__title em {
    color: var(--color-brand);
  }

  .cs-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: 0;
    list-style: none;
  }

  .cs-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    min-height: 2.75rem;
    padding: 0.4em 1.1em;
    border: 1px solid var(--color-on-ink-line-strong);
    border-radius: var(--radius-pill);
    color: var(--color-white);
    font-size: 0.875rem;
    font-weight: var(--pill-weight);
    text-decoration: none;
  }

  .cs-pill--tier {
    border-color: var(--color-brand);
    background: var(--color-brand);
    color: var(--color-ink);
  }

  a.cs-pill:hover,
  a.cs-pill:focus-visible {
    border-color: var(--color-butter);
    background: var(--color-butter);
    color: var(--color-ink);
  }

  /* "Tier" reads in sentence case with the tier name, as one phrase (design review #74) */
  .cs-pill__label {
    font-weight: var(--pill-weight);
  }

  .cs-hero__line {
    max-width: 30ch;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading-sm);
    line-height: 1.35;
  }

  .cs-hero__site {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-2);
  }

  .cs-hero__site .caps-label {
    color: var(--color-brand);
  }

  .cs-hero__media {
    justify-self: center;
    width: 100%;
    max-width: min(100%, calc(var(--shot-max) + 1.25rem));
  }

  .cs-hero--phone .cs-hero__media {
    max-width: none;
    width: auto;
  }

  .cs-hero--mockup .cs-hero__media {
    max-width: min(100%, var(--shot-max));
  }

  @media (min-width: 64rem) {
    .cs-hero {
      padding-block: var(--space-6) var(--space-7);
    }

    .cs-hero__inner {
      grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
      gap: var(--space-6);
    }

    .cs-hero--text .cs-hero__inner {
      grid-template-columns: minmax(0, 1fr);
    }

    .cs-hero__media {
      justify-self: end;
    }

    .cs-hero--phone .cs-hero__media {
      justify-self: center;
    }
  }

  /* ---------- Frames: browser, phone, mockup, photo ---------- */

  .cs-frame__img {
    display: block;
    width: 100%;
    height: auto;
  }

  .cs-frame--browser {
    width: 100%;
    max-width: var(--shot-max);
    overflow: hidden;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-paper);
    box-shadow: 0 1.75rem 3.5rem -1.75rem var(--color-shadow-deep);
  }

  .cs-frame--hero.cs-frame--browser {
    max-width: none;
  }

  .cs-frame__bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 2rem;
    padding-inline: 0.75rem;
  }

  /* Three dots: one circle and two box-shadow copies */
  .cs-frame__dots {
    flex: none;
    width: 0.55rem;
    height: 0.55rem;
    margin-inline-end: 1.9rem;
    border-radius: 50%;
    background: var(--color-accent-2);
    box-shadow: 0.9rem 0 0 var(--color-gold-soft), 1.8rem 0 0 var(--color-brand);
  }

  .cs-frame__url {
    flex: 0 1 auto;
    min-width: 0;
    margin-inline: auto;
    padding: 0.15rem 1rem;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--color-white);
    color: var(--color-muted);
    font-size: 0.6875rem;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* The screen is a window onto the page: 4:3 in the gallery and the splits
     (the whole capture, scrolling), 16:10 in the hero (the top of the page) */
  .cs-frame__screen {
    overflow: hidden;
    background: var(--color-white);
  }

  .cs-frame--browser .cs-frame__screen {
    aspect-ratio: 4 / 3;
    border-top: var(--border);
  }

  .cs-frame--hero.cs-frame--browser .cs-frame__screen {
    aspect-ratio: 16 / 10;
  }

  .cs-frame--phone {
    width: 15rem;
    max-width: 100%;
    padding: 0.55rem;
    border: 1px solid var(--color-on-ink-line-faint);
    border-radius: 2.25rem;
    background: var(--color-ink);
    box-shadow: 0 1.75rem 3.5rem -1.75rem var(--color-shadow-deep);
  }

  .cs-frame--hero.cs-frame--phone {
    width: 17rem;
  }

  .cs-frame--phone .cs-frame__screen {
    aspect-ratio: 9 / 19.5;
    border-radius: 1.75rem;
  }

  /* A whole-page capture (shot.php): the window keeps its size and scrolls
     through the page; cs-scroll.js adds the slow scroll on hover. The focus
     ring sits inside the window, so the frame's rounded clip never hides it */
  .cs-frame__screen--scroll {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: var(--color-ink-track) transparent;
    scrollbar-width: thin;
  }

  .cs-frame__screen--scroll:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: -3px;
  }

  /* A mockup already shows its devices: drawn as it is, never wider than half
     its file and never taller than 34rem */
  .cs-frame--mockup {
    display: grid;
    place-items: center;
    width: 100%;
  }

  /* A definite width before the file loads (width: auto left an unloaded
     mockup 0x0, and it jumped to full height on load): the smallest of half
     the file, the column and the 34rem height cap turned into a width
     (--shot-cap from casestudy/shot.php, docs/design/perf-images.md) */
  .cs-frame--mockup .cs-frame__img {
    width: min(var(--shot-max), 80vw, var(--shot-cap, 100%));
    max-width: min(100%, var(--shot-max));
    max-height: 34rem;
    border-radius: var(--radius-sm);
  }

  @media (min-width: 48rem) {
    .cs-frame--mockup .cs-frame__img {
      width: min(var(--shot-max), 44rem, var(--shot-cap, 100%));
    }
  }

  .cs-frame--photo .cs-frame__img {
    border: 1px solid var(--color-on-ink-line-faint);
    border-radius: var(--radius-sm);
    box-shadow: 0 1.75rem 3.5rem -1.75rem var(--color-shadow-deep);
  }

  /* ---------- One screenshot with its caption ---------- */

  .cs-shot {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
    margin: 0;
  }

  .cs-shot__stage {
    display: grid;
    flex: 1 1 auto;
    place-items: center;
    padding: clamp(1rem, 3vw, 2rem);
    border-radius: var(--radius-lg);
    background: var(--accent-pale);
  }

  .cs-shot__caption {
    color: var(--color-muted);
    font-size: var(--step--1);
    line-height: 1.5;
  }

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

  /* ---------- Summary: quick facts and the positioning line ---------- */

  .cs-facts {
    overflow: hidden;
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--color-white);
    box-shadow: var(--shadow-hard);
  }

  /* Hairlines between the facts: the list's ink shows through 1px gaps, and
     the last row's items grow, so no empty cell is ever drawn */
  .cs-facts__main {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    margin: 0;
    background: var(--color-ink);
  }

  .cs-facts__item {
    flex: 1 1 12rem;
    padding: var(--space-3) var(--space-4);
    background: var(--color-white);
  }

  .cs-facts__label {
    color: var(--color-muted);
    font-size: var(--step--1);
    font-weight: var(--weight-strong);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .cs-facts__value {
    margin: var(--space-1) 0 0;
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading-sm);
    line-height: 1.35;
  }

  .cs-facts__more {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0;
    padding: var(--space-3) var(--space-4);
    border-top: var(--border);
    background: var(--accent-pale);
  }

  .cs-facts__chip {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5em;
    max-width: 100%;
    padding: 0.45em 1em;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    font-size: 0.875rem;
    line-height: 1.4;
  }

  .cs-facts__chip dt {
    font-weight: var(--weight-strong);
  }

  .cs-facts__chip dd {
    margin: 0;
  }

  /* Large type moment: the positioning line */
  .cs-moment {
    max-width: 52rem;
    margin: var(--space-6) auto 0;
    text-align: center;
  }

  .cs-moment__text {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 1.2rem + 2vw, 2.625rem);
    font-weight: var(--weight-heading);
    line-height: 1.25;
  }

  .cs-moment__proof {
    max-width: 40rem;
    margin: var(--space-3) auto 0;
    color: var(--color-muted);
  }

  .cs-moment__proof .caps-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--color-ink);
  }

  @media (min-width: 48rem) {
    .cs-moment__text {
      font-weight: var(--weight-display);
    }
  }

  /* ---------- Story chapters: number, title, split layouts ---------- */

  .cs-chapter__step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-style: italic;
    font-weight: var(--weight-display);
  }

  .cs-chapter__step::before {
    counter-increment: cs-step;
    content: counter(cs-step, decimal-leading-zero);
  }

  .cs-chapter__step::after {
    content: "";
    width: 3rem;
    height: 1px;
    background: currentColor;
  }

  .cs-chapter__title {
    margin-block: var(--space-2) var(--space-4);
    font-size: var(--step-5);
    line-height: var(--leading-tight);
  }

  .cs-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
  }

  .cs-split__text {
    max-width: var(--measure);
  }

  .cs-split--single .cs-split__text {
    margin-inline: auto;
  }

  .cs-blocks > .prose,
  .cs-blocks > * + * {
    margin-top: var(--space-3);
  }

  /* The blocks a study shares with other pages (timeline, exchange, data strip, chart,
     diagram, video) sit in the story column on the section's own background: a block
     left on the default paper draws no box of its own, and the data strip keeps its
     margins (on its own page it trims a whole section's padding) */
  .cs-blocks > .narrow-block {
    margin-block: var(--space-5) 0;
  }

  .cs-blocks > .narrow-block:first-child {
    margin-top: 0;
  }

  .cs-blocks > .narrow-block.section--paper {
    background: none;
  }

  .cs-blocks .datastrip {
    margin-block: 0;
  }

  .cs-card {
    margin-top: var(--space-5);
    padding: var(--space-4);
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--accent-pale);
    box-shadow: var(--shadow-hard);
  }

  .cs-split__aside > .cs-card {
    margin-top: 0;
  }

  .cs-card__title {
    margin-bottom: var(--space-2);
    font-size: var(--step-2);
  }

  .cs-included li + li {
    margin-top: var(--space-1);
  }

  @media (min-width: 64rem) {
    .cs-split:not(.cs-split--single) {
      grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
      gap: var(--space-6);
      align-items: start;
    }

    .cs-split--reverse:not(.cs-split--single) {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    }

    .cs-split--reverse .cs-split__aside {
      order: -1;
    }

    .cs-split--reverse .cs-split__text {
      justify-self: end;
    }

    /* the text and the screenshot start level: the aside skips the chapter number */
    .cs-split__aside {
      padding-top: var(--space-5);
    }
  }

  /* The screenshot or card stays in view beside a long text, when the screen is tall enough for it */
  @media (min-width: 64rem) and (min-height: 50rem) {
    .cs-split--shot .cs-split__aside,
    .cs-split--goals .cs-split__aside,
    .cs-split--included .cs-split__aside {
      position: sticky;
      top: calc(var(--header-height) + 5rem);
    }
  }

  /* ---------- Gallery: a swipeable row on phones, a grid from 48rem ---------- */

  .cs-gallery__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }

  .cs-gallery__title {
    margin: 0;
    font-size: var(--step-5);
  }

  .cs-gallery__hint {
    margin: 0;
    color: var(--color-brand);
  }

  /* A column-flow grid, not a flex row: Chrome prints a flex scroll row with
     positioned children short (blocks.css, "team-row"); the grid prints in full */
  .cs-gallery__list {
    display: grid;
    grid-auto-columns: min(20rem, 82vw);
    grid-auto-flow: column;
    gap: var(--space-3);
    margin-inline: calc(-1 * var(--gutter));
    padding: var(--space-1) var(--gutter) var(--space-3);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-color: var(--color-on-ink-scrollbar) transparent;
    scrollbar-width: thin;
  }

  .cs-gallery__list > .cs-shot,
  .cs-gallery__pair > .cs-shot {
    scroll-snap-align: start;
  }

  /* On phones a before/after pair is two cards in the row */
  .cs-gallery__pair {
    display: contents;
  }

  .cs-gallery .cs-shot__stage {
    border: 1px solid var(--color-on-ink-border-faint);
    background: var(--color-on-ink-fill);
  }

  .cs-gallery .cs-shot__caption {
    color: var(--color-on-ink-text-strong);
  }

  .cs-gallery .cs-shot__device {
    color: var(--color-brand);
  }

  /* Phones: each card is as tall as its own image, not the tallest in the row.
     Page captures and mockups fill the card's width; a very tall one is cut
     at 34rem from the bottom, so the top of the capture stays in view. Phone
     captures keep their phone frame, centered. */
  @media (max-width: 47.9375rem) {
    .cs-gallery__list {
      align-items: start;
    }

    .cs-gallery .cs-shot__stage {
      flex: none;
    }

    .cs-gallery .cs-shot--browser .cs-shot__stage,
    .cs-gallery .cs-shot--mockup .cs-shot__stage {
      padding: 0;
      overflow: hidden;
    }

    .cs-gallery .cs-shot--browser .cs-shot__stage {
      border: 0;
      background: none;
    }

    .cs-gallery .cs-frame--browser,
    .cs-gallery .cs-frame--mockup {
      width: 100%;
      max-width: none;
    }

    .cs-gallery .cs-frame--mockup .cs-frame__img {
      width: 100%;
      max-width: none;
      max-height: 34rem;
      object-fit: cover;
      object-position: top;
    }
  }

  @media (min-width: 48rem) {
    .cs-gallery__hint {
      display: none;
    }

    .cs-gallery__list {
      grid-auto-flow: row;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-5) var(--space-4);
      margin-inline: 0;
      padding: 0;
      overflow: visible;
    }

    .cs-gallery__pair {
      display: grid;
      grid-column: 1 / -1;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-4);
    }

    .cs-gallery__list > .cs-shot:last-child:nth-child(odd) {
      grid-column: 1 / -1;
    }
  }

  /* Desktop: a 7 and 5 column rhythm that alternates row by row; a last
     screenshot on its own takes the whole row (its frame stays at 2x) */
  @media (min-width: 64rem) {
    .cs-gallery__list {
      grid-template-columns: repeat(12, minmax(0, 1fr));
      gap: var(--space-6) var(--space-4);
    }

    .cs-gallery__list > :nth-child(4n + 1),
    .cs-gallery__list > :nth-child(4n + 4) {
      grid-column: span 7;
    }

    .cs-gallery__list > :nth-child(4n + 2),
    .cs-gallery__list > :nth-child(4n + 3) {
      grid-column: span 5;
    }

    .cs-gallery__list > .cs-gallery__pair,
    .cs-gallery__list > .cs-shot:last-child:nth-child(odd) {
      grid-column: 1 / -1;
    }
  }

  @media print {
    .cs-gallery__hint {
      display: none;
    }

    .cs-gallery__list {
      grid-auto-flow: row;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      margin-inline: 0;
      padding: 0;
      overflow: visible;
    }
  }

  /* ---------- What made it work, What this means: title beside the text ---------- */

  .cs-why__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .cs-why__title {
    margin-top: var(--space-2);
    font-size: var(--step-6);
    line-height: 1.05;
  }

  .cs-whofor__title {
    font-size: var(--step-4);
    line-height: var(--leading-heading);
  }

  .cs-why__text {
    max-width: var(--measure);
  }

  /* An optional exhibit under What made it work, Who it is for and the FAQs (snippets/casestudy/exhibits.php) */
  .cs-why__body {
    min-width: 0;
  }

  .cs-exhibits {
    margin-top: var(--space-5);
  }

  /* The first paragraph is the large type moment */
  .cs-why .cs-why__text > p:first-child {
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.35;
  }

  @media (min-width: 64rem) {
    .cs-why__inner {
      grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
      gap: var(--space-6);
      align-items: start;
    }

    .cs-why__head {
      position: sticky;
      top: calc(var(--header-height) + 5rem);
    }
  }

  /* ---------- Pull quote: one lifted sentence, large ---------- */

  .cs-pull__figure {
    max-width: 52rem;
    margin: 0 auto;
    text-align: center;
  }

  .cs-pull__quote {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 1.15rem + 2.8vw, 3.25rem);
    font-style: italic;
    font-weight: var(--weight-heading);
    line-height: 1.2;
  }

  .cs-pull__quote::before {
    content: "\201C";
    display: block;
    height: 0.6em;
    font-size: 2.5em;
    line-height: 1;
  }

  @media (min-width: 48rem) {
    .cs-pull__quote {
      font-weight: var(--weight-display);
    }
  }

  /* ---------- Results (an ink section, design review #76) ---------- */

  /* The figures and the "early results" pill stay white with ink text; the
     hard ink shadow would vanish on ink, so the cards go without it */
  .cs-results :is(.metrics__item, .casestudy-results__early) {
    color: var(--color-ink);
  }

  .cs-results__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
  }

  .cs-results__step {
    flex-basis: 100%;
  }

  .cs-results__title {
    margin: 0;
    font-size: var(--step-6);
    line-height: 1.05;
  }

  .cs-results__head .casestudy-results__early {
    margin: 0;
  }

  .cs-metrics {
    margin: var(--space-5) 0 0;
  }

  .cs-metrics .metrics__item {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .cs-metrics .metrics__figure {
    font-size: var(--step-5);
    font-weight: var(--weight-display);
    line-height: 1.05;
  }

  .cs-metrics .metrics__source {
    margin-top: auto;
    padding-top: var(--space-2);
  }

  .cs-results__story {
    max-width: var(--measure);
    margin-top: var(--space-5);
  }

  /* No figures: the story's first paragraph is the written outcome, in large type */
  .cs-results__story--lead > p:first-child {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
    font-weight: var(--weight-heading);
    line-height: 1.3;
  }

  /* ---------- Client quote and the "From Christina" note ---------- */

  .cs-voices__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    max-width: 56rem;
    margin-inline: auto;
  }

  .cs-voices__inner--both {
    max-width: var(--container);
  }

  .cs-quote {
    margin: 0;
  }

  .cs-quote__text {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.375rem);
    font-weight: var(--weight-heading);
    line-height: 1.3;
  }

  .cs-quote__text::before {
    content: "\201C";
    display: block;
    height: 0.55em;
    color: var(--color-accent-2);
    font-size: 3em;
    line-height: 1;
  }

  .cs-quote__by {
    margin-top: var(--space-3);
  }

  .cs-note {
    align-self: start;
    background: var(--color-white);
  }

  /* ---------- Who speaks: headshot, name and role (casestudy/byline.php) ---------- */

  .cs-byline {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .cs-byline__photo {
    flex: none;
    width: 5rem;
    height: 5rem;
    object-fit: cover;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-paper);
  }

  .cs-byline__text {
    display: grid;
    gap: 0.2rem;
    margin: 0;
  }

  .cs-byline__name {
    font-weight: 600;
  }

  /* ---------- How we built it: Kevin's chapter, the title and his byline beside the blocks ---------- */

  .cs-built__head .cs-chapter__title {
    margin-bottom: var(--space-3);
  }

  .cs-built__body {
    min-width: 0;
    max-width: var(--measure);
  }

  @media (min-width: 64rem) {
    .cs-voices__inner--both {
      grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
      gap: var(--space-6);
      align-items: center;
    }

    .cs-quote__text {
      font-weight: var(--weight-display);
    }
  }

  /* ---------- The service behind this project ---------- */

  .cs-service__box {
    display: grid;
    gap: var(--space-3);
    max-width: 64rem;
    margin-inline: auto;
    padding: var(--space-4);
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--color-paper);
    box-shadow: var(--shadow-hard);
  }

  /* the section takes paper when the one above it is white (templates/casestudy.php): the box turns white */
  .cs-service.section--paper .cs-service__box {
    background: var(--color-white);
  }

  .cs-service__text > * {
    margin: 0;
  }

  .cs-service__text > * + * {
    margin-top: var(--space-2);
  }

  .cs-service__title {
    font-size: var(--step-3);
    font-weight: var(--weight-heading);
  }

  @media (min-width: 48rem) {
    .cs-service__box {
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: var(--space-5);
      padding: var(--space-5);
    }
  }

  /* ---------- Closing band: the soft wash, no shapes (design review #72) ---------- */

  .cs-cta.section--gradient {
    background: var(--gradient-home-wash);
  }

  /* ---------- More case studies ---------- */

  .cs-more__title {
    margin: 0 0 var(--space-5);
  }
}
