/* Process — chamaac/how-it-works visual adaptation (zig-zag cards + connectors) */
[data-section="process"] {
  position: relative;
}

/* Safety: if an old pin-spacer remains after hot reload, don't break flow */
[data-section="process"] .pin-spacer {
  display: contents !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
}

[data-section="process"] > h2 {
  margin-bottom: var(--space-6);
}

[data-hiw] {
  position: relative;
  margin: 0 0 var(--space-7);
  padding: clamp(1.1rem, 2vw, 1.5rem);
  border-radius: 1.4rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-hiw-rail] {
  position: absolute;
  left: 1.95rem;
  top: 2rem;
  bottom: 2rem;
  width: 2px;
  background: rgba(12, 15, 20, 0.12);
  border-radius: 1px;
  overflow: hidden;
}

[data-hiw-progress] {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, #f59e0b, #8b5cf6 55%, #3b82f6);
  transform-origin: top center;
}

[data-hiw-steps] {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(2.5rem, 8vh, 5rem);
}

[data-hiw-step] {
  position: relative;
  display: grid;
  grid-template-columns: 2.3rem 1fr;
  gap: 1rem;
  align-items: start;
  margin: 0;
  opacity: 0.46;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

[data-hiw-step][data-active="true"] {
  opacity: 1;
  transform: none;
}

/* Step accents — chamaac palette: orange / blue / purple */
[data-hiw-step]:nth-child(1),
[data-hiw-step]:nth-child(4) {
  --hiw-accent: #f59e0b;
  --hiw-accent-soft: rgba(245, 158, 11, 0.16);
}

[data-hiw-step]:nth-child(2),
[data-hiw-step]:nth-child(5) {
  --hiw-accent: #3b82f6;
  --hiw-accent-soft: rgba(59, 130, 246, 0.16);
}

[data-hiw-step]:nth-child(3) {
  --hiw-accent: #8b5cf6;
  --hiw-accent-soft: rgba(139, 92, 246, 0.16);
}

[data-hiw-node] {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--hiw-accent) 55%, #fff);
  background: #ffffff;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.1),
    0 0 0 3px var(--hiw-accent-soft);
}

[data-hiw-step][data-active="true"] [data-hiw-node] {
  border-color: var(--hiw-accent);
  background: color-mix(in srgb, var(--hiw-accent) 12%, #fff);
  transform: scale(1.04);
  box-shadow:
    0 12px 28px rgba(15, 23, 42, 0.12),
    0 0 0 4px var(--hiw-accent-soft);
}

[data-hiw-node] span {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  font-weight: 800;
  color: var(--hiw-accent);
}

/* Pin marker — desktop only, top-center like chamaac */
[data-hiw-card]::before {
  content: none;
}

[data-hiw-card] {
  position: relative;
  padding: 1.15rem 1rem 0.95rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  box-shadow:
    0 12px 24px rgba(15, 23, 42, 0.08),
    0 2px 8px rgba(15, 23, 42, 0.05);
  min-height: 5.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-2);
}

[data-hiw-step][data-active="true"] [data-hiw-card] {
  border-color: color-mix(in srgb, var(--hiw-accent) 35%, rgba(15, 23, 42, 0.1));
  box-shadow:
    0 18px 36px rgba(15, 23, 42, 0.12),
    0 4px 12px rgba(15, 23, 42, 0.08),
    0 0 0 1px var(--hiw-accent-soft);
}

[data-hiw-card] h3 {
  margin: 0;
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  font-weight: 600;
  color: #111827;
  line-height: 1.25;
}

[data-hiw-card] h3 span {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

/* Desktop: zig-zag layout close to chamaac visual */
@media (min-width: 960px) {
  [data-hiw] {
    min-height: 38rem;
    display: flex;
    align-items: center;
    padding: clamp(1.3rem, 2.2vw, 1.8rem);
  }

  [data-hiw-steps] {
    width: 100%;
    display: block;
    min-height: 32rem;
    position: relative;
  }

  [data-hiw-step] {
    position: absolute;
    grid-template-columns: 1fr;
    gap: 0.55rem;
    width: min(18rem, 21vw);
    opacity: 0.48;
    transform: translateY(16px) scale(0.96);
    z-index: 1;
  }

  [data-hiw-step][data-active="true"] {
    opacity: 1;
    transform: translateY(0) scale(1);
    z-index: 2;
  }

  [data-hiw-step]:nth-child(1) {
    left: 9%;
    top: 8%;
  }

  [data-hiw-step]:nth-child(2) {
    left: 52%;
    top: 15%;
  }

  [data-hiw-step]:nth-child(3) {
    left: 9%;
    top: 40%;
  }

  [data-hiw-step]:nth-child(4) {
    left: 52%;
    top: 48%;
  }

  [data-hiw-step]:nth-child(5) {
    left: 9%;
    top: 73%;
  }

  [data-hiw-node] {
    position: absolute;
    top: -0.72rem;
    left: 0.85rem;
    width: 2rem;
    height: 2rem;
    box-shadow:
      0 8px 18px rgba(15, 23, 42, 0.12),
      0 0 0 3px var(--hiw-accent-soft);
  }

  [data-hiw-card] {
    width: 100%;
    text-align: left;
    min-height: 5.4rem;
    padding: 1.35rem 1rem 1rem;
  }

  [data-hiw-card]::before {
    content: "";
    position: absolute;
    top: -0.32rem;
    left: 50%;
    width: 0.55rem;
    height: 0.55rem;
    margin-left: -0.28rem;
    border-radius: 2px 2px 2px 0;
    background: var(--hiw-accent);
    transform: rotate(45deg);
    box-shadow: 0 2px 8px var(--hiw-accent-soft);
    z-index: 2;
  }

  [data-hiw-card] h3 {
    color: #111827;
  }

  [data-hiw-step][data-active="true"] [data-hiw-node] span {
    color: var(--hiw-accent);
  }

  [data-hiw-step]:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 2.2rem;
    top: 0.15rem;
    width: 42%;
    border-top: 1px solid rgba(107, 114, 128, 0.35);
    transform-origin: left center;
    z-index: 0;
  }

  [data-hiw-step]:nth-child(1)::after,
  [data-hiw-step]:nth-child(3)::after {
    transform: rotate(21deg);
  }

  [data-hiw-step]:nth-child(2)::after,
  [data-hiw-step]:nth-child(4)::after {
    transform: rotate(160deg);
  }

  [data-hiw-rail] {
    display: none;
  }

  [data-hiw-progress] {
    display: none;
  }
}

/* Mobile / tablet: vertical zig-zag (chamaac-like), no side rail */
@media (max-width: 959px) {
  [data-hiw] {
    background: var(--bg-elevated);
    padding: 0.9rem 0.75rem 1.1rem;
    overflow: hidden;
  }

  [data-hiw-rail],
  [data-hiw-progress] {
    display: none;
  }

  [data-hiw-steps] {
    gap: clamp(1.35rem, 4.5vw, 1.85rem);
  }

  [data-hiw-step] {
    display: block;
    width: min(76%, 17.5rem);
    opacity: 1;
    transform: none;
    z-index: 1;
  }

  /* Left column: 01 / 03 / 05 */
  [data-hiw-step]:nth-child(odd) {
    align-self: flex-start;
    margin-right: auto;
  }

  /* Right column: 02 / 04 */
  [data-hiw-step]:nth-child(even) {
    align-self: flex-end;
    margin-left: auto;
  }

  [data-hiw-node] {
    position: absolute;
    top: -0.55rem;
    left: 0.7rem;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0;
    z-index: 3;
  }

  [data-hiw-node] span {
    font-size: 0.62rem;
  }

  [data-hiw-card] {
    min-height: 4.4rem;
    padding: 1.2rem 0.85rem 0.85rem;
  }

  [data-hiw-card]::before {
    content: "";
    position: absolute;
    top: -0.28rem;
    left: 50%;
    width: 0.48rem;
    height: 0.48rem;
    margin-left: -0.24rem;
    border-radius: 2px 2px 2px 0;
    background: var(--hiw-accent);
    transform: rotate(45deg);
    box-shadow: 0 2px 6px var(--hiw-accent-soft);
    z-index: 2;
  }

  [data-hiw-card] h3 {
    font-size: clamp(0.95rem, 3.6vw, 1.08rem);
  }

  /* Short connectors between zig-zag cards */
  [data-hiw-step]:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: -1.05rem;
    width: 28%;
    border-top: 1px dashed color-mix(in srgb, var(--hiw-accent) 45%, #9ca3af);
    z-index: 0;
  }

  [data-hiw-step]:nth-child(odd):not(:last-child)::after {
    left: 62%;
    transform: rotate(28deg);
    transform-origin: left center;
  }

  [data-hiw-step]:nth-child(even):not(:last-child)::after {
    right: 62%;
    left: auto;
    transform: rotate(-28deg);
    transform-origin: right center;
  }
}

/* Very narrow phones: slightly wider cards so long titles fit */
@media (max-width: 380px) {
  [data-hiw-step] {
    width: min(82%, 18rem);
  }

  [data-hiw-card] {
    padding: 1.15rem 0.75rem 0.8rem;
  }
}

[data-cta="process-start"] {
  color: var(--muted);
  margin-bottom: var(--space-4);
}

[data-cta="process-start"] a {
  color: var(--fg);
}

[data-section="process"] > p:last-of-type {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

@media (prefers-reduced-motion: reduce) {
  [data-hiw-step] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  [data-hiw-progress] {
    height: 100% !important;
    width: 100% !important;
  }
}
