/* ==========================================================================
   NIVRAIT — componentes reutilizables
   ========================================================================== */

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.2;
  padding: 15px 26px;
  min-height: 48px;
  border: 1.5px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease), transform var(--t-fast) var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}
.btn-primary:hover { background: #F5C92B; border-color: #F5C92B; }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-outline:hover { border-color: var(--ink); background: rgba(17, 17, 17, 0.04); }

.btn-sm {
  min-height: 40px;
  padding: 10px 18px;
  font-size: 0.85rem;
}

.section-dark .btn-outline,
.on-dark .btn-outline {
  color: var(--ink-dark);
  border-color: var(--line-dark);
}
.section-dark .btn-outline:hover,
.on-dark .btn-outline:hover {
  border-color: var(--ink-dark);
  background: rgba(242, 239, 234, 0.06);
}

.btn:active { transform: translateY(1px); }

/* Enlace con acento — reemplaza la flecha decorativa por un indicador funcional */
.link-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.94rem;
  padding-bottom: 3px;
  border-bottom: 2px solid var(--accent);
}
/* Flecha trazada a mano, no el carácter → */
.link-cta .arrow {
  width: 24px;
  height: 12px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--t-base) var(--ease);
}
.link-cta:hover .arrow { transform: translateX(4px); }

.section-dark .link-cta { color: var(--accent); }

/* --------------------------------------------------------------------------
   Indicador de progreso de lectura
   -------------------------------------------------------------------------- */

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  z-index: 300;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   System map — animación firma de la marca
   Representa el flujo real: orígenes → API → lógica → datos → cloud
   -------------------------------------------------------------------------- */

.system-map {
  width: 100%;
  height: auto;
  overflow: visible;
}

.map-layers {
  transition: transform 400ms var(--ease);
  will-change: transform;
}

.map-wire {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
}

/* Trazo corto y redondeado: se lee como un dato viajando, no como un segmento suelto */
.map-flow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 4 var(--dash-gap, 200);
  stroke-dashoffset: var(--dash-len, 200);
  opacity: 0;
}

.system-map.is-live .map-flow {
  opacity: 1;
  animation: map-flow-run var(--flow-dur, 3s) linear infinite;
  animation-delay: var(--flow-delay, 0s);
}

@keyframes map-flow-run {
  to { stroke-dashoffset: calc(var(--dash-len, 200) * -1); }
}

.map-node rect {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1;
  transition: stroke var(--t-base) var(--ease), fill var(--t-base) var(--ease);
}

.map-node text {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: middle;
  user-select: none;
}

.map-node {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 500ms var(--ease), transform 500ms var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.system-map.is-live .map-node {
  opacity: 1;
  transform: translateY(0);
}

.map-band {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  fill: var(--muted);
  text-anchor: start;
}

.map-node--accent rect {
  fill: var(--accent);
  stroke: var(--ink);
}

.map-node:hover rect { stroke: var(--ink); stroke-width: 1.6; }

@media (prefers-reduced-motion: reduce) {
  .system-map .map-node { opacity: 1; transform: none; }
  .system-map .map-flow { opacity: 0.55; animation: none; stroke-dasharray: none; stroke-dashoffset: 0; stroke-width: 1.5; }
  .map-layers { transform: none !important; }
}

/* --------------------------------------------------------------------------
   Esquemas de solución — diagramas de mecanismo, no iconos decorativos
   -------------------------------------------------------------------------- */

.solution-viz {
  width: 100%;
  max-width: 210px;
  height: auto;
  align-self: center;
}

.solution-viz .vz-box {
  fill: rgba(242, 239, 234, 0.03);
  stroke: rgba(242, 239, 234, 0.32);
  stroke-width: 1.2;
}
.solution-viz .vz-line {
  fill: none;
  stroke: rgba(242, 239, 234, 0.26);
  stroke-width: 1.2;
}
.solution-viz .vz-accent {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
}
.solution-viz .vz-fill { fill: var(--accent); }
.solution-viz .vz-dim { fill: rgba(242, 239, 234, 0.16); }

.solution-viz text {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  fill: rgba(242, 239, 234, 0.62);
  text-anchor: middle;
}
.solution-viz .vz-sm { font-size: 5.6px; }

/* --------------------------------------------------------------------------
   Revelado del panel de contacto
   -------------------------------------------------------------------------- */

/* Sin JS el formulario queda visible; la compuerta sólo existe con JS. */
.contacto-gate { display: none; }
.js .contacto[data-open="false"] .contacto-gate { display: block; }
.js .contacto[data-open="false"] .contacto-panel { display: none; }

.contacto-gate .gate-title {
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  margin-bottom: var(--s-4);
}
.contacto-gate .lead { margin-bottom: var(--s-5); }

.contacto[data-open="true"] .contacto-panel {
  animation: panel-rise 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes panel-rise {
  from { opacity: 0; transform: translateY(48px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.contacto[data-open="true"] [data-stagger] {
  animation: item-rise 620ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: calc(var(--d, 0) * 85ms + 140ms);
}

/* El orden del stagger va en data-d y no en un atributo style, para que la CSP
   pueda prohibir por completo los estilos inline. */
[data-d="0"] { --d: 0; }
[data-d="1"] { --d: 1; }
[data-d="2"] { --d: 2; }
[data-d="3"] { --d: 3; }
[data-d="4"] { --d: 4; }
[data-d="5"] { --d: 5; }
[data-d="6"] { --d: 6; }

@keyframes item-rise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .contacto[data-open="true"] .contacto-panel,
  .contacto[data-open="true"] [data-stagger] { animation: none; }
}

/* --------------------------------------------------------------------------
   Panel de consola (estado / build log)
   -------------------------------------------------------------------------- */

.console-panel {
  background: var(--bg-dark);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  padding: var(--s-5);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.9;
  color: #B9B5AE;
  overflow-x: auto;
}
.console-panel .prompt { color: var(--accent); }
.console-panel dl {
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  gap: 2px var(--s-4);
  margin: var(--s-3) 0 0;
}
.console-panel dt { color: #8A857E; }
.console-panel dd { margin: 0; color: var(--ink-dark); }

.status-line {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2F9E44;
  flex-shrink: 0;
  animation: status-pulse 2.4s ease-out infinite;
}
@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 158, 68, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(47, 158, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 158, 68, 0); }
}

/* --------------------------------------------------------------------------
   Formulario
   -------------------------------------------------------------------------- */

.contact-form { display: grid; gap: var(--s-5); }

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
}

.field { display: grid; gap: 6px; }

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.field .hint {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 13px 14px;
  min-height: 48px;
  border: 1.5px solid var(--line-field);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field textarea { min-height: 132px; resize: vertical; }

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--ink-soft); }

.field input:focus,
.field select:focus,
.field textarea:focus {
  /* El anillo es un box-shadow, que desaparece en modo de alto contraste de
     Windows: el outline transparente sí se pinta ahí y deja el foco visible. */
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(255, 216, 77, 0.45);
}

.field[data-invalid="true"] input,
.field[data-invalid="true"] select,
.field[data-invalid="true"] textarea { border-color: #B42318; }

.field-error {
  font-size: 0.8rem;
  color: #B42318;
  font-weight: 500;
  min-height: 0;
}
.field[data-invalid="true"] .field-error { min-height: 1.2em; }

/* Consentimiento de datos personales */
.field-consent { margin-top: 4px; }

.consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
  cursor: pointer;
}
.consent input[type="checkbox"] {
  width: 18px;
  min-height: 0;
  height: 18px;
  margin-top: 2px;
  padding: 0;
  accent-color: var(--ink);
  cursor: pointer;
}
.consent a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.field-consent[data-invalid="true"] .consent input[type="checkbox"] { outline: 2px solid #B42318; outline-offset: 2px; }

.form-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4);
}

.form-status {
  font-size: 0.92rem;
  font-weight: 600;
  color: #166534;
  padding: var(--s-3) var(--s-4);
  border-left: 3px solid #2F9E44;
  background: rgba(47, 158, 68, 0.07);
}
.form-status[hidden] { display: none; }

.btn[data-loading="true"] {
  pointer-events: none;
  opacity: 0.75;
}

/* --------------------------------------------------------------------------
   WhatsApp flotante
   -------------------------------------------------------------------------- */

.wa-float {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  z-index: 90;
  transition: transform var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.wa-float:hover { transform: translateY(-2px); background: #000; }
.wa-float svg { width: 24px; height: 24px; }

/* --------------------------------------------------------------------------
   Reveal al hacer scroll
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

/* Mismo criterio que data-d: sin atributos style, la CSP puede prohibirlos. */
[data-i="0"] { --i: 0; }
[data-i="1"] { --i: 1; }
[data-i="2"] { --i: 2; }
[data-i="3"] { --i: 3; }
[data-i="4"] { --i: 4; }
[data-i="5"] { --i: 5; }
[data-i="6"] { --i: 6; }

/* Utilitarias puntuales que antes vivían en atributos style */
.u-narrow { max-width: 44ch; }
.u-mb-0 { margin-bottom: 0; }
.u-mt-16 { margin-top: 16px; }
