/* Tarjetas de funciones (bento), el plan destacado, el cierre y las transiciones al hacer scroll
   (ADR-039). Sin `animation-timeline` en el navegador, entra lo de sitio.js; con movimiento reducido,
   nada se mueve. */

/* ---------------------------------------------------------------- bento */
.tn-bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gutter);
  margin-top: var(--s-7);
}
.tn-bento__celda {
  position: relative;
  grid-column: span 5;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--s-5);
  padding: var(--s-6) var(--s-6) 0;
  overflow: hidden;
  isolation: isolate;
}
.tn-bento__celda--ancha {
  grid-column: span 7;
}
.tn-bento__texto > p {
  margin-top: var(--s-2);
  color: var(--muted);
}
.tn-bento__pantalla {
  height: 300px;
  border-radius: 12px 12px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  /* La captura se apaga hacia la derecha y hacia abajo: el recorte se lee intencional. */
  -webkit-mask-image:
    linear-gradient(to right, #000 82%, transparent),
    linear-gradient(to bottom, #000 72%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, #000 82%, transparent),
    linear-gradient(to bottom, #000 72%, transparent);
  mask-composite: intersect;
}
/* La luz que sigue al cursor, encima del borde y debajo del contenido. */
.tn-bento__celda::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 300ms ease;
  background: radial-gradient(
    420px circle at var(--cx, 50%) var(--cy, 0%),
    var(--tn-coral-tenue),
    transparent 60%
  );
}
@media (hover: hover) and (pointer: fine) {
  .tn-bento__celda:hover::before {
    opacity: 1;
  }
}
@media (max-width: 1023px) {
  .tn-bento__celda,
  .tn-bento__celda--ancha {
    grid-column: span 6;
  }
  .tn-bento__pantalla {
    height: 240px;
  }
}
@media (max-width: 639px) {
  .tn-bento__celda,
  .tn-bento__celda--ancha {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------- plan destacado: borde con luz */
#pricing .card--plan.is-featured {
  position: relative;
  border-color: transparent;
  background:
    linear-gradient(var(--p-surface), var(--p-surface)) padding-box,
    conic-gradient(
        from var(--tn-giro),
        var(--line) 0deg,
        var(--p-accent) 60deg,
        var(--line) 120deg,
        var(--line) 360deg
      )
      border-box;
  box-shadow: 0 30px 80px -40px var(--tn-coral-suave);
}
@keyframes tn-gira {
  to {
    --tn-giro: 360deg;
  }
}

/* ---------------------------------------------------------------- entre páginas */
@view-transition {
  navigation: auto;
}
.nav__logo {
  view-transition-name: tn-logo;
}

/* ---------------------------------------------------------------- al hacer scroll */
@keyframes tn-aparece {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
@keyframes tn-sube-tarjeta {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
}
@keyframes tn-endereza {
  from {
    transform: rotateX(16deg) scale(0.94);
  }
}
@keyframes tn-aviso-entra {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion='off']) .tn-aviso {
    animation: tn-aviso-entra 700ms var(--tn-sube) 1.3s both;
  }
  html:not([data-motion='off']) .tn-escenario__celular {
    animation: tn-aviso-entra 900ms var(--tn-sube) 1s both;
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    html:not([data-motion='off']) .tn-escenario__marco {
      animation: tn-endereza linear both;
      animation-timeline: scroll(root);
      animation-range: 0 70vh;
    }
    /* Títulos: quedan quietos antes de llegar a la zona de lectura. */
    html:not([data-motion='off'])
      main
      > section:not(.hero, .tn-historia)
      :is(.section-head, .grid > h2, .grid > p, .grid > .stack-5),
    html:not([data-motion='off']) .closing__cta {
      animation: tn-aparece both;
      animation-timing-function: var(--tn-sube);
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
    html:not([data-motion='off'])
      main
      :is(.tn-bento__celda, .card--plan, .tn-negocio, .tn-pregunta, .frame) {
      animation: tn-sube-tarjeta both;
      animation-timing-function: var(--tn-sube);
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
    /* La cascada, en el orden de cada fila. */
    html:not([data-motion='off']) main .tn-negocio:nth-child(4n + 2) {
      animation-range: entry 5% entry 65%;
    }
    html:not([data-motion='off']) main .tn-negocio:nth-child(4n + 3) {
      animation-range: entry 10% entry 70%;
    }
    html:not([data-motion='off']) main .tn-negocio:nth-child(4n + 4) {
      animation-range: entry 15% entry 75%;
    }
    html:not([data-motion='off']) main .card--plan:nth-child(3n + 2) {
      animation-range: entry 8% entry 68%;
    }
    html:not([data-motion='off']) main .card--plan:nth-child(3n + 3) {
      animation-range: entry 16% entry 76%;
    }
    html:not([data-motion='off']) main .tn-bento__celda:nth-child(2n) {
      animation-range: entry 8% entry 68%;
    }
    /* El plan destacado sube con los demás y su luz da una sola vuelta mientras entra. */
    html:not([data-motion='off']) #pricing .card--plan.is-featured {
      animation:
        tn-sube-tarjeta both,
        tn-gira linear both;
      animation-timing-function: var(--tn-sube), linear;
      animation-timeline: view(), view();
      animation-range:
        entry 0% entry 60%,
        entry 0% cover 50%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}
html[data-motion='off']::view-transition-group(*) {
  animation: none;
}
