/* New case-study layout (cases with 'layout' => 'v2' in content/projects.php).
   Built on the site tokens in styles.css (colors, fonts, theme switching). */

.case2-page {
  background-color: var(--bg-color);
}

.case2 {
  --case-gutter: clamp(1.25rem, 4vw, 3rem);
  --case-max: 74rem;
  --case-text: 42rem;
  --case-rule: color-mix(in srgb, var(--text-color) 16%, transparent);
  padding-top: 6.5rem;
  overflow-x: clip;
}

.case2-wrap {
  width: min(100% - 2 * var(--case-gutter), var(--case-max));
  margin-inline: auto;
}

/* --- Reading progress (thin line under the navbar) --- */
.case2-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1031;
  pointer-events: none;
}

.case2-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--hover-accent);
  transform: scaleX(0);
  transform-origin: left;
}

/* --- Hero --- */
.case2-hero {
  padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

.case2-kicker {
  font-size: .8rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--hover-accent);
  font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0 !important;
  margin-bottom: 1.25rem;
}

.case2-title {
  font-size: clamp(2.3rem, 1.1rem + 4.6vw, 5.25rem);
  line-height: 1.04;
  letter-spacing: -.015em;
  font-variation-settings: 'wdth' 100, 'wght' 220, 'slnt' 0 !important;
  max-width: 17ch;
  margin-bottom: 1.5rem;
}

.case2-lede {
  font-size: clamp(1.1rem, .95rem + .75vw, 1.6rem);
  line-height: 1.5;
  max-width: 44rem;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
  font-variation-settings: 'wdth' 100, 'wght' 300, 'slnt' 0 !important;
}

.case2-cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1rem;
  box-shadow: 0 4px 30px var(--shadow);
  background: var(--bg-color-alt);
}

/* --- Metadata strip --- */
.case2-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem 2rem;
  padding-block: 1.75rem;
  margin-block: clamp(1.5rem, 4vw, 2.5rem) 0;
  border-block: 1px solid var(--case-rule);

  & dt {
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-color-gray);
    font-weight: 400;
    margin-bottom: .35rem;
  }

  & dd {
    margin: 0;
    font-size: .98rem;
    line-height: 1.45;
    font-variation-settings: 'wdth' 100, 'wght' 400, 'slnt' 0;
  }
}

/* --- Key numbers --- */
.case2-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2rem);
  padding-block: clamp(2.5rem, 7vw, 5rem);
}

.case2-metric {
  border-top: 2px solid var(--hover-accent);
  padding-top: 1.25rem;
}

.case2-metric-number {
  font-size: clamp(3.5rem, 1.5rem + 7vw, 7.5rem);
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--hover-accent);
  font-variation-settings: 'wdth' 100, 'wght' 200, 'slnt' 0 !important;
  font-variant-numeric: tabular-nums;
  margin-bottom: .6rem;
}

.case2-metric-label {
  font-size: clamp(1.05rem, 1rem + .4vw, 1.35rem);
  line-height: 1.3;
  font-variation-settings: 'wdth' 100, 'wght' 450, 'slnt' 0 !important;
  margin-bottom: .4rem;
}

.case2-metric-note {
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text-color-gray);
  max-width: 28rem;
  margin: 0;
}

/* --- Body: sticky index + content column --- */
.case2-body {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.case2-index {
  position: sticky;
  top: 6.5rem;
  padding-top: 1.5rem;

  & ol {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--case-rule);
  }

  & li {
    margin: 0;
  }

  & a {
    display: block;
    padding: .45rem 0 .45rem 1rem;
    margin-left: -1px;
    border-left: 2px solid transparent;
    font-size: .88rem;
    line-height: 1.3;
    text-decoration: none;
    color: var(--text-color-gray);
    transition: color .3s ease, border-color .3s ease;

    &:hover {
      color: var(--text-color);
    }

    &[aria-current="true"] {
      color: var(--hover-accent);
      border-left-color: var(--hover-accent);
      font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
    }
  }
}

.case2-index-title {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-color-gray);
  margin-bottom: .75rem;
}

.case2-content {
  min-width: 0;
}

.case2-section {
  padding-block: clamp(2rem, 5vw, 4rem);
  border-top: 1px solid var(--case-rule);
  scroll-margin-top: 5.5rem;
}

.case2-section:first-child {
  border-top: 0;
  padding-top: clamp(1rem, 3vw, 2rem);
}

.case2-h2 {
  font-size: clamp(1.7rem, 1.2rem + 1.7vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -.01em;
  font-variation-settings: 'wdth' 100, 'wght' 250, 'slnt' 0 !important;
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.case2-h3 {
  font-size: clamp(1.25rem, 1.05rem + .8vw, 1.75rem);
  line-height: 1.25;
  font-variation-settings: 'wdth' 100, 'wght' 400, 'slnt' 0 !important;
  margin: 0;
}

.case2-text,
.case2-section > p,
.case2-section > ul,
.case2-section > ol {
  max-width: var(--case-text);
}

.case2-text p,
.case2-section > p {
  font-size: clamp(1.02rem, 1rem + .2vw, 1.15rem);
  line-height: 1.7;
  margin-bottom: 1.1rem;
}

.case2-section mark {
  background-color: var(--bg-color-mark);
}

.case2-section strong {
  font-variation-settings: 'wdth' 100, 'wght' 550, 'slnt' 0 !important;
}

/* Overview: four short blocks */
.case2-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.5vw, 1.75rem);
  list-style: none;
  padding: 0;
  margin: 0;
}

.case2-overview li {
  border: 1px solid var(--case-rule);
  border-radius: .9rem;
  padding: 1.4rem 1.5rem;
  background: var(--bg-color-alt);
}

.case2-overview h3 {
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hover-accent);
  font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0 !important;
  margin-bottom: .6rem;
}

.case2-overview p {
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

/* Problem list */
.case2-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;

  & li {
    position: relative;
    padding: .9rem 0 .9rem 1.75rem;
    border-top: 1px solid var(--case-rule);
    font-size: 1.05rem;
    line-height: 1.55;
  }

  & li:last-child {
    border-bottom: 1px solid var(--case-rule);
  }

  & li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1.5rem;
    width: .65rem;
    height: 2px;
    background: var(--hover-accent);
  }
}

/* Decisions */
.case2-decision {
  margin-bottom: clamp(3rem, 7vw, 5.5rem);

  &:last-child {
    margin-bottom: 0;
  }

  & > header {
    margin-bottom: 1rem;
    max-width: var(--case-text);
  }
}

/* Same label style as the hero kicker and the overview headings */
.case2-decision-number {
  display: block;
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hover-accent);
  font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0 !important;
  font-variant-numeric: tabular-nums;
  margin-bottom: .6rem;
}

/* Figures */
.case2-figure {
  margin: 1.75rem 0 0;

  & img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: .9rem;
    background: var(--bg-color-alt);
    box-shadow: 0 2px 22px var(--shadow);
  }

  & figcaption {
    margin-top: .75rem;
    font-size: .88rem;
    line-height: 1.45;
    color: var(--text-color-gray);
    max-width: var(--case-text);
  }
}

/* The image is a real button that opens the lightbox; the caption (and any link in it) stays outside */
/* :not(:disabled) outranks the site-wide "button { cursor: pointer }" so the zoom cursor shows */
.case2-figure-trigger:not(:disabled) {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: inherit;
  cursor: zoom-in;
  border-radius: .9rem;

  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 4px;
  }
}

/* Light/dark comparison (case_compare + the lightbox). Two same-size images stacked; the dark one is
   revealed from --pos to the right edge. The range input covers the whole stage (invisible), so
   dragging anywhere, touch and the arrow keys all move the slider; js/scripts.js sets --pos. */
.case2-compare-stage {
  --pos: 50%;
  position: relative;
  aspect-ratio: var(--ar, 16 / 9);
  border-radius: .9rem;
  overflow: hidden;
  background: var(--bg-color-alt);
  box-shadow: 0 2px 22px var(--shadow);
  user-select: none;
  -webkit-user-select: none;

  & img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    pointer-events: none;
  }

  & .compare-dark {
    clip-path: inset(0 0 0 var(--pos));
  }
}

/* In the lightbox the stage is as large as fits in the window, keeping the image proportions */
.case2-compare-modal {
  width: min(100%, calc(90vh * var(--ar, 1.6)));
  margin-inline: auto;
  border-radius: .75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

.compare-range {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y;
  -webkit-appearance: none;
  appearance: none;

  /* zero-width thumb: the value maps exactly onto the edges of the image */
  &::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 0;
    height: 0;
  }

  &::-moz-range-thumb {
    width: 0;
    height: 0;
    border: 0;
  }

  &:focus-visible + .compare-line .compare-knob {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
  }
}

.compare-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  z-index: 1;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
  pointer-events: none;
}

.compare-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}

.compare-label {
  position: absolute;
  bottom: .75rem;
  z-index: 1;
  padding: .2rem .65rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: .75rem;
  letter-spacing: .04em;
  pointer-events: none;
}

.compare-label-light { left: .75rem; }
.compare-label-dark { right: .75rem; }

.compare-zoom:not(:disabled) {
  position: absolute;
  top: .75rem;
  right: .75rem;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  cursor: zoom-in;

  &:hover {
    background: rgba(0, 0, 0, .9);
  }

  &:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
  }
}

/* Text that follows a figure (e.g. the paragraphs before the Storybook screenshots) */
.case2-figure + .case2-text {
  margin-top: 2.25rem;
}

.case2-figure-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 1.75rem;

  & .case2-figure {
    margin-top: 0;
  }
}

.case2-figure-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.75rem;

  & .case2-figure {
    margin-top: 0;
  }
}

@media (max-width: 767.98px) {
  .case2-figure-trio {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Masonry-like gallery: two vertical stacks of figures with different heights */
.case2-figure-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 1.75rem;
  align-items: start;
}

.case2-figure-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;

  & .case2-figure {
    margin-top: 0;
  }
}

@media (max-width: 767.98px) {
  .case2-figure-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Finding cards: a big number, one sentence, optional mini bars or chips, source and outcome */
.case2-findings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.case2-finding {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  padding: 1.5rem;
  border: 1px solid var(--case-rule);
  border-radius: .9rem;
  background: var(--bg-color-alt);

  & p {
    margin: 0;
  }

  & footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .35rem 1rem;
    margin-top: auto;
    padding-top: .85rem;
    border-top: 1px solid var(--case-rule);
    font-size: .8rem;
    color: var(--text-color-gray);
  }
}

.case2-finding-label {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-color-gray);
}

.case2-finding-value {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  line-height: 1;

  & span {
    font-size: clamp(2.6rem, 2rem + 2vw, 3.6rem);
    font-variation-settings: 'wdth' 100, 'wght' 300, 'slnt' 0 !important;
    font-variant-numeric: tabular-nums;
  }

  & small {
    font-size: 1.1rem;
    color: var(--text-color-gray);
  }
}

.case2-finding-text {
  font-size: 1rem;
  line-height: 1.45;
}

.case2-finding-bars {
  display: grid;
  gap: .4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .82rem;

  & li {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr) 1.5rem;
    align-items: center;
    gap: .6rem;
    color: var(--text-color-gray);
  }

  & i {
    display: block;
    width: var(--w);
    height: .5rem;
    border-radius: .25rem;
    background: color-mix(in srgb, var(--text-color) 28%, transparent);
  }

  & b {
    font-weight: 400;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  & li.is-hi {
    color: var(--hover-accent);
  }

  & li.is-hi i {
    background: var(--hover-accent);
  }
}

.case2-finding-note {
  font-size: .8rem;
  color: var(--text-color-gray);
}

.case2-finding-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;

  & span {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .4rem .75rem;
    border: 1px solid var(--case-rule);
    border-radius: 2rem;
    font-size: .82rem;
  }

  & .is-on {
    border-color: var(--hover-accent);
    color: var(--hover-accent);
  }

  & .is-off {
    border-style: dashed;
    color: var(--text-color-gray);
  }
}

.case2-finding-leads {
  color: var(--hover-accent);
}

@media (max-width: 767.98px) {
  .case2-findings {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Roadmap: one column per quarter, each item with a status-colored top bar and a legend */
.case2-roadmap {
  --rm-released: #2f9e6e;
  --rm-progress: #3f87e0;
  --rm-refinement: #7b6bd6;
  --rm-planned: var(--text-color-gray);
  margin-top: 1.75rem;

  & ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  & h4 {
    margin: 0 0 .75rem;
    font-size: .8rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-color-gray);
  }

  & .is-released { --rm-color: var(--rm-released); }
  & .is-progress { --rm-color: var(--rm-progress); }
  & .is-refinement { --rm-color: var(--rm-refinement); }
  & .is-planned { --rm-color: var(--rm-planned); }
}

.case2-roadmap-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;

  & li {
    margin-bottom: .6rem;
    padding: .65rem .8rem;
    border: 1px solid var(--case-rule);
    border-top: 3px solid var(--rm-color);
    border-radius: .5rem;
    background: var(--bg-color-alt);
    font-size: .9rem;
    line-height: 1.35;
  }
}

.case2-roadmap-caption {
  margin: .75rem 0 0;
  font-size: .88rem;
  line-height: 1.45;
  color: var(--text-color-gray);
}

.case2-roadmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin-top: 1rem !important;
  font-size: .82rem;
  color: var(--text-color-gray);

  & li {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
  }

  & li::before {
    content: "";
    width: .9rem;
    height: .25rem;
    border-radius: .15rem;
    background: var(--rm-color);
  }
}

/* Timeline: horizontal on wide screens, vertical below */
.case2-timeline {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 0 1.25rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;

  & li {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding-top: 1.25rem;
    border-top: 2px solid var(--case-rule);
    font-size: .92rem;
    line-height: 1.4;
  }

  & li::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--hover-accent);
  }

  & strong {
    font-size: 1rem;
  }
}

.case2-timeline-date {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hover-accent);
}

.case2-timeline-text {
  color: var(--text-color-gray);
}

/* Goal bars: result against target */
.case2-goals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.case2-goal {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--case-rule);
  border-radius: .9rem;
  background: var(--bg-color-alt);

  & p {
    margin: 0;
  }
}

.case2-goal-label {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-color-gray);
}

.case2-goal-value {
  margin: .4rem 0 .9rem !important;
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem);
  line-height: 1.1;
  font-variation-settings: 'wdth' 100, 'wght' 300, 'slnt' 0 !important;
}

.case2-goal-track {
  position: relative;
  height: .6rem;
  border-radius: .3rem;
  background: color-mix(in srgb, var(--text-color) 14%, transparent);

  & i {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--fill);
    border-radius: .3rem;
    background: var(--hover-accent);
  }

  & b {
    position: absolute;
    top: -.35rem;
    bottom: -.35rem;
    left: var(--mark);
    width: 2px;
    background: var(--text-color);
  }
}

.case2-goal-scale {
  display: flex;
  justify-content: space-between;
  margin-top: .4rem !important;
  font-size: .75rem;
  color: var(--text-color-gray);
}

.case2-goal-target {
  margin-top: .5rem !important;
  font-size: .85rem;
}

@media (max-width: 767.98px) {
  .case2-goals {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 991.98px) {
  .case2-timeline {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;

    & li {
      padding: 0 0 0 1.5rem;
      border-top: 0;
      border-left: 2px solid var(--case-rule);
    }

    & li::before {
      top: .2rem;
      left: -7px;
    }
  }
}

@media (max-width: 991.98px) {
  .case2-roadmap-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .case2-roadmap-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Caption shared by a pair of figures */
.case2-pair-caption {
  margin-top: .75rem;
  font-size: .88rem;
  line-height: 1.45;
  color: var(--text-color-gray);
}

.case2-text code {
  font-size: .88em;
  background: var(--bg-color-mark);
  padding: .1rem .4rem;
  border-radius: .3rem;
  color: var(--text-color);
}

/* The architecture diagram is revealed one layer at a time (only with JavaScript). */
.case-js .case2-reveal-steps img {
  clip-path: inset(0 100% 0 0);
}

.case-js .case2-reveal-steps.is-in img {
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.8s steps(6, end);
}

/* Table */
.case2-table-wrap {
  position: relative; /* keeps the .visually-hidden words inside a cell from widening the page */
  overflow-x: auto;
  margin-top: 1.75rem;
}

.case2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .98rem;
  line-height: 1.5;

  & th,
  & td {
    padding: 1rem 1.25rem 1rem 0;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--case-rule);
  }

  & thead th {
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-color-gray);
    font-weight: 400;
  }

  & tbody th {
    font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
    white-space: nowrap;
  }

  & td:last-child {
    color: var(--hover-accent);
    font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
    white-space: nowrap;
  }
}

/* A short quote from a user */
.case2-quote {
  max-width: var(--case-text);
  margin: 2.5rem 0 0;
  padding: .25rem 0 .25rem 1.5rem;
  border-left: 2px solid var(--hover-accent);

  & p {
    font-size: clamp(1.2rem, 1.1rem + .5vw, 1.55rem);
    line-height: 1.4;
    margin: 0 0 .75rem;
  }

  & footer {
    font-size: .88rem;
    color: var(--text-color-gray);
  }
}

/* The sentence that introduces a link to material elsewhere */
.case2-more {
  margin-top: 2.5rem;
}

.case2-more + .case2-source {
  margin-top: 1.25rem;
}

/* A small gray note under a figure group or a table */
.case2-note {
  max-width: var(--case-text);
  margin: .9rem 0 0;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--text-color-gray);
}

/* Matrix table (who uses what): the last column is a persona, not a result, so no accent color */
.case2-table.is-matrix {
  & td:last-child {
    color: inherit;
    font-variation-settings: inherit;
    white-space: normal;
  }

  & thead th {
    white-space: nowrap;
  }

  & tbody th {
    padding-right: 2rem;
  }
}

.case2-th-sub {
  display: block;
  margin-top: .2rem;
  font-size: .8rem;
  letter-spacing: 0;
  text-transform: none;
}

/* A filled dot marks the main use of a module (the legend and a hidden word say the same) */
.case2-dot {
  display: inline-block;
  width: .6rem;
  height: .6rem;
  margin-right: .55rem;
  border-radius: 50%;
  background: var(--hover-accent);
  vertical-align: .05em;
}

/* Persona cards: photo (opens the full sheet in the lightbox), name, role and an interview quote */
.case2-personas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.case2-persona {
  --tone: #7b5cd6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--case-rule);
  border-top: 3px solid var(--tone);
  border-radius: .9rem;
  background: var(--bg-color-alt);

  &.is-executive { --tone: #7b5cd6; }
  &.is-tactical { --tone: #3b9ae1; }
  &.is-operational { --tone: #1fae9f; }

  & p {
    margin: 0;
  }
}

.case2-persona-photo {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  overflow: hidden;

  & img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: -4px;
  }
}

.case2-persona-open {
  position: absolute;
  left: .75rem;
  bottom: .75rem;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: .78rem;
  letter-spacing: .02em;
}

.case2-persona-text {
  display: grid;
  gap: .2rem;
  padding: 1.1rem 1.25rem 1.4rem;
}

.case2-persona-name {
  font-size: 1.2rem;
  font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
}

.case2-persona-role {
  font-size: .9rem;
  color: var(--text-color-gray);
}

.case2-persona-quote {
  margin-top: .85rem !important;
  padding-left: .9rem;
  border-left: 2px solid var(--tone);
  font-size: .98rem;
  line-height: 1.5;
}

@media (max-width: 767.98px) {
  .case2-personas {
    grid-template-columns: minmax(0, 1fr);
  }

  .case2-persona {
    flex-direction: row;
    border-top-width: 1px;
    border-left: 3px solid var(--tone);
  }

  .case2-persona-photo {
    flex: none;
    width: 9.5rem;
    aspect-ratio: auto;
  }

  .case2-persona-open {
    left: .5rem;
    bottom: .5rem;
    padding: .25rem .55rem;
  }
}

/* Full persona profile (a native <dialog> opened by the photo) */
.case-dialog-open {
  overflow: hidden;
}

.case2-dialog {
  width: min(54rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1.75rem clamp(1.25rem, 3vw, 2.25rem) 2rem;
  border: 1px solid var(--case-rule);
  border-top: 4px solid var(--tone, var(--hover-accent));
  border-radius: 1rem;
  background: var(--bg-color);
  color: var(--text-color);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .4);
  overflow: auto;

  &::backdrop {
    background: rgba(0, 0, 0, .65);
  }

  & p {
    margin: 0;
  }
}

.case2-dialog-close {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  height: 0;
  margin: 0;

  & button {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: -.75rem -.75rem 0 0;
    padding: 0;
    border: 1px solid var(--case-rule);
    border-radius: 50%;
    background: var(--bg-color-alt);
    color: var(--text-color);
    cursor: pointer;

    &:hover {
      border-color: var(--hover-accent);
    }

    &:focus-visible {
      outline: 2px solid var(--focus-ring);
      outline-offset: 2px;
    }
  }
}

.case2-dialog-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;

  & img {
    flex: none;
    width: 6.5rem;
    height: 6.5rem;
    border-radius: .75rem;
    object-fit: cover;
  }
}

.case2-dialog-facts {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.5rem;
  margin: .75rem 0 0;
  font-size: .88rem;

  & dt {
    display: inline;
    margin-right: .35rem;
    font-weight: 400;
    color: var(--text-color-gray);
  }

  & dd {
    display: inline;
    margin: 0;
  }
}

.case2-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 2.25rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--case-rule);

  & h4 {
    margin: 0 0 .5rem;
    font-size: .75rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--hover-accent);
    font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
  }

  & p,
  & li {
    font-size: .95rem;
    line-height: 1.6;
  }

  & ul {
    margin: 0;
    padding-left: 1.1rem;
    list-style: disc;
  }

  & li + li {
    margin-top: .35rem;
  }

  & li::marker {
    color: var(--text-color-gray);
  }
}

@media (max-width: 767.98px) {
  .case2-dialog-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .case2-dialog-head {
    padding-right: 2rem;

    & img {
      width: 5rem;
      height: 5rem;
    }
  }
}

/* Research insights: what we found, what it changed and where it shows up */
.case2-insights {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.case2-insight {
  display: grid;
  gap: 1.1rem;
  padding: 1.5rem;
  border: 1px solid var(--case-rule);
  border-radius: .9rem;
  background: var(--bg-color-alt);

  & p {
    margin: 0;
  }
}

.case2-insight-who {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hover-accent);
}

.case2-insight-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 2.25rem;
  font-size: .98rem;
  line-height: 1.55;
}

.case2-insight-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .4rem !important;
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-color-gray);

  &.is-decision {
    color: var(--hover-accent);
  }
}

.case2-insight-where {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .5rem;
  padding-top: .9rem;
  border-top: 1px solid var(--case-rule);
  font-size: .86rem;
  color: var(--text-color-gray);

  & span {
    font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
  }
}

@media (max-width: 767.98px) {
  .case2-insight {
    padding: 1.25rem;
  }

  .case2-insight-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Link to the full material elsewhere (the research board) */
.case2-source {
  max-width: 38rem;
  margin-top: 2.5rem;
}

.case2-source-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--case-rule);
  border-radius: .9rem;
  background: var(--bg-color-alt);
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease;

  &:hover,
  &:focus-visible {
    border-color: var(--hover-accent);
    color: inherit;
  }

  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
  }

  & > i {
    flex: none;
    font-size: 1.1rem;
    color: var(--hover-accent);
  }
}

.case2-source-logo {
  flex: none;
  width: auto;
  height: 2.25rem;
}

.case2-source-body {
  display: grid;
  flex: 1;
  gap: .15rem;
  min-width: 0;
}

.case2-source-title {
  font-size: 1.05rem;
  font-variation-settings: 'wdth' 100, 'wght' 500, 'slnt' 0;
}

.case2-source-text {
  font-size: .9rem;
  line-height: 1.45;
  color: var(--text-color-gray);
}

.case2-source-note {
  margin: .75rem 0 0 .25rem;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--text-color-gray);

  & code {
    padding: .1rem .4rem;
    border: 1px solid var(--case-rule);
    border-radius: .3rem;
    background: var(--bg-color-alt);
    color: var(--text-color);
    font-size: .95em;
  }
}

/* Space between an intro figure and the first decision */
.case2-gap {
  height: clamp(2.5rem, 6vw, 4.5rem);
}

/* What I learned */
.case2-learned {
  list-style: none;
  counter-reset: learned;
  padding: 0;
  margin: 2rem 0 0;
  max-width: var(--case-text);

  & li {
    counter-increment: learned;
    position: relative;
    padding: 1.25rem 0 1.25rem 3.25rem;
    border-top: 1px solid var(--case-rule);
    font-size: 1.05rem;
    line-height: 1.65;
  }

  & li::before {
    content: counter(learned, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 1.25rem;
    color: var(--hover-accent);
    font-variation-settings: 'wdth' 100, 'wght' 300, 'slnt' 0;
    font-variant-numeric: tabular-nums;
  }

  & strong {
    display: block;
    font-size: 1.15rem;
    margin-bottom: .25rem;
  }
}

.case2-subtitle,
.case2-h3-plain {
  font-size: 1.2rem;
  margin: 2.5rem 0 0;
  font-variation-settings: 'wdth' 100, 'wght' 400, 'slnt' 0 !important;
}

/* A paragraph right after a sub-title needs a little air */
.case2-subtitle + p {
  margin-top: .75rem;
}

.case2-tag {
  display: inline-block;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  border: 1px solid var(--hover-accent);
  color: var(--hover-accent);
  border-radius: 2rem;
  padding: .2rem .7rem;
  margin-bottom: 1rem;
}

/* --- Next case --- */
.case2-next {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: clamp(3rem, 8vw, 6rem);
  padding-block: clamp(2rem, 5vw, 3.5rem);
  border-top: 1px solid var(--case-rule);
}

.case2-next-link {
  display: block;
  text-decoration: none;

  &:hover .case2-next-title {
    color: var(--hover-accent);
  }
}

.case2-next-label {
  display: block;
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-color-gray);
  margin-bottom: .5rem;
}

.case2-next-title {
  display: block;
  font-size: clamp(1.8rem, 1.1rem + 3vw, 3.75rem);
  line-height: 1.1;
  letter-spacing: -.01em;
  font-variation-settings: 'wdth' 100, 'wght' 250, 'slnt' 0;
  transition: color .3s ease;

  & i {
    font-size: 2rem;
  }
}

/* Labs: the button that opens the tool, at the end of the story */
.case2-tool {
  display: flex;
  flex-direction: column;
  align-items: flex-start;

  & i {
    font-size: 1rem;
  }
}

.case2-all {
  font-size: .95rem;

  & i {
    font-size: .95rem;
  }
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
  .case2-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .case2-index {
    display: none;
  }

  .case2-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  /* Metadata: one column, label on the left and value on the right */
  .case2-meta {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-block: .5rem;

    & > div {
      display: grid;
      grid-template-columns: 6.5rem minmax(0, 1fr);
      gap: 1rem;
      align-items: baseline;
      padding-block: .85rem;
    }

    & > div + div {
      border-top: 1px solid var(--case-rule);
    }

    & dt {
      margin-bottom: 0;
    }
  }

  .case2-metrics,
  .case2-overview,
  .case2-figure-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .case2-table th,
  .case2-table td {
    padding-right: .75rem;
  }
}

/* --- Motion preferences --- */
@media (prefers-reduced-motion: reduce) {
  .case-js .case2-reveal-steps img,
  .case-js .case2-reveal-steps.is-in img {
    clip-path: none;
    transition: none;
  }

  .case2-progress span {
    transition: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .case-js {
    scroll-behavior: smooth;
  }
}

/* Labs story helpers */
.case2-lead {
  font-size: clamp(1.15rem, 1.05rem + .5vw, 1.5rem) !important;
  line-height: 1.55 !important;
  font-variation-settings: 'wdth' 100, 'wght' 350, 'slnt' 0 !important;
}

.case2-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
  max-width: none;
}

@media (max-width: 767.98px) {
  .case2-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}
