/* =========================================================
   TRENIA — intro cinematográfica
   Se activa sólo con html.has-intro (lo agrega el script inline del <head>).
   ========================================================= */
.intro { display: none; }
html.has-intro .intro {
  display: block; position: fixed; inset: 0; z-index: 90; /* el grano (z 100) queda por encima: textura de película */
  overflow: hidden; pointer-events: auto; cursor: default;
}
.intro.is-leave { pointer-events: none; }

/* ---------- fondo ---------- */
.intro__bg {
  position: absolute; inset: 0; background: var(--ink);
  transition: opacity .95s cubic-bezier(.4, 0, .2, 1);
}
.intro__bg::after { /* viñeta */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 50%, transparent 45%, rgba(0, 0, 0, .55) 100%);
}
.intro.is-leave .intro__bg { opacity: 0; }

.intro__glow {
  position: absolute; left: 50%; top: 50%; width: min(1100px, 140vw); aspect-ratio: 2.4;
  transform: translate(-50%, -50%) scale(.7);
  background: radial-gradient(closest-side, rgba(var(--acc-rgb), .16), rgba(var(--acc-rgb), .05) 55%, transparent 100%);
  opacity: 0; pointer-events: none;
  transition: opacity 1.8s cubic-bezier(.2, .7, .1, 1), transform 2.6s cubic-bezier(.2, .7, .1, 1);
}
.intro.is-on .intro__glow { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.intro.is-out .intro__glow { opacity: .35; transition-duration: .6s; }
.intro.is-leave .intro__glow { opacity: 0; transition: opacity .6s; }

/* ---------- escenario ---------- */
.intro__stage { position: absolute; inset: 0; display: grid; place-items: center; }
.intro__center { position: relative; width: min(560px, 72vw); }

/* el elemento que viaja al menú (lo mueve el JS) */
.intro__logo { display: block; width: 100%; aspect-ratio: 1021 / 177; will-change: transform; }

/* el logo en sí: barrido + foco + empuje lento */
.intro__mark { position: relative; width: 100%; height: 100%; opacity: 0; }
.intro__mark img { width: 100%; height: 100%; display: block; }
.intro.is-on .intro__mark {
  opacity: 1;
  -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent 55%);
          mask-image: linear-gradient(90deg, #000 45%, transparent 55%);
  -webkit-mask-size: 300% 100%; mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 0 0; mask-position: 0 0;
  animation:
    introWipe  1.15s cubic-bezier(.65, 0, .35, 1) .1s backwards,
    introFocus 1.6s cubic-bezier(.2, .7, .1, 1) .1s backwards,
    introPush  2.3s cubic-bezier(.16, 1, .3, 1) 0s backwards;
}
@keyframes introWipe  { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
@keyframes introFocus { from { filter: blur(10px) brightness(1.6); } to { filter: none; } }
@keyframes introPush  { from { transform: scale(1.09); } to { transform: none; } }

/* destello que recorre las letras una vez reveladas */
.intro__shine {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  -webkit-mask: url("../img/trenia-wordmark.png") 0 0 / 100% 100% no-repeat;
          mask: url("../img/trenia-wordmark.png") 0 0 / 100% 100% no-repeat;
  background: linear-gradient(100deg, transparent 38%, rgba(var(--acc-rgb), .9) 50%, transparent 62%) no-repeat;
  background-size: 300% 100%; background-position: 100% 0;
}
.intro.is-on .intro__shine { animation: introShine 1.1s cubic-bezier(.45, 0, .2, 1) 1.25s both; }
@keyframes introShine {
  0%   { opacity: 1; background-position: 100% 0; }
  85%  { opacity: 1; }
  100% { opacity: 0; background-position: 0 0; }
}

/* haz de luz anamórfico: corre sobre el riel del logo y "pinta" el barrido */
.intro__sweep {
  position: absolute; left: 0; top: 93%; width: 100%; height: 0; pointer-events: none;
  transform: translateX(-50%); opacity: 0;
}
.intro__sweep::before { /* estela */
  content: ""; position: absolute; right: 0; top: -1px; width: 70%; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(var(--acc-rgb), .85));
  filter: drop-shadow(0 0 6px rgba(var(--acc-rgb), .9));
}
.intro__sweep::after { /* núcleo */
  content: ""; position: absolute; right: -40px; top: -12px; width: 80px; height: 24px; border-radius: 50%;
  background: radial-gradient(closest-side, #fff, rgba(var(--acc-rgb), .9) 35%, transparent 100%);
  filter: blur(1px);
}
.intro.is-on .intro__sweep { animation: introSweep 1.15s cubic-bezier(.65, 0, .35, 1) .1s both; }
@keyframes introSweep {
  0%   { transform: translateX(-50%); opacity: 0; }
  12%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateX(150%); opacity: 0; }
}

/* ---------- frase ---------- */
.intro__tag {
  position: absolute; left: 50%; top: calc(100% + clamp(22px, 3.2vw, 42px)); transform: translateX(-50%);
  margin: 0; display: flex; align-items: center; gap: clamp(12px, 1.6vw, 22px); white-space: nowrap;
  font: italic 700 clamp(13px, 1.55vw, 21px)/1 var(--f-d); letter-spacing: .36em; text-transform: uppercase;
  color: var(--bone);
}
.intro__tag em { font-style: inherit; color: var(--acc); }
/* oculta hasta su turno: antes de que intro.js parta la frase en letras, el
   texto crudo se veía un instante, antes que el logo */
.intro:not(.is-tag) .intro__tag { visibility: hidden; }
.intro__tag::before, .intro__tag::after { /* filetes laterales */
  content: ""; width: clamp(18px, 3vw, 44px); height: 1px; background: rgba(var(--acc-rgb), .7);
  transform: scaleX(0); transition: transform .9s cubic-bezier(.2, .7, .1, 1) .25s;
}
.intro__tag::before { transform-origin: 100% 50%; }
.intro__tag::after  { transform-origin: 0 50%; margin-left: -.36em; } /* compensa el tracking de la última letra */
.intro.is-tag .intro__tag::before, .intro.is-tag .intro__tag::after { transform: scaleX(1); }
.intro.is-out .intro__tag::before, .intro.is-out .intro__tag::after { transform: scaleX(0); transition: transform .4s cubic-bezier(.5, 0, .75, 0); }

.intro__tag .w { display: inline-block; }
.intro__tag .c { display: inline-block; opacity: 0; }
.intro.is-tag .intro__tag .c { animation: introTagIn .8s cubic-bezier(.2, .7, .1, 1) calc(var(--i) * 24ms) both; }
.intro.is-tag.is-out .intro__tag .c { animation: introTagOut .5s cubic-bezier(.5, 0, .75, 0) calc(var(--i) * 12ms) both; }
@keyframes introTagIn  { from { opacity: 0; transform: translateY(.7em); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes introTagOut { from { opacity: 1; transform: none; filter: none; } to { opacity: 0; transform: translateY(-.5em); filter: blur(6px); } }

/* ---------- el menú mientras dura la intro ---------- */
html.has-intro .nav__logo img { opacity: 0; }
html.has-intro:not(.intro-land) :is(.nav__links a, .nav__login, .nav .btn--sm, .nav__burger) { opacity: 0; }
html.intro-land :is(.nav__links a, .nav__login, .nav .btn--sm, .nav__burger) {
  animation: introNav .8s cubic-bezier(.2, .7, .1, 1) backwards;
}
html.intro-land .nav__links a:nth-child(2) { animation-delay: .06s; }
html.intro-land .nav__links a:nth-child(3) { animation-delay: .12s; }
html.intro-land .nav__links a:nth-child(4) { animation-delay: .18s; }
html.intro-land .nav__login { animation-delay: .24s; }
html.intro-land .nav .btn--sm:not(.nav__login) { animation-delay: .3s; }
html.intro-land .nav__burger { animation-delay: .12s; }
@keyframes introNav { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
