/* ============================================================================
   M-CTRL — Hoja de estilos
   Los colores, tipografías y espaciados se definen una sola vez, abajo, en
   :root. Cambiando ahí un valor cambia todo el sitio de forma coherente.
   ========================================================================== */

:root {
  /* Paleta de marca */
  --ink:        #16181A;   /* texto principal */
  --charcoal:   #343434;   /* carbón del logotipo */
  --graphite:   #5A6066;   /* texto secundario */
  --cyan:       #05CAF7;   /* acento de marca */
  --cyan-deep:  #026F8C;   /* acento sobre fondo claro, con contraste AA */
  --paper:      #F4F6F7;   /* fondo claro, frío */
  --white:      #FFFFFF;
  --line:       #D7DDE1;   /* filetes y bordes */
  --line-dark:  #4A4A4A;   /* filetes sobre fondo oscuro */

  /* Tipografía */
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Escala tipográfica */
  --fs-hero:  clamp(2.6rem, 7vw, 5.2rem);
  --fs-h1:    clamp(2rem, 4.6vw, 3.2rem);
  --fs-h2:    clamp(1.45rem, 2.6vw, 2rem);
  --fs-h3:    1.15rem;
  --fs-body:  1.0625rem;
  --fs-small: 0.9375rem;
  --fs-mono:  0.75rem;

  /* Ritmo vertical y medidas */
  --gap:       1.25rem;
  --section-y: clamp(4rem, 9vw, 7.5rem);
  --wrap:      1180px;
  --wrap-text: 62ch;
  --radius:    3px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--cyan-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--cyan-deep);
  outline-offset: 3px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; max-width: var(--wrap-text); }

/* --- Utilidades ----------------------------------------------------------- */
.wrap {
  width: min(100% - 2.5rem, var(--wrap));
  margin-inline: auto;
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--white);
  padding: 0.75rem 1.25rem; z-index: 999;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* Etiqueta monoespaciada: el vocabulario del oficio (tags, direcciones) */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.eyebrow::before {
  content: "";
  width: 1.75rem; height: 2px;
  background: var(--cyan);
  flex: none;
}
.on-dark .eyebrow { color: #A8B0B6; }

.section { padding-block: var(--section-y); }
.section--dark { background: var(--charcoal); color: var(--paper); }
.section--dark h2, .section--dark h3 { color: var(--white); }
.section--dark p { color: #C6CCD1; }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4rem); }

.lede {
  font-size: clamp(1.1rem, 1.7vw, 1.3rem);
  color: var(--graphite);
  max-width: 58ch;
}
.section--dark .lede { color: #C6CCD1; }

/* --- Botones -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.9rem 1.5rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--white);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn:hover { background: var(--cyan-deep); border-color: var(--cyan-deep); color: var(--white); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--white); border-color: var(--ink); }
.on-dark .btn--ghost, .section--dark .btn--ghost { color: var(--white); border-color: #6E7479; }
.on-dark .btn--ghost:hover, .section--dark .btn--ghost:hover { background: var(--cyan); border-color: var(--cyan); color: var(--ink); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 2rem; }

/* --- Cabecera ------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(244, 246, 247, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; padding-block: 0.85rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: inherit; }
.brand img { width: 38px; height: 38px; border-radius: 6px; }
.brand__name {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
  line-height: 1;
}
.brand__claim {
  font-family: var(--font-mono);
  font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--graphite); line-height: 1.4;
}

.nav { display: flex; align-items: center; gap: 0.35rem; }
.nav a {
  font-family: var(--font-mono);
  font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--graphite); text-decoration: none;
  padding: 0.55rem 0.8rem; border-radius: var(--radius);
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}
.nav a:hover { color: var(--ink); background: rgba(0,0,0,0.04); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--cyan); }

.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.5rem 0.7rem;
  cursor: pointer; font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
}

@media (max-width: 800px) {
  .nav-toggle { display: block; }
  .brand__claim { display: none; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 1.25rem 1.25rem;
  }
  .nav[hidden] { display: none; }
  .nav a { padding: 0.85rem 0.5rem; border-bottom: 1px solid var(--line); }
}

/* --- Portada -------------------------------------------------------------- */
.hero {
  background: var(--charcoal);
  color: var(--paper);
  padding-block: clamp(3.5rem, 8vw, 6.5rem) clamp(3rem, 6vw, 5rem);
  position: relative;
  overflow: hidden;
}
/* Retícula tenue, como un plano de armario eléctrico */
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
}
.hero > * { position: relative; }

.hero h1 {
  font-size: var(--fs-hero);
  color: var(--white);
  max-width: 16ch;
  margin-bottom: 1.5rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--cyan);
}
.hero__lede {
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  color: #C6CCD1;
  max-width: 54ch;
}

/* Signature: escaneo de bus de campo */
.bus {
  margin-top: clamp(2.5rem, 5vw, 4rem);
  border-top: 1px solid var(--line-dark);
  padding-top: 1.5rem;
}
.bus__label {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.18em; text-transform: uppercase;
  color: #8A9298;
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 1.1rem;
}
.bus__label .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(5, 202, 247, 0.6);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(5,202,247,0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(5,202,247,0); }
  100% { box-shadow: 0 0 0 0 rgba(5,202,247,0); }
}
.bus__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 1px;
}
.node {
  background: var(--charcoal);
  box-shadow: 0 0 0 1px var(--line-dark);
  padding: 0.9rem 1rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.js-anim .node {
  opacity: 0;
  transform: translateY(6px);
  animation: node-online 0.5s var(--ease) forwards;
}
@keyframes node-online {
  to { opacity: 1; transform: none; }
}
.node__top { display: flex; align-items: center; gap: 0.5rem; }
.node__led {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan); flex: none;
}
.node__name {
  font-family: var(--font-display);
  font-weight: 600; font-size: 0.95rem; color: var(--white);
  letter-spacing: -0.01em;
}
.node__detail {
  font-family: var(--font-mono);
  font-size: 0.6875rem; color: #8A9298; letter-spacing: 0.02em;
}
.node__group {
  font-family: var(--font-mono);
  font-size: 0.625rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: #6E7479;
}

/* --- Rejilla de servicios ------------------------------------------------- */
.grid {
  display: grid;
  gap: 1px;
  margin-top: 2.5rem;
}
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card {
  background: var(--white);
  box-shadow: 0 0 0 1px var(--line);
  padding: 1.75rem 1.6rem;
  display: flex; flex-direction: column;
}
.card__tag {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.16em;
  color: var(--cyan-deep);
  margin-bottom: 0.9rem;
}
.card h3 { font-size: var(--fs-h3); margin-bottom: 0.6rem; }
.card p { font-size: var(--fs-small); color: var(--graphite); margin: 0; }
.card ul {
  margin: 1rem 0 0; padding-left: 1.1rem;
  font-size: var(--fs-small); color: var(--graphite);
}
.card li { margin-bottom: 0.4rem; }

/* --- Proyectos ------------------------------------------------------------ */
.project {
  background: var(--white);
  border: 1px solid var(--line);
  padding: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: clamp(1.5rem, 3vw, 3rem);
}
@media (max-width: 760px) { .project { grid-template-columns: 1fr; } }

.project__meta { border-left: 2px solid var(--cyan); padding-left: 1.1rem; }
.project__meta dl { margin: 0; display: grid; gap: 0.7rem; }
.project__meta dt {
  font-family: var(--font-mono);
  font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--graphite);
}
.project__meta dd { margin: 0.1rem 0 0; font-size: var(--fs-small); }
.project h3 { font-size: var(--fs-h2); margin-bottom: 1rem; }
.project h4 {
  font-family: var(--font-mono);
  font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--graphite); font-weight: 500;
  margin: 1.4rem 0 0.5rem;
}
.project ul { margin: 0; padding-left: 1.1rem; color: var(--graphite); font-size: var(--fs-small); }
.project li { margin-bottom: 0.35rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.6875rem; letter-spacing: 0.06em;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.2rem 0.5rem; color: var(--graphite);
}

/* --- Proceso (secuencia real, por eso va numerado) ------------------------ */
.steps { counter-reset: step; margin-top: 2.5rem; display: grid; gap: 0; }
.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line-dark);
}
.step:last-child { border-bottom: 1px solid var(--line-dark); }
.step::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.8125rem; color: var(--cyan); letter-spacing: 0.1em;
  padding-top: 0.2rem;
}
.step h3 { font-size: var(--fs-h3); margin-bottom: 0.35rem; }
.step p { margin: 0; font-size: var(--fs-small); }

/* --- Contacto ------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  margin-top: 2.5rem;
}
@media (max-width: 820px) { .contact-grid { grid-template-columns: 1fr; } }

.contact-list { margin: 0; display: grid; gap: 1.4rem; }
.contact-list dt {
  font-family: var(--font-mono);
  font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--graphite); margin-bottom: 0.25rem;
}
.contact-list dd { margin: 0; font-size: 1.0625rem; }
.contact-list a { color: var(--ink); }
.contact-list a:hover { color: var(--cyan-deep); }

.field { margin-bottom: 1.15rem; }
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--graphite); margin-bottom: 0.45rem;
}
.field input, .field textarea, .field select {
  width: 100%;
  font-family: var(--font-body); font-size: var(--fs-body);
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); color: var(--ink);
  transition: border-color 0.16s var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--cyan-deep); outline: none;
  box-shadow: 0 0 0 3px rgba(5, 202, 247, 0.18);
}
.field textarea { min-height: 150px; resize: vertical; }

.form-status {
  margin-top: 1rem; padding: 0.9rem 1.1rem;
  border-radius: var(--radius); font-size: var(--fs-small);
  border-left: 3px solid var(--cyan-deep);
  background: rgba(5, 202, 247, 0.09);
}
.form-status[data-state="error"] {
  border-left-color: #C0392B; background: rgba(192, 57, 43, 0.08);
}
.form-status[hidden] { display: none; }

/* Trampa antispam: oculta para personas, visible para bots */
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* --- Pie ------------------------------------------------------------------ */
.site-footer {
  background: var(--ink); color: #9BA3A9;
  padding-block: 3rem 2rem;
  font-size: var(--fs-small);
}
.site-footer a { color: #C6CCD1; }
.site-footer a:hover { color: var(--cyan); }
.site-footer__top {
  display: flex; flex-wrap: wrap; gap: 2rem;
  justify-content: space-between; align-items: flex-start;
  padding-bottom: 2rem; border-bottom: 1px solid #2E3336;
}
.site-footer__nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.site-footer__nav a {
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
}
.site-footer__bottom {
  padding-top: 1.5rem; display: flex; flex-wrap: wrap;
  gap: 1rem; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.6875rem;
  letter-spacing: 0.08em; color: #6E7479;
}

/* --- Aparición al hacer scroll -------------------------------------------- */
/* Por defecto todo es visible. La animación solo se activa si el script añade
   la clase .js-anim al <html>, de modo que sin JavaScript, al imprimir o si
   algo falla, el contenido nunca queda oculto. */
.js-anim .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.js-anim .reveal.is-visible { opacity: 1; transform: none; }

@media print {
  .reveal, .js-anim .reveal { opacity: 1 !important; transform: none !important; }
  .node { opacity: 1 !important; transform: none !important; animation: none !important; }
  .site-header { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .js-anim .reveal { opacity: 1; transform: none; }
  .node, .js-anim .node { opacity: 1; transform: none; animation: none; }
}

/* ============================================================================
   GRÁFICOS DE FONDO
   Ilustraciones vectoriales animadas. Son decorativas: nunca deben competir
   con el texto, por eso van a baja opacidad y detrás del contenido.
   Para atenuarlas o realzarlas, cambia --art-opacity.
   ========================================================================== */

:root { --art-opacity: 0.5; }

.art-holder {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  opacity: var(--art-opacity);
}
.art { width: 100%; height: 100%; display: block; overflow: visible; }

/* Colocación en la portada: abajo a la derecha, por debajo del texto */
.hero .art-holder {
  top: 14%; right: -2%;
  width: min(38vw, 500px);
}
@media (max-width: 1150px) { .hero .art-holder { opacity: calc(var(--art-opacity) * 0.5); width: 32vw; top: 10%; } }
@media (max-width: 980px)  { .hero .art-holder { display: none; } }

/* Colocación en secciones: pegada al borde derecho, completa dentro del encuadre */
.section .art-holder {
  top: 50%; right: 1.5rem;
  width: min(34vw, 400px);
  transform: translateY(-50%);
}
@media (max-width: 1000px) { .section .art-holder { display: none; } }

.section, .hero { position: relative; }
.section > .wrap, .hero > .wrap { position: relative; z-index: 1; }

/* --- Trazos comunes ------------------------------------------------------- */
.art-rail-outer { stroke: #7C858C; stroke-width: 2; fill: none; }
.art-rail-inner { stroke: #5C656C; stroke-width: 1; fill: none; stroke-dasharray: 3 6; }
.art-floor      { stroke: #7C858C; stroke-width: 2; }
.art-fixture    { stroke: #6E7780; stroke-width: 1.5; fill: none; }
.art-body       { stroke: #9AA3AA; stroke-width: 2; fill: none; }
.art-joint      { stroke: var(--cyan); stroke-width: 2; fill: none; }
.art-tool       { stroke: var(--cyan); stroke-width: 2; fill: none; }
.art-part       { stroke: var(--cyan); stroke-width: 2; fill: none; }
.art-station    { stroke: #6E7780; stroke-width: 1.5; fill: none; }
.art-nodes      { stroke: #7C858C; stroke-width: 1.5; fill: none; }

/* Sobre fondo claro los trazos se oscurecen para conservar el contraste */
.section:not(.section--dark) .art-rail-outer,
.section:not(.section--dark) .art-floor,
.section:not(.section--dark) .art-body,
.section:not(.section--dark) .art-nodes { stroke: #B4BDC4; }
.section:not(.section--dark) .art-rail-inner,
.section:not(.section--dark) .art-fixture,
.section:not(.section--dark) .art-station { stroke: #C6CDD3; }

/* --- XTS: movers circulando por la vía ------------------------------------ */
/* Las bobinas del estator son una línea discontinua fija sobre la vía. */
.art-coils {
  stroke: #5C656C; stroke-width: 10; fill: none;
  stroke-dasharray: 2 16; opacity: 0.55;
}
/* Los movers son segmentos cortos que recorren la misma trayectoria. */
.art-movers {
  stroke: var(--cyan); stroke-width: 11; fill: none;
  stroke-linecap: butt;
  stroke-dasharray: 26 168;
  animation: movers 9s linear infinite;
}
@keyframes movers { to { stroke-dashoffset: -776; } }

.art-station line { stroke-dasharray: 2 4; }
.art-station--delay { opacity: 0.75; }

/* --- Robot: ciclo de recogida y depósito ---------------------------------- */
.art--robot [class^="art-axis"] { transform-box: view-box; }

.art-axis1 { transform-origin: 230px 298px; animation: eje1 8s ease-in-out infinite; }
.art-axis2 { transform-origin: 230px 196px; animation: eje2 8s ease-in-out infinite; }
.art-axis3 { transform-origin: 334px 195px; animation: eje3 8s ease-in-out infinite; }
.art-part  { animation: pieza 8s ease-in-out infinite; }

@keyframes eje1 {
  0%,   8%  { transform: rotate(26deg); }
  30%, 46%  { transform: rotate(-24deg); }
  70%, 100% { transform: rotate(26deg); }
}
@keyframes eje2 {
  0%,   8%  { transform: rotate(-34deg); }
  30%, 46%  { transform: rotate(16deg); }
  70%, 100% { transform: rotate(-34deg); }
}
@keyframes eje3 {
  0%,   8%  { transform: rotate(18deg); }
  30%, 46%  { transform: rotate(-10deg); }
  70%, 100% { transform: rotate(18deg); }
}
/* La pieza acompaña al brazo entre las dos estaciones */
@keyframes pieza {
  0%,  10%  { transform: translate(0, 0); opacity: 1; }
  26%, 44%  { transform: translate(206px, -6px); opacity: 1; }
  50%, 96%  { transform: translate(206px, -6px); opacity: 0.35; }
  100%      { transform: translate(0, 0); opacity: 1; }
}

/* --- Bus de campo: tramas recorriendo el segmento ------------------------- */
.art-frames {
  stroke: var(--cyan); stroke-width: 4; fill: none;
  stroke-dasharray: 18 96;
  animation: tramas 5.5s linear infinite;
}
@keyframes tramas { to { stroke-dashoffset: -456; } }

/* --- Respeto por la accesibilidad ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .art-movers, .art-frames,
  .art-axis1, .art-axis2, .art-axis3, .art-part { animation: none; }
}
@media print { .art-holder { display: none; } }
