/* EMI PH — sobreescribe la paleta de emi-erp.css (teal) por el verde de EMI PH.
   Cargar SIEMPRE después de styles.css y emi-erp.css. */
:root {
  --emi: #527C41;
  --emi-deep: #3F6234;
  --emi-soft: rgba(82, 124, 65, .13);
  --emi-line: rgba(82, 124, 65, .34);
  --emi-gold: #facc15;
  --emi-panel: rgba(8, 24, 20, .86);
  --emi-panel-2: rgba(10, 30, 24, .94);
  --emi-text: #d8f5ec;
  --emi-muted: #8fb8ab;
  --emi-shadow: 0 24px 70px rgba(0, 0, 0, .32);
  /* Fase 0 — tinte de producto (verde EMI PH) */
  --tint: var(--emi);
  --tint-soft: var(--emi-soft);
}

[data-theme="light"] {
  --emi: #527C41;
  --emi-deep: #3B5C2E;
  --emi-soft: rgba(82, 124, 65, .11);
  --emi-line: rgba(82, 124, 65, .28);
  --emi-panel: rgba(244, 253, 250, .94);
  --emi-panel-2: rgba(232, 248, 243, .98);
  --emi-text: #0c3a30;
  --emi-muted: #4f756a;
  --emi-shadow: 0 24px 70px rgba(5, 61, 50, .13);
}

/* El logo es el aro de colores: quito el tinte teal del drop-shadow y dejo que gire solo. */
.product-mark { margin-bottom: 1.1rem; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .25)); }
.product-mark:hover { transform: scale(1.06); }

.emi-hero-layout {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(360px, 1.12fr);
  gap: clamp(2.4rem, 5vw, 5.6rem);
  align-items: center;
  min-height: 43rem;
}

.emi-hero-copy {
  max-width: 620px;
  margin: 0;
  text-align: left;
  align-items: flex-start;
}

.emi-hero-sub {
  margin-left: 0;
  margin-right: 0;
}

.emi-hero-actions {
  justify-content: flex-start;
}

.emi-back {
  margin-top: 5.4rem;
}

.emi-kicker {
  margin: .9rem 0 .55rem;
}

.emi-hero h1 {
  max-width: 12ch;
  font-size: clamp(2.9rem, 4.75vw, 5.1rem);
}

.emi-hero-sub {
  max-width: 34rem;
  margin: 1rem 0 1.15rem;
  font-size: clamp(1rem, 1.45vw, 1.14rem);
  line-height: 1.5;
}

.emiph-hero-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 520px;
  width: 100%;
}

.emiph-app-stage {
  position: relative;
  width: min(100%, 580px);
  aspect-ratio: 1.05;
  isolation: isolate;
}

.emiph-app-stage::before {
  content: "";
  position: absolute;
  inset: 6% 2%;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, rgba(82, 124, 65, .18), transparent 62%);
  filter: blur(24px);
  opacity: .9;
}

.emiph-app-stage::after {
  content: "";
  position: absolute;
  inset: 14% 8%;
  border: 1px solid rgba(82, 124, 65, .14);
  border-radius: 34px;
  transform: rotate(-9deg);
  opacity: .62;
  box-shadow: 0 0 50px rgba(82, 124, 65, .08);
}

.emiph-stage-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(82, 124, 65, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 124, 65, .05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, #000 0 54%, transparent 78%);
  opacity: .75;
}

.emiph-app-screen {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: min(88%, 430px);
  min-height: 352px;
  overflow: hidden;
  border: 1px solid rgba(82, 124, 65, .36);
  border-radius: 18px;
  background:
    radial-gradient(circle at 78% 8%, rgba(82, 124, 65, .18), transparent 42%),
    linear-gradient(180deg, rgba(9, 25, 22, .96), rgba(5, 10, 10, .94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .08),
    0 26px 80px rgba(0, 0, 0, .42),
    0 0 46px rgba(82, 124, 65, .12);
  color: var(--emi-text);
  transform: translate(-50%, -50%) perspective(1000px) rotateX(6deg) rotateY(-8deg);
}

.emiph-hero-visual.visible .emiph-app-screen {
  animation: emiphScreenFloat 6.8s var(--ease-in-out) infinite;
}

.emiph-screen-bar {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .72rem .85rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .22);
}

.emiph-dots {
  display: flex;
  gap: .28rem;
}

.emiph-dots i,
.emiph-live i {
  display: block;
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--emi);
  box-shadow: 0 0 12px rgba(82, 124, 65, .5);
}

.emiph-dots i:nth-child(2) { opacity: .55; }
.emiph-dots i:nth-child(3) { opacity: .28; }

.emiph-screen-title {
  color: #fff;
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.emiph-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  color: var(--emi);
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .1em;
}

.emiph-hero-visual.visible .emiph-live i {
  animation: emiphLive 1.8s ease-in-out infinite;
}

.emiph-screen-body {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 304px;
}

.emiph-side {
  display: flex;
  flex-direction: column;
  gap: .72rem;
  align-items: center;
  padding-top: 1.1rem;
  border-right: 1px solid rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .025);
}

.emiph-side i {
  width: 18px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .12);
}

.emiph-side i:first-child {
  height: 18px;
  border: 1px solid var(--emi-line);
  background: var(--emi-soft);
}

.emiph-main {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .78rem;
  padding: 1rem;
}

.emiph-tabs {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
}

.emiph-tabs span {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
  padding: .24rem .58rem;
  color: var(--emi-muted);
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.emiph-tabs .active {
  border-color: var(--emi-line);
  background: var(--emi-soft);
  color: var(--emi);
}

.emiph-ledger {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.emiph-hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .55rem;
  align-items: center;
  min-height: 42px;
  padding: .55rem .62rem;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px;
  background: rgba(255, 255, 255, .03);
  opacity: 0;
  transform: translateY(10px);
}

.emiph-hero-row b {
  overflow: hidden;
  color: #fff;
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emiph-hero-row span {
  color: var(--emi-muted);
  font-size: .66rem;
  font-variant-numeric: tabular-nums;
}

.emiph-hero-row em {
  min-width: 54px;
  border-radius: 999px;
  padding: .18rem .42rem;
  background: rgba(255, 255, 255, .06);
  color: var(--emi-muted);
  font-size: .53rem;
  font-style: normal;
  font-weight: 800;
  text-align: center;
}

.emiph-hero-row em.ok {
  background: rgba(82, 124, 65, .14);
  color: var(--emi);
}

.emiph-hero-row em.due {
  background: rgba(250, 204, 21, .13);
  color: var(--emi-gold);
}

.emiph-hero-visual.visible .emiph-hero-row {
  animation: emiphHeroRow .55s var(--ease-out) forwards;
}

.emiph-hero-row.row-a { animation-delay: .18s; }
.emiph-hero-row.row-b { animation-delay: .32s; }
.emiph-hero-row.row-c { animation-delay: .46s; }
.emiph-hero-row.row-d { animation-delay: .6s; }

.emiph-hero-visual.visible .emiph-hero-row.row-b {
  animation:
    emiphHeroRow .55s var(--ease-out) .32s forwards,
    emiphDueGlow 4.8s var(--ease-in-out) 1.4s infinite;
}

.emiph-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .52rem;
  margin-top: auto;
}

.emiph-summary span {
  display: grid;
  gap: .16rem;
  align-content: center;
  min-height: 54px;
  border: 1px solid rgba(82, 124, 65, .16);
  border-radius: 12px;
  background: rgba(82, 124, 65, .055);
  padding: .55rem;
}

.emiph-summary b {
  color: var(--emi);
  font-size: .72rem;
  line-height: 1;
}

.emiph-summary small {
  color: var(--emi-muted);
  font-size: .54rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.emiph-signal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emi);
  box-shadow: 0 0 18px 4px rgba(82, 124, 65, .32);
  opacity: 0;
}

.emiph-hero-visual.visible .signal-a {
  animation: emiphSignalA 4.8s var(--ease-in-out) 1s infinite;
}

.emiph-hero-visual.visible .signal-b {
  animation: emiphSignalB 5.4s var(--ease-in-out) 2.2s infinite;
}

.emiph-float-card {
  position: absolute;
  z-index: 4;
  min-width: 112px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  background: rgba(7, 12, 12, .64);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 18px 45px rgba(0, 0, 0, .28);
  padding: .72rem .82rem;
  backdrop-filter: blur(12px);
}

.emiph-float-card b {
  display: block;
  color: #fff;
  font-family: var(--font-mono);
  font-size: .68rem;
  line-height: 1.2;
}

.emiph-float-card span {
  display: block;
  margin-top: .28rem;
  color: var(--emi-muted);
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.float-excel { left: 0; top: 17%; }
.float-wa { right: 1%; top: 22%; }
.float-pdf { right: 8%; bottom: 13%; }

.emiph-hero-visual.visible .emiph-float-card {
  animation: emiphFloat 5.6s var(--ease-in-out) infinite;
}

.emiph-hero-visual.visible .float-wa { animation-delay: -1.7s; }
.emiph-hero-visual.visible .float-pdf { animation-delay: -3.1s; }

@keyframes emiphScreenFloat {
  50% { transform: translate(-50%, -52%) perspective(1000px) rotateX(6deg) rotateY(-5deg); }
}

@keyframes emiphLive {
  50% { opacity: .35; transform: scale(.72); }
}

@keyframes emiphHeroRow {
  to { opacity: 1; transform: none; }
}

@keyframes emiphDueGlow {
  0%, 18%, 100% { box-shadow: none; border-color: rgba(255, 255, 255, .08); }
  32%, 46% { box-shadow: 0 0 0 1px rgba(250, 204, 21, .16), 0 0 22px rgba(250, 204, 21, .11); border-color: rgba(250, 204, 21, .28); }
}

@keyframes emiphSignalA {
  0% { opacity: 0; transform: translate(-50%, -50%); }
  14%, 72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-190px, -132px); }
}

@keyframes emiphSignalB {
  0% { opacity: 0; transform: translate(-50%, -50%); }
  14%, 72% { opacity: 1; }
  100% { opacity: 0; transform: translate(178px, 120px); }
}

@keyframes emiphFloat {
  50% { transform: translateY(-8px); border-color: var(--emi-line); }
}

[data-theme="light"] .emiph-app-screen {
  background:
    radial-gradient(circle at 78% 8%, rgba(82, 124, 65, .12), transparent 42%),
    linear-gradient(180deg, rgba(250, 255, 253, .96), rgba(237, 248, 244, .94));
  color: var(--emi-text);
  box-shadow: 0 26px 70px rgba(5, 61, 50, .14);
}

[data-theme="light"] .emiph-screen-title,
[data-theme="light"] .emiph-hero-row b,
[data-theme="light"] .emiph-float-card b { color: var(--emi-text); }

[data-theme="light"] .emiph-screen-bar,
[data-theme="light"] .emiph-side,
[data-theme="light"] .emiph-hero-row,
[data-theme="light"] .emiph-float-card {
  background: rgba(255, 255, 255, .58);
  border-color: rgba(5, 61, 50, .12);
}

@media (max-width: 980px) {
  .emi-hero-layout {
    grid-template-columns: 1fr;
    gap: 1.4rem;
    min-height: auto;
    padding-bottom: 4rem;
  }

  .emi-hero-copy {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
    align-items: center;
  }

  .emi-hero-sub {
    margin-left: auto;
    margin-right: auto;
  }

  .emi-hero-actions {
    justify-content: center;
  }

  .emiph-hero-visual {
    min-height: 470px;
  }
}

@media (max-width: 620px) {
  .emiph-hero-visual {
    min-height: 382px;
  }

  .emiph-app-stage {
    width: min(100%, 420px);
  }

  .emiph-app-stage::after {
    inset: 16% 3%;
  }

  .emiph-app-screen {
    width: 92%;
    min-height: 298px;
    border-radius: 14px;
    transform: translate(-50%, -50%);
  }

  .emiph-hero-visual.visible .emiph-app-screen {
    animation: none;
  }

  .emiph-screen-body {
    grid-template-columns: 38px minmax(0, 1fr);
    min-height: 250px;
  }

  .emiph-main {
    gap: .54rem;
    padding: .72rem;
  }

  .emiph-tabs span {
    padding: .2rem .42rem;
    font-size: .5rem;
  }

  .emiph-hero-row {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 36px;
    padding: .42rem .48rem;
  }

  .emiph-hero-row em {
    display: none;
  }

  .emiph-summary {
    gap: .34rem;
  }

  .emiph-summary span {
    min-height: 44px;
    padding: .4rem;
  }

  .emiph-float-card {
    min-width: 92px;
    padding: .52rem .6rem;
  }

  .float-excel { left: -2%; top: 8%; }
  .float-wa { right: -2%; top: 10%; }
  .float-pdf { right: 3%; bottom: 4%; }
}

@media (prefers-reduced-motion: reduce) {
  .emiph-hero-visual.visible .emiph-app-screen,
  .emiph-hero-visual.visible .emiph-live i,
  .emiph-hero-visual.visible .emiph-hero-row,
  .emiph-hero-visual.visible .emiph-hero-row.row-b,
  .emiph-hero-visual.visible .signal-a,
  .emiph-hero-visual.visible .signal-b,
  .emiph-hero-visual.visible .emiph-float-card {
    animation: none;
  }

  .emiph-hero-row {
    opacity: 1;
    transform: none;
  }

  .emiph-signal {
    display: none;
  }
}

/* =============================================================================
   FASE 5 — Maqueta animada "cómo funciona" (vector/CSS, Opción A, tinte EMI PH).
   Flujo: planilla → cartera + mora → cobro WhatsApp → PDF. Decorativa (aria-hidden):
   los 4 pasos en texto siguen siendo el contenido accesible. Arranca al entrar al
   viewport (.visible vía initReveal) y se aplana con prefers-reduced-motion.
   ============================================================================= */
.emiph-flow {
  --flow-dur: 3.6s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 620px;
  margin: 0 auto 3rem;
  padding: 1.4rem 1rem;
}
.emiph-node {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--card-inner-light);
  color: var(--emi);
  font-weight: 700;
}
.emiph-seg {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--glass-border);
}
/* Planilla / Excel */
.emiph-sheet {
  width: 60px;
  grid-auto-rows: max-content;
  align-content: center;
  gap: 7px;
  padding: 0 12px;
}
.emiph-sheet i {
  width: 36px;
  height: 8px;
  border-radius: 2px;
  background: var(--emi-soft);
  border: 1px solid var(--emi-line);
}
.emiph-sheet i:nth-child(2) { width: 26px; }
/* Cartera + mora (filas) */
.emiph-core { gap: 6px; grid-auto-rows: max-content; align-content: center; }
.emiph-core b { display: block; width: 36px; height: 6px; border-radius: 3px; background: var(--emi-line); }
.emiph-core b:nth-child(2) { width: 24px; }
.emiph-core b:nth-child(3) { width: 30px; }
/* Cobro WhatsApp */
.emiph-wa { font-size: 1.5rem; color: var(--emi); }
/* PDF */
.emiph-pdf { font-family: var(--font-mono); font-size: .82rem; letter-spacing: .02em; }

/* Pulso que recorre el flujo (solo cuando la maqueta está en pantalla). */
.emiph-pulse {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 8%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--emi);
  box-shadow: 0 0 12px 2px var(--tint-soft);
  transform: translate(-50%, -50%);
  opacity: 0;
}
.emiph-flow.visible .emiph-pulse {
  animation: emiphPulse var(--flow-dur) var(--ease-in-out) infinite;
}
@keyframes emiphPulse {
  0%   { left: 8%;  opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { left: 92%; opacity: 0; }
}
/* Cada nodo se enciende cuando el pulso pasa por él (activación secuencial). */
.emiph-flow.visible .emiph-node { animation: emiphNode var(--flow-dur) var(--ease-out) infinite; }
.emiph-sheet { animation-delay: 0s; }
.emiph-core  { animation-delay: calc(var(--flow-dur) * .28); }
.emiph-wa    { animation-delay: calc(var(--flow-dur) * .56); }
.emiph-pdf   { animation-delay: calc(var(--flow-dur) * .82); }
@keyframes emiphNode {
  0%, 100% { border-color: var(--glass-border); box-shadow: var(--card-inner-light); }
  9%       { border-color: var(--emi); box-shadow: var(--card-inner-light), 0 0 20px var(--tint-soft); }
  26%      { border-color: var(--glass-border); box-shadow: var(--card-inner-light); }
}

@media (max-width: 560px) {
  .emiph-flow { max-width: 100%; padding: 1.1rem .2rem; }
  .emiph-node { width: 62px; height: 62px; }
  .emiph-sheet { width: 48px; padding: 0 10px; }
  .emiph-sheet i { width: 28px; }
  .emiph-seg { min-width: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .emiph-flow.visible .emiph-pulse { animation: none; opacity: 0; }
  .emiph-flow.visible .emiph-node { animation: none; }
}
