:root {
    --negro: #1d1d1f;
    --gris: #7d8a96;
    --claro: #f2f7fb;
    --azul: #0a84ff;
    --hielo: #64d2ff;
    --escarcha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.8 0 0 0 0 0.92 0 0 0 0 1 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23f)'/%3E%3C/svg%3E");
    --muelle: cubic-bezier(0.32, 0.72, 0, 1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: var(--negro);
    background-color: #01050a;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

.barra {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background-color: rgba(238, 246, 252, 0.68);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    transition: background-color 0.4s ease, color 0.4s ease;
}

.barra.oscura {
    background-color: rgba(6, 12, 20, 0.68);
    border-bottom-color: rgba(100, 210, 255, 0.12);
    color: var(--claro);
}

.barra-dentro {
    max-width: 1000px;
    height: 48px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.marca {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.curso {
    font-size: 13px;
    opacity: 0.8;
}

.portada {
    height: 180vh;
    background-color: var(--claro);
    background-image: radial-gradient(ellipse at 50% 0%, #ddeefa 0%, transparent 60%),
                      radial-gradient(ellipse at 50% 100%, #e3f1fb 0%, transparent 55%);
}

.portada-pegada::after,
.ejercicio-pegado::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: var(--escarcha);
    opacity: 0.35;
    box-shadow: inset 0 0 140px rgba(150, 205, 240, 0.45);
}

.ejercicio-pegado::after {
    opacity: 0.06;
    box-shadow: inset 0 0 180px rgba(100, 210, 255, 0.12);
}

.portada-pegada {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.portada-texto {
    text-align: center;
    will-change: transform, opacity, filter;
}

h1 {
    margin: 0;
    font-size: clamp(110px, 22vw, 320px);
    font-weight: 700;
    letter-spacing: -0.06em;
    line-height: 0.9;
    background-image: linear-gradient(100deg, #1d1d1f 0%, #1d1d1f 35%, #3aa8e8 46%, #a8e2ff 50%, #3aa8e8 54%, #1d1d1f 65%, #1d1d1f 100%);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: entrar 1.4s var(--muelle) both, brillo 6s ease-in-out 1.4s infinite;
}

.subtitulo {
    margin: 20px 0 0;
    font-size: clamp(22px, 2.8vw, 36px);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--gris);
    animation: entrar 1.4s var(--muelle) 0.2s both;
}

.bajar {
    position: absolute;
    bottom: 36px;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--gris);
    translate: -50% 0;
    animation: entrar 1.4s var(--muelle) 0.6s both;
}

.bajar svg {
    animation: flotar 2.4s ease-in-out infinite;
}

.ejercicio {
    height: 260vh;
    background-color: #01050a;
}

.ejercicio-pegado {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 0 22px;
    background-image: radial-gradient(ellipse at 50% 115%, rgba(100, 210, 255, 0.16) 0%, transparent 60%),
                      radial-gradient(ellipse at 50% -20%, rgba(10, 132, 255, 0.1) 0%, transparent 55%);
}

.ejercicio-titulo {
    margin: 0;
    font-size: clamp(90px, 19vw, 300px);
    font-weight: 700;
    letter-spacing: -0.06em;
    line-height: 0.9;
    background-image: linear-gradient(90deg, #0a84ff, #64d2ff, #eaf8ff, #64d2ff, #0a84ff);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: recorrer 10s linear infinite;
    will-change: transform, opacity;
}

.ejercicio-titulo.largo {
    font-size: clamp(40px, 10vw, 160px);
}

.ejercicio-texto {
    margin: 28px 0 36px;
    font-size: clamp(20px, 2.4vw, 28px);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--gris);
}

.ejercicio-texto,
.ejercicio .boton {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 1s var(--muelle);
}

.ejercicio.lleno .ejercicio-texto,
.ejercicio.lleno .boton {
    opacity: 1;
    transform: none;
}

.ejercicio.lleno .boton {
    transition-delay: 0.12s;
}

.boton {
    display: inline-block;
    padding: 16px 32px;
    font-size: 19px;
    letter-spacing: -0.02em;
    color: white;
    background-color: rgba(100, 210, 255, 0.14);
    border: 1px solid rgba(180, 230, 255, 0.35);
    border-radius: 980px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 30px rgba(100, 210, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.ejercicio.lleno .boton:hover {
    background-color: rgba(100, 210, 255, 0.24);
}

.ejercicio.lleno .boton:active {
    transform: scale(0.95);
    transition: transform 0.1s ease-out;
}

.boton:focus-visible,
.bajar:focus-visible,
.marca:focus-visible {
    outline: 3px solid rgba(100, 210, 255, 0.6);
    outline-offset: 4px;
    border-radius: 8px;
}

.pinguinos {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    --cuerpo: #1d1d1f;
    --tripa: white;
    --pico: #ff9f0a;
    opacity: 0.12;
}

.ejercicio .pinguinos {
    --cuerpo: white;
    --tripa: black;
    --pico: white;
    opacity: 0.15;
}

.pinguino {
    position: absolute;
    left: 0;
    animation: correr linear infinite;
}

.pinguino svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.pinguino svg * {
    transform-box: fill-box;
}

.pinguino.al-reves {
    animation-direction: reverse;
}

.pinguino.al-reves svg {
    scale: -1 1;
}

.p-todo {
    transform-origin: 50% 100%;
    animation: balanceo calc(var(--paso) * 2) ease-in-out infinite;
}

.p-pata {
    transform-origin: 30% 0%;
    animation: paso calc(var(--paso) * 2) ease-in-out infinite;
}

.p-aleta {
    transform-origin: 50% 5%;
    animation: aleteo calc(var(--paso) * 2) ease-in-out infinite;
}

.p-pata-atras,
.p-aleta-atras {
    animation-delay: calc(var(--paso) * -1);
}

.p-cola {
    transform-origin: 100% 0%;
    animation: cola var(--paso) ease-in-out infinite alternate;
}

.p-pico-abajo {
    transform-origin: 0% 0%;
    animation: pico-abajo var(--pico-ritmo) ease-in-out var(--pico-retraso) infinite;
}

.p-pico-arriba {
    transform-origin: 0% 100%;
    animation: pico-arriba var(--pico-ritmo) ease-in-out var(--pico-retraso) infinite;
}

.p-ojo {
    transform-origin: 50% 50%;
    animation: parpadeo 4s var(--pico-retraso) infinite;
}

.familia {
    position: absolute;
    left: 0;
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 6px;
    animation: pasar-familia linear both;
}

.familia.al-reves {
    flex-direction: row;
    animation-direction: reverse;
}

.familia .pinguino {
    position: static;
    animation: none;
}

@keyframes pasar-familia {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100vw);
    }
}

@keyframes correr {
    from {
        transform: translateX(-60px);
    }
    to {
        transform: translateX(calc(100vw + 60px));
    }
}

@keyframes balanceo {
    0%, 100% {
        transform: rotate(-5deg);
    }
    25%, 75% {
        transform: translateY(-1.5px);
    }
    50% {
        transform: rotate(5deg);
    }
}

@keyframes paso {
    0%, 100% {
        transform: translate(-3px, 0);
    }
    25% {
        transform: translate(0, -2.5px) rotate(-15deg);
    }
    50% {
        transform: translate(3px, 0);
    }
    75% {
        transform: translate(0, 0) rotate(5deg);
    }
}

@keyframes aleteo {
    0%, 100% {
        transform: rotate(5deg);
    }
    50% {
        transform: rotate(35deg);
    }
}

@keyframes cola {
    from {
        transform: rotate(-8deg);
    }
    to {
        transform: rotate(8deg);
    }
}

@keyframes pico-abajo {
    0%, 70%, 100% {
        transform: rotate(0);
    }
    76% {
        transform: rotate(22deg);
    }
    82% {
        transform: rotate(4deg);
    }
    88% {
        transform: rotate(18deg);
    }
    94% {
        transform: rotate(0);
    }
}

@keyframes pico-arriba {
    0%, 70%, 94%, 100% {
        transform: rotate(0);
    }
    76%, 88% {
        transform: rotate(-6deg);
    }
}

@keyframes parpadeo {
    0%, 92%, 100% {
        transform: scaleY(1);
    }
    96% {
        transform: scaleY(0.1);
    }
}

@keyframes entrar {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.94);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: none;
        filter: blur(0);
    }
}

@keyframes brillo {
    0%, 100% {
        background-position: 100% 0;
    }
    50% {
        background-position: 0% 0;
    }
}

@keyframes recorrer {
    to {
        background-position: 200% 0;
    }
}

@keyframes flotar {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(6px);
    }
}

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

    html {
        scroll-behavior: auto;
    }

    h1,
    .subtitulo,
    .bajar,
    .bajar svg,
    .ejercicio-titulo {
        animation: none;
    }

    .ejercicio-texto,
    .ejercicio .boton {
        transform: none;
        transition: opacity 0.3s;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .barra {
        background-color: var(--claro);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .barra.oscura {
        background-color: #161617;
    }
}
