/* Case study layout on the design system. Layout only: every text style comes from a .ds-* class
   in tokens.css, and every space from the spacing scale. */
#site-root button { font-family: var(--font-sans); } /* buttons don't inherit the page font */
.cs-main { --col: 680px; --media: 960px; --gutter: var(--space-32); }
.cs-sec { padding: var(--section-gap) var(--gutter) 0; }
.cs-hero { padding-top: var(--space-48); }
.cs-col { max-width: var(--col); margin-left: auto; margin-right: auto; }
.cs-media { max-width: var(--media); margin-left: auto; margin-right: auto; }
.cs-hero .cs-col { margin-top: var(--space-48); }
.cs-col + .cs-media { margin-top: var(--media-before); }
.cs-after-media, .cs-after { margin-top: var(--media-after); }
/* a heading sits with what it introduces, even when that's a wide block in the next container: the
   heading's own space after, and an H3 over a list of H4 items gets the H3 to H4 space, as in a column */
.cs-col:has(> :is(h2, .ds-h2):last-child) + :is(.cs-media, .cs-col) { margin-top: var(--h2-after); }
.cs-col:has(> :is(h3, .ds-h3):last-child) + :is(.cs-media, .cs-col) { margin-top: var(--h3-after); }
.cs-col:has(> :is(h3, .ds-h3):last-child) + :is(.cs-fa, .cs-decisions, .cs-problems, .cs-grid-2) { margin-top: var(--space-16); }
.cs-col:has(> :is(h4, .ds-h4):last-child) + :is(.cs-media, .cs-col) { margin-top: var(--h4-after); }
.cs-sub { margin-top: var(--h3-before); }
:where(.cs-main) :where(h1, h2, h3, h4, p, dl, dd, ul, figure, blockquote) { margin: 0; } /* no specificity, so .ds-flow spacing wins */
:where(.cs-main) :where(ul) { list-style: none; padding: 0; }
/* a heading's space after holds outside a ds-flow column too (principle rows, cards, grids) */
.cs-main :is(h3, .ds-h3) + :is(p, .ds-body) { margin-top: var(--h3-after); }
.cs-main :is(h4, .ds-h4) + :is(p, .ds-body) { margin-top: var(--h4-after); }
.cs-main strong { font-weight: var(--weight-semibold); color: var(--ink); }

/* media frames: videos, iframes and image slots */
.cs-frame { position: relative; width: 100%; border-radius: var(--space-16); overflow: hidden; background: var(--ink); }
.cs-16x9 { aspect-ratio: 16 / 9; }
.cs-16x10 { aspect-ratio: 16 / 10; }
.cs-4x3 { aspect-ratio: 4 / 3; }
.cs-frame:is(.cs-16x9, .cs-16x10, .cs-4x3, .cs-4x5, .cs-9x16) > [data-slot] { height: 100%; aspect-ratio: auto; }
.cs-frame > wistia-player { position: relative; z-index: 1; display: block; width: 100%; }
.cs-swatch { position: absolute; inset: calc(var(--space-8) * -1); background: center / cover no-repeat; filter: blur(5px); }
.cs-fill { position: absolute; inset: 0; }
.cs-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-24); }
.cs-shot { display: flex; flex-direction: column; gap: var(--media-caption); min-width: 0; }

/* hero */
.cs-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-16) var(--space-24); }
.cs-meta dt { margin-bottom: var(--space-4); }
.cs-meta dd { color: var(--ink); }
.ds-flow > .cs-meta + * { margin-top: var(--space-24); }
/* tags: plain Small text in the secondary ink with middots, starting on the text column's edge.
   Each tag after the first carries its middot in the 24px gap before it; the list clips to its own
   box, so a tag that wraps to the start of a line has its dot cut off and never starts with one. */
.cs-tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; column-gap: var(--space-24); clip-path: inset(0); }
.cs-tags li { position: relative; color: var(--ink-secondary); white-space: nowrap; }
.cs-tags li + li::before { content: '·'; position: absolute; right: 100%; width: var(--space-24); text-align: center; }

/* problems */
.cs-problems { display: flex; flex-direction: column; gap: var(--row-gap); }
.cs-problem { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-32); align-items: start; }
.cs-media > [data-slot] { border-radius: var(--space-16); overflow: hidden; }
.cs-problem-img, .cs-next-img { position: relative; border-radius: var(--space-12); overflow: hidden; background: var(--sunken); }
.cs-problem-img { aspect-ratio: 4 / 3; }
.cs-problem-img [data-slot], .cs-next-img [data-slot] { height: 100%; aspect-ratio: auto; }

/* tone benchmark */
.cs-tone { display: flex; flex-direction: column; gap: var(--chart-bar-gap); }
.cs-tone-axis { display: flex; justify-content: space-between; }
.cs-tone-row { display: flex; flex-direction: column; gap: var(--chart-label); }
.cs-tone-us .ds-small { color: var(--ink); font-weight: var(--weight-semibold); }
.cs-bar { height: var(--space-12); border-radius: 999px; background: var(--sunken); overflow: hidden; }
.cs-bar > div { height: 100%; border-radius: 999px; background: #CDBDF0; }
.cs-tone-us .cs-bar > div { background: var(--theme-fill); }
.cs-tone figcaption { margin-top: calc(var(--chart-caption) - var(--chart-bar-gap)); }

/* tables */
.cs-table { border-bottom: 1px solid var(--rule); }
.cs-tr { display: grid; border-top: 1px solid var(--rule); align-items: start; }
.cs-tr > * { min-width: 0; padding: var(--cell-y) var(--cell-x); }
.cs-thead { border-top: 0; background: var(--sunken); border-radius: var(--radius-control) var(--radius-control) 0 0; }
.cs-thead > * { padding-top: var(--space-12); padding-bottom: var(--space-12); }
.cs-cols-4 .cs-tr { grid-template-columns: minmax(0, 0.7fr) repeat(3, minmax(0, 1fr)); }
.cs-cols-3 .cs-tr { grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1.6fr); }
.cs-cols-2 .cs-tr { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.cs-tr [role="cell"] > span { display: block; }
.cs-ml { display: none !important; margin-bottom: var(--pair-label); }
.cs-flag { color: var(--theme-text); font-weight: var(--weight-semibold); }

/* figures and stats */
.cs-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-24) var(--space-32); }
.cs-figures-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cs-figures .ds-figure + .ds-small { margin-top: var(--space-4); }
.cs-figure { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--media-caption); }
.cs-caption { max-width: var(--col); }
.cs-dev-cap { display: flex; flex-direction: column; gap: var(--space-4); }

/* voice principles */
.cs-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--unit-gap); }
.cs-card { padding: var(--space-24); background: var(--raised); border: 1px solid var(--rule); border-radius: var(--space-16); }
.cs-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pair-gap); }
.cs-principles .cs-pair { grid-template-columns: minmax(0, 1fr); }
.cs-pair dt { margin-bottom: var(--pair-label); }
.cs-yes, .cs-no { display: flex; align-items: center; gap: var(--space-8); }
.cs-yes::before, .cs-no::before { content: ''; width: var(--space-8); height: var(--space-8); border-radius: 50%; background: var(--theme-fill); }
.cs-no::before { background: var(--rule); }
.cs-quote { padding-left: var(--space-16); border-left: 2px solid var(--rule); }
.cs-quote .ds-small { display: block; margin-top: var(--space-4); }
.cs-accent { padding-left: var(--space-16); border-left: 2px solid var(--theme-fill); }

/* brand swatches */
.cs-swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-24) var(--space-16); }
.cs-swatches > div { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.cs-chip { aspect-ratio: 1 / 1; border-radius: var(--space-12); border: 1px solid var(--rule); display: flex; align-items: flex-end; padding: var(--space-12); margin-bottom: var(--space-8); }
.cs-bar-chip { height: 56px; border-radius: var(--space-8); border: 1px solid var(--rule); display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-8); }
.cs-bar-chip span { width: 34%; height: var(--space-12); border-radius: 999px; }

/* survey data: compared figures, bar charts and a split bar */
.cs-meta-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cs-figure-ink { color: var(--ink); }
.cs-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-24) var(--space-32); }
.cs-compare > div > .ds-figure, .cs-figures .ds-label + .ds-figure { margin-top: var(--space-4); }
.cs-compare > div > .ds-small { margin-top: var(--space-4); }
.cs-facts { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-32); }
.cs-chart { display: flex; flex-direction: column; gap: var(--chart-caption); }
.cs-bars { display: flex; flex-direction: column; gap: var(--chart-bar-gap); }
.cs-bar-row { display: flex; flex-direction: column; gap: var(--chart-label); }
.cs-bar-head { display: flex; justify-content: space-between; gap: var(--space-16); color: var(--ink); }
.cs-bar-head > span:last-child { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.cs-track { height: var(--space-8); border-radius: 999px; background: var(--sunken); overflow: hidden; }
.cs-track > div { height: 100%; border-radius: 999px; background: var(--fill-muted); transform-origin: left center; }
.cs-bar-us .cs-track > div { background: var(--theme-fill); }
.cs-split { display: flex; gap: 2px; height: var(--space-12); border-radius: 999px; overflow: hidden; }
.cs-split-a { background: var(--theme-fill); }
.cs-split-b { background: var(--ink); }
.cs-split-c { background: var(--fill-muted); }
.cs-legend { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-24); color: var(--ink); }
.cs-legend li { display: flex; align-items: center; gap: var(--space-8); }
.cs-dot { width: var(--space-8); height: var(--space-8); border-radius: 50%; }

/* a quote beside a video */
.cs-quote-video { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: var(--space-48); align-items: start; }
.cs-quote.ds-flow > * + * { margin-top: var(--space-12); }

/* research to principle rows */
.cs-principles:not(.cs-grid-2) { display: flex; flex-direction: column; }
.cs-pr-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--space-48) minmax(0, 1fr); gap: var(--space-24); align-items: start; padding: var(--space-32) 0; border-top: 1px solid var(--rule); }
.cs-pr-row:last-child { border-bottom: 1px solid var(--rule); }
.cs-pr-row .ds-label + .ds-body { margin-top: var(--pair-label); }
.cs-pr-arrow { display: flex; justify-content: center; padding-top: var(--space-4); color: var(--theme-text); }

/* a colour key: dot, name, note */
.cs-glow li { display: grid; grid-template-columns: var(--space-16) minmax(0, 1fr) auto; gap: var(--space-12); align-items: center; padding: var(--space-12) 0; border-top: 1px solid var(--rule); }
.cs-glow li:last-child { border-bottom: 1px solid var(--rule); }
.cs-glow-dot { width: var(--space-16); height: var(--space-16); border-radius: 50%; }

/* phone screens and wide diagrams */
.cs-4x5 { aspect-ratio: 4 / 5; }
.cs-light { background: var(--sunken); }
.cs-phone { aspect-ratio: 9 / 19.5; border-radius: var(--space-24); background: var(--sunken); border: 1px solid var(--rule); }
.cs-wide { aspect-ratio: 16 / 10; background: var(--sunken); border: 1px solid var(--rule); }
.cs-phones { display: flex; justify-content: center; gap: var(--space-16); min-width: 0; }
.cs-phones > .cs-shot { width: 240px; max-width: calc(50% - var(--space-8)); }
.cs-fa { display: flex; flex-direction: column; gap: var(--row-gap); }
.cs-fa-row { display: grid; grid-template-columns: minmax(0, 45fr) minmax(0, 55fr); gap: var(--space-48); align-items: start; }
.cs-fa-row .ds-figure + .ds-small, .ds-flow > div > .ds-figure + .ds-small { margin-top: var(--space-4); }

/* personas and result cards */
.cs-persona { display: flex; flex-direction: column; gap: var(--space-8); }
.cs-avatar { width: var(--space-64); height: var(--space-64); border-radius: 50%; overflow: hidden; background: var(--sunken); margin-bottom: var(--space-8); }
.cs-avatar [data-slot] { height: 100%; aspect-ratio: auto; }
.cs-persona > .ds-h4, .cs-persona > .cs-persona-sub { margin-top: var(--space-16); }
.cs-card > .ds-label + .ds-figure { margin-top: var(--space-8); }
.cs-card > .ds-figure + .ds-small { margin-top: var(--space-4); }
.cs-card-rule { margin-top: var(--space-16); padding-top: var(--space-16); border-top: 1px solid var(--rule); }

/* lists, comparison verdicts and a four-step loop */
.cs-list li { padding: var(--space-12) 0; border-top: 1px solid var(--rule); }
.cs-list li:last-child { border-bottom: 1px solid var(--rule); }
.cs-bullets li { position: relative; padding-left: var(--space-16); }
.cs-bullets li::before { content: ''; position: absolute; left: 0; top: calc(var(--body-line) / 2 - 3px); width: 6px; height: 6px; border-radius: 50%; background: var(--theme-fill); }
.cs-bar-ink .cs-track > div { background: var(--ink); }
.cs-v { display: inline-block; font-weight: var(--weight-semibold); color: var(--ink-secondary); }
.cs-v-yes { color: var(--theme-text); }
.cs-v-partly { color: var(--ink); }
.cs-tr [role="cell"] > .cs-v + .ds-small { margin-top: var(--space-4); }
.cs-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--unit-gap) var(--space-32); }

/* design decisions: question beside its screens */
.cs-decisions { display: flex; flex-direction: column; gap: var(--row-gap); }
.cs-9x16 { aspect-ratio: 9 / 16; }
.cs-loop { display: flex; align-items: center; justify-content: center; gap: var(--space-8); }
.cs-loop > .cs-shot { flex: 1 1 0; max-width: 180px; }
.cs-loop > .cs-pr-arrow { flex: none; padding-top: 0; padding-bottom: var(--space-24); }
.cs-palette { aspect-ratio: 680 / 383; background: transparent; }
.cs-palette > [data-slot] { height: 100%; aspect-ratio: auto; }
.cs-palette-keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-8); }
.cs-palette-keys .ds-data { display: block; font-size: var(--label-size); line-height: var(--label-line); }
.cs-chips { display: flex; gap: var(--space-8); }
.cs-chips span { width: var(--space-48); height: var(--space-48); border-radius: var(--space-12); border: 1px solid var(--rule); }

/* wide blocks in a column: text to a figure, chart, table, grid or card gets --media-before, and the
   text after one gets --media-after. A heading keeps its own space after, and notes and sources stay
   tucked under what they describe, at the caption space. The same holds when the block ends one container and the next
   container starts. */
.ds-flow > :not(h1, h2, h3, h4, .ds-title, .ds-h2, .ds-h3, .ds-h4) + :is(figure, .cs-chart, .cs-tone, .cs-table, .cs-swatches, .cs-compare, .cs-facts, .cs-glow, .cs-card, .cs-two, .cs-grid-2, .cs-grid-4, .cs-figures, .cs-bars) { margin-top: var(--media-before); }
.ds-flow > :is(figure, .cs-chart, .cs-tone, .cs-table, .cs-swatches, .cs-compare, .cs-facts, .cs-glow, .cs-card, .cs-two, .cs-grid-2, .cs-grid-4, .cs-figures, .cs-bars) + :not(.ds-label, .ds-small, figcaption) { margin-top: var(--media-after); }
.ds-flow > :is(figure, .cs-chart, .cs-tone, .cs-table, .cs-swatches, .cs-compare, .cs-facts, .cs-glow, .cs-card, .cs-two, .cs-grid-2, .cs-grid-4, .cs-figures, .cs-bars) + :is(.ds-label, figcaption) { margin-top: var(--media-caption); }
.cs-col:has(> :is(figure, .cs-chart, .cs-tone, .cs-table, .cs-swatches, .cs-compare, .cs-facts, .cs-glow, .cs-card, .cs-two, .cs-grid-2, .cs-grid-4, .cs-figures, .cs-bars):last-child) + :is(.cs-media, .cs-col) { margin-top: var(--media-after); }
/* repeated groups in one column: a rule and --unit-gap between them */
.cs-units > h4:not(h3 + h4) { margin-top: var(--unit-gap); padding-top: var(--unit-gap); border-top: 1px solid var(--rule); }

/* see next */
[data-next-grid] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-24); }
.cs-next-card { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-12) var(--space-12) var(--space-16); border-radius: var(--space-16); border: 1px solid var(--rule); background: var(--raised); color: var(--ink); transition: transform var(--duration-base) var(--ease), box-shadow var(--duration-base) var(--ease); }
/* nested in the card: its 16px radius less the 12px padding (DESIGN_SYSTEM.md, Shape) */
.cs-next-img { aspect-ratio: 16 / 11; margin-bottom: var(--space-12); border-radius: calc(var(--radius-card) - var(--space-12)); }
.cs-next-card h3 { margin: 0; }
.cs-next-link { margin-top: var(--space-32); }

/* the TOC sits in the left margin from 1380px; between 1024 and 1379 the content moves right to clear it */
@media (min-width: 1024px) and (max-width: 1379px) {
  .cs-sec { padding-left: 208px; padding-right: var(--space-32); }
  .cs-col, .cs-media { margin-left: 0; }
}
@media (max-width: 1023px) {
  .cs-problem { grid-template-columns: minmax(0, 1fr); gap: var(--space-24); }
  .cs-grid-2 { grid-template-columns: minmax(0, 1fr); }
  /* stacked plain text units get a rule; cards already read as separate */
  .cs-grid-2 > :not(.cs-card) + :not(.cs-card) { padding-top: var(--unit-gap); border-top: 1px solid var(--rule); }
  .cs-quote-video { grid-template-columns: minmax(0, 1fr); gap: var(--space-24); }
  .cs-fa-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-24); }
  .cs-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .cs-main { --gutter: var(--space-16); }
  .cs-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* tables become cards: the row's name is H3, its labels are Label */
  .cs-thead { display: none !important; }
  .cs-table { display: flex; flex-direction: column; gap: var(--unit-gap); border-bottom: 0; }
  .cs-tr, .cs-cols-4 .cs-tr, .cs-cols-3 .cs-tr, .cs-cols-2 .cs-tr { grid-template-columns: minmax(0, 1fr); gap: var(--pair-gap); padding: var(--space-24); border: 1px solid var(--rule); border-radius: var(--radius-card); background: var(--raised); }
  .cs-tr > * { padding: 0; }
  .cs-tr > :first-child.ds-h4, .cs-tr > :first-child > .ds-h4 { font-size: var(--h3-size); line-height: var(--h3-line); }
  .cs-ml { display: block !important; }
  .cs-figures, .cs-figures-3, .cs-pair { grid-template-columns: minmax(0, 1fr); }
  .cs-swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-meta-3, .cs-compare, .cs-two, .cs-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .cs-grid-4 { gap: var(--unit-gap); }
  .cs-pr-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-12); }
  .cs-pr-arrow { justify-content: flex-start; transform: rotate(90deg); width: var(--space-24); }
}
@media (prefers-reduced-motion: reduce) { .cs-next-card { transition: none; } }

/* a secondary action (Skip to solution): an underlined text link with its arrow */
.cs-text-link { display: inline-flex; align-items: center; gap: var(--space-8); min-height: var(--space-48); color: var(--ink); font-family: var(--font-sans); font-size: var(--small-size); line-height: var(--small-line); font-weight: var(--weight-medium); }
