/* ==================================================================
   MISC STUDIO — case study page.
   Sits on top of site.css (tokens, surfaces, header, menu, buttons,
   cards, footer). Only the case-study sections live here.
   ================================================================== */

/* ── Hero ───────────────────────────────────────────────────────── */
/* In the project's own colours: case-study.js sets the surface (void or
   light), --cs-bg / --cs-deep / --cs-glow and .is-themed from the project's
   theme. The ground is the project's base colour, deepened in one corner,
   lit by a soft glow of its palette in the other, with the dot field on top.
   Short on purpose: title left, intro right, so the shot below fills the
   lower half of the first screen. */
.cs-hero {
  position: relative;
  overflow: clip;
  padding-top: calc(var(--header-h) + var(--space-md));
}
.cs-hero.is-themed {
  background:
    var(--dots),
    radial-gradient(65% 75% at 92% -10%, color-mix(in srgb, var(--cs-glow) 26%, transparent) 0%, transparent 70%),
    radial-gradient(90% 80% at 0% 100%, var(--cs-deep) 0%, transparent 70%),
    var(--cs-bg);
}
.cs-hero [data-enter] {
  animation: enter 1s var(--ease-out) both;
  animation-delay: calc(150ms + var(--d, 0) * 90ms);
}
.cs-hero__inner { position: relative; z-index: 1; display: grid; gap: var(--space-md); }
.cs-hero__crumbs {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: var(--text-caption);
  color: var(--ink-soft);
  letter-spacing: 0;
  text-transform: uppercase;
}
.cs-hero__crumbs a { transition: color var(--dur-fast); }
.cs-hero__crumbs a:hover { color: var(--ink); }
.cs-hero__split {
  display: grid;
  gap: var(--space-md) var(--gutter);
  align-items: end;
}
@media (min-width: 64rem) {
  .cs-hero__split { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .cs-hero__title { grid-column: 1 / span 7; }
  .cs-hero__side { grid-column: 8 / -1; }
}
.cs-hero__title {
  max-width: 12ch;
  font-size: clamp(2.75rem, 1.4rem + 4.3vw, 6.5rem);
  font-weight: 500;
  line-height: .92;
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.cs-hero__side { display: grid; gap: var(--space-md); justify-items: start; }
.cs-hero__intro {
  color: var(--ink);
  font-size: clamp(1rem, .92rem + .3vw, 1.1875rem);
  line-height: 1.45;
  text-wrap: pretty;
}
/* the primary button wears the project's accent, with its own text colour
   (dark on yellow, orange and lilac; white on the blues) */
.cs .btn[data-variant="primary"] {
  --copy: var(--cs-on-accent, var(--brand-white));
  --fill: var(--cs-on-accent, var(--brand-white));
  --fill-copy: var(--brand-accent);
}

/* the facts open the story: a row of four on a wide screen */
.cs-facts--strip { margin-bottom: var(--space-xl); }
@media (min-width: 64rem) { .cs-facts.cs-facts--strip { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.cs-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm) var(--gutter);
  width: 100%;
}
.cs-facts > div {
  display: grid;
  gap: .375rem;
  align-content: start;
  padding-top: .75rem;
  border-top: 1px solid var(--rule);
}
.cs-facts dt {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--ink-soft);
}
.cs-facts dd { font-size: .9375rem; line-height: 1.3; }

/* ── Stage: the project shot that grows to full width ───────────── */
/* --p runs 0 → 1 (case-study.js). At 0 the card sits inset by the page
   gutter plus a bit, with the card radius; at 1 it is edge to edge. */
.cs-stage {
  --p: 0;
  --inset: calc(var(--gutter) + 6vw);
  position: relative;
  z-index: 1;
  margin-top: var(--space-lg);
}
.cs-stage__frame {
  position: relative;
  width: calc(100% - var(--inset) * 2 * (1 - var(--p)));
  height: min(62.5vw, 90svh);
  margin-inline: auto;
  border-radius: calc(var(--radius-card) * (1 - var(--p)));
  overflow: clip;
  background: var(--panel);
}
/* the whole shot is always visible (contain); a blurred copy fills
   whatever space is left around it, so nothing gets cropped */
.cs-stage__backdrop,
.cs-stage__img {
  position: absolute;
  max-width: none;
}
.cs-stage__backdrop {
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(40px) saturate(1.2);
  opacity: .7;
}
.cs-stage__img {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Gallery ────────────────────────────────────────────────────── */
.cs-gallery-wrap { position: relative; overflow: clip; padding-block: var(--space-2xl) var(--space-3xl); }
.cs-gallery { display: grid; gap: var(--space-xl); padding-top: var(--space-lg); }
.cs-shot { display: grid; gap: var(--space-xs); }
.cs-shot__frame {
  overflow: clip;
  border-radius: var(--radius-media);
  background: var(--panel);
  box-shadow: 0 1.5rem 4rem #00000066;
  will-change: transform;
}
.cs-shot img,
.cs-shot .cs-media { width: 100%; }
.cs-shot__caption { font-size: .8125rem; color: var(--ink-soft); max-width: 32rem; }

/* Gallery over the shot (case-study.js moves it into the hero): the shot
   pins once it has grown to full width, and the smaller shots scroll up
   over it at their own speeds. The layout of each part stays the same. */
.cs-hero.has-drift .cs-stage {
  position: sticky;
  top: max(0px, calc((100svh - min(62.5vw, 90svh)) / 2));
}
.cs-hero.has-drift > .cs-gallery {
  position: relative;
  z-index: 2;
  margin-top: -50svh;
  padding-bottom: 45svh;
}
/* Phones, as on the old page: once pinned the shot grows to fill the whole
   screen (contained, with the blurred backdrop around it), and the gallery
   shots are narrower so they cross it at staggered widths */
@media (max-width: 47.99rem) {
  .cs-hero.has-drift .cs-stage { top: 0; }
  .cs-hero.has-drift .cs-stage__frame { height: calc(62.5vw + (100svh - 62.5vw) * var(--p)); }
  .cs-hero.has-drift > .cs-gallery { margin-top: -70svh; padding-bottom: 60svh; }
  .cs-hero.has-drift .cs-shot:nth-child(4n + 1) { width: 45%; }
  .cs-hero.has-drift .cs-shot:nth-child(4n + 2) { width: 85%; margin-inline: auto; }
  .cs-hero.has-drift .cs-shot:nth-child(4n + 3) { width: 45%; margin-left: auto; }
  .cs-hero.has-drift .cs-shot:nth-child(4n + 4) { width: 60%; margin-left: 12%; }
  .cs-hero.has-drift .cs-shot__caption { font-size: .75rem; }
}
.cs-hero.has-drift .cs-shot__caption {
  justify-self: start;
  padding: .375rem .75rem;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--brand-void) 80%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--brand-white);
}
@media (min-width: 48rem) {
  .cs-gallery { gap: var(--space-2xl); }
  /* small left, wide centre, small right, medium offset */
  .cs-shot:nth-child(4n + 1) { width: 34%; }
  .cs-shot:nth-child(4n + 2) { width: 62%; margin-inline: auto; }
  .cs-shot:nth-child(4n + 3) { width: 34%; margin-left: auto; }
  .cs-shot:nth-child(4n + 4) { width: 44%; margin-left: 12%; }
}

/* ── Story ──────────────────────────────────────────────────────── */
.cs-chapters {
  display: grid;
  gap: var(--space-lg) var(--gutter);
}
@media (min-width: 64rem) { .cs-chapters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cs-chapter {
  display: grid;
  align-content: start;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--rule);
}
.cs-chapter__num,
.cs-decision__label,
.cs-note__num {
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.cs-chapter__heading { text-wrap: balance; }
.cs-chapter__body { color: var(--ink-soft); text-wrap: pretty; max-width: 34rem; }

/* section headings built by case-study.js */
.cs-head__title { max-width: 22ch; }

/* ── Decisions ──────────────────────────────────────────────────── */
.cs-decisions__list { display: grid; gap: var(--space-2xl); }
.cs-decision {
  display: grid;
  gap: var(--space-md) var(--gutter);
  align-items: center;
}
@media (min-width: 64rem) {
  .cs-decision { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .cs-decision__text { grid-column: 1 / span 4; }
  .cs-decision__shot { grid-column: 6 / -1; }
  .cs-decision--flip .cs-decision__text { grid-column: 9 / -1; grid-row: 1; }
  .cs-decision--flip .cs-decision__shot { grid-column: 1 / span 7; grid-row: 1; }
}
.cs-decision__text { display: grid; gap: var(--space-sm); align-content: start; }
.cs-decision__body { color: var(--ink-soft); text-wrap: pretty; }
.cs-decision__quote {
  display: grid;
  gap: .375rem;
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-well);
  background: var(--panel);
}
.cs-decision__quote p::before {
  content: "";
  display: block;
  width: 1.5rem;
  height: 2px;
  margin-bottom: .75rem;
  background: var(--brand-accent);
}
.cs-decision__quote p { font-size: var(--text-heading); letter-spacing: var(--tracking-heading); line-height: 1.15; }
.cs-decision__quote span { font-size: .8125rem; color: var(--ink-soft); }
.cs-decision__shot {
  padding: var(--space-xs);
  border-radius: var(--radius-card);
  background: var(--panel);
}
.cs-decision__shot img,
.cs-decision__shot .cs-media { width: 100%; border-radius: var(--radius-well); overflow: clip; }

/* ── Looping media (case-study.js: media) ───────────────────────── */
/* a muted loop in place of a screenshot, with a small pause button */
.cs-media { position: relative; }
.cs-media video { width: 100%; height: auto; }
.cs-media__toggle {
  position: absolute;
  right: .75rem;
  bottom: .75rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--brand-white) 18%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-void) 70%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--brand-white);
  cursor: pointer;
  opacity: .55;
  transition: opacity .2s ease;
}
.cs-media__toggle svg { width: .875rem; height: .875rem; fill: currentColor; }
.cs-media:hover .cs-media__toggle,
.cs-media__toggle:focus-visible,
.cs-media__toggle[aria-label="Play animation"] { opacity: 1; }
.cs-media__toggle:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* ── Visual system ──────────────────────────────────────────────── */
.cs-swatches {
  display: grid;
  gap: var(--space-xs);
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}
.cs-swatch {
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-xs);
  border-radius: var(--radius-card);
  background: var(--panel);
}
.cs-swatch__chip {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-well);
  box-shadow: inset 0 0 0 1px var(--rule);
}
.cs-swatch__meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: 0 .25rem .25rem; font-size: .875rem; }
.cs-swatch__meta strong { font-weight: 500; }
.cs-swatch__meta span { color: var(--ink-soft); font-variant-numeric: tabular-nums; text-transform: uppercase; }
.cs-fonts { display: grid; margin-top: var(--space-lg); }
.cs-font {
  display: grid;
  gap: .5rem var(--gutter);
  padding-block: var(--space-sm);
  border-top: 1px solid var(--rule);
}
.cs-font:last-child { border-bottom: 1px solid var(--rule); }
@media (min-width: 48rem) { .cs-font { grid-template-columns: 1fr 2fr; align-items: baseline; } }
.cs-font dd { color: var(--ink-soft); }

/* ── Structure ──────────────────────────────────────────────────── */
.cs-steps {
  display: grid;
  gap: var(--space-xs);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  counter-reset: none;
}
.cs-step { min-height: 13rem; }
.cs-step .card__num { margin-bottom: var(--space-sm); }

/* ── Build notes ────────────────────────────────────────────────── */
.cs-notes {
  display: grid;
  gap: 0 var(--gutter);
}
@media (min-width: 48rem) { .cs-notes { grid-template-columns: 1fr 1fr; } }
.cs-note {
  display: grid;
  gap: .625rem;
  align-content: start;
  padding-block: var(--space-md);
  border-top: 1px solid var(--rule);
}
.cs-note p { color: var(--ink-soft); text-wrap: pretty; max-width: 36rem; }

/* ── Figures ────────────────────────────────────────────────────── */
.cs-figures__row {
  display: grid;
  gap: var(--space-xs);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}
.cs-figure {
  display: grid;
  gap: var(--space-sm);
  align-content: space-between;
  min-height: 12rem;
  padding: var(--space-md);
  border-radius: var(--radius-card);
  background: var(--panel);
}
.cs-figure__value {
  display: flex;
  align-items: baseline;
  gap: .15em;
  font-weight: 500;
  font-size: var(--text-display);
  letter-spacing: var(--tracking-heading);
  line-height: .9;
  font-variant-numeric: tabular-nums;
}
.cs-figure__value small { font-size: var(--text-heading); letter-spacing: var(--tracking-copy); color: var(--ink-soft); }
.cs-figure__label { color: var(--ink-soft); font-size: .9375rem; }

/* ── Next project ───────────────────────────────────────────────── */
.cs-next .shell { position: relative; z-index: 1; }
.cs-next__card {
  display: grid;
  gap: var(--space-md) var(--gutter);
  align-items: end;
}
@media (min-width: 64rem) {
  .cs-next__card { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .cs-next__text { grid-column: 1 / span 5; }
  .cs-next__media { grid-column: 6 / -1; }
}
.cs-next__text { display: grid; gap: var(--space-sm); }
.cs-next__title { overflow-wrap: anywhere; }
.cs-next__tag { color: var(--ink-soft); }
.cs-next__media {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-media);
  overflow: clip;
  background: var(--panel);
}
.cs-next__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.1s var(--ease-out); }
@media (hover: hover) {
  .cs-next__card:hover .cs-next__media img { transform: scale(1.04); }
  .cs-next__card:hover .work__go { transform: none; }
}
.cs-next__card:focus-visible .work__go { transform: none; }
