/* ============================================================
   How It Works page (how-it-works.html), loaded after landing.css.
   Reuses the landing tokens; every class here starts with hiw-.
   market-simulation.html loads this file too, for the hero cards, the step
   bar and the chapter layout.
   Mobile-first, media queries at the end of each block.
   ============================================================ */

/* --- Hero: the page promise, then the four steps as linked cards --- */
.hiw-hero { padding-bottom: 72px; }
.hiw-hero-copy { max-width: 760px; }
/* .subpage-hero p would restyle the kicker as body text */
.hiw-hero .hero-kicker { max-width: none; margin-bottom: 14px; font-size: 0.78rem; line-height: 1.8; color: var(--color-ink); }
.hiw-hero h1 { font-size: 2rem; line-height: 1.12; text-wrap: balance; }
.hiw-hero h1 .accent { color: var(--color-accent); }
.hiw-hero .hiw-hero-lead { max-width: 640px; }
.hiw-hero-links { margin-top: 20px; }
@media (min-width: 768px) {
  .hiw-hero h1 { font-size: 2.5rem; line-height: 1.1; }
}
@media (min-width: 1024px) {
  .hiw-hero { padding-top: 120px; }
}

/* --- Walkthrough: the screen recording of a study being set up (16:10) --- */
.hiw-walkthrough { max-width: 1000px; margin: 44px auto 0; }
.hiw-walkthrough-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  background: #fff;
}
.hiw-walkthrough-caption {
  margin-top: 14px;
  font-size: 0.92rem;
  color: var(--color-text-muted);
  text-align: center;
}
@media (max-width: 700px) {
  .hiw-walkthrough .hero-deck-frame { padding: 6px; }
}
/* Inside a step chapter: the video sits in the right column of .hiw-step-grid */
.hiw-walkthrough--chapter { max-width: none; margin: 0; }
.hiw-walkthrough--chapter .hero-deck-frame { padding: 8px; box-shadow: 0 16px 40px rgba(13, 20, 18, 0.08); }

/* --- Step layout: three short points next to the recording, details collapsed below --- */
.hiw-step-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; margin-top: 8px; }
.hiw-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hiw-points li {
  position: relative;
  padding-left: 30px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-ink);
}
.hiw-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='9'/%3E%3C/svg%3E");
}
.hiw-points li::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  width: 6px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
@media (min-width: 960px) {
  .hiw-step-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 48px; }
  .hiw-chapter--flip .hiw-step-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .hiw-chapter--flip .hiw-step-points { order: 2; }
}

.hiw-details { margin-top: 32px; border-top: 1px solid var(--color-border); }
.hiw-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-primary);
}
.hiw-details > summary::-webkit-details-marker { display: none; }
.hiw-details > summary::before {
  content: '';
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
.hiw-details[open] > summary::before { transform: rotate(45deg); }
.hiw-details-body { padding-bottom: 24px; display: grid; gap: 28px; }
.hiw-walkthrough--chapter.method-carousel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  background: var(--color-bg-alt);
  box-shadow: var(--shadow-sm);
}
.hiw-walkthrough--chapter.method-carousel .hiw-walkthrough-caption { margin: 12px 16px 14px; }

.hiw-steps {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 44px;
  padding: 0;
  scroll-margin-top: 96px;
}
.hiw-steps > li { position: relative; display: flex; min-width: 0; }
.hiw-step-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 26px 24px 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.hiw-step-card:hover,
.hiw-step-card:focus-visible {
  border-color: var(--color-primary);
  box-shadow: 0 12px 30px -18px rgba(13, 20, 18, 0.35);
  transform: translateY(-2px);
  color: inherit;
}
.hiw-step-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.hiw-step-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--color-accent);
}
.hiw-step-card h3 {
  margin: 14px 0 10px;
  font-size: 1.2rem;
  color: var(--color-ink);
}
.hiw-step-card p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}
.hiw-step-card .hiw-step-result {
  margin-top: auto;
  padding-top: 16px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--color-text);
}
.hiw-step-result::before {
  content: "";
  display: block;
  margin: 18px 0 14px;
  border-top: 1px solid var(--color-border);
}
.hiw-step-result strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
/* Method under the model title (analytics page): teal, so the estimation
   method reads at a glance next to the use-case title. */
.hiw-step-card .hiw-step-method {
  margin: -6px 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-accent-dark);
}
.hiw-step-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-primary);
}
/* Phones: the cards become a compact table of contents (number, title and a
   pointer down). The chapters below carry the full text. */
@media (max-width: 719px) {
  .hiw-steps { gap: 10px; margin-top: 32px; }
  .hiw-step-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    padding: 16px 18px;
  }
  .hiw-step-num { font-size: 1.8rem; }
  .hiw-step-card h3 { margin: 0; font-size: 1.08rem; }
  .hiw-step-card > p { display: none; }
  /* The method stays visible as a second line under the title. */
  .hiw-step-card:has(.hiw-step-method) .hiw-step-num { grid-row: 1 / span 2; }
  .hiw-step-card:has(.hiw-step-method) h3 { grid-column: 2; grid-row: 1; }
  .hiw-step-card > p.hiw-step-method {
    display: block;
    grid-column: 2;
    grid-row: 2;
    margin: 2px 0 0;
    font-size: 0.85rem;
  }
  .hiw-step-more { margin-top: 0; font-size: 0; }
  .hiw-step-more span { font-size: 1rem; color: var(--color-text-light); }
}
@media (min-width: 720px) {
  .hiw-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
}
@media (min-width: 1100px) {
  .hiw-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
  /* A small chevron in the gap between two cards reads as "then". */
  .hiw-steps > li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 42px;
    right: -19px;
    width: 10px;
    height: 10px;
    border-top: 2px solid var(--color-text-light);
    border-right: 2px solid var(--color-text-light);
    transform: rotate(45deg);
  }
}

/* --- Step chapters with a sticky step bar --- */
.hiw-chapters { position: relative; }
.hiw-stepnav {
  position: sticky;
  top: 64px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
/* Centred as wide as its steps; when they do not fit it takes the full width
   and scrolls (justify-content: center would cut off the first steps). */
.hiw-stepnav ol {
  list-style: none;
  display: flex;
  gap: 4px 28px;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.hiw-stepnav ol::-webkit-scrollbar { display: none; }
/* landing.js sets these while the bar scrolls: a soft edge where more steps are */
.hiw-stepnav ol.has-more {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}
.hiw-stepnav ol.has-before {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 40px);
  mask-image: linear-gradient(to right, transparent, #000 40px);
}
.hiw-stepnav ol.has-before.has-more {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 48px), transparent);
}
.hiw-stepnav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 2px 12px;
  border-bottom: 2px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--color-text-muted);
  text-decoration: none;
}
.hiw-stepnav a span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-light);
}
.hiw-stepnav a:hover { color: var(--color-primary); }
.hiw-stepnav a[aria-current="step"] {
  color: var(--color-ink);
  border-bottom-color: var(--color-accent);
}
.hiw-stepnav a[aria-current="step"] span { color: var(--color-accent); }

.hiw-chapter {
  padding: 80px 0 88px;
  background: var(--color-bg);
  scroll-margin-top: 112px;
}
.hiw-chapter + .hiw-chapter { border-top: 1px solid var(--color-border); }
.hiw-chapter--alt { background: var(--color-bg-alt); }
.hiw-chapter-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px 40px;
  margin-bottom: 40px;
}
.hiw-chapter-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3.6rem;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--color-accent);
}
.hiw-kicker {
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
/* Method of the chapter, between the kicker and the question. */
.hiw-method {
  margin: -2px 0 10px;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-accent-dark);
}
.hiw-method .analytics-badge {
  position: static;
  display: inline-block;
  margin-left: 8px;
  vertical-align: 3px;
}
.hiw-chapter-head .section-title { margin-bottom: 14px; max-width: 760px; }
.hiw-lead {
  max-width: 760px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-text-muted);
}
.hiw-chapter-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}
.hiw-chapter-text { min-width: 0; }
.hiw-chapter-visual { min-width: 0; }
.hiw-split + .hiw-split { margin-top: 30px; }
.hiw-split-title {
  margin-bottom: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
/* "You decide" list: a plain ink dot; the "Choicery takes care of" list keeps the teal check. */
.hiw-you-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
}
.hiw-you-list li {
  position: relative;
  padding-left: 24px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text);
}
.hiw-you-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-ink);
}
.hiw-chapter .feature-list li strong,
.hiw-you-list li strong { font-weight: 600; color: var(--color-ink); }

/* Spec sheet with the defaults of a step */
.hiw-spec {
  margin: 32px 0 0;
  border-top: 2px solid var(--color-primary);
}
.hiw-spec-caption {
  margin-top: 32px;
  margin-bottom: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.hiw-spec-caption + .hiw-spec { margin-top: 0; }
.hiw-spec-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.hiw-spec dt {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--color-text-muted);
}
.hiw-spec dd {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--color-text);
}
.hiw-spec dd strong { font-weight: 600; color: var(--color-ink); }
@media (min-width: 540px) {
  .hiw-spec-row { grid-template-columns: 150px minmax(0, 1fr); }
}
/* Below the chapter body the sheet runs full width, in two columns on desktop. */
.hiw-spec-wrap { margin-top: 48px; }
.hiw-spec-wrap .hiw-spec-caption { margin-top: 0; }
@media (min-width: 900px) {
  .hiw-spec-wrap .hiw-spec {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 56px;
  }
}

/* What the step leaves behind: a neutral row of chips */
.hiw-outcome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 10px;
  margin-top: 44px;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
}
.hiw-outcome-label {
  margin-right: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-ink);
}
.hiw-outcome ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
}
.hiw-outcome li {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  font-size: 0.84rem;
  line-height: 1.3;
  color: var(--color-text);
}
.hiw-more {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  margin-top: 22px;
  padding: 0;
  list-style: none;
}
.hiw-more a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary);
}
.hiw-more a:hover { color: var(--color-accent-dark); }

/* Slides of different heights share one stage: centre the shorter screenshots
   in the free space instead of leaving a white band under them. */
.hiw-chapter-visual .method-carousel__slide > .method-carousel__visual:not(.method-carousel__visual--phone) {
  flex: 1;
  display: flex;
  align-items: center;
}

/* A video slide inside a carousel keeps the 16:9 frame of the loops */
.hiw-video-slide video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #fff;
  pointer-events: none;
}

/* Phones: a smaller chapter number and less padding, so the text starts sooner */
@media (max-width: 600px) {
  .hiw-chapter { padding: 56px 0 60px; }
  .hiw-chapter-head { margin-bottom: 28px; }
  .hiw-chapter-num { font-size: 2.6rem; }
}
@media (min-width: 768px) {
  .hiw-chapter-num { font-size: 4.6rem; }
}
@media (min-width: 1024px) {
  .hiw-chapter { padding: 96px 0 100px; }
  .hiw-chapter-head { grid-template-columns: 150px minmax(0, 1fr); align-items: start; }
  .hiw-chapter-num { font-size: 5.6rem; padding-top: 4px; }
  .hiw-chapter-body { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; }
  .hiw-chapter--flip .hiw-chapter-body { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .hiw-chapter--flip .hiw-chapter-visual { order: -1; }
}
/* The screens stay in view while the longer text column scrolls past, but only
   on screens tall enough to show them whole (not on short laptops). */
@media (min-width: 1024px) and (min-height: 860px) {
  .hiw-chapter-visual { position: sticky; top: 132px; }
}
/* Short screens: no sticky screens, so they sit level with the middle of the text */
@media (min-width: 1024px) and (max-height: 859px) {
  .hiw-chapter-visual { align-self: center; }
}

/* --- Panel inside a chapter: a titled grid of short label + text pairs --- */
.hiw-panel {
  margin-top: 48px;
  padding: 26px 24px 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
}
.hiw-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}
.hiw-panel-head h3 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
.hiw-panel-head p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.hiw-panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px 32px;
}
.hiw-panel-item { min-width: 0; }
.hiw-panel-item h4 {
  margin-bottom: 4px;
  font-size: 0.95rem;
  color: var(--color-ink);
}
.hiw-panel-item h4 small {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.hiw-panel-item p {
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--color-text-muted);
}
@media (min-width: 640px) {
  .hiw-panel { padding: 28px 30px 30px; }
  .hiw-panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .hiw-panel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hiw-panel-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* --- Checks: what Choicery verifies at each step, as a data sheet --- */
.hiw-checks {
  padding: var(--section-py) 0;
  background: var(--color-bg);
}
.hiw-checks-head { max-width: 760px; margin-bottom: 36px; }
.hiw-checks-head .section-desc { max-width: none; margin-bottom: 0; }
.hiw-check-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
}
.hiw-check-col { padding: 24px 22px 26px; min-width: 0; }
.hiw-check-col + .hiw-check-col { border-top: 1px solid var(--color-border); }
.hiw-check-col h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-primary);
  font-size: 1.05rem;
  color: var(--color-ink);
}
.hiw-check-col h3 span {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-accent);
}
.hiw-check-col .feature-list { gap: 12px; }
.hiw-check-col .feature-list li { font-size: 0.86rem; }
@media (min-width: 720px) {
  .hiw-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hiw-check-col + .hiw-check-col { border-top: none; }
  .hiw-check-col:nth-child(even) { border-left: 1px solid var(--color-border); }
  .hiw-check-col:nth-child(n+3) { border-top: 1px solid var(--color-border); }
}
@media (min-width: 1100px) {
  .hiw-check-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hiw-check-col:nth-child(n+2) { border-left: 1px solid var(--color-border); }
  .hiw-check-col:nth-child(n+3) { border-top: none; }
}

/* --- One project: the files a study builds up, in order --- */
.hiw-project {
  padding: var(--section-py) 0;
  background: var(--color-bg-alt);
}
.hiw-project-head { max-width: 760px; margin-bottom: 36px; }
.hiw-project-head .section-desc { max-width: none; margin-bottom: 0; }
.hiw-chain {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 0;
  counter-reset: hiw-chain;
}
.hiw-chain li {
  position: relative;
  min-width: 0;
  padding: 18px 18px 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
}
.hiw-chain h3 {
  margin-bottom: 6px;
  font-size: 0.98rem;
  color: var(--color-ink);
}
.hiw-chain p {
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--color-text-muted);
}
.hiw-chain-step {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-light);
}
.hiw-project-note {
  margin-top: 22px;
  max-width: 760px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}
@media (min-width: 720px) {
  .hiw-chain { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .hiw-chain { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px; }
  .hiw-chain li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -14px;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-top: 2px solid var(--color-text-light);
    border-right: 2px solid var(--color-text-light);
    transform: rotate(45deg);
  }
}
