/* ==========================================================================
   Road Layout — S-Curve Road with Horizontal Rows
   ========================================================================== */

/* ---------- Road Rows ---------- */

.road-row {
  position: relative;
  margin-bottom: 0;
}

.road-segment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border-radius: 0;
  padding: var(--space-2xl) var(--space-md);
  position: relative;
  min-height: auto;
  box-shadow: none;
  gap: var(--space-md);
}

@media (min-width: 1025px) {
  .road-segment {
    gap: 0;
    padding: var(--space-2xl) var(--space-sm);
  }
}

/* Slim road bar — runs horizontally behind the PNGs.
   PNGs sit on top, "driving" along it. */
.road-segment::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 18px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #5a6a7a 0%, #4a5462 100%);
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 6px 16px rgba(0, 0, 0, 0.28);
  z-index: 0;
}

/* Dashed orange center line painted on the bar */
.road-segment::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 2%;
  right: 2%;
  height: 2px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(
    to right,
    var(--orange) 0px,
    var(--orange) 14px,
    transparent 14px,
    transparent 28px
  );
  opacity: 0.7;
  z-index: 1;
}

/* Row 2 flows left-to-right (4, 5, 6) — same direction as rows 1 and 3.
   Note: the road U-turn curves were drawn for an S-flow so they may read
   oddly with all three rows running the same direction. */
.road-row--2 .road-segment {
  flex-direction: row;
}

/* ---------- U-Turn Curves ---------- */

.road-curve {
  position: relative;
  height: 280px;
  width: 280px;
  /* Pull the curve into the rows above and below so it visually bridges
     them instead of sitting in a gap. The negative margins are tuned to
     overlap the road bar that runs through the middle of each row. */
  margin-top: -48px;
  margin-bottom: -48px;
  z-index: 1;
}

.road-curve--right {
  margin-left: auto;
  margin-right: 0;
}

.road-curve--left {
  margin-right: auto;
  margin-left: 0;
}

.road-curve svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.road-curve__path {
  fill: none;
  stroke: #5a6a7a;
  stroke-width: 18;
  stroke-linecap: round;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.28));
}

.road-curve__center {
  fill: none;
  stroke: var(--orange);
  stroke-width: 3;
  stroke-dasharray: 16 16;
  opacity: 0.8;
}

/* ---------- START / FINISH Markers ---------- */

.road-marker {
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.road-marker--finish {
  justify-content: flex-end;
  margin-top: var(--space-md);
  margin-bottom: 0;
}

/* ---------- Hide Old Vertical Line Pseudo-elements ---------- */

.journey__container::before,
.journey__container::after {
  display: none;
}

/* ---------- Phase Labels (above road rows) ---------- */

.phase {
  margin-bottom: var(--space-xs);
  margin-top: var(--space-sm);
}

.phase:first-of-type {
  margin-top: 0;
}

.phase__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  text-align: center;
}

.phase__number {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.phase__title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--white);
}

/* ---------- Journey Opener — Welcome Pulse Ring ---------- */

/* A one-shot ring that expands outward from Step 1's node when the journey
   first enters the viewport. Communicates "the journey just arrived." */
.step__welcome-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--orange);
  pointer-events: none;
  opacity: 0;
  transform: scale(1);
  z-index: 1;
}

.step__welcome-ring--firing {
  animation: welcomeRingExpand 1400ms var(--ease-smooth) forwards;
}

@keyframes welcomeRingExpand {
  0%   { opacity: 0.7; transform: scale(0.8); }
  60%  { opacity: 0.35; transform: scale(2.2); }
  100% { opacity: 0; transform: scale(3); }
}

/* Shimmer sweep across road row 1 — sets the road "alight" left-to-right */
.road-row--shimmer {
  position: relative;
  overflow: hidden;
}

.road-row--shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -30%;
  width: 30%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(250, 173, 98, 0.18) 45%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(250, 173, 98, 0.18) 55%,
    transparent 100%
  );
  pointer-events: none;
  animation: roadShimmerSweep 1400ms var(--ease-smooth) forwards;
  z-index: 2;
  border-radius: 50px;
}

@keyframes roadShimmerSweep {
  0%   { transform: translateX(0); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateX(450%); opacity: 0; }
}

/* Hide shimmer on mobile (vertical timeline has no road row backgrounds) */
@media (max-width: 767px) {
  .road-row--shimmer::after { display: none; }
}

/* ---------- Reduced Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .road-segment {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }
  .step__welcome-ring--firing,
  .road-row--shimmer::after {
    animation: none;
    display: none;
  }
}

/* ---------- Tablet ---------- */

@media (max-width: 1024px) and (min-width: 768px) {
  .road-segment {
    padding: var(--space-xl) var(--space-sm);
    gap: var(--space-xs);
  }

  /* Stale rule reset — the road bar now spans the full width, not inset */
  .road-segment::before {
    left: 0;
    right: 0;
  }
  .road-segment::after {
    left: 2%;
    right: 2%;
  }

  .road-curve {
    height: 240px;
    width: 240px;
    margin-top: -40px;
    margin-bottom: -40px;
  }
}

/* ---------- Mobile: Vertical Timeline ---------- */

@media (max-width: 767px) {
  .road-row {
    margin-bottom: 0;
  }

  .road-segment {
    flex-direction: column !important;
    background: transparent;
    border-radius: 0;
    padding: 0;
    min-height: auto;
    box-shadow: none;
    gap: 0;
  }

  /* Hide dashed center line on mobile */
  .road-segment::before {
    display: none;
  }

  /* Hide U-turn curves on mobile */
  .road-curve {
    display: none;
  }

  .journey__container {
    position: relative;
  }

  /* Vertical road bridge between stacked steps —
     connects each PNG visually so the journey reads as one road. */
  .step {
    position: relative;
  }

  .step:not(:first-child) {
    padding-top: 56px;
  }

  /* Asphalt strip in the gap above each step (after the first). */
  .step:not(:first-child)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 92px;
    height: 56px;
    background:
      radial-gradient(rgba(0, 0, 0, 0.18) 0.8px, transparent 1.6px) 0 0 / 7px 7px,
      radial-gradient(rgba(255, 255, 255, 0.04) 0.8px, transparent 1.6px) 3px 3px / 11px 11px,
      linear-gradient(180deg, #627283 0%, #4c5b6a 100%);
    box-shadow:
      inset 1px 0 0 rgba(255, 255, 255, 0.08),
      inset -1px 0 0 rgba(255, 255, 255, 0.08),
      0 4px 12px rgba(0, 0, 0, 0.18);
    z-index: 0;
  }

  /* Marching orange center dashes — same DNA as desktop, rotated to vertical. */
  .step:not(:first-child)::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 56px;
    background: repeating-linear-gradient(
      to bottom,
      var(--orange) 0px,
      var(--orange) 10px,
      transparent 10px,
      transparent 20px
    );
    animation: roadMarchVertical 2.4s linear infinite;
    box-shadow: 0 0 8px rgba(250, 173, 98, 0.45);
    z-index: 1;
  }

  @keyframes roadMarchVertical {
    from { background-position: 0 0; }
    to   { background-position: 0 30px; }
  }

  /* Step labels — large and prominent on mobile */
  .phase {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
  }

  .phase__label {
    align-items: flex-start;
    text-align: left;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(180deg, #2f3c48 0%, #435464 100%);
    border: 2px solid var(--orange);
    border-radius: var(--radius-lg);
    box-shadow:
      inset 0 0 0 3px rgba(15, 22, 30, 0.6),
      inset 0 0 0 4px rgba(250, 173, 98, 0.55),
      0 8px 18px rgba(0, 0, 0, 0.4);
  }

  .phase__title {
    font-size: 1.6rem;
  }

  .phase__number {
    font-size: 0.9rem;
    letter-spacing: 0.15em;
  }

  /* Road markers on mobile */
  .road-marker {
    font-size: 0.8rem;
  }

  .road-marker--finish {
    justify-content: flex-start;
  }
}

@media (max-width: 479px) {
  .journey__container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  .step:not(:first-child) {
    padding-top: 44px;
  }

  .step:not(:first-child)::before {
    width: 76px;
    height: 44px;
  }

  .step:not(:first-child)::after {
    height: 44px;
  }

  .phase__title {
    font-size: 1.4rem;
  }

  .phase__number {
    font-size: 0.85rem;
  }
}
