/* ==========================================================================
   css/fx.css — capa de efectos visuales de Tyakxa
   (índice espiral, huecos de video, campo de partículas del hero y la
   escena "del caos al control").

   Se carga DESPUÉS de style.css y usa sus tokens de :root (--c-void,
   --c-green, --ease-out, …). Aquí no se redefine ningún token: si algún día
   cambia la paleta, se cambia en un solo lugar.

   Las reglas de "acomodo" que tocan elementos del agente de estructura van
   envueltas en :where() (especificidad 0) -- son valores por defecto que
   style.css puede sobrescribir sin pelear por especificidad.
   ========================================================================== */


/* ==========================================================================
   1. Hero — capas del fondo
   ========================================================================== */
:where(.hero__media) {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.hero__field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none; /* el cursor se lee desde window: el canvas nunca bloquea clics */
}


/* ==========================================================================
   2. Índice espiral (#spiralIndex)
   El isotipo como barra de progreso: trazo base tenue + trazo verde que se
   llena con el scroll. Una estación (punto) por sección sobre la espiral.
   ========================================================================== */
.spiral-index {
  position: fixed;
  z-index: 45;
  right: clamp(14px, 1.8vw, 30px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  pointer-events: none; /* solo sus controles reciben clic, no la caja completa */
}
.spiral-index__svg {
  display: block;
  width: 75px;
  height: 64px;
  overflow: visible;
  pointer-events: auto;
}
.spiral-index__base,
.spiral-index__fill {
  fill: none;
  stroke-width: 17.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.spiral-index__base {
  stroke: var(--c-navy-bright);
  stroke-opacity: .38;
  transition: stroke .4s var(--ease-out), stroke-opacity .4s var(--ease-out);
}
.spiral-index__fill {
  stroke: var(--c-green);
  transition: opacity .3s var(--ease-out);
}

/* Estaciones: marcas tenues sobre el trazo base; al pasar se vuelven una
   muesca oscura en el trazo verde; la activa se enciende en papel. */
.spiral-index__dot {
  fill: rgba(var(--c-paper-rgb), .3);
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition: fill .3s var(--ease-out), transform .35s var(--ease-out);
}
.spiral-index__dot.is-passed { fill: var(--c-void); }
.spiral-index__dot.is-active { fill: var(--c-paper); transform: scale(1.35); }
.spiral-index__dot.is-hover { fill: var(--c-green-glow); transform: scale(1.5); }

.spiral-index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.spiral-index__list li { margin: 0; padding: 0; }
.spiral-index__list a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 22px;
  padding: 3px 0 3px 10px;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-mute);
  text-decoration: none;
  pointer-events: auto;
  transition: color .3s var(--ease-out);
}
/* marca de regla a la derecha de cada código */
.spiral-index__list a::after {
  content: "";
  width: 10px;
  height: 1px;
  background: currentColor;
  opacity: .7;
  transition: width .35s var(--ease-out), background-color .3s var(--ease-out), opacity .3s;
}
.spiral-index__code { font-variant-numeric: tabular-nums; }

/* La etiqueta sale a la izquierda como un "tooltip" de HUD; mientras está
   oculta no ocupa espacio ni atrapa clics sobre el contenido de la página. */
.spiral-index__label {
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  transform: translate(6px, -50%);
  white-space: nowrap;
  padding: 5px 8px;
  border: 1px solid var(--c-line);
  border-radius: 3px;
  background: rgba(var(--c-void-rgb), .88);
  color: var(--c-paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease-out), transform .35s var(--ease-out);
}
.spiral-index:hover .spiral-index__label,
.spiral-index:focus-within .spiral-index__label {
  opacity: 1;
  transform: translate(0, -50%);
}
/* aparición escalonada, de afuera hacia el núcleo */
.spiral-index__list li:nth-child(2) .spiral-index__label { transition-delay: 25ms; }
.spiral-index__list li:nth-child(3) .spiral-index__label { transition-delay: 50ms; }
.spiral-index__list li:nth-child(4) .spiral-index__label { transition-delay: 75ms; }
.spiral-index__list li:nth-child(5) .spiral-index__label { transition-delay: 100ms; }
.spiral-index__list li:nth-child(6) .spiral-index__label { transition-delay: 125ms; }
.spiral-index__list li:nth-child(7) .spiral-index__label { transition-delay: 150ms; }
.spiral-index__list li:nth-child(8) .spiral-index__label { transition-delay: 175ms; }

.spiral-index__list a:hover { color: var(--c-paper); }
.spiral-index__list a:hover::after { width: 16px; opacity: 1; }
.spiral-index__list a[aria-current="true"] { color: var(--c-green-text); }
.spiral-index__list a[aria-current="true"]::after { width: 22px; background: var(--c-green); opacity: 1; }
.spiral-index__list a:focus-visible {
  outline: 2px solid var(--c-green);
  outline-offset: 2px;
  border-radius: 2px;
  color: var(--c-paper);
}

/* Sobre la sección clara (#origen, fondo papel) el índice cambia a navy. */
.spiral-index.is-on-light .spiral-index__base { stroke: var(--c-navy); stroke-opacity: .26; }
.spiral-index.is-on-light .spiral-index__dot { fill: rgba(var(--c-navy-rgb), .35); }
.spiral-index.is-on-light .spiral-index__dot.is-passed { fill: var(--c-paper); }
.spiral-index.is-on-light .spiral-index__dot.is-active { fill: var(--c-navy); }
.spiral-index.is-on-light .spiral-index__list a { color: rgba(var(--c-navy-rgb), .78); }
.spiral-index.is-on-light .spiral-index__list a:hover { color: var(--c-navy); }
/* verde oscurecido: el verde de marca sobre papel no llega a contraste AA */
.spiral-index.is-on-light .spiral-index__list a[aria-current="true"] { color: #00754A; }
.spiral-index.is-on-light .spiral-index__label {
  background: rgba(var(--c-paper-rgb), .95);
  border-color: rgba(var(--c-navy-rgb), .2);
  color: var(--c-navy);
}

@media (max-width: 899.98px) {
  .spiral-index { display: none; }
}


/* ==========================================================================
   3. Huecos de video / animación — [data-media-slot] (media-slots.js)
   ========================================================================== */

/* Huecos de contenido ("full"): proporción fija desde el primer pintado
   para que insertar el video (o el placeholder) nunca mueva el layout. */
:where([data-media-slot]:not([data-slot-mode="tag"])) {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--c-ink);
  isolation: isolate;
}
/* Huecos de fondo ("tag"): llenan su sección, debajo del arte. */
:where(.hero__media, .contacto__media, .caos__slot, [data-media-slot][data-slot-mode="tag"]) {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ---------- Video real ---------- */
.tyx-slot__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.tyx-slot--tag .tyx-slot__video { opacity: .35; }
.hero__media .tyx-slot__video { opacity: .35; filter: saturate(.75) contrast(1.05); }
.contacto__media .tyx-slot__video { opacity: .28; }

/* Reduced-motion: sin autoplay, poster + botón accesible */
.tyx-slot__play {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(var(--c-green-rgb), .6);
  border-radius: 50%;
  background: rgba(var(--c-void-rgb), .74);
  color: var(--c-paper);
  cursor: pointer;
  pointer-events: auto;
}
.tyx-slot__play:hover { border-color: var(--c-green); }
.tyx-slot__play:focus-visible { outline: 2px solid var(--c-green); outline-offset: 3px; }
.tyx-slot__play-icon {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-left: 11px solid currentColor;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}
.tyx-slot__play[aria-pressed="true"] .tyx-slot__play-icon {
  width: 10px;
  height: 12px;
  margin: 0;
  border: 0;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}

/* ---------- Placeholder de diseño (TYX_MOSTRAR_HUECOS = true) ----------
   Marco con marcas de corte verdes, rejilla fina que se desliza muy lento,
   una línea de escaneo y la etiqueta técnica del hueco. */
.tyx-slot__ph {
  position: absolute;
  inset: 0;
  overflow: hidden;
  container-type: inline-size;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--c-mute);
  pointer-events: none;
}
.tyx-slot__ph--full {
  background:
    radial-gradient(120% 90% at 80% 10%, rgba(var(--c-navy-rgb), .55), transparent 62%),
    radial-gradient(90% 80% at 8% 100%, rgba(var(--c-green-rgb), .07), transparent 60%),
    var(--c-ink);
}

/* La rejilla se mueve por transform en un pseudo-elemento (compositor, sin
   repintar); la máscara vive en el contenedor fijo para que el
   desvanecido de las orillas no se desplace con ella. */
.tyx-slot__grid {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: radial-gradient(ellipse 78% 72% at 50% 50%, #000 35%, transparent 100%);
  mask-image: radial-gradient(ellipse 78% 72% at 50% 50%, #000 35%, transparent 100%);
}
.tyx-slot__grid::before {
  content: "";
  position: absolute;
  top: -96px;
  left: -96px;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(var(--c-line-rgb), .13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-line-rgb), .13) 1px, transparent 1px),
    linear-gradient(rgba(var(--c-line-rgb), .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-line-rgb), .06) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
  animation: tyx-grid-drift 48s linear infinite;
  animation-play-state: paused;
  will-change: transform;
}
.tyx-slot.is-visible .tyx-slot__grid::before { animation-play-state: running; }
@keyframes tyx-grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(96px, 96px, 0); }
}

.tyx-slot__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(var(--c-green-rgb), .06) 80%, rgba(var(--c-green-rgb), .28) 100%);
  transform: translateY(-100%);
  animation: tyx-scan 7.5s var(--ease-inout) infinite;
  animation-play-state: paused;
}
.tyx-slot.is-visible .tyx-slot__scan { animation-play-state: running; }
@keyframes tyx-scan {
  0%        { transform: translateY(-100%); }
  72%, 100% { transform: translateY(360%); }
}

/* Mira central con el isotipo en miniatura */
.tyx-slot__reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(44px, 12cqi, 72px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
}
.tyx-slot__reticle::before,
.tyx-slot__reticle::after {
  content: "";
  position: absolute;
  background: linear-gradient(90deg, transparent, rgba(var(--c-green-rgb), .55), transparent);
}
.tyx-slot__reticle::before { left: -40%; right: -40%; top: 50%; height: 1px; }
.tyx-slot__reticle::after {
  top: -40%; bottom: -40%; left: 50%; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(var(--c-green-rgb), .55), transparent);
}
.tyx-slot__reticle-mark {
  position: absolute;
  inset: 26%;
  width: 48%;
  height: 48%;
  fill: none;
  stroke: rgba(var(--c-paper-rgb), .26);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Marcas de corte (crop marks) */
.tyx-slot__corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 0 solid var(--c-green);
  pointer-events: none;
}
.tyx-slot__corner--tl { top: 10px; left: 10px; border-top-width: 1.5px; border-left-width: 1.5px; }
.tyx-slot__corner--tr { top: 10px; right: 10px; border-top-width: 1.5px; border-right-width: 1.5px; }
.tyx-slot__corner--bl { bottom: 10px; left: 10px; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.tyx-slot__corner--br { bottom: 10px; right: 10px; border-bottom-width: 1.5px; border-right-width: 1.5px; }

/* Texto técnico: etiqueta arriba, specs + idea abajo, mira al centro */
.tyx-slot__meta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 22px 18px;
  font-size: 10.5px;
  font-size: clamp(9px, 2.1cqi, 11.5px);
  line-height: 1.5;
}
.tyx-slot__meta p,
.tyx-slot__tagbox p { margin: 0; }
.tyx-slot__tag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-green-text);
}
.tyx-slot__id { font-weight: 500; color: var(--c-paper); letter-spacing: .06em; text-transform: none; }
.tyx-slot__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-green-glow);
  box-shadow: 0 0 8px rgba(var(--c-green-rgb), .9);
  animation: tyx-blink 1.8s steps(2, jump-none) infinite;
}
.tyx-slot__chip {
  padding: 1px 6px;
  border: 1px solid rgba(var(--c-green-rgb), .4);
  border-radius: 2px;
  font-size: .88em;
  letter-spacing: .12em;
  color: var(--c-mute);
}
.tyx-slot__specs {
  margin-top: auto !important;
  color: rgba(var(--c-paper-rgb), .74);
  letter-spacing: .02em;
}
.tyx-slot__tag + .tyx-slot__idea { margin-top: auto !important; }
.tyx-slot__idea {
  margin-top: 4px !important;
  max-width: 68ch;
  color: var(--c-mute);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tyx-slot__idea-k { color: var(--c-green-text); letter-spacing: .12em; }
.tyx-slot__warn { margin-top: 4px !important; color: var(--c-sand); }

@container (max-width: 360px) {
  .tyx-slot__meta { padding: 14px 16px 12px; }
  .tyx-slot__idea { -webkit-line-clamp: 2; }
  .tyx-slot__chip { display: none; }
}

@keyframes tyx-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .25; }
}

/* ---------- Modo "tag" (huecos de fondo) ----------
   Solo esquinas + una etiqueta chica: el arte que va encima (partículas,
   formulario) se sigue viendo completo. */
.tyx-slot__ph--tag .tyx-slot__corner { width: 22px; height: 22px; opacity: .75; }
.tyx-slot__tagbox {
  position: absolute;
  right: clamp(16px, 3vw, 40px);
  bottom: clamp(16px, 3vw, 40px);
  max-width: min(360px, calc(100% - 32px));
  padding: 10px 12px 11px;
  border: 1px solid rgba(var(--c-green-rgb), .32);
  border-left: 2px solid var(--c-green);
  background: rgba(var(--c-void-rgb), .8);
  font-size: 10px;
  line-height: 1.5;
}
.tyx-slot__tagbox .tyx-slot__tag + .tyx-slot__idea,
.tyx-slot__tagbox .tyx-slot__specs,
.tyx-slot__tagbox .tyx-slot__idea { margin-top: 5px !important; }
.tyx-slot__tagbox .tyx-slot__idea { -webkit-line-clamp: 2; }

/* Posición de la etiqueta en cada fondo: fuera de las lecturas HUD del hero,
   del formulario del contacto y de la etiqueta de "datos de ejemplo". */
.hero__media .tyx-slot__ph--tag .tyx-slot__corner--tl,
.hero__media .tyx-slot__ph--tag .tyx-slot__corner--tr { top: 84px; }
.hero__media .tyx-slot__tagbox { bottom: auto; top: 96px; right: clamp(16px, 4vw, 56px); }
.caos__slot .tyx-slot__tagbox { top: 10px; right: 10px; bottom: auto; }
.caos__slot .tyx-slot__ph--tag .tyx-slot__corner { width: 16px; height: 16px; }
.contacto__media .tyx-slot__tagbox { top: 24px; bottom: auto; }

@media (max-width: 899.98px) {
  .hero__media .tyx-slot__tagbox { top: auto; bottom: 88px; left: 16px; right: 16px; max-width: none; }
  .tyx-slot__tagbox .tyx-slot__idea { display: none; }
}

/* ---------- Sin video y sin modo propuesta (producción) ---------- */
.tyx-slot__empty {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tyx-slot__empty--full {
  background:
    radial-gradient(120% 90% at 78% 12%, rgba(var(--c-navy-rgb), .5), transparent 60%),
    linear-gradient(160deg, var(--c-panel), var(--c-ink));
}
.tyx-slot__empty-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(var(--c-line-rgb), .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-line-rgb), .07) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse 70% 65% at 50% 50%, #000 20%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 65% at 50% 50%, #000 20%, transparent 100%);
}
.tyx-slot__empty-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18%;
  max-width: 96px;
  height: auto;
  transform: translate(-50%, -50%);
  fill: none;
  stroke: rgba(var(--c-paper-rgb), .09);
  stroke-width: 17.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tyx-slot__empty--tag {
  background: radial-gradient(80% 70% at 70% 40%, rgba(var(--c-navy-rgb), .22), transparent 70%);
}


/* ==========================================================================
   4. #caos — escena del caos al control (fx-caos-orden.js)
   ========================================================================== */
:where(.caos__viz) { position: relative; min-height: 18rem; }

.caos__frames {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.caos__grid {
  --k: 1;
  --u: 22px;
  position: absolute;
  inset: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--c-paper);
  pointer-events: none;
}
.caos__grid[hidden],
.caos__frames[hidden] { display: none !important; }

/* Las cifras del tablero son ilustrativas: se rotula siempre. Cuando el
   tablero queda armado, su propio encabezado ya dice "DATOS DE EJEMPLO". */
.caos__grid:not(:empty)::after {
  content: "DATOS DE EJEMPLO";
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 100;
  padding: 3px 7px;
  border: 1px solid rgba(var(--c-paper-rgb), .2);
  border-radius: 2px;
  background: rgba(var(--c-void-rgb), .82);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: .14em;
  color: var(--c-sand);
  transition: opacity .4s var(--ease-out);
}
.caos__grid.is-ordered::after { opacity: 0; }

/* Barrido de luz cuando el tablero termina de armarse ("todo en orden") */
.caos__grid::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(43, 227, 154, .08) 47%, rgba(43, 227, 154, .16) 50%, transparent 56%);
  background-size: 260% 100%;
  background-position: 130% 0;
  opacity: 0;
}
.caos__grid.is-ordered::before { animation: tyx-sweep 1.5s var(--ease-out) 1 both; }
@keyframes tyx-sweep {
  0%   { opacity: 1; background-position: 130% 0; }
  85%  { opacity: 1; }
  100% { opacity: 0; background-position: -40% 0; }
}

/* ---------- Pieza (contenedor que viaja) ---------- */
.caos-piece {
  position: absolute;
  transform-origin: 50% 50%;
  will-change: transform;
}
.caos-piece__order { position: absolute; inset: 0; opacity: 0; }
.caos-piece__chaos {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.caos-piece__chaos-in { transition: opacity .45s var(--ease-out); }
.caos-piece.is-dim .caos-piece__chaos-in { opacity: .34; }
.caos-piece.is-focus .cp {
  box-shadow:
    0 0 0 1px rgba(var(--c-green-rgb), .55),
    0 0 18px rgba(var(--c-green-rgb), .18),
    0 14px 30px rgba(31, 60, 89, .18);
}

/* ---------- Caras del caos: papel, Excel, WhatsApp ---------- */
.cp {
  position: relative;
  font-size: calc(11px * var(--k));
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(31, 60, 89, .18), 0 2px 4px rgba(31, 60, 89, .12);
}

/* Celda de hoja de cálculo (con el triángulo verde de "error" de Excel) */
.cp-cell {
  display: flex;
  align-items: stretch;
  background: var(--c-paper);
  color: var(--c-navy);
  border: 1px solid rgba(var(--c-navy-rgb), .3);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.cp-cell__ref {
  padding: .4em .55em;
  background: var(--c-sand);
  border-right: 1px solid rgba(var(--c-navy-rgb), .3);
  color: rgba(var(--c-navy-rgb), .75);
  font-size: .85em;
}
.cp-cell__v { position: relative; min-width: 6.4em; padding: .4em .75em; }
.cp-cell--wide .cp-cell__v { min-width: 8em; }
.cp-cell--err .cp-cell__v { font-weight: 500; }
.cp-cell--err .cp-cell__v::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  border-top: .6em solid var(--c-green);
  border-right: .6em solid transparent;
}

/* Ventana de Excel "FINAL_v2 (3).xlsx" */
.cp-sheet {
  width: calc(214px * var(--k));
  overflow: hidden;
  border: 1px solid rgba(var(--c-navy-rgb), .35);
  border-radius: 4px;
  background: var(--c-paper);
  color: var(--c-navy);
}
.cp-sheet__bar {
  padding: .4em .7em;
  background: var(--c-green);
  color: var(--c-void);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .85em;
  font-weight: 500;
}
.cp-sheet__grid {
  display: grid;
  grid-template-columns: 1.7em repeat(3, 1fr);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .86em;
}
.cp-sheet__c {
  padding: .32em .45em;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid rgba(var(--c-navy-rgb), .14);
  border-bottom: 1px solid rgba(var(--c-navy-rgb), .14);
}
.cp-sheet__c.is-head { background: var(--c-sand); color: rgba(var(--c-navy-rgb), .7); text-align: center; }
.cp-sheet__c.is-err { font-weight: 600; background: rgba(var(--c-green-rgb), .14); }

/* Mensajes de WhatsApp */
.cp-bubble {
  display: flex;
  align-items: flex-end;
  gap: .8em;
  max-width: calc(216px * var(--k));
  padding: .55em .75em .45em;
  border-radius: 8px 8px 8px 2px;
  background: #FFFFFF;
  color: var(--c-paper);
  font-size: calc(11.5px * var(--k));
  white-space: normal;
}
.cp-bubble--out { border-radius: 8px 8px 2px 8px; background: #D9FDD3; }
.cp-bubble__time {
  flex: none;
  font-size: .72em;
  color: rgba(var(--c-paper-rgb), .55);
  white-space: nowrap;
}
.cp-voice { align-items: center; }
.cp-voice__play {
  flex: none;
  width: 0;
  height: 0;
  border-left: .85em solid var(--c-paper);
  border-top: .5em solid transparent;
  border-bottom: .5em solid transparent;
}
.cp-voice__wave { display: flex; align-items: center; gap: 2px; }
.cp-voice__wave i { display: block; width: 2px; border-radius: 1px; background: rgba(var(--c-paper-rgb), .6); }

.cp-chat {
  display: flex;
  align-items: center;
  gap: .7em;
  min-width: calc(206px * var(--k));
  padding: .6em .8em;
  border-radius: 6px;
  background: #F3EFE8;
  color: var(--c-paper);
}
.cp-chat__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  background: var(--c-navy-bright);
  font-size: .8em;
  font-weight: 600;
}
.cp-chat__txt { display: flex; flex-direction: column; }
.cp-chat__txt small { font-size: .8em; color: var(--c-mute); }
.cp-chat__badge {
  margin-left: auto;
  padding: .1em .55em;
  border-radius: 999px;
  background: var(--c-green);
  color: var(--c-void);
  font-size: .75em;
  font-weight: 600;
}

/* Nota de libreta (renglones + margen + cinta) */
.cp-note {
  width: calc(172px * var(--k));
  padding: .55em .8em .75em 1.7em;
  border-radius: 1px;
  background:
    repeating-linear-gradient(180deg, transparent 0, transparent calc(1.45em - 1px), rgba(var(--c-navy-rgb), .22) calc(1.45em - 1px), rgba(var(--c-navy-rgb), .22) 1.45em),
    var(--c-paper);
  color: var(--c-navy);
  font-style: italic;
  line-height: 1.45em;
  white-space: normal;
}
.cp-note::before {
  content: "";
  position: absolute;
  left: 1.05em;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(var(--c-green-rgb), .5);
}
.cp-note::after {
  content: "";
  position: absolute;
  top: -.55em;
  left: 38%;
  width: 3.2em;
  height: 1.1em;
  background: rgba(217, 205, 188, .78);
  transform: rotate(-5deg);
}
.cp-note--title { font-style: normal; font-weight: 600; }
.cp-note--big { font-size: calc(14px * var(--k)); font-weight: 600; }

/* Factura / nota de remisión */
.cp-invoice {
  display: flex;
  flex-direction: column;
  gap: .3em;
  width: calc(176px * var(--k));
  padding: .8em .9em .9em;
  border-top: 3px solid var(--c-navy);
  background: var(--c-paper);
  color: var(--c-navy);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: calc(10px * var(--k));
  white-space: normal;
}
.cp-invoice--nota { border-top-color: var(--c-gray); background: var(--c-sand); }
.cp-invoice__title { font-weight: 600; letter-spacing: .06em; }
.cp-invoice__line { padding-bottom: .2em; border-bottom: 1px dashed rgba(var(--c-navy-rgb), .28); color: rgba(var(--c-navy-rgb), .75); }
.cp-invoice__total { font-size: 1.4em; font-weight: 600; }
.cp-invoice__stamp {
  position: absolute;
  right: .7em;
  bottom: .9em;
  padding: .15em .45em;
  border: 2px solid var(--c-navy-bright);
  color: var(--c-navy-bright);
  font-style: normal;
  font-weight: 600;
  letter-spacing: .08em;
  transform: rotate(-12deg);
  opacity: .85;
}

/* ---------- Caras del orden: el tablero ---------- */
.op {
  position: absolute;
  inset: 0;
  font-size: 10px;
  font-size: clamp(8px, calc(var(--u) * .46), 12.5px);
  line-height: 1.3;
  color: var(--c-paper);
}
.op-panel {
  overflow: hidden;
  padding: .8em 1em;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(var(--c-panel-rgb), .97), rgba(var(--c-ink-rgb), .97));
}
.op-panel__head {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .8em;
  letter-spacing: .12em;
  color: var(--c-mute);
  white-space: nowrap;
}
.op-panel__aside { color: var(--c-green-text); }

/* KPI */
.op-kpi { display: flex; flex-direction: column; justify-content: space-between; padding-left: 1.2em; }
.op-kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: .9em;
  bottom: .9em;
  width: 2px;
  background: var(--c-green);
}
.op-kpi__label,
.op-kpi__foot {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.op-kpi__label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .78em;
  letter-spacing: .12em;
  color: var(--c-mute);
}
.op-kpi__value {
  font-family: "Archivo", "IBM Plex Sans", sans-serif;
  font-stretch: 125%;
  font-weight: 700;
  font-size: 2.1em;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.op-kpi__value small {
  margin-left: .45em;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-stretch: 100%;
  font-size: .36em;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--c-mute);
}
.op-kpi__foot { font-size: .8em; color: var(--c-mute); }
.op-kpi--alert { border-color: rgba(217, 205, 188, .32); }
.op-kpi--alert::before { background: var(--c-sand); }
.op-kpi--alert .op-kpi__value { color: var(--c-sand); }

/* Gráfica: marco + barras (cada barra es su propia pieza) */
.op-chart__plot { position: absolute; left: 1em; right: 1em; top: 26%; bottom: 12%; }
.op-chart__line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed rgba(var(--c-line-rgb), .12);
}
.op-chart__line:nth-child(1) { top: 0; }
.op-chart__line:nth-child(2) { top: 33.33%; }
.op-chart__line:nth-child(3) { top: 66.66%; }
.op-chart__line:nth-child(4) { top: 100%; border-top-style: solid; }
.op-chart__meta {
  position: absolute;
  left: 0;
  right: 0;
  top: 16%;
  border-top: 1px dashed rgba(var(--c-green-rgb), .55);
}
.op-chart__meta em {
  position: absolute;
  right: 0;
  top: -1.5em;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .72em;
  font-style: normal;
  letter-spacing: .12em;
  color: var(--c-green-text);
}

.op-bar { display: flex; flex-direction: column; }
.op-bar__track { position: relative; flex: 1; }
.op-bar__fill {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 0;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, rgba(var(--c-green-rgb), .95), rgba(var(--c-green-rgb), .3));
  transform-origin: 50% 100%;
}
.op-bar--peak .op-bar__fill {
  background: linear-gradient(180deg, var(--c-green-glow), rgba(var(--c-green-rgb), .45));
  box-shadow: 0 0 14px rgba(43, 227, 154, .3);
}
.op-bar__day {
  padding-top: .4em;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .72em;
  letter-spacing: .06em;
  text-align: center;
  color: var(--c-mute);
}

/* Tabla de pedidos / inventario (filas pegadas = una sola tabla) */
.op-row {
  display: grid;
  grid-template-columns: .8fr 2fr 1fr 1.35fr;
  align-items: center;
  gap: 0 1em;
  padding: 0 1em;
  border: 1px solid var(--c-line);
  border-top: 0;
  background: rgba(var(--c-panel-rgb), .95);
  white-space: nowrap;
}
.op-row > span { overflow: hidden; text-overflow: ellipsis; }
.op-row--head {
  border-top: 1px solid var(--c-line);
  border-radius: 6px 6px 0 0;
  background: rgba(var(--c-panel-rgb), .98);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .76em;
  letter-spacing: .12em;
  color: var(--c-mute);
}
.op-row--last { border-radius: 0 0 6px 6px; }
.op-row__id { font-family: "IBM Plex Mono", ui-monospace, monospace; color: var(--c-green-text); }
.op-row__qty { font-family: "IBM Plex Mono", ui-monospace, monospace; color: rgba(var(--c-paper-rgb), .8); }
.op-row__st { text-align: right; }
.op-pill {
  display: inline-block;
  padding: .12em .65em;
  border: 1px solid;
  border-radius: 999px;
  font-size: .84em;
  line-height: 1.4;
}
.op-pill--prod { color: var(--c-green-text); border-color: rgba(var(--c-green-rgb), .5); background: rgba(var(--c-green-rgb), .12); }
.op-pill--env  { color: var(--c-navy-bright); border-color: rgba(47, 90, 132, .85); background: rgba(47, 90, 132, .25); }
.op-pill--aj   { color: var(--c-sand); border-color: rgba(217, 205, 188, .45); }
.op-pill--pri  { color: var(--c-void); border-color: var(--c-green); background: var(--c-green); }
.op-pill--fac  { color: var(--c-mute); border-color: rgba(var(--c-line-rgb), .3); }

.op-invhead { grid-template-columns: 1fr auto; }
.op-inv { grid-template-columns: 1.4fr 1.6fr .75fr; }
.op-inv__meter {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(var(--c-paper-rgb), .08);
}
.op-inv__meter i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: var(--c-green);
  transform-origin: 0 50%;
}
.op-inv__days { font-family: "IBM Plex Mono", ui-monospace, monospace; text-align: right; color: rgba(var(--c-paper-rgb), .8); }
.op-inv--crit .op-inv__meter i { background: var(--c-sand); }
.op-inv--crit .op-inv__days,
.op-inv--crit .op-inv__name { color: var(--c-sand); }

/* Encabezado del tablero */
.op-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 0 1em;
}
.op-header__brand { display: flex; align-items: center; gap: .6em; white-space: nowrap; min-width: 0; }
.op-header__mark {
  flex: none;
  width: 1.7em;
  height: 1.45em;
  fill: none;
  stroke: var(--c-green);
  stroke-width: 17.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.op-header__brand b {
  font-family: "Archivo", "IBM Plex Sans", sans-serif;
  font-stretch: 125%;
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: .08em;
}
.op-header__brand em {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-style: normal;
  font-size: .76em;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-mute);
}
.op-header__meta {
  display: flex;
  align-items: center;
  gap: 1em;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .74em;
  letter-spacing: .12em;
  color: var(--c-mute);
  white-space: nowrap;
}
.op-header__ex { padding: .15em .5em; border: 1px solid rgba(217, 205, 188, .4); border-radius: 2px; color: var(--c-sand); }
.op-header__live { display: flex; align-items: center; gap: .5em; color: var(--c-green-text); }
.op-header__live i {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: var(--c-green-glow);
  box-shadow: 0 0 8px var(--c-green-glow);
  animation: tyx-blink 1.8s ease-in-out infinite;
}

/* Al quedar en su lugar: destello breve del borde + la barra/medidor crece */
.caos-piece.is-placed .op-panel { animation: tyx-placed .9s var(--ease-out) both; }
.caos-piece.is-placed .op-bar__fill { animation: tyx-grow-y .7s var(--ease-out) both; }
.caos-piece.is-placed .op-inv__meter i { animation: tyx-grow-x .8s var(--ease-out) both; }
@keyframes tyx-placed {
  0%   { box-shadow: 0 0 0 1px rgba(var(--c-green-rgb), .75), 0 0 24px rgba(var(--c-green-rgb), .25); }
  100% { box-shadow: 0 0 0 0 rgba(var(--c-green-rgb), 0), 0 0 0 rgba(var(--c-green-rgb), 0); }
}
@keyframes tyx-grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes tyx-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Escenarios angostos: menos columnas, menos texto secundario */
.caos__grid.is-compact .op-row { grid-template-columns: .9fr 1fr 1.4fr; padding: 0 .7em; gap: 0 .6em; }
.caos__grid.is-compact .op-row .op-row__client { display: none; }
.caos__grid.is-compact .op-inv { grid-template-columns: 1.5fr 1fr .8fr; }
.caos__grid.is-compact .op-invhead { grid-template-columns: 1fr auto; }
.caos__grid.is-compact .op-kpi__foot,
.caos__grid.is-compact .op-header__week,
.caos__grid.is-compact .op-header__brand em { display: none; }
.caos__grid.is-compact .op-panel { padding: .55em .7em; }
.caos__grid.is-compact .op-kpi { padding-left: .9em; justify-content: center; gap: .3em; }
.caos__grid.is-tiny .op-header__live { display: none; }
.caos__grid.is-tiny .op-panel__aside { display: none; }

/* ---------- Pasos de texto: el activo resalta ----------
   Solo cuando el JS ya está corriendo ([data-progress]): sin JS los cuatro
   pasos se leen completos como lista normal. */
.caos__stage[data-progress] .caos__steps li {
  opacity: .3;
  transition: opacity .5s var(--ease-out), color .5s var(--ease-out);
}
.caos__stage[data-progress] .caos__steps li.is-current { opacity: 1; color: var(--c-paper); }
.caos__stage[data-progress] .caos__steps li.caos__step--final.is-current { color: var(--c-green-text); }


/* ==========================================================================
   5. Reduced motion: estado final estático, sin loops decorativos
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .tyx-slot__grid::before,
  .tyx-slot__dot,
  .op-header__live i,
  .caos-piece.is-placed .op-panel,
  .caos-piece.is-placed .op-bar__fill,
  .caos-piece.is-placed .op-inv__meter i,
  .caos__grid.is-ordered::before { animation: none !important; }
  .tyx-slot__scan { display: none; }
  .spiral-index *,
  .caos-piece__chaos-in,
  .caos__stage[data-progress] .caos__steps li { transition: none !important; }
}

