@layer reset, fonts, tokens, foundation, layout, components;

@layer reset {

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

    html {
        scroll-behavior: smooth;
    }

    body {
        margin: 0;
        min-height: 100dvh;
    }

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

@layer fonts {
    @font-face {
        font-family: "Geist Mono";
        src: url("/fonts/GeistMono/GeistMono-VariableFont_wght.ttf") format("truetype");
        font-weight: 100 900;
        font-style: normal;
        font-display: swap;
    }

    @font-face {
        font-family: "Geist Mono";
        src: url("/fonts/GeistMono/GeistMono-Italic-VariableFont_wght.ttf") format("truetype");
        font-weight: 100 900;
        font-style: italic;
        font-display: swap;
    }

    @font-face {
        font-family: "Poppins";
        src: url("/fonts/Poppins/Poppins-Regular.woff2") format("woff2");
        font-weight: 400;
        font-style: normal;
        font-display: swap;
    }

    @font-face {
        font-family: "Poppins";
        src: url("/fonts/Poppins/Poppins-SemiBold.woff2") format("woff2");
        font-weight: 600;
        font-style: normal;
        font-display: swap;
    }
}

@layer tokens {
    :root {
        --palette-brand-primary: #FEC246;
        --palette-neutral-1000: #070210;
        --font-family-base: "Poppins", system-ui, sans-serif;
        --font-family-heading: "Geist Mono", monospace;
        --font-family-brand: "Geist Mono", monospace;
        --color-background: linear-gradient(156deg, #120825 10%, #070210 35%);
        --color-text: oklch(98% 0 0);
        --color-text-secondary: oklch(75% 0 0);
        --color-brand: var(--palette-brand-primary);
        --space-sm: 1rem;
        --space-md: 1.5rem;
        --space-xl: 4rem;
        --radius-full: 999px;
    }
}

@layer foundation {
    body {
        background: var(--color-background);
        color: var(--color-text);
        font-family: var(--font-family-base);
    }

    h1 {
        margin: 0;
        font-family: var(--font-family-heading);
        font-size: clamp(4rem, 10vw, 8.5rem);
        font-weight: 800;
        line-height: .9;
        letter-spacing: -.06em;
    }

    p {
        margin: 0;
    }
}

@layer layout {
    .container {
        width: 100%;
        max-width: 75rem;
        padding-inline: var(--space-md);
        margin-inline: auto;

        @media (min-width: 48rem) {
            padding-inline: var(--space-xl);
        }
    }

    .hero-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--space-xl);
        align-items: stretch;

        @media (min-width: 64rem) {
            grid-template-columns: 1fr 1fr;
            gap: clamp(1rem, 5vw, 1rem);
        }
    }

    .hero-right-column {
        display: flex;
        flex-direction: column-reverse;
        gap: var(--space-xl);
        width: 100%;

        @media (min-width: 64rem) {
            flex-direction: column;
                justify-content: flex-end;
        }
    }
}

@layer components {

    .hero-content>*,
    .hero-metadata>*,
    .hero-canvas {
        animation-duration: 0.8s;
        animation-fill-mode: both;
        animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
    }

    .hero {
        min-height: 100dvh;
        display: grid;
        align-items: center;
        padding-block: var(--space-xl);
    }

    .hero-content {
        display: flex;
        flex-direction: column;

        /* El eyebrow aparece primero */
        .eyebrow {
            animation-name: revealUp;
            animation-delay: 0.6s;
        }

        /* El logo/brand segundo */
        .brand svg {
            width: 100%;
            max-width: 12rem;
            height: auto;
            /* Combina la entrada fluida con tu animación sutil infinita existente */
            animation: revealUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both, subtleScale 8s ease-in-out infinite;

            @media (min-width: 48rem) {
                max-width: 15rem;
            }
        }

        /* El rol profesional tercero */
        .hero-role {
            animation-name: revealUp;
            animation-delay: 0.3s;
            /* Tus estilos se mantienen intactos... */
            font-family: var(--font-family-brand);
            font-size: clamp(1rem, 2vw, 1.25rem);
            color: var(--color-brand);
            line-height: 1.4;
            display: flex;
            flex-direction: column;
            gap: 0.25rem;

            span {
                display: inline-flex;
                align-items: center;
                gap: 0.75rem;

                &::before {
                    content: "";
                    width: 4px;
                    height: 4px;
                    background-color: var(--color-text);
                    border-radius: 50%;
                    display: inline-block;
                    opacity: 0.85;
                    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
                }
            }
        }

        /* La descripción cuarta */
        .hero-description {
            animation-name: revealUp;
            animation-delay: 0.4s;
            max-width: 35rem;
            margin-block: calc(var(--space-md) + 1.5rem);
            color: var(--color-text-secondary);
            font-size: 1.1rem;
            line-height: 1.6;
        }

        /* El contacto al final de la primera columna */
        .contact {
            animation-name: revealUp;
            animation-delay: 0.5s;
            margin-top: var(--space-xl);

            a {
                font-family: var(--font-family-brand);
                color: var(--color-brand);
                font-size: 1rem;
                font-weight: 400;
                border-bottom: 1px solid rgba(254, 194, 70, 0.3);
                padding-bottom: 4px;
                transition: opacity .2s ease;

                &:hover {
                    opacity: .75;
                }
            }
        }
    }

    .hero-role {
        font-family: var(--font-family-brand);
        font-size: clamp(1rem, 2vw, 1.25rem);
        color: var(--color-brand);
        line-height: 1.4;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;

        span {
            display: inline-flex;
            align-items: center;
            gap: 0.75rem;

            &::before {
                content: "";
                width: 4px;
                height: 4px;
                background-color: var(--color-text);
                border-radius: 50%;
                display: inline-block;
                opacity: 0.85;
                box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
            }
        }
    }

    .hero-description {
        max-width: 35rem;
        margin-top: var(--space-xl);
        color: var(--color-text-secondary);
        font-size: 1.1rem;
        line-height: 1.6;
    }

    .contact {
        margin-top: var(--space-xl);

        a {
            font-family: var(--font-family-brand);
            color: var(--color-brand);
            font-size: 1rem;
            font-weight: 400;
            border-bottom: 1px solid rgba(254, 194, 70, 0.3);
            padding-bottom: 4px;
            transition: opacity .2s ease;

            &:hover {
                opacity: .75;
            }
        }
    }

    .hero-metadata {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-md);
        justify-content: flex-start;

        @media (min-width: 64rem) {
            flex-direction: column;
            align-items: flex-end;
            text-align: right;
            gap: var(--space-sm);
        }

        /* Animamos secuencialmente los items de metadata */
        .meta-item:nth-child(1) {
            animation-name: revealRight;
            animation-delay: 0.4s;
        }

        .meta-item:nth-child(2) {
            animation-name: revealRight;
            animation-delay: 0.5s;
        }

        .meta-item:nth-child(3) {
            animation-name: revealRight;
            animation-delay: 0.6s;
        }
    }

    .hero-canvas {
        animation-name: revealUp;
        animation-delay: 0.6s;
        /* El canvas entra majestuosamente al final */
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        perspective: 1000px;
    }

    .meta-item {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .meta-label {
        font-family: var(--font-family-brand);
        font-size: 0.75rem;
        letter-spacing: 0.1em;
        color: var(--color-brand);
        opacity: 0.8;
    }

    .meta-value {
        font-family: var(--font-family-brand);
        font-size: 0.95rem;
        color: var(--color-text-secondary);
    }

    .hero-canvas {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        perspective: 1000px;
    }

    @keyframes revealUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes revealRight {
        from {
            opacity: 0;
            transform: translateX(30px);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .ui-blueprint {
        --mx: 0deg;
        --my: 0deg;
        --guide-x: 0px;
        --guide-y: 0px;
        position: relative;
        width: 100%;
        max-width: 50rem;
        background: rgba(7, 2, 16, 0.6);
        border: 1px solid rgba(254, 194, 70, .3);
        border-radius: 10px;
        padding: var(--space-md);
        padding-block-end: calc(var(--space-md) + 0.75rem);
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        overflow: hidden;
        backdrop-filter: blur(8px);

        @media (min-width: 64rem) {
            aspect-ratio: 4 / 3;
            overflow: visible;
            transform: rotateX(var(--mx)) rotateY(var(--my));
            transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.4s ease;

            &:hover {
                border-color: rgba(254, 194, 70, 0.6);

                .ui-element {
                    border-color: rgba(254, 194, 70, 0.15);
                }

                .layout-guide-x, .layout-guide-y {
                    opacity: 0.5;
                }
            }
        }
    }

    .layout-guide-x, .layout-guide-y {
        position: absolute;
        background: var(--color-brand);
        opacity: 0;
        z-index: 1;
        will-change: transform;
        pointer-events: none;
        transition: opacity 0.4s ease;

        @media (min-width: 64rem) {
            opacity: 0.06;
        }
    }

    .layout-guide-x {
        top: 0;
        bottom: 0;
        left: 0;
        width: 1px;
        border-left: 1px dashed white;

        @media (min-width: 64rem) {
            transform: translateX(var(--guide-x));
        }
    }

    .layout-guide-y {
        left: 0;
        right: 0;
        top: 0;
        height: 1px;
        border-top: 1px dashed white;

        @media (min-width: 64rem) {
            transform: translateY(var(--guide-y));
        }
    }

    .grid-backdrop {
        position: absolute;
        inset: 0;
        background-image:
            linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
        background-size: 20px 20px;
        z-index: 0;
    }

    .ui-element {
        position: relative;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.002);
        transition: all 0.3s ease;
        z-index: 2;

        &:hover {
            border-color: var(--color-brand) !important;
            background: rgba(254, 194, 70, 0.05) !important;
            box-shadow: 0 0 12px rgba(254, 194, 70, 0.05);

            &::after {
                opacity: 1;
                transform: translateY(0);
            }
        }

        &::after {
            content: attr(data-label);
            position: absolute;
            top: 2px;
            left: 6px;
            font-family: var(--font-family-brand);
            font-size: 0.75rem;
            letter-spacing: 0.05em;
            color: white;
            opacity: 0;
            pointer-events: none;
            transform: translateY(-2px);
            transition: opacity 0.25s ease, transform 0.25s ease;
        }
    }

    .header-block {
        height: 2rem;
        width: 50%;

        @media (min-width: 64rem) {
            height: 1.2rem;
            width: 35%;
        }
    }

    .hero-block {
        height: 6rem;
        width: 100%;

        @media (min-width: 64rem) {
            height: 5.5rem;
        }
    }

    .ui-group {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        z-index: 2;

        @media (min-width: 64rem) {
            flex-direction: row;
        }
    }

    .card-block {
        height: 4rem;
        width: 100%;

        @media (min-width: 64rem) {
            height: 3.5rem;
            flex: 1;
        }
    }

    .footer-block {
        height: 2.5rem;
        width: 100%;
        margin-top: var(--space-sm);

        @media (min-width: 64rem) {
            height: 2.8rem;
            margin-top: auto;
        }
    }

    .ui-coordinates {
        position: absolute;
        bottom: 8px;
        right: 12px;
        font-family: var(--font-family-brand);
        font-size: 0.65rem;
        letter-spacing: 0.05em;
        z-index: 3;

        .coord-label {
            color: oklch(50% 0 0);
        }

        .coord-value {
            color: var(--color-brand);
            font-family: var(--font-family-brand)
        }
    }

    @keyframes subtleScale {
        0%, 100% {
            transform: scale(1);
        }

        50% {
            transform: scale(1.02);
        }
    }

    /* El punto viajero del canvas */
    .canvas-core-dot {
        position: absolute;
        top: 0;
        left: 0;
        width: 12px;
        height: 12px;
        background: white;
        border-radius: 50%;
        z-index: 10;
        pointer-events: none;
        will-change: transform, opacity;
        opacity: 0;
        transform: translate(var(--guide-x), var(--guide-y)) translate(-50%, -50%) translate(-300px, -100px) scale(2);
        /* AL SALIR: Transición ultra veloz para que no deje rastro tosco ni cree un "segundo punto" visible */
        transition:
            opacity 0.15s ease-in,
            transform 0.15s ease-in;
    }

    /* Cuando el mouse entra al canvas */
    .ui-blueprint:hover .canvas-core-dot {
        opacity: 1;
        transform: translate(var(--guide-x), var(--guide-y)) translate(-50%, -50%) translate(0, 0) scale(0.65);
        /* AL ENTRAR: Mantiene tu curva arqueada suave original */
        transition:
            opacity 0.4s ease-in-out,
            transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    }

    /* El círculo original dentro del logo */
    .path-circle {
        will-change: transform, opacity;
        transform-origin: 84.44px 80vw;
        /* AL SALIR (Regreso al logo): El punto reaparece suavizado con la curva orgánica */
        transition:
            opacity 0.4s ease-in-out,
            transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    }

    /* Cuando el mouse entra al canvas */
    body:has(#interactiveCanvas:hover) .path-circle {
        opacity: 0;
        transform: translate(250px, 80px) scale(0.3);
        /* AL ENTRAR: Se desvanece rápido persiguiendo al canvas */
        transition:
            opacity 0.2s ease-out,
            transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    }

    @media (min-width: 64rem) {
        .ui-blueprint:hover .canvas-core-dot {
            opacity: 1;
            transform: translate(var(--guide-x), var(--guide-y)) translate(-50%, -50%) translate(0, 0) scale(0.65);
            transition:
                opacity 0.4s ease-in-out,
                transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15);
        }

        body:has(#interactiveCanvas:hover) .path-circle {
            opacity: 0;
            transform: translate(250px, 80px) scale(0.3);
            transition:
                opacity 0.2s ease-out,
                transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
        }
    }
}
