/* ============================================================
   Case Study styles — imports tokens.css (global) + components.css.
   All values via var(). No raw hex / hardcoded px that exist as tokens.
   ============================================================ */

/* ---------- Case header (sticky two-row chrome) ---------- */
.case-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--scrim-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.case-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Hardening: space-between only distributes leftover room — once the back
     link + cluster content is wider than the row (long client names on
     narrow phones, e.g. "SAP Concur" at 320-360px), it collapses to zero and
     the two touch or overlap. A real gap guarantees breathing room even
     then, and pairs with .case-header__client's own truncation below. */
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 14px;
}
.case-header__back {
  font-size: var(--fs-nav);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 13px;   /* 44px tap box */
  margin-block: -13px;
  white-space: nowrap;
  flex-shrink: 0; /* the back link is short and fixed; the tag truncates instead */
  transition: color var(--hover-color-dur);
}
.case-header__back:hover { color: var(--text-primary); }
.case-header__cluster { display: flex; align-items: center; gap: 18px; min-width: 0; }
.case-header__tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-chip);
  color: var(--text-muted);
  min-width: 0; /* let __client shrink + truncate instead of colliding with __back */
}
/* Hardening: on narrow phones the client name (data-driven, length varies
   per case study) can outgrow the space left after the back link and theme
   toggle claim theirs. Truncate with an ellipsis rather than wrapping or
   overlapping — the full name is always repeated in the summary heading
   just below the fold, so nothing here is lost. */
.case-header__client {
  font-weight: 600;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.case-header__subnav { border-top: 1px solid var(--border); }
.case-header__subnav-inner {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.case-header__subnav-inner::-webkit-scrollbar { display: none; }
.case-header__nav-link {
  flex-shrink: 0;
  padding: 16px 20px 16px 0; /* 44px tap box */
  margin-block: -4px;
  font-size: var(--fs-chip);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--hover-color-dur);
}
.case-header__nav-link:first-child { padding-left: 0; }
.case-header__nav-link:hover { color: var(--text-primary); }

/* ---------- Section number label ---------- */
.cs-section-num {
  display: block;
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: var(--ls-eyebrow);
  color: var(--accent-text);
  margin-bottom: 18px;
}

/* ---------- Section split layout (reused across all narrative sections) ---------- */
.cs-split {
  display: grid;
  grid-template-columns: 0.55fr 1fr;
  gap: var(--gap-split);
  align-items: start;
}
.cs-split__left {
  position: sticky;
  top: 110px; /* clears the two-row sticky case header */
}
.cs-split__right {
  padding-top: 32px; /* first paragraph aligns with the headline, not the eyebrow */
}
.cs-section-headline {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-section-sm);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-serif);
  font-weight: 500;
  color: var(--text-primary);
}

/* ---------- Body copy ---------- */
.cs-body {
  margin: 0 0 20px;
  max-width: 65ch;
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  color: var(--text-secondary);
}

/* No-artifact narrative beat (e.g. Exploration without a supporting image):
   closing line takes the homepage's Statement scale, capped for readability,
   so the section reads as a deliberate pause, not a missing screenshot. */
.cs-exploration-statement {
  margin-top: 8px;
  max-width: 46ch;
  text-wrap: pretty;
}
.cs-body:last-child { margin-bottom: 0; }
.cs-body--lead { color: var(--text-muted); }

/* ---------- Validation findings list ---------- */
.cs-val-cue { color: var(--text-muted); }
.cs-val-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cs-val-item {
  position: relative;
  padding-left: 30px;
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  color: var(--text-primary);
}
.cs-val-item::before {
  position: absolute;
  left: 0;
  color: var(--accent-text);
  content: "→";
}

/* ---------- Summary card (build-spec — matches featured card style) ---------- */
.cs-summary { padding-top: var(--section-pad); padding-bottom: var(--section-pad); }
.cs-summary__card {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--bg-card);
  /* Lighter edge than the flat --border line: a near-invisible hairline plus
     the same Ambient Rest shadow the case-study cards use, so depth comes
     from elevation rather than a heavier ink border. */
  border: 1px solid var(--hairline);
  border-radius: var(--r-feature);
  box-shadow: var(--shadow-ambient-rest);
  overflow: hidden;
}
.cs-summary__left { padding: 48px 50px; }
.cs-summary__right {
  /* Committed split: the outcomes panel commits to the accent hue (reusing
     the Outcome band's own tokens), while the left stays plain paper — a
     bolder two-tone contrast than a flat inset background. */
  background: var(--surface-committed);
  color: var(--band-text);
  padding: 48px 50px;
  display: flex;
  align-items: center;
}
.cs-summary__right .cs-summary__outcome { color: inherit; }
.cs-summary__right .cs-arrow { color: inherit; }
.cs-summary__eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 22px;
}
.cs-summary__client { color: var(--text-bright); }
.cs-summary__sep { color: var(--text-faint); }
.cs-summary__title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: var(--fs-section); /* page h1 must outrank the h2 section headlines */
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-serif);
  font-weight: 500;
  color: var(--text-primary);
}
.cs-summary__question {
  margin: 0 0 32px;
  font-size: var(--fs-lead);
  font-style: italic;
  font-weight: 600;
  color: var(--text-secondary);
}
.cs-summary__meta { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.cs-summary__meta-row { display: flex; flex-direction: column; gap: 6px; }
.cs-summary__meta-val { margin: 0; font-size: var(--fs-body); color: var(--text-secondary); }
.cs-summary__caps { display: flex; flex-direction: column; gap: 12px; }
.cs-summary__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.cs-summary__outcomes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.cs-summary__outcome {
  display: flex;
  align-items: start;
  gap: 14px;
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  color: var(--text-primary);
}
.cs-arrow {
  flex-shrink: 0;
  color: var(--accent-text);
  font-size: 1.125rem;
  margin-top: 2px;
}

/* ---------- Challenge blocks ---------- */
.cs-challenges .cs-split { margin-bottom: var(--gap-split); } /* air before the first rule */
.cs-challenge-list { display: flex; flex-direction: column; gap: 0; }
.cs-challenge {
  border-top: 1px solid var(--border);
  padding: var(--section-pad) 0;
}
.cs-challenge__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-split);
  align-items: start;
}
.cs-challenge__media--stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-stack);
  justify-items: center;
}
.cs-challenge__media--stack .image-slot__img { height: auto; max-height: 500px; width: auto; max-width: 100%; object-fit: contain; }
/* Two portrait screenshots side by side instead of stacked — half the total
   height of two tall images, reading as two states of one screen. Same
   breakpoint-free technique as .cs-full-image-grid. */
.cs-challenge__media--grid {
  display: grid;
  gap: var(--gap-stack);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: start;
}
.cs-challenge__media--grid .image-slot__img { height: auto; width: 100%; object-fit: contain; }
.cs-challenge__inner--right { direction: rtl; }
.cs-challenge__inner--right > * { direction: ltr; }
.cs-challenge__label {
  display: block;
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 16px;
}
.cs-challenge__headline {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: var(--fs-section-sm);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-serif);
  font-weight: 500;
  color: var(--text-primary);
}
.cs-decision {
  margin: 0;
  max-width: 65ch;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-secondary);
}
.cs-decision__label { color: var(--accent-text); font-weight: 700; }
/* Impact follows Decision in the same challenge (Challenge 3): give it its
   own beat instead of reading as a continuation of the Decision paragraph. */
.cs-decision + .cs-decision { margin-top: 16px; }

/* Options considered: a footnote below the decision, not competing with it —
   Decision leads with the answer, this rewards the reader who wants the
   rejected alternatives. */
.cs-options {
  margin: 20px 0 0;
  max-width: 65ch;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  color: var(--text-tertiary);
}
.cs-options__label {
  display: block;
  margin-bottom: 4px;
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--text-faint-2);
}

/* ---------- Quote (participant/session callout) ---------- */
.cs-quote {
  position: relative;
  margin: 32px 0 0;
  padding: 4px 0 4px 40px;
}
.cs-quote::before {
  content: "\201C";
  position: absolute;
  left: 0;
  top: -6px;
  font-family: var(--font-display);
  font-size: 2.75rem;
  line-height: 1;
  color: var(--accent-text);
}
.cs-quote__text {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  color: var(--text-primary);
}
.cs-quote__attribution {
  margin: 12px 0 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* ---------- Full-width image slot (Validation section) ---------- */
.cs-full-image {
  margin-top: 56px;
  border-radius: var(--r-feature);
  overflow: hidden;
  background: var(--bg-inset); /* letterbox field behind contained images */
}
.cs-full-image .image-slot { min-height: 360px; }
.cs-full-image .image-slot__img { width: 100%; max-height: 640px; object-fit: contain; }

/* bare: asset already reads as a held artifact (own rounded card / shadow /
   transparent canvas) — drop the letterbox mat so it isn't nested in a card. */
.cs-full-image--bare { background: none; border-radius: 0; }

/* ---------- Split with single media (plain two-column: text block | image,
   no letterbox card) — shared by any narrative section reduced to exactly
   one supporting image (Context, Exploration, Validation). ---------- */
.cs-split-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-split);
  align-items: start;
}
.cs-split-media__text .cs-section-headline { margin-bottom: 20px; }
.cs-split-media__media .image-slot__img { height: auto; object-fit: contain; }
/* Alternates the section rhythm (same rtl trick as .cs-challenge__inner--right):
   text stays reading-order LTR, only its grid position flips to the right. */
.cs-split-media--reverse { direction: rtl; }
.cs-split-media--reverse > * { direction: ltr; }

/* ---------- Outcome band (cyan teal, build-spec §07) ---------- */
.cs-outcome {
  background: var(--band-bg);
  color: var(--band-text);
  padding: var(--section-pad) 0;
}
.cs-outcome .cs-section-num { color: var(--band-text); opacity: 0.95; margin-bottom: 24px; }
.cs-outcome__headline {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: var(--fs-section);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-serif);
  font-weight: 500;
  color: var(--band-text);
}
.cs-outcome__body {
  margin: 0 0 72px; /* breath before the impact grid (live polish, breath=72) */
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  color: var(--band-text);
  max-width: 56ch;
  opacity: 0.95;
}
.cs-impact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--band-hairline);
  border-radius: var(--r-card);
  overflow: hidden;
}
.cs-impact {
  background: var(--band-card);
  padding: 34px 30px;
}
.cs-impact__label {
  margin: 0 0 10px;
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--band-card-text);
}
.cs-impact__desc {
  margin: 0;
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  color: var(--band-card-text-2);
}

/* ---------- Next case study link (Reflection section) ---------- */
.cs-next {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 72px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}
.cs-next__link {
  font-size: var(--fs-section-sm);
  font-weight: 700;
  letter-spacing: var(--ls-section);
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--hover-color-dur);
  display: flex;
  align-items: center;
  gap: 16px;
}
.cs-next__arrow { color: var(--accent-text); transition: transform var(--hover-color-dur); }
.cs-next__link:hover { color: var(--accent-text); }
.cs-next__link:hover .cs-next__arrow { transform: translateX(6px); }

/* ---------- Case footer ---------- */
.cs-footer {
  background: var(--bg-footer);
  padding: 36px 0;
  border-top: 1px solid var(--border);
}
.cs-footer__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}
.cs-footer__back {
  font-size: var(--fs-nav);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--hover-color-dur);
  margin-right: auto;
  padding-block: 14px;   /* 44px tap box */
  margin-block: -14px;
}
.cs-footer__back:hover { color: var(--text-primary); }
.cs-footer__link {
  font-size: var(--fs-nav);
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--hover-color-dur);
  padding-block: 14px;   /* 44px tap box */
  margin-block: -14px;
}
.cs-footer__link:hover { color: var(--text-primary); }
.cs-footer__copy { font-size: var(--fs-chip); color: var(--text-faint-2); margin-left: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cs-split { grid-template-columns: 1fr; gap: var(--gap-stack); }
  .cs-split__left { position: static; }
  .cs-split__right { padding-top: 0; }
  .cs-split-media { grid-template-columns: 1fr; gap: var(--gap-stack); }
  .cs-split-media--reverse { direction: ltr; }
  .cs-summary__card { grid-template-columns: 1fr; }
  .cs-challenge__inner { grid-template-columns: 1fr; }
  .cs-challenge__inner--right { direction: ltr; }
  .cs-impact-grid { grid-template-columns: 1fr; }
  .cs-footer__copy { margin-left: 0; }
}
@media (max-width: 600px) {
  .cs-summary__left,
  .cs-summary__right { padding: 32px 26px; }
  .case-header__nav-link { padding: 14px 16px 14px 0; } /* 44px tap box — was 37px measured */
  /* Narrow phones scroll the tab strip fast; widen the "more tabs" scrim so
     the cue survives a quick thumb-flick instead of needing a lingering look. */
  .case-header__subnav::after { width: 72px; }
  .case-header__subnav::before { right: 20px; font-size: var(--fs-small); }
  /* Theme drops to its own deliberate line instead of wrapping mid-flex,
     which strands the separator dot at the start of the wrapped line. */
  .cs-summary__theme { flex-basis: 100%; }
  .cs-summary__sep { display: none; }
  /* The back link's own name always wins the top row; drop the redundant
     "Case Study ·" label and the toggle's text so "Tad Natsuhara" never wraps. */
  .case-header__tag-label { display: none; }
  .case-header .theme-toggle__label { display: none; }
}
@media (max-width: 400px) {
  /* Hardening: even with just the client name left (previous breakpoint),
     the back link + theme toggle alone can fill the row on the smallest
     phones — longer names (e.g. "SAP Concur") truncate to a bare "SA…"
     fragment via .case-header__client's ellipsis, which reads as broken
     rather than deliberate. Drop the tag outright here, the same way the
     "Case Study ·" label was already dropped at 600px; the client name is
     always repeated in the summary heading one scroll away. */
  .case-header__tag { display: none; }
}

/* ---------- Subnav scrollspy + overflow fade ---------- */
.case-header__nav-link[aria-current] {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 6px;
}
.case-header__subnav { position: relative; }
/* Right-edge scrim signalling more items off-screen; matches header tint */
.case-header__subnav::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 56px;
  background: linear-gradient(to right, var(--scrim-0), var(--scrim-strong));
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--hover-color-dur);
}
.case-header__subnav.has-more::after { opacity: 1; }
/* Chevron over the scrim: the fade alone reads as a soft vignette (it tints
   toward the header's own tone), not an unambiguous "more tabs" cue. */
.case-header__subnav::before {
  content: '\2192';
  position: absolute;
  top: 50%;
  right: 16px;
  z-index: 1;
  transform: translate(6px, -50%);
  font-size: var(--fs-chip);
  font-weight: 700;
  color: var(--accent-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hover-color-dur), transform var(--hover-dur);
}
.case-header__subnav.has-more::before { opacity: 1; transform: translate(0, -50%); }

/* ---------- Back-to-top: quick exit on a long single-scroll page ---------- */
.cs-back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40; /* below the sticky header (50) */
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px; /* 44px tap box — was 40px measured */
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--hover-dur), transform var(--hover-dur), color var(--hover-color-dur);
}
.cs-back-to-top.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.cs-back-to-top:hover { color: var(--text-primary); }
.cs-back-to-top__arrow { color: var(--accent-text); transition: transform var(--hover-dur); }
.cs-back-to-top:hover .cs-back-to-top__arrow { transform: translateY(-2px); }
/* Over the Outcome band the muted ink + accent arrow drop below 3:1; switch to
   band ink, mirroring the footer's focus-ring fix on the same accent field. */
.cs-back-to-top.is-on-band,
.cs-back-to-top.is-on-band:hover { color: var(--band-text); }
.cs-back-to-top.is-on-band .cs-back-to-top__arrow { color: var(--band-text); }
.cs-back-to-top.is-on-band:focus-visible { outline-color: var(--band-text); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .case-header__back,
  .case-header__nav-link,
  .case-header__subnav::after,
  .cs-next__link,
  .cs-next__arrow,
  .cs-footer__back,
  .cs-footer__link,
  .cs-back-to-top,
  .cs-back-to-top__arrow { transition: none; }
  .cs-next__link:hover .cs-next__arrow { transform: none; }
  .cs-back-to-top { transform: none; }
  .cs-back-to-top:hover .cs-back-to-top__arrow { transform: none; }
}

/* Text-only challenge (no artifact yet): single readable column, no empty slot */
.cs-challenge__inner--solo { grid-template-columns: 1fr; max-width: 62ch; }

/* ---------- Typeset: even heading rags, orphan-free prose ---------- */
.cs-summary__title,
.cs-section-headline,
.cs-challenge__headline,
.cs-outcome__headline { text-wrap: balance; }
.cs-body,
.cs-outcome__body,
.cs-impact__desc,
.cs-summary__question { text-wrap: pretty; }

/* ---------- Full-image gallery (2+ supporting images/GIFs in one section) ---------- */
.cs-full-image-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 56px;
}
.cs-full-image-grid .cs-full-image { margin-top: 0; }
.cs-full-image--grid .image-slot,
.cs-full-image--grid .image-slot__img { min-height: 260px; max-height: 420px; }
