/* ==========================================================================
   Case study
   The page takes the project's own ground, ink and accent (set as --bg, --fg
   and --accent on <html> from case.json → theme). It returns to white for
   the closing ask, so every page ends the same way: white, moonset, night.
   ========================================================================== */

.case {
  --measure: 56ch;
}

/* ---------- opening ---------- */

.case-hero {
  padding: clamp(7.5rem, 17vh, 10.5rem) var(--gutter) 0;
}
.case-hero__crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.9em;
  margin-bottom: clamp(1.25rem, 3vh, 2.25rem);
  color: var(--soft);
}
.case-hero__crumbs a {
  color: var(--fg);
  text-decoration: none;
}
.case-hero__head {
  display: grid;
  gap: clamp(1.5rem, 4vh, 2.5rem) 3rem;
  margin-bottom: clamp(2.25rem, 6vh, 4rem);
}
.case-hero__title {
  font-size: min(var(--step-4), 15vh);
  max-width: 11ch;
}
.case-hero__intro {
  display: grid;
  gap: 1rem;
  align-content: end;
  /* a long disclaimer wraps here rather than widening the column into the title */
  max-width: 30rem;
}
.case-hero__dek {
  max-width: 26ch;
  font-size: var(--step-1);
  line-height: 1.32;
}
.case-hero__project,
.case-hero__disclaimer {
  color: var(--accent);
}
.case-hero__media {
  margin: 0 calc(-1 * var(--gutter));
  overflow: hidden;
}
.case-hero__media img {
  width: 100%;
  height: min(72vh, 62vw);
  object-fit: cover;
}
@media (min-width: 900px) {
  .case-hero__head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
  .case-hero__intro {
    padding-bottom: 0.9rem;
  }
}

/* ---------- TL;DR: the sales summary, in view fast ---------- */

.tldr {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
  padding: clamp(3rem, 7vw, 6rem) var(--gutter);
}
.tldr__main {
  display: grid;
  gap: clamp(1.75rem, 3vw, 2.5rem);
}
.tldr dt,
.tldr h2 {
  margin-bottom: 0.7rem;
  color: var(--accent);
}
.tldr__main dd {
  max-width: 36ch;
}
.tldr__side {
  display: grid;
  gap: 1.75rem;
  align-content: start;
}
.tldr__side li + li {
  margin-top: 0.2rem;
}
.tldr__side p {
  max-width: 34ch;
}
@media (min-width: 900px) {
  .tldr {
    grid-template-columns: minmax(0, 9fr) minmax(0, 3fr);
  }
  .tldr__main {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- story blocks ---------- */

.block {
  padding: clamp(3rem, 7vw, 6.5rem) var(--gutter);
}
.block__label {
  margin-bottom: 1.25rem;
  color: var(--accent);
}
.block__heading {
  font-size: var(--step-3);
  line-height: 0.96;
  max-width: 14ch;
  margin-bottom: clamp(1.75rem, 3.4vw, 3rem);
}
.block__body {
  display: grid;
  gap: 1.1em;
  max-width: var(--measure);
}
@media (min-width: 900px) {
  .block--text {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
    column-gap: clamp(2rem, 4vw, 4rem);
  }
  .block--text .block__label {
    padding-top: 0.9em;
  }
}

.block--image,
.block--gallery {
  padding-block: clamp(1rem, 2.5vw, 2.25rem);
}
.block--image.is-full {
  padding-inline: 0;
}
.block figure,
.gallery__item {
  overflow: hidden;
}
.block img {
  width: 100%;
}
.caption {
  max-width: 62ch;
  margin-top: 0.9rem;
  color: var(--soft);
}
.block--image.is-full .caption {
  padding-inline: var(--gutter);
}

.gallery {
  display: grid;
  gap: clamp(1rem, 2.5vw, 2.25rem);
  align-items: start;
}
@media (min-width: 700px) {
  .gallery--grid-2,
  .gallery--pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gallery--grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .gallery--row-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- the lines: the campaign's own headlines, set big ---------- */

.lines {
  margin-top: clamp(1rem, 3vw, 2.5rem);
  border-top: 1px solid var(--rule);
}
.lines li {
  padding: clamp(0.9rem, 1.8vw, 1.5rem) 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.6rem, 1.05rem + 2.5vw, 3.6rem);
  line-height: 1.06;
  letter-spacing: -0.008em;
  text-wrap: balance;
}
.lines__note {
  margin-top: 1.25rem;
  color: var(--soft);
}

/* ---------- pull quote ---------- */

.block--quote blockquote {
  max-width: 24ch;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: var(--step-3);
  line-height: 1.05;
}
.block--quote cite {
  display: block;
  margin-top: 1.5rem;
  font-style: normal;
  color: var(--soft);
}

/* the story's last block needs air before the page turns white */
.case__end {
  height: clamp(3rem, 8vw, 7rem);
}

/* scripted entrance states (see the note at the end of home.css) */
.motion .case-hero__crumbs,
.motion .case-hero__intro > * {
  opacity: 0;
}

/* ---------- more gallery layouts ---------- */

/* a strip: tall pieces of one system, side by side */
@media (min-width: 700px) {
  .gallery--strip {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    grid-auto-flow: column;
  }
}
/* logos: on the page's own ground, given room, never cropped */
.gallery--logo {
  align-items: center;
  justify-items: center;
  gap: clamp(2.5rem, 6vw, 5rem);
  padding-block: clamp(2rem, 6vw, 5rem);
}
.gallery--logo .gallery__item {
  overflow: visible;
}
.gallery--logo img {
  width: auto;
  max-width: 100%;
  max-height: min(42vh, 22rem);
  object-fit: contain;
}
@media (min-width: 700px) {
  .gallery--logo {
    grid-template-columns: 2fr 1fr;
  }
}

/* ---------- compare: the steps of a build ----------
   Without JS the steps sit side by side, each with its label. With JS they
   stack in one frame and the tabs move between them. */

.block--compare > .block--text {
  padding: 0 0 clamp(1.75rem, 3.4vw, 3rem);
}
.steps__tabs {
  display: none;
}
.steps__frames {
  display: grid;
  gap: clamp(1rem, 2.5vw, 2.25rem);
}
.steps__frame {
  position: relative;
}
.steps__label {
  margin-top: 0.8rem;
  color: var(--soft);
}
.steps__label span,
.steps__tab span {
  color: var(--accent);
  margin-right: 0.5em;
}
@media (min-width: 700px) {
  .steps__frames {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    grid-auto-flow: column;
  }
}

.js .steps__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem clamp(1rem, 3vw, 2.5rem);
  margin-bottom: 1.1rem;
}
.js .steps__tab {
  position: relative;
  padding: 0.5rem 0;
  border: 0;
  background: none;
  color: var(--soft);
  cursor: pointer;
  transition: color var(--dur-ui) linear;
}
.js .steps__tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.2rem;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.5s var(--ease-out);
}
.js .steps__tab[aria-selected="true"] {
  color: var(--fg);
}
.js .steps__tab[aria-selected="true"]::after {
  transform: none;
}
@media (hover: hover) and (pointer: fine) {
  .js .steps__tab:hover {
    color: var(--fg);
  }
}
.js .steps__frames {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
}
/* every frame occupies the same cell; the chosen one sits on top */
.js .steps__frame {
  grid-area: 1 / 1;
  visibility: hidden;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.9s var(--ease-in-out), visibility 0s 0.9s;
}
.js .steps__frame.is-current {
  z-index: 1;
  visibility: visible;
  clip-path: inset(0);
  transition: clip-path 0.9s var(--ease-in-out), visibility 0s;
}
/* the one being left stays visible underneath until the new one has wiped over it */
.js .steps__frame.is-leaving {
  visibility: visible;
  clip-path: inset(0);
  transition: none;
}
.js .steps__label {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .js .steps__frame,
  .js .steps__frame.is-current {
    transition: none;
  }
}

/* ---------- the way on: another case study, named and glimpsed ----------
   Under the ask, for the reader who is not ready to write yet (M07: give a
   next step). The whole row is the link. */

.next-case {
  display: grid;
  gap: 0.9rem;
  justify-items: start;
  width: 100%;
  margin-top: clamp(2.5rem, 6vw, 5rem);
  padding-top: clamp(1.5rem, 3vw, 2.5rem);
  border-top: 1px solid var(--rule);
  text-decoration: none;
}
.next-case__label {
  color: var(--soft);
}
.next-case__title {
  font-size: var(--step-3);
  max-width: 12ch;
  transition: translate 0.6s var(--ease-out);
}
.next-case__media {
  display: block;
  width: 100%;
  overflow: hidden;
  margin: 0.5rem 0;
}
.next-case__media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
  transition: scale 1.2s var(--ease-out);
}
@media (min-width: 760px) {
  .next-case {
    grid-template-columns: minmax(0, 1fr) clamp(16rem, 34vw, 30rem);
    grid-template-rows: auto 1fr auto;
    column-gap: clamp(2rem, 5vw, 5rem);
  }
  .next-case__media {
    grid-column: 2;
    grid-row: 1 / -1;
    margin: 0;
  }
  .next-case .link-arrow {
    align-self: end;
  }
}
@media (hover: hover) and (pointer: fine) {
  .next-case:hover .next-case__title {
    translate: 0.18em 0;
  }
  .next-case:hover .next-case__media img {
    scale: 1.05;
  }
}

/* ---------- a cover case: the cover opens the page as a book ---------- */

.case-hero__stage {
  display: grid;
  justify-items: center;
  gap: clamp(2rem, 5vh, 3.25rem);
  margin: 0 calc(-1 * var(--gutter));
  padding: clamp(2.5rem, 7vh, 5rem) var(--gutter) clamp(3rem, 8vh, 5.5rem);
  background: color-mix(in srgb, var(--fg) 5%, transparent);
}
.case-hero__stage .book {
  width: min(62vw, 41vh, 26rem);
  /* turned toward the reader, the near corner comes down past the box: leave it room above the hint */
  margin-bottom: clamp(1rem, 3vh, 2rem);
}
.motion .case-hero__stage .book {
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.case-hero__stage .book.is-held {
  cursor: grabbing;
}
.case-hero__stage .book img {
  pointer-events: none;
}
.case-hero__hint {
  display: none;
  color: var(--soft);
}
@media (hover: hover) and (pointer: fine) {
  .motion .case-hero__hint {
    display: block;
  }
}

/* ---------- covers as objects inside the story ---------- */

.block--books {
  display: grid;
  gap: clamp(2.5rem, 6vw, 5rem);
}
.block--books > .block--text {
  padding: 0;
}
.bookwall {
  display: grid;
  justify-content: center;
  padding: clamp(2rem, 5vw, 4.5rem) clamp(0.5rem, 3vw, 3rem);
  background: color-mix(in srgb, var(--fg) 4%, transparent);
}
.bookwall__item {
  display: grid;
  /* room for the turned book's near corner and its shadow above the label */
  gap: clamp(1.75rem, 3vw, 2.5rem);
  align-content: start;
}
.bookwall__item figcaption {
  display: grid;
  gap: 0.15rem;
  justify-items: center;
  text-align: center;
}
.bookwall__no {
  color: var(--soft);
}
.bookwall__note {
  color: var(--accent);
}
/* fifteen comps: three across on a phone, five on a wide screen */
.bookwall--wall {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(2rem, 5vw, 4.5rem) clamp(1.1rem, 4vw, 4.5rem);
}
/* nine on a wide screen sit three by three, a little larger */
@media (min-width: 760px) {
  .bookwall--wall {
    grid-template-columns: repeat(3, minmax(0, 14rem));
    column-gap: clamp(3rem, 8vw, 8rem);
  }
}
.bookwall--pair {
  grid-template-columns: repeat(2, minmax(0, 20rem));
  gap: clamp(1.5rem, 8vw, 8rem);
}
.bookwall--solo {
  grid-template-columns: minmax(0, min(62vw, 24rem));
}

/* prototype only: copy that waits on Stephen */
.tbd {
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.tbd::after {
  content: "⚑";
  font-size: 0.6em;
  vertical-align: super;
  margin-left: 0.2em;
  text-decoration: none;
}

/* upright pieces and small photographs are held to a sensible width and centred */
.block--image.is-narrow figure,
.block--image.is-medium figure,
.block--compare.is-narrow .steps {
  margin-inline: auto;
}
.block--image.is-narrow figure,
.block--compare.is-narrow .steps {
  max-width: min(100%, 30rem);
}
.block--image.is-medium figure {
  max-width: min(100%, 60rem);
}
.block--image.is-narrow .caption,
.block--image.is-medium .caption {
  text-align: center;
}
.block--image.is-narrow figure {
  box-shadow: 0 1.5rem 3rem -1.5rem color-mix(in srgb, var(--fg) 45%, transparent);
}

/* a quote that waits on an OK carries the flag only: no line under the words */
.block--quote .tbd {
  text-decoration: none;
}

/* small labels on a case page sit on the project's own ground, which is rarely
   pure white or black: a step more ink keeps them above 4.5:1 */
:root {
  --soft: color-mix(in srgb, var(--fg) 72%, transparent);
}

/* ---------- services, on small bands of the project's own colours ----------
   After Stephen's old case decks: each service sits on a highlighter band with
   a bullet. The colours come from the work (case.json → theme.tags). With
   motion the bands ink in from the left as the summary arrives; until then the
   labels are plain text in the page's ink, so they are never unreadable. */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tldr__side .tags li + li {
  margin-top: 0;
}
.tag {
  padding: 0.3em 0.75em 0.34em 0.6em;
  background: linear-gradient(var(--tag), var(--tag)) 0 0 / 100% 100% no-repeat;
  color: var(--tag-ink);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
}
.tag::before {
  content: "•";
  margin-right: 0.45em;
}
.motion .tags .tag {
  transition: background-size 0.9s var(--ease-out), color 0.35s linear;
  transition-delay: calc(var(--i) * 80ms), calc(var(--i) * 80ms + 120ms);
}
.motion .tags:not(.is-inked) .tag {
  background-size: 0% 100%;
  color: inherit;
}
