/* ============================================================
   Página «Academias»: movimiento, tarjetas y fondos.
   Se carga después de style.css. Todo está acotado a .page-aca
   salvo los keyframes.
   ============================================================ */
@keyframes fxIn { from { opacity: 0; transform: translateY(30px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes drawStroke { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes popIn { 0% { transform: scale(0.4); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes orb { from { transform: translate3d(-3%, 2%, 0) scale(1); } to { transform: translate3d(4%, -3%, 0) scale(1.1); } }
@keyframes flashOk { 0% { background: rgba(31,107,74,0.16); } 100% { background: transparent; } }
@keyframes flashKo { 0% { background: rgba(163,32,32,0.14); } 100% { background: transparent; } }
@keyframes flashWa { 0% { background: rgba(184,89,10,0.14); } 100% { background: transparent; } }
@keyframes ctaPulse { 0% { box-shadow: 0 0 0 0 rgba(27,77,143,0.38); } 70%, 100% { box-shadow: 0 0 0 16px rgba(27,77,143,0); } }
@keyframes chkPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Entrada escalonada: sólo se oculta si academias.js va a mostrarlo (html.fx-ready). */
html.fx-ready .page-aca [data-fx]:not(.in) { opacity: 0; }
.page-aca [data-fx].in { animation: fxIn 0.9s var(--e-out) backwards; animation-delay: calc(var(--i, 0) * 90ms); }

/* Tarjetas: foco de luz que sigue al puntero y filo superior que se dibuja */
.page-aca .fx-card { position: relative; overflow: hidden; }
.page-aca .fx-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  transition: opacity 0.45s var(--e-out);
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), rgba(27,77,143,0.10), transparent 65%);
}
.page-aca .fx-card::before {
  content: ''; position: absolute; left: 0; top: 0; height: 2px; width: 100%; pointer-events: none; z-index: 2;
  background: linear-gradient(90deg, var(--norma), var(--oro));
  transform: scaleX(0); transform-origin: left; transition: transform 0.7s var(--e-out);
}
.page-aca .fx-card:hover::after { opacity: 1; }
.page-aca .fx-card:hover::before { transform: scaleX(1); }
.page-aca .section--dark .fx-card::after { background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), rgba(176,141,79,0.16), transparent 65%); }
.page-aca .trace-card.fx-card:hover, .page-aca .tema.fx-card:hover { transform: translateY(-4px); }

/* Reglas como tarjetas */
.page-aca .cond-regla.fx-card { padding: 1.6rem 1.5rem; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; transition: transform 0.45s var(--e-out), box-shadow 0.45s var(--e-out); }
.page-aca .cond-regla.fx-card:hover { transform: translateY(-4px); box-shadow: 0 26px 56px -36px rgba(20,22,28,0.28); }
.page-aca .cond-reglas { border-top: none; padding-top: 0; }

/* Notas bajo las comparativas: a todo el ancho de la tarjeta */
.page-aca .compare-note { max-width: none; }

/* Hero: informe de auditoría animado */
.aud-wrap { position: relative; padding: 1.8rem 0; }
.aud-orb { position: absolute; inset: -6% -8%; z-index: 0; pointer-events: none; filter: blur(34px); animation: orb 9s ease-in-out infinite alternate;
  background: radial-gradient(closest-side at 35% 45%, rgba(27,77,143,0.20), transparent 70%), radial-gradient(closest-side at 72% 28%, rgba(176,141,79,0.20), transparent 70%); }
.aud-card { position: relative; z-index: 1; transition: transform 0.35s var(--e-out); will-change: transform; }
.aud-body { position: relative; }
.aud-chip { position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 0.5rem; background: #fff; border: 1px solid var(--line-str); border-radius: 999px;
  padding: 0.5rem 0.9rem; font-size: 0.72rem; box-shadow: 0 18px 40px -22px rgba(20,22,28,0.4); animation: floatY 6s ease-in-out infinite; white-space: nowrap; }
.aud-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--verificado); box-shadow: 0 0 0 0 rgba(31,107,74,0.5); animation: pulse 2.6s infinite; }
.aud-chip b { font-family: var(--mono); font-weight: 500; font-size: 0.68rem; color: var(--norma); }
.aud-chip--a { top: 0; left: -1.2rem; }
.aud-chip--b { bottom: 0.2rem; right: -0.8rem; animation-delay: -3s; }
.aud-scan { position: absolute; left: -1.3rem; right: -1.3rem; top: 0; height: 2px; z-index: 3; pointer-events: none; display: none;
  background: linear-gradient(90deg, transparent, var(--norma) 20%, var(--oro) 80%, transparent); box-shadow: 0 0 22px 5px rgba(27,77,143,0.30); opacity: 0;
  transition: transform 0.5s var(--e-inout), opacity 0.3s; }
.aud-live .aud-scan { display: block; }
.aud-list li { transition: background 0.3s; }
.aud-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem; margin-top: 0.6rem; padding-top: 0.95rem; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--text-dim); }
.aud-foot .af b { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; margin-right: 0.25rem; }
.af-ok b { color: var(--verificado); } .af-ko b { color: var(--alerta); } .af-wa b { color: var(--dato); }
.aud-stamp { margin-left: auto; font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--verificado);
  border: 2px solid var(--verificado); border-radius: 4px; padding: 0.3rem 0.6rem; transform: rotate(-6deg); }
.aud-live .aud-foot { opacity: 0; transform: translateY(8px); transition: opacity 0.5s, transform 0.5s var(--e-out); }
.aud-live .aud-foot.show { opacity: 1; transform: none; }
.aud-live .aud-stamp { opacity: 0; transform: rotate(-6deg) scale(1.9); transition: opacity 0.2s, transform 0.45s var(--e-spring); }
.aud-live .aud-stamp.show { opacity: 1; transform: rotate(-6deg) scale(1); }
.aud-live li.is-pend svg circle { fill: #d9d4c8; }
.aud-live li.is-pend svg path { opacity: 0; }
.aud-live li.is-pend span { color: transparent; user-select: none; border-radius: 4px; background: linear-gradient(90deg, #eee9df 25%, #f8f5ee 50%, #eee9df 75%); background-size: 200% 100%; animation: shim 1.3s linear infinite; }
.aud-live li.done svg { animation: popIn 0.45s var(--e-out); }
.aud-live li.done svg path { stroke-dasharray: 24; animation: drawStroke 0.5s 0.08s var(--e-out) backwards; }
.aud-live li.done.ok { animation: flashOk 1.2s; } .aud-live li.done.ko { animation: flashKo 1.2s; } .aud-live li.done.wa { animation: flashWa 1.2s; }
.page-aca .hero-actions .btn-primary { animation: ctaPulse 3.4s 1.5s infinite; }

/* Vigilancia: radar semanal */
.aca-vig { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(1.5rem, 3.5vw, 3.2rem); align-items: start; margin-top: clamp(2.2rem, 4vw, 3.2rem); }
.aca-vig-reglas { display: flex; flex-direction: column; gap: 1rem; }
.aca-radar { background: var(--ink); color: var(--paper); border-radius: var(--r-lg); padding: clamp(1.2rem, 2.4vw, 1.7rem); box-shadow: 0 40px 80px -44px rgba(20,22,28,0.6); min-width: 0; }
.aca-radar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 0.86rem; }
.aca-radar-head b { font-weight: 500; }
.aca-radar-head span { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.5; }
.aca-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; margin: 1.2rem 0; }
.aca-days span { text-align: center; padding: 0.6rem 0; border-radius: 8px; border: 1px solid rgba(250,248,244,0.14); font-family: var(--mono); font-size: 0.74rem; color: rgba(250,248,244,0.5); transition: background 0.3s, color 0.3s, box-shadow 0.4s; }
.aca-days .hot { border-color: var(--oro); color: var(--oro); }
.r-live .aca-days span.on { background: rgba(250,248,244,0.1); color: var(--paper); }
.r-live .aca-days .hot.on { background: var(--oro); color: var(--ink); box-shadow: 0 0 0 6px rgba(176,141,79,0.22); }
.aca-norms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.aca-norms li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0.9rem; border-radius: 10px; background: rgba(250,248,244,0.05); font-size: 0.82rem; transition: background 0.3s; }
.aca-norms .n { min-width: 0; }
.aca-norms .st { font-style: normal; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.3rem 0.6rem; border-radius: 999px; white-space: nowrap; background: rgba(111,203,159,0.16); color: #6FCB9F; }
.aca-norms .alerta .st { background: rgba(184,89,10,0.24); color: #F0A868; }
.r-live .aca-norms li:not(.ok):not(.warn) .st { background: rgba(250,248,244,0.1); color: rgba(250,248,244,0.55); }
.r-live .aca-norms li.chk .st { animation: chkPulse 0.8s infinite; }
.r-live .aca-norms li.ok { background: rgba(111,203,159,0.07); } .r-live .aca-norms li.warn { background: rgba(184,89,10,0.12); }
.aca-toast { margin-top: 1rem; padding: 0.85rem 1rem; border-radius: 10px; border: 1px solid rgba(240,168,104,0.4); background: rgba(184,89,10,0.16); font-size: 0.8rem; color: #F6C79D; }
.aca-toast b { color: #fff; font-weight: 500; }
.r-live .aca-toast { opacity: 0; transform: translateY(10px); transition: opacity 0.5s, transform 0.5s var(--e-out); }
.r-live .aca-toast.show { opacity: 1; transform: none; }

/* Comparativa: marcas que se dibujan y filas escalonadas */
.compare-table--3.in .compare-row { animation: fxIn 0.7s var(--e-out) backwards; }
.compare-table--3.in .compare-row:nth-child(2) { animation-delay: 0.10s; } .compare-table--3.in .compare-row:nth-child(3) { animation-delay: 0.17s; }
.compare-table--3.in .compare-row:nth-child(4) { animation-delay: 0.24s; } .compare-table--3.in .compare-row:nth-child(5) { animation-delay: 0.31s; }
.compare-table--3.in .compare-row:nth-child(6) { animation-delay: 0.38s; } .compare-table--3.in .compare-row:nth-child(7) { animation-delay: 0.45s; }
.compare-table--3.in .compare-row:nth-child(8) { animation-delay: 0.52s; } .compare-table--3.in .compare-row:nth-child(9) { animation-delay: 0.59s; }
.compare-table--3.in .c-ico path { stroke-dasharray: 24; animation: drawStroke 0.6s 0.6s var(--e-out) backwards; }

/* Pasos: línea que se dibuja y números en círculo */
.aca-steps { position: relative; margin-top: 3rem; padding-top: 2.4rem; }
.aca-steps::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--norma), var(--oro)); transform-origin: left; }
html.fx-ready .aca-steps::before { transform: scaleX(0); transition: transform 1.6s var(--e-out) 0.2s; }
html.fx-ready .aca-steps:has(.in)::before { transform: scaleX(1); }
.aca-steps .cond-regla-num { width: 2.3rem; height: 2.3rem; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--norma); background: #fff; font-size: 0.7rem; margin-bottom: 1rem; }

/* Fondo oscuro de «Servicios» */
.aca-dark .tema, .aca-dark .cond-regla.fx-card { background: rgba(250,248,244,0.035); border-color: rgba(250,248,244,0.12); }
.aca-dark .tema h3, .aca-dark .cond-regla h3, .aca-dark .aca-sub { color: var(--paper); }
.aca-dark .tema-why, .aca-dark .cond-regla p { color: rgba(250,248,244,0.62); }
.aca-dark .tema-code { background: rgba(176,141,79,0.16); color: var(--oro); }
.aca-dark .cond-regla-num { color: var(--oro); border-color: rgba(176,141,79,0.5); background: transparent; }
.aca-dark .cond-regla.fx-card:hover, .aca-dark .tema.fx-card:hover { box-shadow: 0 26px 56px -30px rgba(0,0,0,0.6); border-color: rgba(176,141,79,0.35); }

/* Móvil */
@media (max-width: 1080px) { .aca-vig { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .aud-chip { display: none; } .aud-wrap { padding: 0.4rem 0; } .aud-orb { inset: -4% -2%; } }
@media (max-width: 700px) {
  .aud-scan { left: -1rem; right: -1rem; }
  .aca-days { gap: 0.25rem; } .aca-days span { padding: 0.5rem 0; font-size: 0.68rem; }
  .aca-norms li { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .aca-steps .cond-regla-num { margin-bottom: 0.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .aud-chip, .aud-orb, .page-aca .hero-actions .btn-primary { animation: none; }
}

/* ============================================================
   Ventana emergente: solicitud de auditoría
   ============================================================ */
.amodal { position: fixed; inset: 0; z-index: 3300; display: none; align-items: center; justify-content: center; padding: clamp(0.6rem, 3vw, 2rem); }
.amodal.open { display: flex; }
.amodal-fondo { position: absolute; inset: 0; background: rgba(20,22,28,0.66); backdrop-filter: blur(4px); animation: amFondo 0.35s ease-out; }
.amodal-panel {
  position: relative; z-index: 1; width: min(720px, 100%); max-height: min(92dvh, 900px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: var(--r-xl, 22px); padding: clamp(1.4rem, 3.4vw, 2.4rem);
  box-shadow: 0 50px 120px -30px rgba(0,0,0,0.55); animation: amPanel 0.5s var(--e-out);
}
@keyframes amFondo { from { opacity: 0; } to { opacity: 1; } }
@keyframes amPanel { from { opacity: 0; transform: translateY(26px) scale(0.97); } to { opacity: 1; transform: none; } }
html.amodal-abierto, html.amodal-abierto body { overflow: hidden; }
.amodal-x { position: absolute; top: 0.9rem; right: 0.9rem; width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line-str); background: #fff; color: var(--ink); cursor: pointer; transition: transform 0.3s var(--e-out), background 0.3s; }
.amodal-x:hover { transform: rotate(90deg); background: var(--paper-2); }
.amodal-panel h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.6rem, 3.4vw, 2.1rem); line-height: 1.1; letter-spacing: -0.01em; margin: 0.7rem 2.6rem 0 0; }
.amodal-lead { margin: 0.8rem 0 1.5rem; font-size: 0.94rem; line-height: 1.65; color: var(--text-dim); max-width: 54ch; }
.am-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.95rem 1rem; }
.am-campo { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.am-2 { grid-column: 1 / -1; }
.am-campo label, .am-etq { font-size: 0.78rem; font-weight: 500; color: var(--ink); }
.am-campo label b { color: var(--alerta); font-weight: 600; }
.am-campo small { font-weight: 400; color: var(--text-muted); }
.am-campo input[type="text"], .am-campo input[type="email"], .am-campo input[type="tel"], .am-campo textarea {
  width: 100%; padding: 0.72rem 0.85rem; font: inherit; font-size: 0.92rem; color: var(--ink);
  border: 1px solid var(--line-str); border-radius: var(--r-sm, 8px); background: #fff; transition: border-color 0.25s, box-shadow 0.25s;
}
.am-campo textarea { resize: vertical; min-height: 5.2rem; line-height: 1.5; }
.am-campo input:focus-visible, .am-campo textarea:focus-visible { outline: none; border-color: var(--norma); box-shadow: 0 0 0 3px rgba(27,77,143,0.16); }
.am-campo input.is-mal { border-color: var(--alerta); box-shadow: 0 0 0 3px rgba(163,32,32,0.12); }
.am-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.am-drop {
  display: flex; align-items: center; gap: 0.9rem; padding: 1.05rem 1.1rem; border: 1.5px dashed var(--line-str); border-radius: var(--r-md, 12px);
  background: var(--paper-2); cursor: pointer; color: var(--ink); font-size: 0.88rem; line-height: 1.5; transition: border-color 0.25s, background 0.25s, transform 0.25s var(--e-out);
}
.am-drop svg { flex: none; color: var(--norma); }
.am-drop small { color: var(--text-muted); font-size: 0.76rem; }
.am-drop:hover, .am-drop.is-over { border-color: var(--norma); background: rgba(27,77,143,0.06); }
.am-drop.is-over { transform: scale(1.01); }
.am-campo:focus-within .am-drop, .am-file:focus-visible + .am-lista { outline: none; }
.am-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.am-lista:empty { display: none; }
.am-lista li { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.4rem 0.5rem 0.8rem; background: #fff; border: 1px solid var(--line); border-radius: 9px; font-size: 0.84rem; }
.am-lista li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-lista li small { color: var(--text-muted); white-space: nowrap; }
.am-lista li button { width: 1.7rem; height: 1.7rem; border: none; border-radius: 50%; background: transparent; font-size: 1.15rem; line-height: 1; cursor: pointer; color: var(--text-dim); }
.am-lista li button:hover { background: var(--paper-2); color: var(--alerta); }
.am-trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.am-check { display: flex; gap: 0.7rem; align-items: flex-start; margin-top: 1.2rem; font-size: 0.82rem; line-height: 1.55; color: var(--text-dim); cursor: pointer; }
.am-check input { margin-top: 0.2rem; width: 1.05rem; height: 1.05rem; flex: none; cursor: pointer; accent-color: var(--norma); }
.am-check a { color: var(--norma); text-decoration: underline; text-underline-offset: 2px; }
.am-error { margin: 1rem 0 0; padding: 0.7rem 0.9rem; border-radius: 9px; background: rgba(163,32,32,0.08); border: 1px solid rgba(163,32,32,0.25); color: var(--alerta); font-size: 0.84rem; line-height: 1.5; }
.am-error[hidden], .am-barra[hidden], .amodal-vista[hidden] { display: none; }
.am-acciones { display: flex; gap: 0.7rem; margin-top: 1.3rem; justify-content: flex-end; }
.am-acciones .btn-primary { min-width: 12rem; justify-content: center; }
.am-acciones .btn-primary[disabled] { opacity: 0.7; cursor: progress; }
.am-barra { height: 4px; margin-top: 1rem; border-radius: 2px; background: var(--line); overflow: hidden; }
.am-barra span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--norma), var(--oro)); transition: width 0.25s linear; }
.am-ok { text-align: center; padding: 1.2rem 0 0.4rem; }
.am-ok h2 { margin: 1rem 0 0; }
.am-ok p { margin: 0.8rem auto 1.5rem; max-width: 40ch; font-size: 0.95rem; line-height: 1.65; color: var(--text-dim); }
.am-ok-ico { color: var(--verificado); }
.am-ok-ico path { stroke-dasharray: 40; animation: drawStroke 0.7s 0.2s var(--e-out) backwards; }
.am-ok-ico circle { stroke-dasharray: 170; animation: drawStroke 0.8s var(--e-out) backwards; }
@media (max-width: 560px) {
  .amodal { padding: 0; align-items: flex-end; }
  .amodal-panel { width: 100%; max-height: 96dvh; border-radius: 20px 20px 0 0; padding: 1.3rem 1.1rem 1.6rem; }
  .am-grid { grid-template-columns: 1fr; }
  .am-2 { grid-column: auto; }
  .am-acciones { flex-direction: column-reverse; }
  .am-acciones .btn-primary, .am-acciones .btn-ghost { width: 100%; justify-content: center; min-width: 0; }
  .am-campo input[type="text"], .am-campo input[type="email"], .am-campo input[type="tel"], .am-campo textarea { font-size: 16px; } /* evita el zoom de iOS al enfocar */
  .am-drop { flex-direction: column; text-align: center; }
}

.am-drop b { color: var(--ink); font-weight: 600; }
