/* HART long-form feature articles.
   Reusable by any article: wrap the page in .feature, put the header in .feature-head,
   the contents list in .feature-toc and the text in .feature-body. Everything here is
   scoped under those classes so nothing global in ops.css changes. */

.feature {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

/* —— Header —— */
.feature-head {
  max-width: 46rem;
  margin-bottom: 0.5rem;
}

.feature-head .kicker {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.feature-head .kicker a {
  color: var(--accent-text);
  text-decoration: none;
}

.feature-head .kicker a:hover {
  color: var(--ink);
}

.feature-head h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  line-height: 1.02;
  letter-spacing: 0.02em;
  color: var(--brand);
  margin: 0 0 0.7rem;
}

.feature-head .standfirst {
  font-family: var(--font-story);
  font-size: clamp(1.08rem, 2vw, 1.25rem);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 0.8rem;
}

.feature-head .byline {
  margin: 0;
  padding-top: 0.6rem;
  border-top: 3px solid var(--accent);
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
}

/* —— Contents: chips on phones, sticky rail on wide screens —— */
.feature-toc {
  font-size: 0.9rem;
}

.feature-toc h2 {
  margin: 0 0 0.45rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.feature-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.feature-toc a {
  display: block;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}

.feature-toc a:hover,
.feature-toc a[aria-current="true"] {
  color: var(--brand);
  border-color: var(--brand-2);
}

@media (min-width: 1000px) {
  .feature {
    grid-template-columns: minmax(0, 1fr) 15rem;
    column-gap: 3rem;
    align-items: start;
  }

  .feature-head {
    grid-column: 1 / -1;
  }

  .feature-toc {
    grid-column: 2;
    grid-row: 2;
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
  }

  .feature-toc ol {
    display: block;
    border-left: 2px solid var(--rule);
    counter-reset: toc;
  }

  .feature-toc li {
    counter-increment: toc;
  }

  .feature-toc a {
    border: 0;
    background: none;
    padding: 0.35rem 0 0.35rem 0.85rem;
    margin-left: -2px;
    border-left: 2px solid transparent;
    font-weight: 600;
  }

  .feature-toc a::before {
    content: counter(toc, decimal-leading-zero) "  ";
    color: var(--muted);
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    white-space: pre;
  }

  .feature-toc a[aria-current="true"] {
    border-left-color: var(--accent);
  }

  .feature-body {
    grid-column: 1;
    grid-row: 2;
  }
}

/* —— Body text —— */
.feature-body {
  max-width: 44rem;
  font-family: var(--font-story);
  font-size: 1.08rem;
  line-height: 1.7;
}

.feature-body p {
  margin: 0 0 1.05rem;
}

.feature-body section {
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.feature-body section + section {
  margin-top: 2.6rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

.feature-body h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  line-height: 1.1;
  letter-spacing: 0.03em;
  color: var(--brand);
  margin: 0 0 0.8rem;
}

.feature-body h2 .num {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--accent-text);
  margin-bottom: 0.15rem;
}

.feature-body .lede::first-letter {
  float: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.6rem;
  line-height: 0.85;
  padding: 0.3rem 0.45rem 0 0;
  color: var(--brand);
}

.feature-body sup a {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0 0.1em;
}

/* —— Pull-out: a key sentence from the text, set large —— */
.feature-body .pull {
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 4px solid var(--accent);
  font-size: 1.28rem;
  line-height: 1.45;
  color: var(--brand);
}

.feature-body .pull p {
  margin: 0;
}

/* —— Figures —— */
.feature-body figure {
  margin: 1.6rem 0;
}

.feature-body figure img {
  width: 100%;
  border: 1px solid var(--rule);
  background: #fff;
}

.feature-body figcaption {
  margin-top: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.feature-body figcaption strong {
  color: var(--ink-soft);
}

.feature-body .fig-pair {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.feature-body .fig-pair figcaption {
  grid-column: 1 / -1;
  margin-top: 0;
}

/* Wide crop for a 4:3 photo that would otherwise run tall */
.feature-body figure.crop-wide img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* —— Panels that break from the text column: steps, flows, stats —— */
.feature-body .aside-box {
  margin: 1.6rem 0;
  padding: 1rem 1.15rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--brand-2);
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.5;
}

.feature-body .aside-box > h3 {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  color: var(--brand);
}

.feature-body .aside-box > p {
  margin: 0.8rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* Numbered steps */
.feature-body .step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
  display: grid;
  gap: 0.55rem;
}

.feature-body .step-list > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.6rem;
  min-height: 1.9rem;
}

.feature-body .step-list > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.05rem;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.feature-body .step-list strong {
  color: var(--brand);
}

/* Left-to-right flow of stages (wraps on phones) */
.feature-body .stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem 1.4rem;
}

.feature-body .stages > li {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--brand-2);
}

.feature-body .stages > li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -1.15rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-text);
  font-weight: 700;
}

.feature-body .stages b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  color: var(--brand);
}

.feature-body .stages span {
  display: block;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.feature-body .stages.loop > li:last-child::after {
  content: "↺";
  position: absolute;
  right: -1.15rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-text);
  font-weight: 700;
}

/* Decision: one input, two outcomes */
.feature-body .decision {
  display: grid;
  gap: 0.6rem;
}

.feature-body .decision .from {
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--brand-2);
}

.feature-body .decision .outs {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}

.feature-body .decision .out {
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--rule);
}

.feature-body .decision .out.ok {
  border-left: 3px solid var(--ok);
}

.feature-body .decision .out.no {
  border-left: 3px solid var(--signal);
}

.feature-body .decision b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  color: var(--brand);
}

.feature-body .decision .arrow {
  text-align: center;
  color: var(--accent-text);
  font-weight: 700;
  line-height: 1;
}

/* Chips: a set of named steps without numbers */
.feature-body .chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.feature-body .chips li {
  padding: 0.3rem 0.65rem;
  background: #fff;
  border: 1px solid var(--rule);
  font-weight: 600;
  font-size: 0.92rem;
}

.feature-body .chips li.opt {
  border-style: dashed;
  color: var(--ink-soft);
  font-weight: 400;
}

/* Two-column "too much / too little" contrast */
.feature-body .contrast {
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.5;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-body .contrast > div {
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--rule);
}

.feature-body .contrast b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  color: var(--brand);
}

.feature-body .contrast .mid {
  grid-column: 1 / -1;
  border-left: 3px solid var(--ok);
}

/* Stat strip */
.feature-body .stats {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  margin: 0;
}

.feature-body .stats > div {
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1px solid var(--rule);
}

.feature-body .stats dt {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--brand);
}

.feature-body .stats dd {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* —— References —— */
.feature-body .refs {
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-soft);
  padding-left: 1.4rem;
}

.feature-body .refs li {
  margin: 0 0 0.6rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.feature-body .refs li:target {
  background: rgba(201, 146, 18, 0.14);
}

.feature-body .refs a {
  overflow-wrap: anywhere;
}

.feature-more {
  margin-top: 2.4rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .feature-body {
    font-size: 1.03rem;
    line-height: 1.65;
  }

  .feature-body .pull {
    font-size: 1.15rem;
  }

  .feature-body .stages > li {
    flex-basis: 100%;
  }

  .feature-body .contrast {
    grid-template-columns: minmax(0, 1fr);
  }

  .feature-body .stages > li:not(:last-child)::after,
  .feature-body .stages.loop > li:last-child::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -0.55rem;
    transform: translateX(-50%) rotate(90deg);
    z-index: 1;
    background: var(--card);
    line-height: 1;
  }

  .feature-body .stages.loop > li:last-child::after {
    transform: translateX(-50%);
  }

  .feature-body .stages {
    gap: 0.75rem;
  }
}

.feature-body sup {
  line-height: 0;
}

@media (max-width: 640px) {
  .feature-body .stages.loop > li:last-child::after {
    content: none;
  }
}

/* Code in articles: inline names and short listings (STL Studio). */
.feature-body code,
.feature-body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.feature-body pre {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--paper-2);
  border-left: 3px solid var(--brand);
  overflow-x: auto;
  line-height: 1.5;
}

/* —— Banner photo at the top of an article (optional) —— */
.feature-head:has(> .feature-banner) {
  max-width: none;
}

.feature-head:has(> .feature-banner) > :not(.feature-banner) {
  max-width: 46rem;
}

.feature-banner {
  margin: 0 0 1.25rem;
}

.feature-banner img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 3;
  object-fit: cover;
  border: 1px solid var(--rule);
}

.feature-banner figcaption {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}
