/* ===== Problem: the gap. One still picture, the headline drawn. Code written (a band of fine azure strokes)
   climbs away from the point where it started; product shipped (one warm line) barely rises toward the dawn.
   The four problems stand in the gap between them, each with a rule that measures the gap at its place.
   Nothing moves; a problem lights its place in the gap on hover or focus, and the reverse. ===== */
.problem { position: relative; padding-block: var(--space-xl) var(--space-lg); overflow-x: clip; }
.problem__head { position: relative; z-index: 1; display: grid; gap: var(--space-md); }
.problem__head h2 { max-width: 20ch; }
.problem__head .lead { max-width: 40ch; }

/* The stage: the picture and the four problems share one box, so both are placed by the same percentages */
.problem__stage { position: relative; }
.problem__fig { position: relative; margin: 0; }
.problem__art { position: relative; height: 100%; }
.problem__svg { width: 100%; height: 100%; overflow: visible; }
.problem__svg * { vector-effect: non-scaling-stroke; }

/* Colour stops, through tokens */
.problem__s-dawn { stop-color: var(--color-dawn); }
.problem__s-dawn2 { stop-color: var(--color-dawn-2); }
.problem__s-deep { stop-color: var(--color-accent-ink); }
.problem__s-azure { stop-color: var(--color-accent); }
.problem__s-ink { stop-color: var(--color-ink); }

.problem__code path { fill: none; stroke: var(--color-accent); stroke-width: 1; }
.problem__body-band { fill: color-mix(in oklab, var(--color-accent) 9%, transparent); }
.problem__core { fill: none; stroke: color-mix(in oklab, var(--color-accent) 60%, var(--color-ink)); stroke-width: 2; }
.problem__prod { fill: none; stroke: var(--color-dawn); stroke-width: 3; }

/* The four places in the gap */
.problem__rule { stroke: var(--color-ink); stroke-width: 1; opacity: 0.45; transition: opacity var(--dur-short) var(--ease-out); }
.problem__cap { stroke-width: 2; opacity: 0.8; transition: opacity var(--dur-short) var(--ease-out); }
.problem__cap--code { stroke: var(--color-accent); }
.problem__cap--prod { stroke: var(--color-dawn); }
.problem__shaft { opacity: 0; transition: opacity var(--dur-short) var(--ease-out); }

/* End labels */
.problem__end { position: absolute; z-index: 2; font-size: var(--text-sm); font-weight: 500; line-height: 1.2; white-space: nowrap; pointer-events: none; }
.problem__end--code { right: calc(100% - var(--x) + var(--space-3xl)); top: var(--y); color: var(--color-accent); transform: translateY(-50%); }
.problem__end--prod { right: 0; top: calc(83% + var(--space-sm)); color: var(--color-dawn); }

/* The four problems */
.problem__list { margin: 0; padding: 0; list-style: none; }
.problem__item { position: relative; outline-offset: 4px; transition: opacity var(--dur-short) var(--ease-out); }
.problem__item:focus-visible { outline: 2px solid var(--color-focus); transition: none; }
.problem__title { font-size: var(--text-lg); line-height: 1.2; color: var(--color-ink); }
.problem__item p { margin-top: var(--space-2xs); font-size: var(--text-md); line-height: 1.45; color: var(--color-ink-2); }
.problem__n { display: none; }
.problem__pin { display: none; }

/* Lit: a problem and its place, either way round. Marks rest unlit; once anything is pointed at, the other problems step back. */
.problem__mark { --lit: 0; pointer-events: all; cursor: default; }
.problem__rule { opacity: calc(0.32 + 0.68 * var(--lit)); }
.problem__shaft { opacity: var(--lit); }
.problem__cap { opacity: calc(0.75 + 0.25 * var(--lit)); }
.problem__stage:has(.problem__item:hover, .problem__item:focus, .problem__mark:hover) .problem__item { opacity: 0.72; }
.problem__stage:has([data-item="1"]:is(:hover, :focus), [data-mark="1"]:hover) :is([data-mark="1"], [data-item="1"]),
.problem__stage:has([data-item="2"]:is(:hover, :focus), [data-mark="2"]:hover) :is([data-mark="2"], [data-item="2"]),
.problem__stage:has([data-item="3"]:is(:hover, :focus), [data-mark="3"]:hover) :is([data-mark="3"], [data-item="3"]),
.problem__stage:has([data-item="4"]:is(:hover, :focus), [data-mark="4"]:hover) :is([data-mark="4"], [data-item="4"]) { --lit: 1; opacity: 1; }

/* Desktop: one screen; the picture fills the stage and the problems stand in the gap, on the product line */
@media (min-width: 68.8125rem) {
  .problem { display: flex; flex-direction: column; height: calc(100vh - var(--nav-h)); height: calc(100svh - var(--nav-h)); min-height: 700px; max-height: 1000px; }
  .problem__body { flex: 1 1 auto; display: flex; min-height: 0; padding-top: var(--space-md); }
  .problem__stage { flex: 1 1 auto; min-height: 460px; }
  .problem__fig { position: absolute; inset: 0; }
  .problem__end--code { right: auto; left: calc(var(--dx) + var(--space-md)); top: var(--dy); }
  .problem__list { position: absolute; inset: 0; pointer-events: none; }
  .problem__item { position: absolute; left: var(--x); bottom: calc(100% - var(--y) + var(--space-sm)); width: 17.5%; padding-left: var(--space-md); pointer-events: auto; }
}

/* Below a wide screen: the picture first, compact, numbered at its four places; the problems follow */
@media (max-width: 68.75rem) {
  .problem { padding-block: var(--section-gap-s); }
  .problem__body { padding-top: var(--space-xl); }
  .problem__fig { aspect-ratio: 16 / 10; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, transparent, var(--color-ink) 22%); mask-image: linear-gradient(to bottom, transparent, var(--color-ink) 22%); margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .problem__pin { position: absolute; display: block; left: var(--x); top: var(--y); transform: translate(8px, calc(-100% - 6px)); font-size: var(--text-sm); font-weight: 500; line-height: 1; color: var(--color-ink); }
  .problem__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xl) var(--gap-columns); margin-top: var(--space-xl); counter-reset: none; }
  .problem__n { display: block; margin-bottom: var(--space-xs); font-size: var(--text-md); font-weight: 500; color: var(--color-muted); }
  .problem__item { padding-top: var(--space-md); border-top: 1px solid var(--color-rule); }
}
@media (max-width: 40rem) {
  .problem__fig { aspect-ratio: 4 / 3; }
  .problem__end--code { right: calc(100% - var(--x) + var(--space-xl)); }
  .problem__list { grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); }
}
