/* Intro cinematográfica de Arnaldos Parquet.
   Secuencia (≈2,9 s de entrada + 1,6 s de salida):
   franjas de cine → filete dorado → logo con barrido de revelado → lugar → contador.
   Salida (.salida): la cámara atraviesa el logo (zoom), el telón se abre en iris
   y la página entra con un zoom hacia dentro. Solo CSS + cine.js (que decide
   cuándo salir). Con prefers-reduced-motion cine.js la quita entera. */

@property --ic-num {
  syntax: "<integer>";
  inherits: true;
  initial-value: 0;
}
@property --ic-r {
  syntax: "<percentage>";
  inherits: true;
  initial-value: -12%;
}

.intro-cine {
  --ic-fondo: #1b1a16;
  --ic-texto: #f2ede2;
  --ic-acento: #b7a077;
  --ic-curva: cubic-bezier(0.22, 1, 0.36, 1);
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--ic-texto);
  background: radial-gradient(ellipse at 50% 46%, #2d2b25 0%, var(--ic-fondo) 52%, #0e0d0b 100%);
  /* El iris: un agujero con borde suave que crece desde el centro. */
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent var(--ic-r), #000 calc(var(--ic-r) + 9%));
  mask-image: radial-gradient(ellipse at 50% 50%, transparent var(--ic-r), #000 calc(var(--ic-r) + 9%));
}

/* Grano de película muy sutil */
.intro-cine::after {
  content: "";
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: ic-grano 0.9s steps(6) infinite;
}
@keyframes ic-grano {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* Franjas de cine */
.ic-franja {
  position: absolute;
  left: 0;
  right: 0;
  height: 10vh;
  background: #0a0908;
  z-index: 3;
  animation: ic-franja-entra 1.1s var(--ic-curva) both;
}
.ic-franja.sup { top: 0; transform-origin: top; }
.ic-franja.inf { bottom: 0; transform-origin: bottom; }
@keyframes ic-franja-entra { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Escena central: es lo que hace el zoom en la salida */
.ic-escena {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.2vw, 22px);
  transform-origin: 50% 50%;
}

.ic-linea {
  width: clamp(90px, 14vw, 170px);
  height: 1px;
  background: var(--ic-acento);
  transform: scaleX(0);
  animation: ic-linea 1.1s 0.25s var(--ic-curva) forwards;
}
@keyframes ic-linea { to { transform: scaleX(1); } }

/* Logo: barrido de revelado con borde suave (como si se escribiera) */
.ic-logo {
  display: block;
  height: clamp(64px, 10.5vw, 118px);
  width: auto;
  opacity: 0;
  filter: blur(10px);
  -webkit-mask-image: linear-gradient(90deg, #000 42%, transparent 58%);
  mask-image: linear-gradient(90deg, #000 42%, transparent 58%);
  -webkit-mask-size: 260% 100%;
  mask-size: 260% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  animation: ic-logo 1.7s 0.7s cubic-bezier(0.65, 0, 0.2, 1) forwards;
}
@keyframes ic-logo {
  0% { opacity: 0; filter: blur(10px); -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  18% { opacity: 1; }
  100% { opacity: 1; filter: blur(0); -webkit-mask-position: 0% 0; mask-position: 0% 0; }
}

.ic-lugar {
  font-family: var(--font-display, "Work Sans", system-ui, sans-serif);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--ic-acento);
  white-space: nowrap;
  opacity: 0;
  letter-spacing: 0.55em;
  animation: ic-lugar 1.4s 1.65s var(--ic-curva) forwards;
}
@keyframes ic-lugar { to { opacity: 1; letter-spacing: 0.24em; } }

/* Contador discreto + hilo de progreso */
.ic-pie {
  position: absolute;
  left: clamp(20px, 4vw, 56px);
  right: clamp(20px, 4vw, 56px);
  bottom: calc(10vh + 22px);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-display, "Work Sans", system-ui, sans-serif);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  animation: ic-aparece 0.8s 0.9s ease forwards;
}
@keyframes ic-aparece { to { opacity: 0.85; } }
.ic-hilo {
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--ic-texto) 18%, transparent);
  overflow: hidden;
}
.ic-hilo > span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ic-acento);
  transform: scaleX(0);
  transform-origin: left;
  animation: ic-hilo 2.7s 0.1s cubic-bezier(0.45, 0, 0.25, 1) forwards;
}
@keyframes ic-hilo { to { transform: scaleX(1); } }
.ic-cifra::before {
  content: counter(ic-n, decimal-leading-zero);
  counter-reset: ic-n var(--ic-num);
  animation: ic-contar 2.7s 0.1s cubic-bezier(0.45, 0, 0.25, 1) forwards;
}
@keyframes ic-contar { from { --ic-num: 0; } to { --ic-num: 100; } }

.ic-saltar {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 4;
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--font-display, "Work Sans", system-ui, sans-serif);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  color: var(--ic-texto);
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.ic-saltar:hover { opacity: 1; }

/* ---------------- SALIDA: inmersión ---------------- */
.intro-cine.salida {
  pointer-events: none;
  animation: ic-iris 1.45s 0.35s cubic-bezier(0.7, 0, 0.25, 1) forwards;
}
@keyframes ic-iris { from { --ic-r: -12%; } to { --ic-r: 100%; } }

/* La cámara atraviesa el logo */
.intro-cine.salida .ic-escena {
  animation: ic-vuelo 1.6s cubic-bezier(0.8, 0, 0.3, 1) forwards;
}
@keyframes ic-vuelo {
  0% { transform: scale(1); opacity: 1; filter: blur(0); }
  70% { opacity: 1; }
  100% { transform: scale(26); opacity: 0; filter: blur(14px); }
}
.intro-cine.salida .ic-pie,
.intro-cine.salida .ic-saltar {
  animation: ic-fuera 0.4s ease forwards;
}
@keyframes ic-fuera { to { opacity: 0; } }
.intro-cine.salida .ic-franja { animation: ic-franja-sale 0.9s 0.25s cubic-bezier(0.7, 0, 0.25, 1) forwards; }
@keyframes ic-franja-sale { from { transform: scaleY(1); } to { transform: scaleY(0); } }

/* La página llega con zoom desde dentro. cine.js marca con .ic-zoom solo los bloques
   visibles y no flotantes: así no se "enciende" nada que deba seguir oculto (toast, diálogos). */
html.ic-salida body > .ic-zoom {
  transform-origin: 50vw 50vh;
  animation: ic-pagina 1.9s 0.2s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
@keyframes ic-pagina {
  from { transform: scale(1.28); opacity: 0.2; }
  to { transform: scale(1); opacity: 1; }
}

html.ic-bloqueo { overflow: hidden; }

@media (max-width: 640px) {
  .ic-lugar { font-size: 9px; }
  .ic-franja { height: 7vh; }
  .ic-pie { bottom: calc(7vh + 18px); }
}

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