/* =========================================================================
   INTRO ERFAP — "El logotipo es la ventana"
   1 · el contorno de ERFAP se graba de izquierda a derecha con una barra de luz
   2 · una segunda pasada rellena las letras con la FOTO REAL de ERFAP
   3 · filete dorado + subtítulo
   4 · pausa larga y legible
   5 · la cámara atraviesa el logotipo y la foto inunda la pantalla → hero
   Animación sólo con transform / opacity / clip-path (compositor GPU).
   ========================================================================= */

html.erfap-intro-active,
html.erfap-intro-active body { overflow: hidden; }

.erfap-intro {
  --ei-ink: #04070d;
  --ei-gold: #d8b672;
  --ei-gold-hi: #ffe9bd;
  --ei-photo: url("/static/uploads/sitio/edificio-erfap.jpg?v=7");
  --ei-mark-w: min(76vw, 1060px);

  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  overflow: hidden;
  background: var(--ei-ink);
  color: #fff;
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  contain: layout paint;
}

/* ---------- Fondo cinematográfico ---------- */
.ei-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(58% 42% at 50% 36%, rgba(38, 76, 122, 0.5), rgba(10, 20, 34, 0) 72%),
    radial-gradient(80% 40% at 50% 108%, rgba(120, 92, 48, 0.22), rgba(10, 20, 34, 0) 70%),
    linear-gradient(180deg, #04070d 0%, #070d18 42%, #060a12 74%, #03050a 100%);
}
.ei-grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.38;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ---------- Foto real a pantalla completa (fase final, empalma con el hero) ---------- */
.ei-photo {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-image: var(--ei-photo);
  background-repeat: no-repeat;
  background-position: 78% 2%;
  background-size: cover;
  opacity: 0;
  transform: scale(1.06);
  will-change: transform, opacity;
}

/* ---------- Wordmark: contorno + foto vista A TRAVÉS de las letras ----------
   Ambas capas comparten exactamente la misma caja, así el relleno y el
   contorno quedan siempre registrados al pixel. */
.ei-mark {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 5;
  width: var(--ei-mark-w);
  aspect-ratio: 1982 / 640;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}
/* la foto recortada por la silueta del wordmark: las letras son ventanas */
.ei-mark-fill {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--ei-photo) center 22% / cover no-repeat;
  -webkit-mask-image: url("/static/uploads/sitio/ei-word-fill.webp");
          mask-image: url("/static/uploads/sitio/ei-word-fill.webp");
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-size: 100% 100%;
          mask-size: 100% 100%;
  clip-path: inset(0 100% 0 0);
  will-change: clip-path, opacity;
}
.ei-mark-line {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: url("/static/uploads/sitio/ei-word-line.webp") center / 100% 100% no-repeat;
  opacity: 0.92;
  clip-path: inset(0 100% 0 0);
  filter: drop-shadow(0 0 22px rgba(150, 190, 235, 0.45));
  will-change: clip-path, opacity;
}
/* barra de luz que "graba" y luego "revela" */
.ei-scan {
  position: absolute;
  top: -22%;
  bottom: -22%;
  left: 0;
  width: 2px;
  z-index: 3;
  opacity: 0;
  background: linear-gradient(180deg, rgba(255, 240, 210, 0) 0%, var(--ei-gold-hi) 22%, #fff 50%, var(--ei-gold-hi) 78%, rgba(255, 240, 210, 0) 100%);
  box-shadow: 0 0 26px 7px rgba(255, 236, 200, 0.55), 0 0 90px 26px rgba(190, 215, 255, 0.28);
  mix-blend-mode: screen;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- Filete + subtítulo ---------- */
.ei-meta {
  position: absolute;
  left: 50%;
  top: calc(42% + (var(--ei-mark-w) * 0.3229 * 0.5));
  z-index: 6;
  transform: translateX(-50%);
  margin-top: clamp(1.1rem, 3.2vw, 2.1rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.75rem, 1.8vw, 1.05rem);
  width: max-content;
  max-width: 92vw;
  will-change: transform, opacity;
}
.ei-rule {
  display: block;
  width: clamp(120px, 22vw, 260px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ei-gold), transparent);
  transform: scaleX(0);
  will-change: transform;
}
.ei-sub {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  column-gap: 0.9em;
  row-gap: 0.3em;
  font-size: clamp(0.58rem, 1.55vw, 0.76rem);
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(233, 240, 250, 0.82);
  opacity: 0;
  will-change: transform, opacity;
}
.ei-sub span { white-space: nowrap; }
.ei-sub i { color: var(--ei-gold); font-style: normal; }

/* ---------- Destello de transición ---------- */
.ei-bloom {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(60% 50% at 50% 46%, rgba(255, 250, 238, 0.95), rgba(255, 246, 226, 0.35) 45%, rgba(255, 246, 226, 0) 78%);
  will-change: opacity;
}

/* ---------- Saltar intro ---------- */
.erfap-intro__skip {
  position: absolute;
  z-index: 10;
  top: max(1.15rem, env(safe-area-inset-top));
  right: max(1.3rem, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.15rem;
  background: none;
  border: 0;
  color: rgba(226, 236, 248, 0.45);
  font: 600 0.64rem/1 "Inter", sans-serif;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.erfap-intro__skip-label { position: relative; }
.erfap-intro__skip-label::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -4px;
  height: 1px;
  background: var(--ei-gold);
  transition: right 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.erfap-intro__skip svg {
  width: 10px; height: 10px;
  stroke: currentColor; fill: none; stroke-width: 2;
  opacity: 0.8;
  transition: transform 0.3s ease;
}
.erfap-intro__skip:hover,
.erfap-intro__skip:focus-visible { color: #fff; outline: none; }
.erfap-intro__skip:hover .erfap-intro__skip-label::after,
.erfap-intro__skip:focus-visible .erfap-intro__skip-label::after { right: 0; }
.erfap-intro__skip:hover svg,
.erfap-intro__skip:focus-visible svg { transform: translateX(3px); }

.erfap-intro.is-leaving { pointer-events: none; }

/* ---------- Móvil ---------- */
@media (max-width: 700px) {
  .erfap-intro { --ei-mark-w: min(86vw, 560px); }
  .ei-meta { margin-top: clamp(1rem, 5vw, 1.6rem); gap: 0.85rem; }
  .ei-sub {
    flex-direction: column;
    align-items: center;
    row-gap: 0.55em;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
  }
  .ei-sub i { display: none; }
  .erfap-intro__skip { font-size: 0.6rem; letter-spacing: 0.18em; top: max(0.9rem, env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right)); }
  .erfap-intro__skip-label > span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .erfap-intro:not(.erfap-intro--force) { display: none; }
}
