/* Heat treatment process story — vertical narrative, type-forward */

/*
 * Sticky needs ancestors without overflow:hidden.
 * Global `section { overflow: hidden }` would pin-kill .ht-story__nav.
 */
section.ht-story-section {
  overflow: visible !important;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding-top: 0.5rem;
  /* Extra bottom space so timeline is clearly separated from the next section */
  padding-bottom: clamp(3.5rem, 7vw, 6rem);
  margin-bottom: clamp(1rem, 3vw, 2rem);
  height: auto;
  max-width: 100%;
}

.ht-story {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: clamp(1.5rem, 3vw, 2.5rem) 1.25rem clamp(2rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  /* Header ↔ layout use gap; induction uses its own larger margin-top */
  gap: clamp(1.75rem, 3.5vw, 2.5rem);
  overflow: visible;
}

/* ── Header ───────────────────────────────────────────────────────── */
.ht-story__header {
  text-align: left;
  max-width: 36rem;
}

.ht-story__header .cap-title {
  margin-bottom: 0.65rem;
}

.ht-story__lead {
  margin: 0;
  font-size: 1.08rem;
  font-weight: var(--fm-font-weight-regular);
  color: var(--fm-color-text-muted);
  line-height: 1.65;
  max-width: 34rem;
}

/* ── Layout: full-height sidebar + steps ──────────────────────────── */
.ht-story__layout {
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.75rem);
  /* stretch so sidebar column is as tall as steps (required for sticky) */
  align-items: stretch;
}

.ht-story__sidebar {
  position: relative;
  /* column runs the full height of the steps stack */
  min-height: 100%;
}

@media (max-width: 900px) {
  .ht-story__layout {
    grid-template-columns: 1fr;
  }

  .ht-story__sidebar {
    min-height: 0;
  }
}

/* Sticky step list — travels while its tall sidebar is in view */
.ht-story__nav {
  position: sticky;
  top: 5.75rem; /* below fixed site nav */
  z-index: 5;
  width: 100%;
  padding: 0.5rem 0.35rem 0.75rem 0;
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--fm-color-bg);
  box-sizing: border-box;
}

/* JS fixed mode (when ancestor overflow still kills sticky) */
.ht-story__nav.is-fixed {
  position: fixed;
  z-index: 30;
  margin: 0;
}

.ht-story__nav.is-pinned-bottom {
  position: absolute;
  top: auto !important;
  bottom: 0;
  left: 0 !important;
  right: auto !important;
  width: 100% !important;
}

.ht-story__nav-label {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: var(--fm-font-weight-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fm-color-brand-start);
}

.ht-story__nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-left: 2px solid rgba(51, 51, 51, 0.1);
}

.ht-story__nav-link {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.55rem 0 0.55rem 0.9rem;
  margin-left: -2px;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--fm-color-text-muted);
  /* Longer ease so top→bottom lighting feels sequential, not flickery */
  transition:
    color 0.4s ease,
    border-color 0.4s ease,
    background 0.4s ease,
    opacity 0.4s ease;
  border-radius: 0 0.5rem 0.5rem 0;
  opacity: 0.72;
}

.ht-story__nav-link:hover {
  color: var(--fm-color-text);
  opacity: 0.95;
  background: rgba(0, 0, 0, 0.03);
}

.ht-story__nav-link.is-passed {
  opacity: 0.88;
  color: var(--fm-color-text);
  border-left-color: rgba(255, 106, 0, 0.35);
}

.ht-story__nav-link.is-active {
  color: var(--fm-color-text);
  border-left-color: var(--fm-color-brand-start);
  background: linear-gradient(90deg, rgba(255, 106, 0, 0.1), transparent);
  opacity: 1;
}

/* Upcoming (not yet reached) stay quieter */
.ht-story__nav-link:not(.is-active):not(.is-passed) {
  opacity: 0.5;
}

.ht-story__nav-num {
  font-size: 0.8rem;
  font-weight: var(--fm-font-weight-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: inherit;
  opacity: 0.75;
  transition: color 0.4s ease, opacity 0.4s ease;
}

.ht-story__nav-link.is-active .ht-story__nav-num {
  opacity: 1;
  color: var(--fm-color-brand-start);
}

.ht-story__nav-text {
  font-size: 0.88rem;
  font-weight: var(--fm-font-weight-medium);
  line-height: 1.35;
  transition: font-weight 0.25s ease;
}

.ht-story__nav-link.is-active .ht-story__nav-text {
  font-weight: var(--fm-font-weight-bold);
}

@media (max-width: 900px) {
  /* Mobile: sticky bar under site nav, horizontal chips */
  .ht-story__nav,
  .ht-story__nav.is-fixed,
  .ht-story__nav.is-pinned-bottom {
    position: sticky !important;
    top: 4.5rem !important;
    left: auto !important;
    width: 100% !important;
    bottom: auto !important;
    z-index: 20;
    max-height: none;
    overflow: visible;
    padding: 0.35rem 0 0.5rem;
    margin: 0;
    background: rgba(240, 240, 240, 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(51, 51, 51, 0.08);
  }

  .ht-story__nav-label {
    display: none;
  }

  .ht-story__nav-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-left: none;
    border-bottom: none;
    gap: 0;
    padding: 0 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .ht-story__nav-list::-webkit-scrollbar {
    display: none;
  }

  .ht-story__nav-link {
    flex: 0 0 auto;
    grid-template-columns: auto;
    gap: 0.2rem;
    margin-left: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 0.5rem;
    padding: 0.5rem 0.85rem 0.55rem;
    text-align: center;
  }

  .ht-story__nav-link.is-active {
    border-left-color: transparent;
    border-bottom-color: var(--fm-color-brand-start);
    background: rgba(255, 106, 0, 0.08);
  }

  .ht-story__nav-text {
    display: none;
  }

  .ht-story__nav-num {
    font-size: 0.95rem;
  }
}

/* ── Step blocks ──────────────────────────────────────────────────── */
.ht-story__steps {
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 4vw, 3.25rem);
}

.ht-step {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2rem);
  align-items: center;
  scroll-margin-top: 6rem;
  /* Always full opacity — no scroll fade on text / media */
  opacity: 1;
}

.ht-step--flip .ht-step__media {
  order: 2;
}

.ht-step--flip .ht-step__copy {
  order: 1;
}

@media (max-width: 700px) {
  .ht-step,
  .ht-step--flip {
    grid-template-columns: 1fr;
  }

  .ht-step--flip .ht-step__media,
  .ht-step--flip .ht-step__copy {
    order: unset;
  }
}

.ht-step__media {
  position: relative;
  border-radius: 1.1rem;
  overflow: hidden;
  background: #1a2229;
  aspect-ratio: 4 / 3;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.1);
}

.ht-step__media img,
.ht-step__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Type block — generous measure, clear hierarchy */
.ht-step__copy {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.25rem 0;
  max-width: 32rem;
}

.ht-step__meta {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: var(--fm-font-weight-bold);
  letter-spacing: 0.06em;
  color: var(--fm-color-brand-start);
}

.ht-step__meta-sep {
  opacity: 0.45;
  font-weight: var(--fm-font-weight-regular);
}

.ht-step__meta-total {
  opacity: 0.55;
  color: var(--fm-color-text-muted);
}

.ht-step__title {
  margin: 0;
  font-size: clamp(1.45rem, 2.8vw, 1.9rem);
  font-weight: var(--fm-font-weight-black);
  color: var(--fm-color-text);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.ht-step__body {
  margin: 0;
  font-size: 1.05rem;
  font-weight: var(--fm-font-weight-regular);
  color: var(--fm-color-text-muted);
  line-height: 1.7;
}

/* ── Process methods (HF + vacuum furnace) ────────────────────────── */
.ht-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
  margin-top: clamp(2.75rem, 6vw, 4.5rem);
}

.ht-method {
  display: flex;
  flex-direction: column;
  border-radius: 1.15rem;
  overflow: hidden;
  background: var(--fm-color-surface);
  border: 1px solid rgba(51, 51, 51, 0.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
  height: 100%;
}

.ht-method__media {
  aspect-ratio: 16 / 10;
  background: #1a2229;
  overflow: hidden;
}

.ht-method__media img,
.ht-method__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ht-method__copy {
  padding: 1.35rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.ht-method__copy h3 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  font-weight: var(--fm-font-weight-black);
  color: var(--fm-color-text);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.ht-method__copy p {
  margin: 0;
  font-size: 0.98rem;
  font-weight: var(--fm-font-weight-regular);
  color: var(--fm-color-text-muted);
  line-height: 1.65;
}

@media (max-width: 800px) {
  .ht-methods {
    grid-template-columns: 1fr;
  }
}

/* legacy selector kept as belt-and-suspenders */
section.cap-section:has(.ht-story) {
  overflow: visible !important;
  flex-direction: column;
  align-items: stretch;
}
