/* Atyp Display: se usa la copia instalada si existe; si no, los archivos de assets/fonts.
   Atención: Atyp es una tipografía con licencia; para web hace falta licencia de uso web. */
@font-face {
  font-family: "Atyp Display";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: local("Atyp Display Bold"), local("AtypDisplay-Bold"), url("../fonts/AtypDisplay-Bold.woff2") format("woff2");
}

/* ==========================================================================
   Grafil - Próximamente
   Todos los parámetros de ubicación de la impresora y el papel están en :root.
   Las coordenadas son fracciones de la imagen printer.png (1844 x 1192 px).
   ========================================================================== */

:root {
  /* --- Colores --- */
  --bg: #000000;
  --ink: #1c1c1c;
  --accent: #e8272b;            /* tachado y detalles, tomado del logo */
  --paper-color: #fbf8f1;       /* blanco ligeramente cálido */

  /* --- Impresora --- */
  --printer-ratio: calc(1844 / 1192);

  /* --- Ranura de salida (porcentajes sobre la imagen) --- */
  --slot-y: 57.4%;              /* borde inferior del cuerpo frontal */
  --paper-w: 42%;             /* ancho de la hoja respecto al ancho de la máquina */
  --paper-h: 41%;               /* alto de la hoja respecto al alto de la máquina */

  /* --- Tipografía del papel (en cqw: relativa al ancho de la hoja) --- */
  --font-title: 5.8cqw;
  --font-note: 2.6cqw;

}


*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); overflow: hidden; height: 100%; touch-action: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Escenario ---------- */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.scene {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
}

.scene { overflow: visible; }

/* Mundo: foto del taller. Cubre el viewport, pero nunca tan grande que la impresora supere ~92% del ancho. */
.world {
  --ww: min(max(100vw, calc(100svh * 2752 / 1536)), 245vw);
  --wh: calc(var(--ww) * 1536 / 2752);
  position: absolute;
  width: var(--ww);
  height: var(--wh);
  left: calc(50% - var(--ww) / 2);
  top: calc(50% - var(--wh) / 2);
}
.world__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  /* en pantallas altas se funde con el relleno borroso */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 9%, #000 91%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 9%, #000 91%, transparent 100%);
}
/* el video lleva el mismo fundido en pantallas altas */
.world__video {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 9%, #000 91%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 9%, #000 91%, transparent 100%);
}
@media (min-aspect-ratio: 9/10) {
  .world__img, .world__video { -webkit-mask-image: none; mask-image: none; }
}


/* Posición de la impresora sobre la foto (porcentajes del mundo).
   Ancho 30% = tamaño; top = altura (los pies quedan en ~76% del alto de la foto). */
.machine {
  position: absolute;
  left: 35%;
  top: 41.3%;
  width: 30%;
  aspect-ratio: 1844 / 1192;
}

/* Sombra de contacto en el piso */
.machine__shadow {
  position: absolute;
  left: 2%; right: 2%; bottom: -3%; height: 9%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.6), rgba(0,0,0,0) 70%);
  filter: blur(6px);
  pointer-events: none;
}

.machine__img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Ranura y papel ---------- */

.gate {
  position: absolute;
  left: calc(50% - var(--paper-w) / 2);
  top: var(--slot-y);
  width: var(--paper-w);
  height: var(--paper-h);
  /* Recorta el borde superior (dentro de la máquina) y deja libres los otros lados para la sombra. */
  clip-path: inset(0 -14% -8% -14%);
}

.paper-fx {
  position: absolute; inset: 0;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.2)) drop-shadow(0 1px 1.5px rgba(0,0,0,.3));
}

.paper {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  background:
    linear-gradient(90deg, rgba(0,0,0,.035), transparent 6%, transparent 94%, rgba(0,0,0,.04)),
    var(--paper-color);
  transform-origin: 50% 0;
}

.paper__ink {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3.4cqw;
  padding: 4cqw 5cqw 7cqw;
  text-align: center;
}

.paper__logo {
  width: 26cqw;
  height: auto;
}

.paper__tag {
  margin: -1.2cqw 0 0;
  font-size: 2.2cqw;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
}

.paper__title {
  margin: 0;
  font-size: var(--font-title);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
}

.line { display: block; white-space: nowrap; }
.line--swap { font-weight: 700; }

.old, .new { text-decoration: none; position: relative; display: inline-block; }
.old { color: #6c6c6c; }
.new { color: var(--ink); }

/* Línea de tachado: se dibuja de izquierda a derecha */
.old::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  top: 56%;
  height: .09em;
  background: var(--accent);
  transform: scaleX(var(--strike, 1));   /* animada por GSAP: 0 -> 1 */
  transform-origin: 0 50%;
}

.paper__note {
  margin: 0;
  font-size: var(--font-note);
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #7a7a7a;
}

/* Sombra que proyecta el cuerpo de la impresora sobre el papel que sale */
.gate__shade {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 7%;
  background: linear-gradient(rgba(0,0,0,.32), rgba(0,0,0,0));
  pointer-events: none;
}

/* ---------- Estados iniciales de la animación (solo si hay JS y no hay movimiento reducido) ---------- */

.is-anim .machine { opacity: 0; }
.is-anim .scroll-hint { opacity: 0; }

/* ---------- Indicador de scroll ---------- */

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 22px;
  height: 36px;
  padding: 0;
  background: none;
  cursor: pointer;
  margin-left: -11px;
  border: 1.5px solid rgba(255,255,255,.6);
  border-radius: 12px;
}
.scroll-hint span {
  position: absolute;
  left: 50%; top: 7px;
  width: 3px; height: 7px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: rgba(255,255,255,.75);
  animation: hint 1.8s ease-in-out infinite;
}
@keyframes hint {
  0%   { transform: translateY(0); opacity: 1; }
  70%  { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- Botón de sonido ---------- */

.sound {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 40px; height: 40px;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
  color: rgba(0,0,0,.55);
  cursor: pointer;
  transition: color .2s, background .2s;
}
.sound:hover, .sound:focus-visible { color: var(--ink); background: #fff; }
.sound:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sound .sound__waves { display: none; }
.sound[aria-pressed="true"] .sound__waves { display: inline; }
.sound[aria-pressed="true"] .sound__mute { display: none; }

@media (prefers-reduced-motion: reduce) {
  .scroll-hint span { animation: none; }
}

/* ---------- Fondo de video (aparece al hacer scroll) ---------- */

.bgvideo {
  position: absolute;
  inset: 0;
  opacity: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #3a3a3a, #121212);
  pointer-events: none;
}
.bgvideo video,
.bgvideo iframe {
  position: absolute;
  left: 50%; top: 50%;
  min-width: 100%; min-height: 100%;
  transform: translate(-50%, -50%) scale(1.1);   /* escala para ocultar los bordes del desenfoque */
  filter: blur(14px);
  border: 0;
  object-fit: cover;
}
.bgvideo iframe { width: max(100vw, 177.78svh); height: max(56.25vw, 100svh); }
.bgvideo::after {            /* velo oscuro para que la hoja destaque */
  content: "";
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
}
.scene { z-index: 1; }

/* ---------- Botón flotante de WhatsApp ---------- */

.wa {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
.wa__menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.wa__menu[hidden] { display: none; }
.wa__menu a {
  display: block; padding: 10px 16px; border-radius: 999px;
  background: #fff; color: #1c1c1c; text-decoration: none;
  font: 600 14px/1 "Montserrat", system-ui, sans-serif;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  transition: background .2s, color .2s;
}
.wa__menu a:hover, .wa__menu a:focus-visible { background: #25d366; color: #fff; outline: none; }

.whatsapp {
  border: 0; padding: 0; cursor: pointer;
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
}
.whatsapp:hover, .whatsapp:focus-visible { transform: scale(1.07); box-shadow: 0 6px 18px rgba(0,0,0,.32); }
.whatsapp:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.sound { z-index: 10; }
.scroll-hint { z-index: 5; }

/* ---------- Detalles de papel impreso / rasgado ---------- */

/* Textura de fibra */
.paper::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* Marcas de corte en las esquinas */
.paper__marks {
  position: absolute; inset: 2.6cqw; pointer-events: none;
  --m: 2.6cqw; --c: #b9b3a4;
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / var(--m) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) 0 0 / 1px var(--m) no-repeat,
    linear-gradient(var(--c), var(--c)) 100% 0 / var(--m) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) 100% 0 / 1px var(--m) no-repeat;
}

/* Barra de color CMYK */
.paper__cmyk {
  position: absolute; right: 6cqw; bottom: 8.4cqw;
  display: flex; gap: .8cqw;
}
.paper__cmyk i { width: 1.8cqw; height: 1.8cqw; border-radius: 50%; display: block; }
.paper__cmyk i:nth-child(1) { background: #26a9e0; }
.paper__cmyk i:nth-child(2) { background: #e5007d; }
.paper__cmyk i:nth-child(3) { background: #ffd400; }
.paper__cmyk i:nth-child(4) { background: #222; }

/* Borde rasgado: fibras claras junto al corte (el recorte irregular lo genera main.js) */
.paper__fibers {
  position: absolute; left: 0; right: 0; bottom: 0; height: 6%;
  background: linear-gradient(to top, #fff, rgba(255,255,255,0));
  pointer-events: none;
}


/* Texto solo para buscadores y lectores de pantalla */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Video opcional del taller (reemplaza a la foto cuando carga) */
.world__video {
  position: absolute; inset: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.world__video video,
.world__video iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border: 0;
}

/* ---------- Botón "Ver video" y ventana emergente ---------- */

.watch {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 6;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px;
  border: 0; border-radius: 999px;
  background: #fff; color: #1c1c1c;
  font: 600 15px/1 "Montserrat", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  opacity: 0; visibility: hidden;      /* lo muestra el salto a la hoja */
  transition: background .2s, color .2s;
}
.watch svg { color: var(--accent); transition: color .2s; }
.watch:hover, .watch:focus-visible { background: var(--accent); color: #fff; outline: none; }
.watch:hover svg, .watch:focus-visible svg { color: #fff; }

.modal {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(0,0,0,.9);
}
.modal[hidden] { display: none; }
.modal__frame {
  width: min(90vw, calc(90svh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
}
.modal__frame iframe, .modal__frame video { width: 100%; height: 100%; border: 0; display: block; }
.modal__close {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right));
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}
.modal__close:hover, .modal__close:focus-visible { background: rgba(255,255,255,.28); outline: none; }

/* ---------- Frases con efecto máquina de escribir ---------- */

.ticker {
  position: absolute;
  left: 50%;
  bottom: 59.5%;                         /* apoya justo sobre la impresora (que empieza en 41.3% desde arriba) */
  transform: translateX(-50%);
  width: min(94%, 96vw);
  margin: 0;
  text-align: center;
  font-family: "Atyp Display", "Montserrat", system-ui, sans-serif;
  font-weight: 700;
  font-size: min(calc(var(--ww) * 0.06), 11.5vw);
  line-height: 1.02;
  letter-spacing: .01em;
  text-transform: uppercase;
  text-wrap: balance;
  color: #fff;
  pointer-events: none;
}
.ticker__caret {
  display: inline-block;
  width: .07em; height: .95em;
  margin-left: .12em;
  vertical-align: -.12em;
  background: #fff;
  animation: caret 0.8s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ticker__caret { animation: none; } }
