/* =========================================
   INTRO VIALSA - CONSTRUCCIÓN POR PIEZAS
   Solo Inicio /tienda
========================================= */

.intro-vialsa-build {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 20%, rgba(14, 165, 233, .22), transparent 34%),
        radial-gradient(circle at 82% 74%, rgba(7, 87, 216, .28), transparent 38%),
        linear-gradient(135deg, #020817 0%, #061936 48%, #082347 100%);
    opacity: 1;
    visibility: visible;
    transition: opacity .7s ease, visibility .7s ease;
}

.intro-vialsa-build.intro-hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.intro-activa {
    overflow: hidden;
}

/* Fondo técnico */
.build-grid {
    position: absolute;
    inset: 0;
    opacity: .52;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 48px 48px;
}

.build-grid::before,
.build-grid::after {
    content: "";
    position: absolute;
    width: 72vw;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(103, 232, 249, .72), transparent);
    opacity: 0;
}

.build-grid::before {
    top: 32%;
    left: -10%;
    transform: rotate(-8deg);
    animation: gridLineIn .9s ease .15s forwards;
}

.build-grid::after {
    bottom: 24%;
    right: -10%;
    transform: rotate(8deg);
    animation: gridLineIn .9s ease .35s forwards;
}

.build-light {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(20px);
    opacity: .75;
}

.build-light-left {
    left: 6%;
    top: 18%;
    background: radial-gradient(circle, rgba(14, 165, 233, .27), transparent 65%);
    animation: buildPulse 1.9s ease-in-out infinite;
}

.build-light-right {
    right: 8%;
    bottom: 12%;
    background: radial-gradient(circle, rgba(7, 87, 216, .30), transparent 65%);
    animation: buildPulse 1.9s ease-in-out .4s infinite;
}

/* Escenario general */
.build-stage {
    position: relative;
    z-index: 3;
    width: min(1200px, 94vw);
    min-height: min(700px, 88vh);
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
    align-items: center;
    gap: clamp(26px, 5vw, 76px);
}

/* Ensamble del edificio */
.building-assembly {
    position: relative;
    min-height: 560px;
    display: grid;
    place-items: center;
    perspective: 1200px;
}

/* Piso luminoso */
.build-floor {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 72px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(103, 232, 249, .92), transparent);
    filter: blur(.2px);
    box-shadow: 0 0 34px rgba(103, 232, 249, .5);
    opacity: 0;
    transform: scaleX(.15);
    animation: floorBuild .5s ease .25s forwards;
}

/* Vigas / aluminio */
.build-beam {
    position: absolute;
    z-index: 2;
    display: block;
    background: linear-gradient(90deg, rgba(255,255,255,.92), rgba(103,232,249,.58), rgba(148,163,184,.95));
    box-shadow: 0 0 18px rgba(103, 232, 249, .36);
    border-radius: 999px;
    opacity: 0;
}

.beam-1 {
    left: 17%;
    bottom: 132px;
    width: 0;
    height: 6px;
    animation: beamX  .48s ease .48s forwards;
}

.beam-2 {
    left: 20%;
    top: 175px;
    width: 0;
    height: 6px;
    animation: beamX  .48s ease .62s forwards;
}

.beam-3 {
    left: 34%;
    top: 118px;
    width: 6px;
    height: 0;
    animation: beamY .55s ease .76s forwards;
}

.beam-4 {
    right: 28%;
    top: 145px;
    width: 6px;
    height: 0;
    animation: beamY .55s ease .86s forwards;
}

.beam-5 {
    right: 14%;
    top: 205px;
    width: 0;
    height: 6px;
    animation: beamXShort .48s ease .96s forwards;
}

/* Piezas del edificio */
.building-piece {
    position: absolute;
    z-index: 4;
    width: min(760px, 96%);
    height: 430px;
    background-image: url("/img/tienda/intro-edificio-vialsa.png");
    background-size: cover;
    background-position: center;
    filter:
        drop-shadow(0 32px 50px rgba(0, 0, 0, .34))
        drop-shadow(0 0 26px rgba(14, 165, 233, .18));
    opacity: 0;
}

/* Parte inferior: base y suelo */
.piece-base {
    clip-path: polygon(0 70%, 100% 70%, 100% 100%, 0 100%);
    transform: translateY(42px) scale(.98);
    animation: pieceBaseIn .55s cubic-bezier(.2,.8,.2,1) .85s forwards;
}

/* Bloque izquierdo */
.piece-left {
    clip-path: polygon(0 26%, 39% 18%, 39% 100%, 0 100%);
    transform: translateX(-80px) translateY(18px) scale(.98);
    animation: pieceLeftIn .62s cubic-bezier(.2,.8,.2,1) 1.05s forwards;
}

/* Bloque central de vidrio */
.piece-center {
    clip-path: polygon(32% 12%, 72% 8%, 75% 100%, 29% 100%);
    transform: translateY(-90px) scale(.96);
    animation: pieceCenterIn .62s cubic-bezier(.2,.8,.2,1) 1.25s forwards;
}

/* Bloque derecho */
.piece-right {
    clip-path: polygon(64% 10%, 100% 24%, 100% 100%, 67% 100%);
    transform: translateX(90px) translateY(18px) scale(.98);
    animation: pieceRightIn .62s cubic-bezier(.2,.8,.2,1) 1.45s forwards;
}

/* Techo */
.piece-roof {
    clip-path: polygon(24% 0, 88% 0, 100% 20%, 35% 22%);
    transform: translateY(-72px) scale(1.02);
    animation: pieceRoofIn .55s cubic-bezier(.2,.8,.2,1) 1.66s forwards;
}

/* Brillos de vidrio */
.build-shine {
    position: absolute;
    z-index: 8;
    top: 130px;
    width: 90px;
    height: 300px;
    background: linear-gradient(110deg, transparent, rgba(255, 255, 255, .85), transparent);
    filter: blur(1px);
    opacity: 0;
    transform: skewX(-18deg);
    pointer-events: none;
}

.shine-1 {
    left: 18%;
    animation: shineBuild .72s ease 1.86s forwards;
}

.shine-2 {
    left: 42%;
    animation: shineBuild .72s ease 2.02s forwards;
}

/* Marca */
.build-brand {
    position: relative;
    z-index: 10;
    text-align: center;
    color: #ffffff;
    opacity: 0;
    transform: translateY(22px);
    animation: brandBuildIn .66s ease 1.86s forwards;
}

.build-logo-box {
    width: 92px;
    height: 92px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 28px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(219, 234, 254, .9);
    box-shadow:
        0 24px 50px rgba(14, 165, 233, .24),
        0 0 0 10px rgba(255, 255, 255, .055);
    transform: scale(.74) rotate(-5deg);
    animation: logoBuildPop .65s cubic-bezier(.2,.8,.2,1) 2.02s forwards;
}

.build-logo-box img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.build-brand h1 {
    margin: 0;
    color: #ffffff;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 950;
    letter-spacing: 12px;
    line-height: .95;
    text-shadow: 0 12px 30px rgba(0,0,0,.24);
}

.build-brand p {
    margin: 12px 0 0;
    color: #67e8f9;
    font-size: clamp(.82rem, 1.2vw, 1.05rem);
    font-weight: 900;
    letter-spacing: 2.4px;
    text-transform: uppercase;
}

.build-loader {
    width: 250px;
    height: 5px;
    margin: 24px auto 0;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
}

.build-loader span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0757d8, #06b6d4, #67e8f9);
    transform-origin: left;
    transform: scaleX(0);
    animation: loaderBuildFill 2.55s ease .35s forwards;
}

.build-brand small {
    display: block;
    margin-top: 14px;
    color: rgba(255,255,255,.64);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Animaciones */
@keyframes gridLineIn {
    from {
        opacity: 0;
        transform: translateX(-90px) rotate(-8deg);
    }
    to {
        opacity: .75;
    }
}

@keyframes buildPulse {
    0%, 100% {
        transform: scale(.94);
        opacity: .62;
    }
    50% {
        transform: scale(1.06);
        opacity: .86;
    }
}

@keyframes floorBuild {
    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes beamX {
    from {
        opacity: 0;
        width: 0;
    }
    to {
        opacity: 1;
        width: 64%;
    }
}

@keyframes beamXShort {
    from {
        opacity: 0;
        width: 0;
    }
    to {
        opacity: 1;
        width: 32%;
    }
}

@keyframes beamY {
    from {
        opacity: 0;
        height: 0;
    }
    to {
        opacity: 1;
        height: 280px;
    }
}

@keyframes pieceBaseIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pieceLeftIn {
    to {
        opacity: 1;
        transform: translateX(0) translateY(0) scale(1);
    }
}

@keyframes pieceCenterIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pieceRightIn {
    to {
        opacity: 1;
        transform: translateX(0) translateY(0) scale(1);
    }
}

@keyframes pieceRoofIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes shineBuild {
    0% {
        opacity: 0;
        transform: translateX(0) skewX(-18deg);
    }
    35% {
        opacity: .92;
    }
    100% {
        opacity: 0;
        transform: translateX(330px) skewX(-18deg);
    }
}

@keyframes brandBuildIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoBuildPop {
    70% {
        transform: scale(1.08) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0);
    }
}

@keyframes loaderBuildFill {
    to {
        transform: scaleX(1);
    }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .intro-vialsa-build,
    .intro-vialsa-build * {
        animation: none !important;
        transition: none !important;
    }
}

/* Responsive */
@media (max-width: 991px) {

    .build-stage {
        grid-template-columns: 1fr;
        gap: 8px;
        min-height: 90vh;
    }

    .building-assembly {
        min-height: 430px;
    }

    .building-piece {
        width: min(680px, 96vw);
        height: 390px;
    }

    .build-brand {
        margin-top: -28px;
    }

    .build-beam {
        display: none;
    }
}

@media (max-width: 575px) {

    .build-stage {
        width: 94vw;
    }

    .building-assembly {
        min-height: 340px;
    }

    .building-piece {
        width: 96vw;
        height: 300px;
    }

    .build-floor {
        bottom: 42px;
    }

    .build-logo-box {
        width: 76px;
        height: 76px;
        border-radius: 23px;
    }

    .build-logo-box img {
        width: 52px;
        height: 52px;
    }

    .build-brand h1 {
        letter-spacing: 6px;
        font-size: 2.3rem;
    }

    .build-brand p {
        font-size: .72rem;
        letter-spacing: 1.6px;
    }

    .build-loader {
        width: 190px;
    }
}