/* =========================================================================
   06 · Cómo trabajamos (.s-trabajamos, #como-trabajamos)
   Estructura de la lámina 05 de PuenteOS-2026: línea horizontal con 4 nodos
   circulares (ícono de línea), pastilla mono de quién lo hace sobre cada
   nodo, tarjetas oscuras alineadas debajo con mini visual al pie.
   Al entrar (.is-in, una vez): la línea se dibuja, los nodos se encienden en
   cascada y las tarjetas suben. Mientras se ve (.is-live): pulsos que viajan
   de nodo en nodo, onda de audio, lista que elige, piezas que se encienden.
   Desktop ≥1100: 4 columnas. Tablet y mobile: línea vertical a la izquierda.
   ========================================================================= */

.s-trabajamos {
  --tw-gap: clamp(14px, 1.5vw, 22px);
  --tw-node: 60px;
  --tw-who-h: 26px;
  --tw-who-gap: 16px;
  --tw-line: rgba(201, 189, 230, 0.32);
  --tw-period: 6s;              /* ciclo completo de los pulsos */
  --tw-step: 1.2s;              /* de un nodo al siguiente */
  --tw-viz-h: 132px;            /* cabe la lista de 4 procesos con su rótulo */
  --tw-io: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Resplandor violeta tenue al pie, como el fondo de la lámina */
.s-trabajamos::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 70%;
  background: radial-gradient(60% 90% at 45% 100%, rgba(78, 66, 170, 0.22), rgba(29, 26, 92, 0) 70%);
  pointer-events: none;
  z-index: -1;
}

/* ---------- Cabecera ---------- */
.s-trabajamos .tw-head {
  display: grid;
  gap: clamp(16px, 1.8vw, 24px);
  margin-bottom: clamp(44px, 5.5vw, 76px);
}
.s-trabajamos .tw-head .eyebrow { margin: 0; }
.s-trabajamos .tw-title { max-width: 21em; }

/* ---------- Pasos (desktop: 4 columnas) ---------- */
.s-trabajamos .tw-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--tw-gap);
}
.s-trabajamos .tw-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  --tw-t: calc(var(--i) * 600ms);           /* cuándo se enciende el nodo */
  --tw-pd: calc(var(--i) * var(--tw-step)); /* fase del pulso */
}

/* Pastilla de quién lo hace */
.s-trabajamos .tw-who {
  margin: 0;
  display: inline-flex;
  align-items: center;
  height: var(--tw-who-h);
  padding: 0 11px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.6s var(--ease) var(--tw-t), transform 0.6s var(--ease) var(--tw-t);
}
.s-trabajamos .tw-who--celeste { color: var(--celeste); background: rgba(179, 225, 239, 0.07); box-shadow: inset 0 0 0 1px rgba(179, 225, 239, 0.3); }
.s-trabajamos .tw-who--lila { color: var(--lila-claro); background: rgba(169, 155, 216, 0.12); box-shadow: inset 0 0 0 1px rgba(169, 155, 216, 0.38); }
.s-trabajamos .tw-who--white { color: #fff; background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5); }

/* Nodo circular */
.s-trabajamos .tw-node {
  position: relative;
  z-index: 1;
  margin-top: var(--tw-who-gap);
  width: var(--tw-node);
  height: var(--tw-node);
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1c1b20;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26), 0 0 28px -6px rgba(107, 95, 184, 0.65);
  transition: box-shadow 0.7s var(--ease) var(--tw-t), color 0.7s var(--ease) var(--tw-t), background 0.7s var(--ease) var(--tw-t);
}
.s-trabajamos .tw-node svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Anillo que se expande cuando llega el pulso */
.s-trabajamos .tw-node::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(201, 189, 230, 0.7);
  opacity: 0;
}

/* Segmento de línea hasta el nodo siguiente, con chevron al final */
.s-trabajamos .tw-seg {
  position: absolute;
  top: calc(var(--tw-who-h) + var(--tw-who-gap) + var(--tw-node) / 2);
  left: calc(var(--tw-node) + 10px);
  right: calc(-1 * var(--tw-gap) + 14px);
  height: 1px;
  pointer-events: none;
}
.s-trabajamos .tw-seg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tw-line);
  transform-origin: left center;
  transition: transform 0.6s var(--tw-io) calc(var(--tw-t) + 120ms);
}
.s-trabajamos .tw-seg--tail { right: 0; }
.s-trabajamos .tw-seg--tail::before {
  background: linear-gradient(90deg, var(--tw-line), rgba(201, 189, 230, 0));
}
.s-trabajamos .tw-seg__chev {
  position: absolute;
  right: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px rgba(201, 189, 230, 0.45);
  transition: opacity 0.3s linear calc(var(--tw-t) + 600ms);
}
.s-trabajamos .tw-seg__chev::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6.5px;
  width: 4px;
  height: 4px;
  border-top: 1.3px solid rgba(255, 255, 255, 0.85);
  border-right: 1.3px solid rgba(255, 255, 255, 0.85);
  transform: rotate(45deg);
}
/* Pulso que viaja por el segmento */
.s-trabajamos .tw-seg::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 56px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(201, 189, 230, 0), #fff);
  box-shadow: 0 0 10px rgba(201, 189, 230, 0.8);
  opacity: 0;
}

/* ---------- Tarjeta ---------- */
.s-trabajamos .tw-card {
  position: relative;
  flex: 1;
  align-self: stretch;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: clamp(22px, 2vw, 28px);
  background: linear-gradient(180deg, #211f20, #1c1b1c);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -36px rgba(0, 0, 0, 0.7);
  transition:
    opacity 0.8s var(--ease) calc(var(--i) * 120ms + 200ms),
    transform 0.8s var(--ease) calc(var(--i) * 120ms + 200ms),
    box-shadow 0.35s var(--ease);
}
.s-trabajamos .tw-card:hover { box-shadow: inset 0 0 0 1px var(--line-2), 0 30px 60px -30px rgba(0, 0, 0, 0.8); }
/* Brillo del borde cuando el pulso llega a su nodo */
.s-trabajamos .tw-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(201, 189, 230, 0.32);
  opacity: 0;
  pointer-events: none;
}

.s-trabajamos .tw-card__text { display: grid; gap: 10px; align-content: start; }
.s-trabajamos .tw-card__num {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.s-trabajamos .tw-card__title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(24px, 2vw, 30px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.s-trabajamos .tw-card__desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.66);
  text-wrap: pretty;
}

/* ---------- Mini visuales (al pie, con hairline arriba) ---------- */
.s-trabajamos .tw-viz {
  margin-top: auto;
  height: var(--tw-viz-h);
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}
.s-trabajamos .tw-viz ul { list-style: none; margin: 0; padding: 0; }
.s-trabajamos .tw-viz p { margin: 0; }
.s-trabajamos .tw-viz__tag {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px !important;
}

/* 01 · Onda de audio */
.s-trabajamos .tw-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 44px;
}
.s-trabajamos .tw-wave i {
  flex: 1 1 0;
  max-width: 4px;
  min-width: 2px;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(179, 225, 239, 0.95), rgba(169, 155, 216, 0.6));
  transform-origin: bottom;
  transform: scaleY(var(--h));
}
.s-trabajamos .tw-rec {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px !important;
  letter-spacing: 0.06em;
  color: var(--celeste);
}
.s-trabajamos .tw-rec__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--celeste);
  box-shadow: 0 0 0 3px rgba(179, 225, 239, 0.16);
}

/* 02 · Lista que elige */
.s-trabajamos .tw-list {
  position: relative;
  display: grid;
  --row: 20px;
  grid-auto-rows: var(--row);
  gap: 2px;
}
.s-trabajamos .tw-list__hl {
  position: absolute;
  left: -8px;
  right: -8px;
  top: 0;
  height: var(--row);
  border-radius: 6px;
  background: rgba(169, 155, 216, 0.16);
  box-shadow: inset 0 0 0 1px rgba(169, 155, 216, 0.35);
  transform: translateY(calc(var(--hl, 1) * (var(--row) + 2px)));
  transition: transform 0.45s var(--ease), background 0.3s var(--ease);
}
.s-trabajamos .tw-list[data-row="0"] { --hl: 0; }
.s-trabajamos .tw-list[data-row="1"] { --hl: 1; }
.s-trabajamos .tw-list[data-row="2"] { --hl: 2; }
.s-trabajamos .tw-list[data-row="3"] { --hl: 3; }
.s-trabajamos .tw-list__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
  transition: color 0.3s var(--ease);
}
.s-trabajamos .tw-box {
  position: relative;
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.s-trabajamos .tw-box::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1.5px;
  width: 3px;
  height: 6px;
  border-right: 1.5px solid #0e0d0c;
  border-bottom: 1.5px solid #0e0d0c;
  transform: rotate(45deg) scale(0);
  transition: transform 0.3s var(--ease);
}
.s-trabajamos .tw-list[data-chosen="true"] .tw-list__hl { background: rgba(169, 155, 216, 0.26); }
.s-trabajamos .tw-list[data-chosen="true"] .tw-list__row--pick { color: #fff; }
.s-trabajamos .tw-list[data-chosen="true"] .tw-list__row--pick .tw-box { background: #fff; box-shadow: none; }
.s-trabajamos .tw-list[data-chosen="true"] .tw-list__row--pick .tw-box::after { transform: rotate(45deg) scale(1); }

/* 03 · Las cuatro piezas que se encienden */
.s-trabajamos .tw-build {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.s-trabajamos .tw-build li {
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: color 0.4s var(--ease), background 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.s-trabajamos .tw-build[data-lit="1"] li:nth-child(-n+1),
.s-trabajamos .tw-build[data-lit="2"] li:nth-child(-n+2),
.s-trabajamos .tw-build[data-lit="3"] li:nth-child(-n+3),
.s-trabajamos .tw-build[data-lit="4"] li {
  color: #fff;
  background: rgba(169, 155, 216, 0.14);
  box-shadow: inset 0 0 0 1px rgba(201, 189, 230, 0.45), 0 0 18px -6px rgba(107, 95, 184, 0.8);
}

/* 04 · Sistemas en vivo */
.s-trabajamos .tw-live {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.s-trabajamos .tw-live li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  color: #fff;
  background: rgba(62, 207, 142, 0.06);
  box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.3);
}
.s-trabajamos .tw-live__dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.s-trabajamos .tw-live__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ok);
  opacity: 0;
}

/* ---------- Pie ---------- */
.s-trabajamos .tw-foot {
  margin: clamp(28px, 3.2vw, 44px) 0 0;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--celeste);
}
.s-trabajamos .tw-foot__arrow { font-size: 18px; letter-spacing: 0; line-height: 1; color: rgba(255, 255, 255, 0.7); }

/* =========================================================================
   Estados de animación (solo con JS: .tw-js en la sección)
   ========================================================================= */
/* Antes de entrar */
.s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-who { opacity: 0; transform: translateY(6px); }
.s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-node {
  background: var(--bg-2);
  color: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0 0 0 rgba(107, 95, 184, 0);
}
.s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-seg::before { transform: scaleX(0); }
.s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-seg__chev { opacity: 0; }
.s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-card { opacity: 0; transform: translateY(26px); }

/* Mientras se ve: pulsos y mini visuales (pausados fuera de pantalla) */
.s-trabajamos.tw-js .tw-seg::after {
  animation: tw-pulse-x var(--tw-period) linear calc(var(--tw-pd) + 0.15s) infinite both;
  animation-play-state: paused;
}
.s-trabajamos.tw-js .tw-node::after {
  animation: tw-ping var(--tw-period) var(--ease) var(--tw-pd) infinite both;
  animation-play-state: paused;
}
.s-trabajamos.tw-js .tw-card::after {
  animation: tw-glow var(--tw-period) var(--ease) var(--tw-pd) infinite both;
  animation-play-state: paused;
}
.s-trabajamos.tw-js .tw-wave i {
  animation: tw-wave 1.15s ease-in-out calc(var(--i) * -0.137s) infinite alternate;
  animation-play-state: paused;
}
.s-trabajamos.tw-js .tw-wave i:nth-child(3n) { animation-duration: 0.9s; }
.s-trabajamos.tw-js .tw-wave i:nth-child(4n+1) { animation-duration: 1.4s; }
.s-trabajamos.tw-js .tw-rec__dot { animation: tw-blink 1.6s steps(1, end) infinite; animation-play-state: paused; }
.s-trabajamos.tw-js .tw-live__dot::after {
  animation: tw-dot 2.4s var(--ease) calc(var(--p) * 0.5s) infinite;
  animation-play-state: paused;
}
.s-trabajamos.tw-js.is-live .tw-steps.is-in .tw-seg::after,
.s-trabajamos.tw-js.is-live .tw-steps.is-in .tw-node::after,
.s-trabajamos.tw-js.is-live .tw-steps.is-in .tw-card::after,
.s-trabajamos.tw-js.is-live .tw-wave i,
.s-trabajamos.tw-js.is-live .tw-rec__dot,
.s-trabajamos.tw-js.is-live .tw-live__dot::after { animation-play-state: running; }

@keyframes tw-pulse-x {
  0% { left: 0; opacity: 0; }
  3% { opacity: 1; }
  15% { opacity: 1; }
  17.5% { left: calc(100% - 56px); opacity: 0; }
  100% { left: calc(100% - 56px); opacity: 0; }
}
@keyframes tw-pulse-y {
  0% { top: 0; opacity: 0; }
  3% { opacity: 1; }
  15% { opacity: 1; }
  17.5% { top: calc(100% - 44px); opacity: 0; }
  100% { top: calc(100% - 44px); opacity: 0; }
}
@keyframes tw-ping {
  0% { transform: scale(1); opacity: 0; }
  2% { transform: scale(1); opacity: 0.85; }
  14% { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes tw-glow {
  0% { opacity: 0; }
  5% { opacity: 1; }
  22% { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes tw-wave {
  from { transform: scaleY(var(--h)); }
  to { transform: scaleY(calc(var(--h) * 0.3 + 0.08)); }
}
@keyframes tw-blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0.25; }
}
@keyframes tw-dot {
  0% { transform: scale(1); opacity: 0.6; }
  60%, 100% { transform: scale(3); opacity: 0; }
}

/* =========================================================================
   Tablet y mobile: línea vertical a la izquierda, tarjetas a lo ancho
   ========================================================================= */
@media (max-width: 1099px) {
  .s-trabajamos { --tw-row-gap: 28px; --tw-col: var(--tw-node); }
  .s-trabajamos .tw-steps {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--tw-row-gap);
  }
  .s-trabajamos .tw-step {
    display: grid;
    grid-template-columns: var(--tw-col) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: clamp(14px, 2.4vw, 24px);
    align-items: start;
  }
  .s-trabajamos .tw-node { grid-column: 1; grid-row: 1 / span 2; margin-top: 0; }
  .s-trabajamos .tw-who {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    margin-top: calc((var(--tw-node) - var(--tw-who-h)) / 2);
  }
  .s-trabajamos .tw-card {
    grid-column: 2;
    grid-row: 2;
    margin-top: 16px;
    flex-direction: row;
    align-items: stretch;
    gap: 28px;
  }
  .s-trabajamos .tw-card__text { flex: 1 1 auto; min-width: 0; }
  .s-trabajamos .tw-viz {
    flex: 0 0 260px;
    height: auto;
    min-height: var(--tw-viz-h);
    margin-top: 0;
    padding: 0 0 0 28px;
    border-top: 0;
    border-left: 1px solid var(--line);
    justify-content: center;
  }

  /* El segmento baja desde el nodo hasta el nodo del paso siguiente */
  .s-trabajamos .tw-seg {
    top: calc(var(--tw-node) + 10px);
    bottom: calc(-1 * var(--tw-row-gap) + 14px);
    left: calc(var(--tw-node) / 2);
    right: auto;
    width: 1px;
    height: auto;
  }
  .s-trabajamos .tw-seg::before { transform-origin: center top; }
  .s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-seg::before { transform: scaleY(0); }
  .s-trabajamos .tw-seg--tail { display: none; }
  .s-trabajamos .tw-seg__chev { right: auto; left: -9px; top: auto; bottom: -9px; transform: rotate(90deg); }
  .s-trabajamos .tw-seg::after {
    top: 0;
    left: -1px;
    width: 3px;
    height: 44px;
    background: linear-gradient(180deg, rgba(201, 189, 230, 0), #fff);
  }
  .s-trabajamos.tw-js .tw-seg::after { animation-name: tw-pulse-y; }
}

@media (max-width: 767px) {
  .s-trabajamos { --tw-node: 46px; --tw-row-gap: 24px; }
  .s-trabajamos .tw-node svg { width: 18px; height: 18px; }
  .s-trabajamos .tw-step { column-gap: 14px; }
  .s-trabajamos .tw-card {
    flex-direction: column;
    gap: 22px;
    padding: 20px;
  }
  .s-trabajamos .tw-viz {
    flex: none;
    min-height: 0;
    padding: 16px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .s-trabajamos .tw-viz--build .tw-build li,
  .s-trabajamos .tw-live li { font-size: 11.5px; }
  .s-trabajamos .tw-card__title { font-size: 24px; }
  .s-trabajamos .tw-foot { align-items: flex-start; font-size: 11px; letter-spacing: 0.08em; line-height: 1.6; }
}

/* ---------- Movimiento reducido: estado final, quieto ---------- */
@media (prefers-reduced-motion: reduce) {
  .s-trabajamos .tw-who,
  .s-trabajamos .tw-node,
  .s-trabajamos .tw-seg::before,
  .s-trabajamos .tw-seg__chev,
  .s-trabajamos .tw-card,
  .s-trabajamos .tw-list__hl,
  .s-trabajamos .tw-build li { transition: none !important; }
  .s-trabajamos .tw-seg::after,
  .s-trabajamos .tw-node::after,
  .s-trabajamos .tw-card::after,
  .s-trabajamos .tw-wave i,
  .s-trabajamos .tw-rec__dot,
  .s-trabajamos .tw-live__dot::after { animation: none !important; }
  .s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-who,
  .s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-card { opacity: 1; transform: none; }
  .s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-seg::before { transform: none; }
  .s-trabajamos.tw-js .tw-steps:not(.is-in) .tw-seg__chev { opacity: 1; }
}
