/* Colmena (humorosa.com) · página provisional
   Capas, de abajo arriba:
   1 .reserva  humo en CSS (sin JS, sin WebGL o si se pierde el contexto)
   2 .nombre   el nombre gigante
   3 .humo     canvas WebGL, transparente donde el humo es fino: pasa por delante de las letras
   4 .velo     oscurece arriba y abajo para que se lean etiqueta y pie
   5 .grano    grano fino
   6 resto del texto
*/

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-italic-latin.woff2") format("woff2");
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrainsmono-500-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  --ciruela: #0c0510;
  --ciruela-2: #1a0820;
  --magenta: #5a0b3d;
  --chicle: #ff3ea5;
  --rosa: #ff7ac3;
  --palo: #ffd0e8;
  --nata: #fff1f7;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --margen: clamp(18px, 3.2vw, 44px);
  --px: 0;
  --py: 0;
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ciruela);
  color: var(--nata);
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* El puntero y el tacto mueven el humo; se permite el zoom con dos dedos. */
  touch-action: pinch-zoom;
  -webkit-tap-highlight-color: transparent;
}

p {
  margin: 0;
}

/* ---------- 1 · humo de reserva en CSS ---------- */

.reserva {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 115%, rgba(255, 62, 165, 0.55), transparent 60%),
    radial-gradient(80% 60% at 50% 50%, rgba(90, 11, 61, 0.7), transparent 70%),
    var(--ciruela);
  transition: opacity 1.4s ease;
}

.reserva::before,
.reserva::after {
  content: "";
  position: absolute;
  inset: -30%;
  background:
    radial-gradient(28% 22% at 30% 70%, rgba(255, 62, 165, 0.55), transparent 70%),
    radial-gradient(24% 30% at 68% 62%, rgba(255, 122, 195, 0.42), transparent 70%),
    radial-gradient(18% 14% at 46% 40%, rgba(255, 208, 232, 0.22), transparent 70%),
    radial-gradient(30% 20% at 80% 30%, rgba(255, 62, 165, 0.25), transparent 70%),
    radial-gradient(26% 26% at 18% 28%, rgba(122, 18, 84, 0.6), transparent 70%);
  animation: deriva 26s ease-in-out infinite alternate;
}

.reserva::after {
  background:
    radial-gradient(22% 18% at 62% 78%, rgba(255, 208, 232, 0.2), transparent 70%),
    radial-gradient(30% 24% at 38% 58%, rgba(255, 62, 165, 0.35), transparent 70%),
    radial-gradient(20% 26% at 74% 44%, rgba(255, 122, 195, 0.28), transparent 70%),
    radial-gradient(34% 22% at 24% 86%, rgba(255, 62, 165, 0.45), transparent 70%);
  animation-duration: 34s;
  animation-direction: alternate-reverse;
  mix-blend-mode: screen;
}

@keyframes deriva {
  0% { transform: translate3d(-4%, 6%, 0) rotate(-4deg) scale(1); }
  50% { transform: translate3d(3%, -3%, 0) rotate(3deg) scale(1.08); }
  100% { transform: translate3d(-2%, -8%, 0) rotate(-2deg) scale(1.02); }
}

/* Con WebGL en marcha la reserva se apaga cuando el canvas ya ha pintado. */
.webgl-listo .reserva {
  opacity: 0;
}
.webgl-listo .reserva::before,
.webgl-listo .reserva::after {
  animation-play-state: paused;
}

/* ---------- 3 · canvas ---------- */

.humo {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.webgl-listo .humo {
  opacity: 1;
}

.sin-webgl .humo {
  display: none;
}

/* ---------- 4 · velo y 5 · grano ---------- */

.velo {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(12, 5, 16, 0.6), rgba(12, 5, 16, 0) 16%),
    linear-gradient(to top, rgba(12, 5, 16, 0.6), rgba(12, 5, 16, 0) 16%),
    radial-gradient(150% 110% at 50% 50%, transparent 60%, rgba(12, 5, 16, 0.4));
}

.grano {
  position: fixed;
  inset: -50%;
  z-index: 4;
  pointer-events: none;
  background-image: url("../img/grano.png");
  background-size: 160px 160px;
  opacity: 0.06;
  mix-blend-mode: overlay;
  animation: grano 0.9s steps(5) infinite;
}

@keyframes grano {
  0% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-7%, 4%, 0); }
  40% { transform: translate3d(5%, -9%, 0); }
  60% { transform: translate3d(-11%, -3%, 0); }
  80% { transform: translate3d(9%, 7%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* ---------- composición ---------- */

.escena {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding:
    max(var(--margen), env(safe-area-inset-top))
    max(var(--margen), env(safe-area-inset-right))
    max(var(--margen), env(safe-area-inset-bottom))
    max(var(--margen), env(safe-area-inset-left));
  text-align: center;
  pointer-events: none;
}

.escena a {
  pointer-events: auto;
}

.etiqueta,
.pie {
  position: relative;
  z-index: 5;
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(0.68rem, 0.62rem + 0.25vw, 0.8rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--palo);
  text-shadow: 0 0 14px rgba(12, 5, 16, 0.9), 0 1px 2px rgba(12, 5, 16, 0.9);
}

.etiqueta {
  display: inline-flex;
  align-items: center;
  gap: 0.85em;
  padding: 0.7em 1.15em 0.7em 1em;
  border: 1px solid rgba(255, 208, 232, 0.22);
  border-radius: 999px;
  background: rgba(12, 5, 16, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: aparece 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s both;
}

.punto {
  position: relative;
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  background: var(--chicle);
  box-shadow: 0 0 10px var(--chicle);
}

.punto::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--chicle);
  animation: late 1.8s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

@keyframes late {
  0% { transform: scale(1); opacity: 0.8; }
  70%, 100% { transform: scale(3.2); opacity: 0; }
}

.centro {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ---------- el nombre ---------- */

.nombre {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 900;
  /* «Colmena» mide unas 3,9 em: 21vw deja aire a los lados también a 390 px */
  font-size: min(21vw, 40vh);
  line-height: 0.86;
  letter-spacing: -0.025em;
  color: var(--nata);
  white-space: nowrap;
}

.letras {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  /* el cursivo se sale por la derecha: compensar para que quede centrado a ojo */
  padding-right: 0.05em;
}

.l {
  display: inline-block;
  translate: calc(var(--px) * var(--k, 1) * 1px) calc(var(--py) * var(--k, 1) * 1px);
  animation: respira 6.5s ease-in-out infinite;
}

.l > span {
  display: inline-block;
  text-shadow: 0 0 0.12em rgba(255, 62, 165, 0.35);
  animation: condensa 1s cubic-bezier(0.16, 0.8, 0.24, 1) both;
}

.l:nth-child(1) { --k: 0.6; animation-delay: 0s; }
.l:nth-child(2) { --k: 1.1; animation-delay: -0.9s; }
.l:nth-child(3) { --k: 0.8; animation-delay: -1.8s; }
.l:nth-child(4) { --k: 1.3; animation-delay: -2.7s; }
.l:nth-child(5) { --k: 0.9; animation-delay: -3.6s; }
.l:nth-child(6) { --k: 1.4; animation-delay: -4.5s; }
.l:nth-child(7) { --k: 0.7; animation-delay: -5.4s; }

.l:nth-child(1) > span { animation-delay: 0.15s; }
.l:nth-child(2) > span { animation-delay: 0.24s; }
.l:nth-child(3) > span { animation-delay: 0.33s; }
.l:nth-child(4) > span { animation-delay: 0.42s; }
.l:nth-child(5) > span { animation-delay: 0.51s; }
.l:nth-child(6) > span { animation-delay: 0.6s; }
.l:nth-child(7) > span { animation-delay: 0.69s; }

@keyframes condensa {
  0% {
    opacity: 0;
    filter: blur(0.14em);
    transform: translate3d(0, 0.32em, 0) scale(1.18, 0.9) skewX(-8deg);
  }
  45% {
    opacity: 0.75;
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: none;
  }
}

@keyframes respira {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(0, -0.025em, 0) rotate(-1.2deg); }
}

.frase {
  position: relative;
  z-index: 5;
  margin-top: clamp(0.6rem, 2.2vh, 1.6rem);
  font-family: var(--display);
  font-style: italic;
  font-weight: 480;
  font-size: clamp(1.15rem, 0.7rem + 1.7vw, 2.1rem);
  letter-spacing: 0.005em;
  color: var(--nata);
  text-shadow:
    0 0 18px rgba(12, 5, 16, 0.85),
    0 0 4px rgba(12, 5, 16, 0.7),
    0 1px 1px rgba(12, 5, 16, 0.6);
  animation: aparece 1s cubic-bezier(0.2, 0.7, 0.2, 1) 1.05s both;
}

.pie {
  align-self: end;
  animation: aparece 1s cubic-bezier(0.2, 0.7, 0.2, 1) 1.3s both;
}

.pie a {
  color: var(--nata);
  text-decoration: none;
  background-image: linear-gradient(var(--chicle), var(--chicle));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 0.2em;
  transition: background-size 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), color 0.25s ease;
}

.pie a:hover {
  color: #ffffff;
  background-size: 100% 0.32em;
}

.pie a:focus-visible {
  outline: 2px solid var(--chicle);
  outline-offset: 3px;
  border-radius: 3px;
}

@keyframes aparece {
  from {
    opacity: 0;
    filter: blur(6px);
    transform: translate3d(0, 0.6em, 0);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: none;
  }
}

.solo-lectores {
  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;
}

/* ---------- móvil en vertical: algo más de aire bajo el nombre ---------- */

@media (max-aspect-ratio: 4/5) {
  .frase {
    margin-top: clamp(0.9rem, 2.6vh, 1.8rem);
  }
}

/* ---------- movimiento reducido: todo quieto ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .l {
    translate: none;
  }
}
