/* ========================================
   Case study steps: shared layout for long-form product case studies
   (Subscrr, Finaura, DIFC, Forbes). Loaded after the page's own
   case-study.css, which still owns the hero, CTA, next link and cursor.
   ======================================== */

:root {
  --step-toc-w: 220px;
  --step-text-w: 720px;
  --step-radius: 16px;
  --step-surface: rgba(255, 255, 255, 0.04);
  --step-surface-2: rgba(255, 255, 255, 0.07);
}

/* ---- Summary: problem / what I did / result ---- */
.steps-summary {
  padding: 0 var(--gutter) var(--space-xl);
}

.steps-summary__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--step-radius);
  overflow: hidden;
}

.summary-card {
  background: var(--color-bg);
  padding: var(--space-md);
}

.summary-card .label {
  margin-bottom: 1rem;
}

.summary-card p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
}

.summary-card--result p {
  color: var(--color-text);
}

.summary-card--result strong {
  color: var(--color-accent);
  font-weight: 600;
}

/* ---- Layout: sticky table of contents + steps ---- */
.steps {
  padding: 0 var(--gutter);
}

.steps__body {
  min-width: 0;
}

.steps__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--step-toc-w) minmax(0, 1fr);
  gap: var(--space-lg);
}

.steps__toc {
  position: sticky;
  top: 6.5rem;
  align-self: start;
  padding-top: var(--space-xl);
}

.steps__toc ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.steps__toc a {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.4rem 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  transition: color 0.3s ease;
}

.steps__toc a span:first-child {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  width: 1.5rem;
  flex: none;
}

.steps__toc a:hover {
  color: var(--color-text);
}

.steps__toc a.is-active {
  color: var(--color-text);
}

.steps__toc a.is-active span:first-child {
  color: var(--color-accent);
}

/* ---- A step ---- */
.step {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--color-border);
  scroll-margin-top: 5rem;
}

.step:first-child {
  border-top: none;
}

.step__head {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
}

.step__num {
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
}

.step__head .label {
  margin-bottom: 0;
}

.step__title {
  font-size: clamp(1.75rem, 3.4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.03em;
  max-width: 18em;
  margin-bottom: var(--space-md);
}

.step__text {
  max-width: var(--step-text-w);
}

.step__text p {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--color-text-dim);
}

.step__text p + p {
  margin-top: 1rem;
}

.step__text strong {
  color: var(--color-text);
  font-weight: 500;
}

.step__lead {
  font-size: clamp(1.125rem, 2vw, 1.375rem) !important;
  line-height: 1.55 !important;
  color: var(--color-text) !important;
}

.step__sub {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: var(--space-lg) 0 1.25rem;
}

/* ---- Media inside a step: full width of the content column ---- */
.step-media {
  margin-top: var(--space-lg);
}

.step-media + .step-media {
  margin-top: var(--space-md);
}

.step-media img,
.step-media video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0;
  background: #111;
}

.step-media figcaption {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.step-media--pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.step-media--pair .step-media__cell {
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 0;
  background: #000;
}

.step-media--pair video {
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* ---- Bullet list with rules ---- */
.step-list {
  list-style: none;
  max-width: var(--step-text-w);
  border-top: 1px solid var(--color-border);
}

.step-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-dim);
}

.step-list strong {
  color: var(--color-text);
  font-weight: 500;
}

/* Numbered issues, annotation style */
.issues {
  list-style: none;
  counter-reset: issue;
  display: grid;
  gap: 1rem;
  max-width: var(--step-text-w);
}

.issues li {
  counter-increment: issue;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 1rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-dim);
}

.issues li::before {
  content: counter(issue);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: #000;
  font-size: 0.8125rem;
  font-weight: 600;
}

.issues strong {
  color: var(--color-text);
  font-weight: 500;
}

/* ---- Horizontal bar chart ---- */
.hbars {
  display: grid;
  gap: 1rem;
  max-width: var(--step-text-w);
}

.hbar__row {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 1rem;
  align-items: center;
}

.hbar__value {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.hbar__track {
  position: relative;
  height: 2.75rem;
  border-radius: 10px;
  background: var(--step-surface);
  overflow: hidden;
}

.hbar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  background: var(--color-accent);
  opacity: 0.9;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1.2s var(--ease);
}

.is-drawn .hbar__fill {
  transform: scaleX(1);
}

.hbar__label {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9375rem;
  color: #fff;
  z-index: 1;
  white-space: nowrap;
}

.hbars__note {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ---- Cards (scenarios, hypotheses) ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card-s {
  background: var(--step-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--step-radius);
  padding: 1.5rem;
}

.card-s__num {
  font-size: 0.75rem;
  color: var(--color-accent);
  margin-bottom: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.card-s h3 {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.card-s p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text-dim);
}

/* Hypothesis: If / Then / Because */
.hypos {
  display: grid;
  gap: 1rem;
}

.hypo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-md);
  background: var(--step-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--step-radius);
  padding: var(--space-md);
}

.hypo--solo {
  grid-template-columns: 1fr;
}

.hypo__head {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
}

.hypo__head span {
  font-size: 0.75rem;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

.hypo__head h3 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.hypo__logic {
  display: grid;
  gap: 0.75rem;
}

.hypo__logic p {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text-dim);
}

.hypo__logic b {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding-top: 0.2rem;
}

.hypo__result {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text);
}

.hypo__result::before {
  content: "→ ";
  color: var(--color-accent);
}

.hypo {
  align-items: center;
}

.hypo__media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

/* ---- Before / after flow schema ---- */
.flow {
  display: grid;
  gap: var(--space-md);
}

.flow__row .label {
  margin-bottom: 0.75rem;
}

.flow__steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

.flow__step {
  position: relative;
  min-height: 5.5rem;
  padding: 0.875rem;
  border-radius: 12px;
  background: var(--step-surface);
  border: 1px solid var(--color-border);
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--color-text-dim);
}

.flow__step small {
  display: block;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.flow__step--cut {
  opacity: 0.45;
  border-style: dashed;
}

.flow__step--value {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #000;
}

.flow__step--value small {
  color: rgba(0, 0, 0, 0.6);
}

/* ---- Comparison table ---- */
.bench {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--step-radius);
}

.bench table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.bench th,
.bench td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  line-height: 1.4;
}

.bench tr:last-child td {
  border-bottom: none;
}

.bench thead th {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.bench tbody th {
  font-weight: 400;
  color: var(--color-text-dim);
}

.bench td {
  color: var(--color-text-muted);
}

.bench .is-own {
  background: rgba(255, 75, 56, 0.1);
  color: var(--color-text);
}

.bench thead .is-own {
  color: var(--color-accent);
}

.bench .yes {
  color: var(--color-text);
}

.bench .no {
  color: rgba(255, 255, 255, 0.35);
}

.bench__source {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.bench__source a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Numbered takeaways */
.takeaways {
  list-style: none;
  counter-reset: t;
  display: grid;
  gap: 1.25rem;
  max-width: var(--step-text-w);
}

.takeaways li {
  counter-increment: t;
  display: grid;
  grid-template-columns: 2rem 1fr;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-dim);
}

.takeaways li::before {
  content: counter(t, decimal-leading-zero);
  font-size: 0.75rem;
  color: var(--color-accent);
  padding-top: 0.25rem;
}

.takeaways strong {
  color: var(--color-text);
  font-weight: 500;
}

/* ---- Column chart (daily installs) ---- */
.colchart {
  background: var(--step-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--step-radius);
  padding: 1.5rem 1.5rem 1rem;
}

.colchart__plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 180px;
}

.colchart__bar {
  flex: 1;
  height: var(--h);
  min-height: 2px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px 2px 0 0;
  transform-origin: bottom;
  transform: scaleY(0);
  transition: transform 0.9s var(--ease);
}

.colchart__bar.is-peak {
  background: var(--color-accent);
}

.is-drawn .colchart__bar {
  transform: scaleY(1);
}

.colchart__callout {
  position: absolute;
  top: 0;
  transform: translateX(-100%);
  text-align: right;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--color-text);
  white-space: nowrap;
}

.colchart__axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

/* ---- Metric tiles ---- */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.metric {
  background: var(--step-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--step-radius);
  padding: var(--space-md) 1.5rem 1.5rem;
}

.metric__value {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 1rem;
}

.metric__value em {
  font-style: normal;
  color: var(--color-accent);
}

.metric p {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--color-text-dim);
}

/* Assumption vs reality */
.versus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.versus__col {
  border-radius: var(--step-radius);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
}

.versus__col--was {
  border-style: dashed;
}

.versus__col--is {
  background: var(--step-surface-2);
}

.versus__col .label {
  margin-bottom: 1rem;
}

.versus__col p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-dim);
}

.versus__col ul {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.versus__col li {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text-dim);
}

.versus__col li strong {
  color: var(--color-text);
  font-weight: 500;
}

/* ---- Mobile progress bar (the TOC collapses into it) ---- */
.steps-progress {
  display: none;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
  :root {
    --step-toc-w: 180px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .hypo {
    grid-template-columns: 1fr;
  }

  .flow__steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .steps-summary__inner {
    grid-template-columns: 1fr;
  }

  /* minmax(0, 1fr), not 1fr: a plain 1fr track grows to its widest child,
     and the benchmark table (min-width 720px) pushed the whole column past
     the screen. The table scrolls inside .bench instead. */
  .steps__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .hbar__track {
    height: auto;
    min-height: 2.75rem;
  }

  .hbar__label {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    display: block;
    padding: 0.7rem 1rem;
    white-space: normal;
    line-height: 1.35;
  }

  .summary-card {
    padding: 1.5rem;
  }

  .hypo {
    padding: 1.5rem;
  }

  .step__title {
    margin-bottom: 1.5rem;
  }



  .steps__toc {
    display: none;
  }

  .step {
    padding: var(--space-lg) 0;
  }

  .step__text p {
    font-size: 1.0625rem;
  }

  .metrics,
  .versus {
    grid-template-columns: 1fr;
  }

  .flow__steps {
    grid-template-columns: repeat(2, 1fr);
  }

  .colchart {
    padding: 1rem 1rem 0.75rem;
  }

  .colchart__plot {
    height: 140px;
    gap: 1px;
  }

  .hypo__logic p {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }

  .steps-progress {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.82);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--color-border);
    font-size: 0.8125rem;
    color: var(--color-text-dim);
    transform: translateY(110%);
    transition: transform 0.4s var(--ease);
  }

  .steps-progress.is-visible {
    transform: none;
  }

  .steps-progress__num {
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
  }

  .steps-progress__track {
    position: absolute;
    left: 0;
    right: 0;
    top: -1px;
    height: 2px;
  }

  .steps-progress__fill {
    height: 100%;
    width: 100%;
    background: var(--color-accent);
    transform-origin: left;
    transform: scaleX(var(--p, 0));
  }
}

@media (max-width: 480px) {
  /* Two 9:16 reels side by side are too small on a phone: stack them */
  .step-media--pair {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hbar__fill,
  .colchart__bar {
    transition: none;
    transform: none;
  }
}

/* A hypothesis visual sits under its card, full column width */
.hypos .hypo__figure {
  margin-top: 0;
  margin-bottom: var(--space-md);
}
