/**
 * Section: Stages of Work (#stages / .stages-section)
 * Space Chemical Design System
 * Figma spec: node 359:1113, 1440x739px
 * Title: 46px ExtraBold, line-height 51px
 * Padding: 60px 0 99px
 * Grid: 3 columns (358px cards), gap: space-between, row-gap: 93px
 * Serpentine flow:
 *   Row 1: ШАГ 1 (col 1), ШАГ 2 (col 2), ШАГ 3 (col 3)
 *   Row 2: ШАГ 6 (col 1), ШАГ 5 (col 2), ШАГ 4 (col 3)
 */

.stages-section {
  width: 100%;
  height: auto;
  min-height: auto;
  padding: 72px 0 90px;
  background-color: var(--color-white, #FFFFFF);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.stages-section__container {
  max-width: var(--sc-container-max, 1440px);
  margin: 0 auto;
  padding: 0 var(--space-77, 77px);
  box-sizing: border-box;
}

.stages-section__header {
  margin-bottom: 48px;
}

.stages-section__title {
  font-family: var(--font-cygre, 'Cygre', sans-serif);
  font-size: clamp(30px, 3.2vw, 42px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-black, #000000);
  margin: 0;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

/* 6-Card Serpentine Grid (3 columns, 2 rows, exact Figma gap: 81px) */
.stages-section__grid {
  display: grid;
  grid-template-columns: repeat(3, 358px);
  column-gap: 81px;
  row-gap: 93px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

/* Desktop Serpentine Positioning */
.stage-card:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.stage-card:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.stage-card:nth-child(3) {
  grid-column: 3;
  grid-row: 1;
}

.stage-card:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}

.stage-card:nth-child(5) {
  grid-column: 2;
  grid-row: 2;
}

.stage-card:nth-child(6) {
  grid-column: 1;
  grid-row: 2;
}

/* Individual Stage Card: strict flex-start to prevent badge stretching */
.stage-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  width: 358px;
  position: relative;
  box-sizing: border-box;
}

/* Step Badge: compact, solid white background, NO hover */
.stage-card__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  min-width: 96px;
  height: 38px;
  padding: 0 16px;
  border: 1.5px solid var(--color-primary, #FF5C00);
  border-radius: 999px;
  background-color: var(--color-white, #FFFFFF);
  position: relative;
  z-index: 2;
  font-family: var(--font-nt-somic, 'NT Somic', sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary, #FF5C00);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-sizing: border-box;
  cursor: default;
  transition: none;
}

/* Card Content Box: uniform height, calm background, NO hover jumps */
.stage-card__box {
  background-color: #FAFBFD;
  border: 1px solid #E5E7EB;
  border-radius: 16px;
  padding: 24px;
  width: 358px;
  min-height: 116px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: none;
  transition: none;
}

/* Typography inside card */
.stage-card__title {
  font-family: var(--font-cygre, 'Cygre', sans-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  color: #111827;
  margin: 0 0 6px 0;
}

.stage-card__desc {
  font-family: var(--font-inter, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: #6B7280;
  margin: 0;
}

/* Connector lines: exact geometry, zero overlap with badges */
.stage-card__connector {
  position: absolute;
  pointer-events: none;
  z-index: 1;
}

.stage-card__connector--right {
  left: 96px;
  top: 19px;
  width: 331px;
  height: 14px;
  transform: translateY(-50%);
}

.stage-card__connector--left {
  left: -331px;
  top: 19px;
  width: 331px;
  height: 14px;
  transform: translateY(-50%);
}

.stage-card__connector--loop {
  left: 96px;
  top: 19px;
  width: 330px;
  height: 280px;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
  .stages-section {
    height: auto;
    padding: 60px 0;
  }

  .stage-card__connector {
    display: none;
  }

  .stages-section__grid {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 24px;
    row-gap: 36px;
  }

  .stage-card,
  .stage-card__box {
    width: 100%;
  }

  /* Reset serpentine order for tablet */
  .stage-card:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
  }

  .stage-card:nth-child(n) .stage-card__box {
    height: auto;
    min-height: 100px;
  }
}

@media (max-width: 767px) {
  .stages-section {
    padding: 40px 0 60px;
  }

  .stages-section__container {
    padding: 0 20px;
  }

  .stages-section__header {
    margin-bottom: 36px;
  }

  .stages-section__title {
    font-size: 32px;
  }

  .stages-section__grid {
    grid-template-columns: 1fr;
    row-gap: 24px;
  }

  .stage-card__box {
    min-height: auto;
    padding: 20px;
  }

  .stage-card__title {
    font-size: 16px;
  }

  .stage-card__desc {
    font-size: 13px;
  }
}
