/* --- Global & Setup --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
    
    /* Animated Gradient Background */
    background: linear-gradient(270deg, #1a2a3a, #0d1a2b, #1a2a3a);
    background-size: 400% 400%;
    animation: gradient-animation 20s ease infinite;
}

/* Animation for the background */
@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Scene Handling --- */
.scene {
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

/* This is our most important utility class */
.hidden {
    display: none !important;
}
.fading-out {
    opacity: 0;
}

/* --- Phase 2: Welcome Screen Layout & Face --- */

#welcome-scene {
    /* This lets us position children (eyes, nose, mouth) absolutely */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Face Components --- */
.header {
    position: absolute;
    top: 20px;
    width: 100%;
    text-align: center;
    font-size: 1.4em;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.eye-container {
    position: absolute;
    top: 100px; /* Base position */
    display: flex;
    justify-content: center;
    gap: 80px; 
    width: 100%;
    /* NEW: Add subtle float animation */
    animation: eye-float 3s infinite ease-in-out alternate; 
}

.eye {
    width: 90px;
    height: 90px;
    background: #00bfff;
    border-radius: 50%;
    box-shadow: 0 0 35px #00bfff, inset 0 0 15px rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
    
    /* This centers the pupil */
    display: flex;
    justify-content: center;
    align-items: center;
}

.pupil {
    width: 28px;
    height: 28px;
    background: #000;
    border: 2px solid #333;
    border-radius: 50%;
    position: relative; /* Will be 'absolute' when we move it, but this is fine for now */
    z-index: 2;
    transition: transform 0.1s ease-out;
}

.eye-lid {
    width: 100%;
    height: 100%;
    background: #0d1a2b; 
    position: absolute;
    top: 0; /* <-- 1. CHANGED */
    left: 0;
    z-index: 3;
    transform: translateY(-100%); /* <-- 2. ADDED */
    animation: blink 4s infinite; /* <-- 3. ADDED (Blinks every 4s) */
}

/* --- "Nose" Content Box --- */
/* --- "Nose" Content Box --- */
.content-box-nose {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    
    padding: 20px;
    width: 350px;
    text-align: center;
    
    /* This is the "nose" */
    position: absolute;
    top: 220px;
    
    /* --- ADDED FOR CENTERING --- */
    left: 50%;
    transform: translateX(-50%);
}

.logo-small {
    width: 60px;
    height: 60px;
    margin: 10px 0;
}

.btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    font-size: 1.1em;
    font-weight: bold;
    color: #ffffff;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 15px;
}

.btn:hover {
    background-color: #0056b3;
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.5);
}

/* --- New Robot Mouth (Voice Visualizer) --- */
/* --- New Robot Mouth (Voice Visualizer) --- */
.robot-mouth {
    position: absolute;
    bottom: 100px;
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Aligns dots to the bottom */
    gap: 8px;
    width: 200px;
    height: 50px;

    /* --- ADDED FOR CENTERING --- */
    left: 50%;
    transform: translateX(-50%);
}

.robot-mouth span {
    width: 12px;
    height: 5px; /* Start small */
    background-color: #00bfff;
    box-shadow: 0 0 15px #00bfff;
    border-radius: 4px;
    /* Animation will be added in Phase 6 */
    transition: height 0.1s ease;
}

/* Static "smile" shape for now */
.robot-mouth span:nth-child(1),
.robot-mouth span:nth-child(5) {
    height: 10px;
}
.robot-mouth span:nth-child(2),
.robot-mouth span:nth-child(4) {
    height: 25px;
}
.robot-mouth span:nth-child(3) {
    height: 40px;
}
/* This rule is new */
/* This rule is new */
#tech-quiz-scene .robot-mouth {
    position: absolute;
    bottom: 30px; /* Position it at the bottom */
    
    /* --- USE THIS FOR CENTERING --- */
    left: 50%;
    transform: translateX(-50%);
}
/* --- Phase 3: Quiz Scene Layout & Components --- */

#tech-quiz-scene {
    /* This is the critical part for this layout */
    display: flex;
    flex-direction: column;
    justify-content: space-around; /* Pushes header/eyes up, logo down */
    align-items: center;
    padding-bottom: 30px; /* Give logo at bottom some space */
}

/* We need to override the absolute positioning from the welcome screen */
#tech-quiz-scene .header {
    position: static; /* Back to normal flow */
}

#tech-quiz-scene .eye-container {
    position: static; /* Back to normal flow */
    margin-top: 15px; /* Give it some space from the header */
    gap: 100px;
    animation: eye-float 3s infinite ease-in-out alternate;
}

/* This is the main "glass" box for questions and results */
.content-box-main {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    
    width: 90%;
    max-width: 700px;
    padding: 25px;
    text-align: center;
    /* margin-top: 20px; <-- REMOVED THIS */
    /* min-height: 250px; <-- REMOVED THIS */
}

#question-text {
    font-size: 1.5em;
    margin-bottom: 20px;
}

.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
}

.info-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 15px 0;
}

.btn-info {
    background-color: #17a2b8;
}
.btn-info:hover {
    background-color: #117a8b;
}

/* The logo at the very bottom of the quiz scene */
.logo-top-right {
    position: absolute;
    top: 20px;
    right: 15px;
    width: 60px;
    height: 60px;
    opacity: 0.8;
}
/* --- Phase 4: Button Feedback --- */
.btn.correct {
    background-color: #2ecc71;
    box-shadow: 0 0 15px #28a745;
}

.btn.wrong {
    background-color: #e74c3c;
    box-shadow: 0 0 15px #dc3545;
}

.btn:disabled {
    background-color: #5a5a5a;
    opacity: 0.7;
    cursor: not-allowed;
}
/* --- Phase 5: Voice Visualizer Animation --- */
.robot-mouth.speaking span {
    /*
      This creates a random-looking up-and-down animation.
      Each 'span' (dot) gets its own delay and height.
    */
    animation: speak-animation 0.4s infinite alternate;
}

@keyframes speak-animation {
    0% { height: 5px; }
    100% { height: 40px; }
}

/* Stagger the animation for each dot */
.robot-mouth.speaking span:nth-child(1) { animation-delay: -0.3s; }
.robot-mouth.speaking span:nth-child(2) { animation-delay: -0.1s; }
.robot-mouth.speaking span:nth-child(3) { animation-delay: -0.2s; }
.robot-mouth.speaking span:nth-child(4) { animation-delay: -0.15s; }
.robot-mouth.speaking span:nth-child(5) { animation-delay: -0.25s; }

/* Make the pupils absolute for eye-tracking */
.pupil {
    width: 28px;
    height: 28px;
    background: #000;
    border: 2px solid #333;
    border-radius: 50%;
    position: absolute; 
    z-index: 2;
    transition: transform 0.1s ease-out;
    /* NEW: Automatic movement */
    animation: auto-gaze 8s infinite ease-in-out; 
}
/* --- Phase 6: Modals --- */
#modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 101;
    
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    
    width: 90%;
    max-width: 500px;
    padding: 25px;
    text-align: center;
}

.logo-modal {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
}

.modal h2 {
    margin-bottom: 10px;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2.5em;
    color: #ffffff;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.7;
}
.close-modal:hover {
    opacity: 1;
}
/* --- Phase 6: Blinking Animation --- */
@keyframes blink {
    /* Stays open for 90% of the time */
    0%, 90% {
        transform: translateY(-100%);
    }
    /* Blinks shut quickly */
    95% {
        transform: translateY(0%);
    }
    /* Opens again */
    100% {
        transform: translateY(-100%);
    }
}
/* --- Phase 6: Automatic Eye Movement (Replaces mousemove) --- */
/* --- Phase 6: Automatic Eye Movement (Updated: Less Upward Gaze) --- */
@keyframes auto-gaze {
    0% { transform: translate(0px, 0px); }     /* Center */
    20% { transform: translate(15px, 5px); }    /* Look Right/Down */
    40% { transform: translate(-10px, 10px); }  /* Look Left/Down */
    60% { transform: translate(0px, 0px); }     /* Center */
    80% { transform: translate(0px, 15px); }    /* Look Down */
    100% { transform: translate(0px, 0px); }    /* Center */
}

/* NEW: Simple vertical movement for the whole eye container */
@keyframes eye-float {
    0% { top: 100px; } /* Same as current position */
    50% { top: 90px; } /* Move up 10px */
    100% { top: 100px; } /* Return */
}
/* --- Phase 6: Eye Pulse (Active when speaking) --- */

/* Keyframes for the subtle pulse animation */
@keyframes pulse-glow {
    0% { box-shadow: 0 0 35px #00bfff, inset 0 0 15px rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 50px #00bfff, inset 0 0 20px rgba(255, 255, 255, 0.8); } /* Brighter */
    100% { box-shadow: 0 0 35px #00bfff, inset 0 0 15px rgba(255, 255, 255, 0.5); }
}

/* Apply pulse ONLY when the scene is tagged as 'speaking' */
.scene.speaking .eye {
    animation: pulse-glow 1.5s infinite alternate;
}
/* --- Phase 7: Emotion Detector Styles --- */

#emotion-scene {
    /* This is needed so we can position children inside it */
    position: relative;
}

#video-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover; /* Fill the whole screen */
    z-index: -1; /* Sit BEHIND all other content */
    transform: scaleX(-1); /* Mirror the camera */
}

/* Position the UI box at the bottom, above the mouth */
#emotion-ui-box {
    position: absolute;
    bottom: 100px; /* Leave space for mouth */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
}

/* Position the mouth on the emotion screen */
#emotion-scene .robot-mouth {
    position: absolute;
    bottom: 30px; 
    
    /* --- NEW CENTERING METHOD --- */
    left: 50%;
    transform: translateX(-50%);
    
    /* --- Explicitly setting these again just in case --- */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    width: 200px;
    height: 50px;
}
/* --- Phase 7: Emotion Quiz Screen Styles (NEW!) --- */

#emotion-quiz-scene {
    /* This is needed so we can position children inside it */
    position: relative;
    
    /* Ensure robot face elements are centered */
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding-bottom: 30px;
}

#video-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover; /* Fill the whole screen */
    z-index: -1; /* Sit BEHIND all other content */
    transform: scaleX(-1); /* Mirror the camera */
}

/* This is the hidden canvas, we don't need to see it */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

/* Position the UI box at the bottom, above the mouth */
#emotion-ui-box {
    position: absolute;
    bottom: 100px; /* Leave space for mouth */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    
    /* Re-using the glass effect */
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    padding: 25px;
    text-align: center;
    min-height: 0; /* Override min-height from content-box-main */
}

/* Position the mouth on the emotion screen */
#emotion-quiz-scene .robot-mouth {
    position: absolute;
    bottom: 30px; 
    left: 50%;
    transform: translateX(-50%);
}

/* --- Fixes for Robot Face on Emotion Screen --- */
/* We need to override the static positioning */
#emotion-quiz-scene .header {
    position: absolute;
    top: 20px;
}

#emotion-quiz-scene .eye-container {
    position: absolute;
    top: 100px;
    animation: eye-float 3s infinite ease-in-out alternate;
}
/* --- Phase 8: Welcome Screen Gesture Styles (NEW!) --- */

/* Make the welcome screen a container */
#welcome-scene {
    position: relative;
}

/* Style the new video feed */
#welcome-video-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: -1; /* Sit BEHIND all content */
    transform: scaleX(-1); /* Mirror the camera */
}

/* Make the pupils' position absolute again, 
  so we can control them with JavaScript.
  (This overrides the 'auto-gaze' animation)
*/
#left-pupil, #right-pupil {
    position: absolute;
    animation: none; /* Turn off the auto-gaze */
}
/* Style for the 'Tap to Begin' screen */
#audio-unlock-scene {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer; /* <-- !! THIS IS THE FIX !! */
}
/* Style for the new gesture instruction on the welcome screen */
#gesture-instruction {
    font-size: 0.9em;  /* Makes it a bit smaller */
    color: #ffffff;
    opacity: 0.7;      /* Makes it slightly faded */
    margin-top: 15px;  /* Adds space from the button */
}