/* --- style.css --- */

/* --- ESTILS GENERALS --- */
body {
    margin: 0;
    padding: 0;
    background-color: #FAFAFA;
    padding-top: 100px;
    padding-bottom: 50px;
    font-family: sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

header {
    background-color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1000;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    box-sizing: border-box;
}

.logo {
    font-weight: 700;
    font-size: 1.5rem;
    color: #3c559f;
    text-decoration: none;
    text-transform: uppercase;
}

.btn-home-nav {
    position: absolute; left: 20px;
    text-decoration: none; color: white;
    background-color: #3c559f;
    padding: 8px 15px; border-radius: 15px;
    font-weight: 500; font-size: 0.9rem;
}

/* --- CONTENIDOR BLANC --- */
#main-container {
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    
    /* Mòbil per defecte */
    width: calc(100% - 40px); 
    max-width: 500px;
    height: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px; 
    position: relative;
    box-sizing: border-box;
    margin-bottom: 20px;
}

/* --- TEXTOS (Classes generals) --- */
.text-label {
    font-family: sans-serif;
    color: black;
    text-align: center;
    position: relative;
    width: 100%;
}

.text-previous {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: -20px; 
    z-index: 5;
}

.text-instruction {
    font-size: 24px;
    font-weight: 400;
    top:-1%;
}

/* --- DISPOSITIUS --- */
.device-wrapper {
    position: relative;
    width: 270px; 
    height: 270px;
    flex-shrink: 0;
}

.device-box {
    background: #E6421D;
    border-radius: 15px;
    padding: 5px;
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    position: relative; 
}

/* --- CARA I ELEMENTS --- */
.face-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 738 / 716; 
    margin-top: 20px;

    left:-6.5%;
    top: -3%;
    
}

.face-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.coil-img {
    position: absolute;
    width: 50%;
    height: auto;
    left: 48%;
    top: 45%;
    object-fit: contain;
}

/* --- LÍNIES I ELEMENTS SOBRE LA CARA --- */
/* Configuració MÒBIL per defecte */
.line-h, .stick-highlight {
    position: absolute;
    left: 14%;       
    width: 99%;      
    height: 2%;
    top: 42%;
    object-fit: fill; 
}

.line-h-torta {
    position: absolute;
    top: 4%;        
    height: 76%;     
    width: 68%;
    left: 12%;
    object-fit: fill;
}

.cylon-highlight {
    position: absolute;
    left: 14%;       
    width: 2%;      
    height: 2%;
    top: 42%;
    object-fit: fill; 
    border-radius: 50%;
}

.cylon-highlight-vertical {
    position: absolute;
    left: 44%;
    width: 2%;
    height: 2%;
    top: 10%;
    object-fit: fill; 
    border-radius: 50%;
}

.line-v {
    position: absolute;
    top: 7%;        
    height: 76%;     
    width: 2%;
    left: 44%;
    object-fit: fill;
}

.line-v-torta {
    position: absolute;
    top: 7%;        
    height: 76%;     
    width: 90%;
    left: 0%;
    object-fit: fill;
}

/* LED Indicator */
.led-indicator {
    position: absolute;
    width: 3%; 
    height: auto;
    aspect-ratio: 1/1;
    left: 111%; /* Mòbil */
    top: 42.3%;
    border-radius: 50%;
}

/* Zona Clicable */
.click-area {
    position: absolute;
    left: 14%; 
    top: 40%;
    width: 90%;
    height: 6%; 
    cursor: pointer;
    background: transparent;
    z-index: 10;
}

/* --- IMATGES LATERALS --- */
.side-images-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.side-image-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.side-image {
    width: 100%;
    max-width: 363px;
    height: auto;
    border-radius: 15px;
    border: 10px solid white;
}

/* --- ANIMACIONS --- */
@keyframes blink-led { 0% { opacity: 1; } 50% { opacity: 0.1; } 100% { opacity: 1; } }
.led-parpadejant { animation: blink-led 1s infinite; }

@keyframes blink-ui { 0% { opacity: 0.9; } 50% { opacity: 0; } 100% { opacity: 0.9; } }
.animacio-parpadejant { animation: blink-ui 1.5s infinite; pointer-events: none; }

@keyframes moure-lateral {
    0% { 
        transform: translateX(0); 
    }
    50% { 
        transform: translateX(428px); /* Arriba al final a la meitat del temps */ 
    }
    100% {
        transform: translateX(0); /* Torna al principi per aturar-se */
    }
}

@keyframes moure-vertical {
    0% { 
        transform: translateY(0); 
    }
    50% { 
        transform: translateY(465px); /* Arriba al final a la meitat del temps */ 
    }
    100% {
        transform: translateY(0); /* Torna al principi per aturar-se */
    }
}

.moviment-cylon {
    /* S'executa 1 sola vegada durant 3 segons */
    animation: moure-lateral 10s ease-in-out 1 forwards;
}

.moviment-cylon-vertical {
    animation: moure-vertical 10s ease-in-out 1 forwards;
}

@media (min-width: 1280px) {
    
    #main-container {
        width: 1280px;
        height: 1342px;
        max-width: none;
        display: block;
        padding: 0;
        transform-origin: top center;
        margin-top: 20px;
    }

    /* TEXTOS */
    .text-label { text-align: left; position: absolute; width: auto; }
    
    .text-previous {
        left: 490px;
        top: 29px;
        font-size: 24px;
        margin-bottom: 0;
    }

    .text-instruction {
        left: 130px;
        top: 345px;
        font-size: 32px;
    }

    /* POSICIONS DISPOSITIUS */
    .device-pos-1 {
        position: absolute;
        left: 125px;
        top: 75px;
        z-index: 20;
    }

    .device-pos-2 {
        position: absolute;
        left: 500px;
        top: 75px;
        z-index: 20;
    }
    
    /* Si només hi ha un dispositiu, el posem a l'esquerra per defecte */
    .device-wrapper:not(.device-pos-1):not(.device-pos-2) {
        position: absolute;
        left: 125px;
        top: 75px;
        z-index: 20;
    }

    /* CARA */
    .face-wrapper {
        position: absolute;
        width: 738px;
        height: 716px;
        left: 0px;
        top: 375px;
        z-index: 10;
        margin-top: 0;
    }

    /* AJUSTOS ELEMENTS CARA EN ESCRIPTORI */
    .line-h, .stick-highlight, .click-area {
        left: 18%;  
        width: 88%; 
    }

    .line-h-torta {
        top: 4%;        
        height: 76%;     
        width: 60%;
        left: 17%;
    }

    .cylon-highlight {
        left: 18%;
        width: 2%;
    }

    .cylon-highlight-vertical {
        left: 44%;
        width: 2%;
        height: 2%;
    }
    
    .led-indicator {
        left: 104%;
        top: 42.1%;
    }

    /* --- IMATGES LATERALS (ARREGLAT) --- */
    
    .side-images-group { 
        display: block; 
    }

    /* REGLA D'OR: Qualsevol contenidor d'imatge lateral es posa a la dreta absolutament */
    .side-image-wrapper {
        display: block;
        position: absolute; 
        left: 840px; 
        top: 100px; /* Posició per defecte (Dalt) */
        width: auto;
        z-index: 5;
    }

    /* Si necessitem una segona imatge a baix, només canviem el TOP */
    .side-img-pos-2 {
        top: 740px; 
    }

    /* Fixem la mida de la imatge perquè no s'estiri com al mòbil */
    .side-image { 
        width: 363px; 
        height: auto;
    }

    @keyframes moure-lateral {
        0% { 
            transform: translateX(0); 
        }
        50% { 
            /* Canvia el 650px pels píxels que necessitis en escriptori */
            transform: translateX(632px); 
        }
        100% {
            transform: translateX(0); 
        }
    }

    @keyframes moure-vertical {
        0% { 
            transform: translateY(0); 
        }
        50% { 
            /* Canvia el 700px pels píxels que necessitis en escriptori */
            transform: translateY(692px); 
        }
        100% {
            transform: translateY(0); 
        }
    }
}

@media (min-width: 1280px) and (max-width: 1400px) {
    #main-container {
        transform: scale(0.85);
        margin-top: 0;
    }
}