Fondo de lava CSS en móvil (WebGL solo en escritorio)
En móvil (<=768px) el shader WebGL queda negro, así que se monta en su lugar un fondo CSS con blobs difuminados naranja/magenta (mix-blend screen), animados con transform/opacity y respetando prefers-reduced-motion. Escritorio sigue usando el WebGL sin cambios; un switch con matchMedia decide cuál montar de forma reactiva. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ac6fdedf17
commit
a00a051da3
4 files changed
+150
-12
No files matched your search
+99
-9
@@ -90,18 +90,27 @@ body {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* ===== Fondo de lava (capas fijas) ===== */
|
||||
.lava-layer {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
/* ===== Fondo de lava: capa fija a pantalla completa, SIEMPRE detrás ===== */
|
||||
/* Dimensiones explícitas (no solo inset) para que el contenedor fixed tome el
|
||||
tamaño real del viewport en todos los navegadores (incl. móvil) y el canvas
|
||||
lo llene; z-index negativo para quedar detrás de la tarjeta/contenido sin
|
||||
ocupar espacio en el flujo. */
|
||||
.lava-layer,
|
||||
.lava-veil {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.lava-veil {
|
||||
/* El velo va encima de la lava (mismo z-index, va después en el DOM) pero
|
||||
sigue detrás del contenido. */
|
||||
background: radial-gradient(
|
||||
ellipse 95% 90% at 50% 60%,
|
||||
rgba(8, 4, 16, 0.05) 0%,
|
||||
@@ -109,6 +118,87 @@ body {
|
||||
);
|
||||
}
|
||||
|
||||
/* ===== Fondo de lava MÓVIL (CSS, sin WebGL) =====
|
||||
Blobs redondos difuminados, mezclados en "screen" sobre fondo oscuro;
|
||||
imitan el naranja→magenta del shader. Animación lenta (transform/opacity).
|
||||
Repartidos verticalmente para no amontonarse sobre la tarjeta. */
|
||||
.lava-mobile {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
background: #0a0613;
|
||||
}
|
||||
.lava-mobile__blob {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
filter: blur(70px);
|
||||
mix-blend-mode: screen;
|
||||
opacity: 0.85;
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
/* Naranja caliente, arriba-izquierda */
|
||||
.lava-mobile__blob--1 {
|
||||
width: 95vw;
|
||||
height: 95vw;
|
||||
left: -22vw;
|
||||
top: -8vh;
|
||||
background: radial-gradient(circle, #f97316 0%, rgba(249, 115, 22, 0) 68%);
|
||||
animation: lavaFloat1 26s ease-in-out infinite;
|
||||
}
|
||||
/* Magenta, banda media-derecha */
|
||||
.lava-mobile__blob--2 {
|
||||
width: 88vw;
|
||||
height: 88vw;
|
||||
right: -26vw;
|
||||
top: 28vh;
|
||||
background: radial-gradient(circle, #e82b7b 0%, rgba(232, 43, 123, 0) 68%);
|
||||
animation: lavaFloat2 32s ease-in-out infinite;
|
||||
}
|
||||
/* Rosa/naranja, abajo-izquierda */
|
||||
.lava-mobile__blob--3 {
|
||||
width: 78vw;
|
||||
height: 78vw;
|
||||
left: -18vw;
|
||||
bottom: -6vh;
|
||||
background: radial-gradient(circle, #ff3d90 0%, rgba(255, 61, 144, 0) 70%);
|
||||
animation: lavaFloat3 29s ease-in-out infinite;
|
||||
}
|
||||
/* Púrpura profundo, centro-bajo (da volumen sin saturar) */
|
||||
.lava-mobile__blob--4 {
|
||||
width: 70vw;
|
||||
height: 70vw;
|
||||
left: 22vw;
|
||||
bottom: 10vh;
|
||||
background: radial-gradient(circle, #4c1280 0%, rgba(76, 18, 128, 0) 72%);
|
||||
opacity: 0.7;
|
||||
animation: lavaFloat4 35s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes lavaFloat1 {
|
||||
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.8; }
|
||||
50% { transform: translate(6vw, 5vh) scale(1.12); opacity: 0.95; }
|
||||
}
|
||||
@keyframes lavaFloat2 {
|
||||
0%, 100% { transform: translate(0, 0) scale(1.05); opacity: 0.75; }
|
||||
50% { transform: translate(-7vw, -6vh) scale(0.92); opacity: 0.9; }
|
||||
}
|
||||
@keyframes lavaFloat3 {
|
||||
0%, 100% { transform: translate(0, 0) scale(0.95); opacity: 0.8; }
|
||||
50% { transform: translate(8vw, -7vh) scale(1.1); opacity: 0.92; }
|
||||
}
|
||||
@keyframes lavaFloat4 {
|
||||
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
|
||||
50% { transform: translate(-5vw, 4vh) scale(1.15); opacity: 0.78; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lava-mobile__blob {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Inputs ===== */
|
||||
.ci {
|
||||
width: 100%;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Source_Serif_4, Hanken_Grotesk } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import LavaBackground from "@/components/LavaBackground";
|
||||
import LavaBackgroundSwitch from "@/components/LavaBackgroundSwitch";
|
||||
|
||||
// Tipografías del diseño (Google Fonts vía next/font, expuestas como variables).
|
||||
const serif = Source_Serif_4({
|
||||
@@ -34,8 +34,8 @@ export default function RootLayout({
|
||||
className={`${serif.variable} ${hanken.variable} antialiased`}
|
||||
>
|
||||
<body>
|
||||
{/* Fondo de lava decorativo (capas fijas, detrás de todo) */}
|
||||
<LavaBackground />
|
||||
{/* Fondo de lava decorativo (WebGL en escritorio, CSS en móvil) */}
|
||||
<LavaBackgroundSwitch />
|
||||
<div className="lava-veil" aria-hidden />
|
||||
{children}
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Fondo de lava para MÓVIL — 100% CSS, sin WebGL. Imita el look del shader
|
||||
* (naranja + rosa/magenta sobre fondo oscuro) con blobs redondos difuminados
|
||||
* mezclados en "screen". Animación lenta solo con transform/opacity; se
|
||||
* detiene con prefers-reduced-motion (ver globals.css). Decorativo puro.
|
||||
*/
|
||||
|
||||
export default function LavaBackgroundMobile() {
|
||||
return (
|
||||
<div className="lava-mobile" aria-hidden>
|
||||
<span className="lava-mobile__blob lava-mobile__blob--1" />
|
||||
<span className="lava-mobile__blob lava-mobile__blob--2" />
|
||||
<span className="lava-mobile__blob lava-mobile__blob--3" />
|
||||
<span className="lava-mobile__blob lava-mobile__blob--4" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import LavaBackground from "./LavaBackground";
|
||||
import LavaBackgroundMobile from "./LavaBackgroundMobile";
|
||||
|
||||
/*
|
||||
* Decide qué fondo montar según el ancho de pantalla:
|
||||
* - Móvil (<= 768px): fondo CSS (LavaBackgroundMobile). El WebGL no se monta.
|
||||
* - Escritorio: el WebGL original (LavaBackground), idéntico a antes.
|
||||
* Reactivo al cambio de tamaño vía matchMedia. En el primer render (SSR /
|
||||
* pre-hidratación) no pinta nada para evitar desajuste de hidratación; el
|
||||
* fondo oscuro base (body) cubre ese instante.
|
||||
*/
|
||||
|
||||
const MOBILE_QUERY = "(max-width: 768px)";
|
||||
|
||||
export default function LavaBackgroundSwitch() {
|
||||
const [isMobile, setIsMobile] = useState<boolean | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia(MOBILE_QUERY);
|
||||
const update = () => setIsMobile(mq.matches);
|
||||
update();
|
||||
mq.addEventListener("change", update);
|
||||
return () => mq.removeEventListener("change", update);
|
||||
}, []);
|
||||
|
||||
if (isMobile === null) return null;
|
||||
return isMobile ? <LavaBackgroundMobile /> : <LavaBackground />;
|
||||
}
|
||||
Reference in new issue
Block a user