/* ==========================================================================
   COMO TRABAJAMOS V3 — Arquetipo E (diagrama vivo)
   Fusion de #diferenciacion + #metodo. Trazo SVG transformador con 4
   estaciones; la explicacion vive en zona fija (no tooltip). Mobile: trazo
   vertical + acordeon. Reduced-motion: trazo estatico, todo visible.
   ========================================================================== */

.ctv3 {
  --ct-obsidian: #080a0c;
  --ct-graphite: #15191d;
  --ct-titanium: #aeb5ba;
  --ct-champagne: #c8ad83;
  --ct-ivory: #f2f0eb;
  --ct-muted: #858b90;
  --ct-line: rgba(174, 181, 186, 0.16);
  --ct-green: #5fd08a;
  --ct-green-bright: #6fe39a;
  --ct-red: #e0645a;
  --ct-red-bright: #f07a6e;
  --ct-font-display: "Manrope", "Inter", system-ui, sans-serif;
  --ct-font-body: "Inter", system-ui, sans-serif;
  --ct-font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ct-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ct-dur: 320ms;
  --ctv-progress: 10.8;

  position: relative;
  background: var(--ct-obsidian);
  color: var(--ct-ivory);
  padding-block: clamp(4rem, 8vw, 7rem);
  overflow: hidden;
}

/* ---------- Fondo: lineas topograficas (CSS motion art) ------------------ */

.ctv3__topo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background:
    repeating-radial-gradient(circle at 18% 30%, transparent 0 46px, rgba(174, 181, 186, 0.05) 46px 47px),
    repeating-radial-gradient(circle at 82% 70%, transparent 0 60px, rgba(200, 173, 131, 0.04) 60px 61px);
  animation: ctv3-topo 40s linear infinite alternate;
}

@keyframes ctv3-topo {
  from { background-position: 0 0, 0 0; }
  to { background-position: 120px 60px, -100px -40px; }
}

.ctv3__head {
  position: relative;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.ctv3__eyebrow {
  margin: 0 0 1.25rem;
  font-family: var(--ct-font-mono);
  font-size: clamp(0.75rem, 0.9vw, 0.875rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ct-champagne);
}

.ctv3__eyebrow span { color: var(--ct-muted); margin-right: 0.75em; }

.ctv3__title {
  margin: 0;
  font-family: var(--ct-font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* ---------- Escenario: trazo + estaciones + zona fija -------------------- */

.ctv3__stage {
  position: relative;
}

/* En escritorio manda el grafico grande; el compacto es solo movil. */
.ctv3__mobile-chart { display: none; }

.ctv3__svg {
  display: block;
  width: 100%;
  height: clamp(140px, 22vh, 220px);
}

.ctv3__svg .trazo-base { stroke: var(--ct-green); fill: none; opacity: 0.3; }
.ctv3__svg .trazo-progress {
  stroke: var(--ct-green-bright);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--ctv-progress));
  transition: stroke-dashoffset var(--motion-cinema) var(--ease-out);
  filter: drop-shadow(0 0 6px rgba(95, 208, 138, 0.5));
}

/* Grafico: rejilla, area y flecha de direccion. */
.ctv3__chart-grid {
  stroke: rgba(174, 181, 186, 0.12);
  stroke-width: 1;
  fill: none;
}

.ctv3__chart-area { stroke: none; }

.ctv3__chart-arrow {
  stroke: var(--ct-green);
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}

/* C.3 — Entrada: el trazo se dibuja y las estaciones aparecen despues, en
   stagger. Solo opacidad: la posicion absoluta de cada estacion no se toca. */
.ctv3.is-armed .ctv3__station {
  opacity: 0;
  transition: opacity var(--motion-slow) var(--ease-out);
}

/* Antes de entrar, el trazo se posiciona en 0 sin animar: al entrar se
   dibuja de una sola vez con --motion-cinema. */
.ctv3.is-armed:not(.is-entered) .ctv3__svg .trazo-progress {
  transition: none;
}

.ctv3.is-armed.is-entered .ctv3__station {
  opacity: 1;
}

.ctv3.is-armed.is-entered .ctv3__station-wrap:nth-child(2) .ctv3__station { transition-delay: 120ms; }
.ctv3.is-armed.is-entered .ctv3__station-wrap:nth-child(3) .ctv3__station { transition-delay: 240ms; }
.ctv3.is-armed.is-entered .ctv3__station-wrap:nth-child(4) .ctv3__station { transition-delay: 360ms; }

/* Estaciones (tabs en desktop) */
.ctv3__stations {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: clamp(140px, 22vh, 220px);
}

.ctv3__station-wrap { position: static; }

.ctv3__station {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  background: none;
  border: 0;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--ct-titanium);
  font-family: var(--ct-font-mono);
}

/* Las estaciones se apoyan sobre la curva ascendente. Solo escritorio:
   en movil el acordeon es flujo normal y estos top lo desplazarian. */
@media (min-width: 901px) {
  .ctv3__stations > .ctv3__station-wrap:nth-child(1) .ctv3__station { left: 12.5%; top: 80%; }
  .ctv3__stations > .ctv3__station-wrap:nth-child(2) .ctv3__station { left: 37.5%; top: 60%; }
  .ctv3__stations > .ctv3__station-wrap:nth-child(3) .ctv3__station { left: 62.5%; top: 40%; }
  .ctv3__stations > .ctv3__station-wrap:nth-child(4) .ctv3__station { left: 87.5%; top: 20%; }
}

.ctv3__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ct-titanium);
  background: var(--ct-obsidian);
  transition: border-color var(--ct-dur) var(--ct-ease), background-color var(--ct-dur) var(--ct-ease), box-shadow var(--ct-dur) var(--ct-ease);
}

.ctv3__station-label {
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ctv3__station-num { font-size: 0.6875rem; color: var(--ct-muted); letter-spacing: 0.2em; }

.ctv3__station[aria-expanded="true"] { color: var(--ct-ivory); }
.ctv3__station[aria-expanded="true"] .ctv3__dot {
  border-color: var(--ct-green-bright);
  background: var(--ct-green-bright);
  box-shadow: 0 0 0 5px rgba(95, 208, 138, 0.16), 0 0 18px rgba(95, 208, 138, 0.45);
}
.ctv3__station:hover .ctv3__dot { border-color: var(--ct-green-bright); }
.ctv3__station:focus-visible { outline: 2px solid var(--ct-champagne); outline-offset: 4px; border-radius: 6px; }

/* Zona fija de explicacion (desktop): los paneles se superponen aqui. */
.ctv3__explain {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + clamp(1.5rem, 3vh, 2.5rem));
  display: none;
  max-width: 70ch;
  margin-inline: auto;
  background: var(--ct-graphite);
  border: 1px solid var(--ct-line);
  border-radius: 8px;
  padding: clamp(1.5rem, 3vw, 2.25rem);
}

.ctv3__explain.is-active { display: block; }

.ctv3__explain h3 {
  margin: 0 0 0.75rem;
  font-family: var(--ct-font-display);
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 700;
  color: var(--ct-champagne);
}

.ctv3__explain p {
  margin: 0;
  font-family: var(--ct-font-body);
  font-size: clamp(0.9375rem, 1.1vw, 1.0625rem);
  line-height: 1.6;
  color: var(--ct-titanium);
}

/* Reserva de altura para la zona fija (evita salto al cambiar estacion). */
.ctv3__stage { padding-bottom: clamp(13rem, 28vh, 18rem); }

/* ---------- Mobile: trazo vertical + acordeon ---------------------------- */

@media (max-width: 900px) {
  .ctv3__stage .ctv3__svg { display: none; }

  /* Grafico compacto: la misma subida, como sintesis sobre el acordeon. */
  .ctv3__mobile-chart {
    position: relative;
    display: block;
    margin: 0 0 1.75rem;
  }

  .ctv3__svg--mobile { height: clamp(112px, 30vw, 148px); }

  .ctv3__mobile-points {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .ctv3__mobile-point {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: var(--ct-obsidian);
    border: 2px solid rgba(95, 208, 138, 0.55);
    transition: border-color var(--ct-dur) var(--ct-ease), background-color var(--ct-dur) var(--ct-ease), box-shadow var(--ct-dur) var(--ct-ease);
  }

  .ctv3__mobile-point:nth-child(1) { left: 12.5%; top: 80%; }
  .ctv3__mobile-point:nth-child(2) { left: 37.5%; top: 60%; }
  .ctv3__mobile-point:nth-child(3) { left: 62.5%; top: 40%; }
  .ctv3__mobile-point:nth-child(4) { left: 87.5%; top: 20%; }

  .ctv3__mobile-point.is-active {
    border-color: var(--ct-green-bright);
    background: var(--ct-green-bright);
    box-shadow: 0 0 0 5px rgba(95, 208, 138, 0.16), 0 0 18px rgba(95, 208, 138, 0.45);
  }

  .ctv3__stations {
    position: relative;
    inset: auto;
    display: grid;
    gap: 0;
    /* La altura de escritorio (clamp 140-220px) es solo para la superposicion
       absoluta. En vertical el contenedor debe medir su contenido; si no,
       overflow:hidden del .ctv3 recorta las estaciones 02-04. */
    height: auto;
    padding-left: 1.25rem;
    border-left: 1px solid rgba(95, 208, 138, 0.28);
  }

  .ctv3__station-wrap { position: relative; }

  .ctv3__station {
    position: relative;
    top: auto;
    left: auto !important;
    transform: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    padding: 0.9rem 0;
  }

  .ctv3__station::before {
    content: "";
    position: absolute;
    left: -1.25rem;
    top: 50%;
    width: 9px;
    height: 9px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--ct-obsidian);
    border: 2px solid var(--ct-titanium);
  }

  .ctv3__station[aria-expanded="true"]::before { border-color: var(--ct-green-bright); background: var(--ct-green-bright); }

  .ctv3__dot { display: none; }

  .ctv3__explain {
    position: static;
    display: none;
    max-width: none;
    margin: 0 0 1rem;
    background: transparent;
    border: 0;
    border-left: 1px solid var(--ct-line);
    border-radius: 0;
    padding: 0 0 0.5rem 1.25rem;
  }

  .ctv3__explain.is-active { display: block; }

  .ctv3__stage { padding-bottom: 0; }
}

/* ---------- Reduced motion: trazo estatico, todo visible ----------------- */

@media (prefers-reduced-motion: reduce) {
  .ctv3__topo { animation: none; }
  .ctv3__stage .ctv3__svg .trazo-progress { transition: none; stroke-dashoffset: 0; }
  .ctv3__svg--cost .trazo-progress { transition: none; }
  .ctv3__mobile-chart .trazo-progress { transition: none; }
  .ctv3__dot, .ctv3__mobile-point, .ctv3__station::before, .ctv3__cost-point, .ctv3__cost-item { transition: none; }
}

/* Estado estatico (reduced motion o sin JS): todas las explicaciones visibles. */
.ctv3.is-static .ctv3__svg .trazo-progress { stroke-dashoffset: 0; }
.ctv3.is-static .ctv3__explain { display: block; position: static; max-width: none; margin: 0 0 1.25rem; }
.ctv3.is-static .ctv3__stage { padding-bottom: 0; }
.ctv3.is-static .ctv3__stations { position: relative; display: grid; gap: 0.5rem; height: auto; }
.ctv3.is-static .ctv3__station { position: static; transform: none; display: flex; gap: 0.75rem; align-items: center; }

/* ---------- Lead, ventaja, cierre y costo (auditoria editorial) ---------- */

.ctv3__lead {
  margin: 1.25rem 0 0;
  max-width: 58ch;
  font-family: var(--ct-font-body);
  font-size: clamp(1rem, 1.2vw, 1.125rem);
  line-height: 1.6;
  color: var(--ct-titanium);
}

.ctv3__adv {
  display: block;
  margin-top: 0.75rem;
  font-family: var(--ct-font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ct-champagne);
}

.ctv3__close {
  margin-top: clamp(2rem, 4vw, 3rem);
  text-align: center;
  font-family: var(--ct-font-display);
  font-weight: 700;
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ct-ivory);
  text-wrap: balance;
}

.ctv3__cost {
  margin-top: clamp(3rem, 6vw, 5rem);
  border-top: 1px solid var(--ct-line);
  padding-top: clamp(2rem, 4vw, 3rem);
}

.ctv3__cost-head { max-width: 64ch; }

.ctv3__cost-title {
  margin: 0;
  font-family: var(--ct-font-display);
  font-weight: 700;
  font-size: clamp(1.375rem, 2.6vw, 2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--ct-ivory);
  text-wrap: balance;
}

.ctv3__cost-sub {
  margin: 0.85rem 0 0;
  font-family: var(--ct-font-body);
  font-size: clamp(0.9375rem, 1.1vw, 1.0625rem);
  line-height: 1.6;
  color: var(--ct-titanium);
}

.ctv3__cost-grid {
  margin: clamp(1.75rem, 3vw, 2.5rem) 0 0;
  display: grid;
  gap: 1px;
  /* Cuatro columnas alineadas con los cuatro puntos del grafico. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--ct-line);
  border: 1px solid var(--ct-line);
  border-radius: 8px;
  overflow: hidden;
}

/* Tablet: 2x2 para no dejar una cuarta tarjeta sola. */
@media (max-width: 900px) {
  .ctv3__cost-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .ctv3__cost-grid { grid-template-columns: 1fr; }
}

.ctv3__cost-item {
  background: var(--ct-obsidian);
  padding: clamp(1.25rem, 2vw, 1.75rem);
  transition: background-color var(--ct-dur) var(--ct-ease), box-shadow var(--ct-dur) var(--ct-ease);
}

.ctv3__cost-item.is-active {
  background: rgba(224, 100, 90, 0.06);
  box-shadow: inset 0 0 0 1px rgba(224, 100, 90, 0.16);
}

.ctv3__cost-item dt { margin: 0; }

.ctv3__cost-tab {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  font-family: var(--ct-font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ct-ivory);
  text-align: left;
  cursor: pointer;
}

.ctv3__cost-tab:focus-visible {
  outline: 2px solid var(--ct-red-bright);
  outline-offset: 4px;
  border-radius: 4px;
}

.ctv3__cost-num { color: rgba(224, 100, 90, 0.72); }
.ctv3__cost-item.is-active .ctv3__cost-num { color: var(--ct-red-bright); }

.ctv3__cost-item dd { margin: 0.85rem 0 0; }

.ctv3__cost-lead {
  display: block;
  font-family: var(--ct-font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ct-ivory);
}

.ctv3__cost-formula {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--ct-font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ct-muted);
}

.ctv3__cost-note {
  margin: 1.25rem 0 0;
  font-family: var(--ct-font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ct-muted);
}

/* ---------- Grafico descendente del costo ------------------------------- */

.ctv3__cost-chart {
  position: relative;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
}

.ctv3__svg--cost { height: clamp(120px, 16vh, 170px); }

.ctv3__svg--cost .trazo-base { stroke: var(--ct-red); opacity: 0.32; }

.ctv3__svg--cost .trazo-progress {
  stroke: var(--ct-red-bright);
  stroke-dashoffset: calc(100 - var(--ctv-cost-progress, 10.8));
  filter: drop-shadow(0 0 6px rgba(224, 100, 90, 0.5));
}

.ctv3__svg--cost .ctv3__chart-arrow { stroke: var(--ct-red); }

.ctv3__cost.is-armed:not(.is-entered) .ctv3__svg--cost .trazo-progress { transition: none; }

.ctv3__cost-points {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ctv3__cost-point {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--ct-obsidian);
  border: 2px solid rgba(224, 100, 90, 0.55);
  transition: border-color var(--ct-dur) var(--ct-ease), background-color var(--ct-dur) var(--ct-ease), box-shadow var(--ct-dur) var(--ct-ease);
}

.ctv3__cost-point:nth-child(1) { left: 12.5%; top: 20%; }
.ctv3__cost-point:nth-child(2) { left: 37.5%; top: 40%; }
.ctv3__cost-point:nth-child(3) { left: 62.5%; top: 60%; }
.ctv3__cost-point:nth-child(4) { left: 87.5%; top: 80%; }

.ctv3__cost-point.is-active {
  border-color: var(--ct-red-bright);
  background: var(--ct-red-bright);
  box-shadow: 0 0 0 5px rgba(240, 122, 110, 0.16), 0 0 18px rgba(240, 122, 110, 0.5);
}
