/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    --bg-primary: #050811;
    --bg-doors: #0b0f19;
    --color-neon-cyan: #39ff14;
    --color-neon-purple: #a020f0;
    --color-neon-green: #39ff14;
    --color-municipal-green: #006837; /* Miraflores brand green */
    --color-text-muted: rgba(255, 255, 255, 0.5);
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-door: 2.2s cubic-bezier(0.77, 0, 0.175, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-primary);
    font-family: var(--font-family);
    color: #ffffff;
}

/* ==========================================================================
   REVEALED SCREEN (UNDERLAY)
   ========================================================================== */
#revealed-screen {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-primary);
    overflow: hidden;
}

/* Tech grid texture background */
.tech-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    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: 40px 40px;
    background-position: center;
    opacity: 0.6;
    z-index: 1;
}

/* Futuristic radial ambient glows */
.glow-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 800px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(57, 255, 20, 0.05) 0%, rgba(160, 32, 240, 0.02) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 4s ease-out;
    z-index: 2;
    pointer-events: none;
}

.hub-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    z-index: 3;
}

/* The Hub Logo Wrapper */
.logo-hub-wrapper {
    position: relative;
    max-width: 450px;
    width: 80vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-hub {
    max-width: 100%;
    width: 100%;
    height: auto;
    object-fit: contain;
    will-change: opacity, transform;
}

/* Off state (dormant) */
.logo-off {
    opacity: 0.15;
    filter: grayscale(100%) brightness(30%) contrast(90%);
    transform: scale(0.96);
    transition: opacity 4s cubic-bezier(0.25, 1, 0.5, 1), transform 4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* On state (glowing) */
.logo-on {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    filter: 
        grayscale(0%) 
        brightness(105%) 
        drop-shadow(0 0 12px rgba(57, 255, 20, 0.45)) 
        drop-shadow(0 0 35px rgba(57, 255, 20, 0.25))
        drop-shadow(0 0 70px rgba(160, 32, 240, 0.2));
    transform: scale(0.96);
    transition: opacity 4s cubic-bezier(0.25, 1, 0.5, 1), transform 4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Cross-fade triggers when wrapper has the .ignite class */
.logo-hub-wrapper.ignite .logo-off {
    opacity: 0;
    transform: scale(1);
}

.logo-hub-wrapper.ignite .logo-on {
    opacity: 1;
    transform: scale(1);
    animation: hubPulse 6s ease-in-out infinite alternate;
}

/* Green orbital loader below the status text */
.hub-loader {
    position: relative;
    width: 64px;
    height: 64px;
    margin-top: 15px;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.9) rotate(-20deg);
    transition: 
        opacity 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), 
        transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 4;
}

.hub-loader.active {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.hub-loader-bg {
    stroke: rgba(57, 255, 20, 0.04);
    stroke-width: 1.5;
    fill: none;
}

.hub-loader-bar {
    stroke: var(--color-neon-green);
    stroke-width: 1.5;
    fill: none;
    stroke-dasharray: 565.5;
    stroke-dashoffset: 565.5;
    stroke-linecap: round;
    filter: drop-shadow(0 0 5px var(--color-neon-green));
}

/* Status badge indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--color-text-muted);
    transition: all 1s ease;
    backdrop-filter: blur(5px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6b7280; /* Gray (dormant) */
    box-shadow: 0 0 0 rgba(107, 114, 128, 0);
    transition: all 1s ease;
}

/* Status states */
.status-indicator.starting {
    color: #f59e0b; /* Yellow */
    border-color: rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.02);
}
.status-indicator.starting .status-dot {
    background-color: #f59e0b;
    animation: dotPulseYellow 1s infinite alternate;
}

.status-indicator.online {
    color: var(--color-neon-cyan);
    border-color: rgba(57, 255, 20, 0.3);
    background: rgba(57, 255, 20, 0.02);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.05);
}
.status-indicator.online .status-dot {
    background-color: var(--color-neon-cyan);
    box-shadow: 0 0 10px var(--color-neon-cyan);
    animation: dotPulseCyan 2s infinite alternate;
}


/* ==========================================================================
   SPLIT OVERLAY SCREEN DOORS
   ========================================================================== */
.split-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    overflow: hidden;
    pointer-events: auto; /* Handles hold interaction */
    cursor: pointer;
}

.door {
    position: absolute;
    top: 0;
    height: 100vh;
    width: calc(50vw + 1.5px); /* Overlap by a tiny margin to prevent subpixel black line leak */
    overflow: hidden;
    transition: transform var(--transition-door);
    will-change: transform;
}

.door-left {
    left: 0;
    border: none;
}

.door-right {
    right: 0;
    border: none;
}

/* The contents inside the doors which overlap perfectly to center the logo */
.door-content {
    position: absolute;
    top: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.door-left .door-content {
    left: 0; /* Keep aligned left */
}

.door-right .door-content {
    right: 0; /* Keep aligned right */
}

/* Beautiful dark carbon glassmorphism background for the doors */
.door-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at center, #ffffff 0%, #f9fafb 100%);
    z-index: -1;
}

/* Adding a tech honeycomb pattern to the doors */
.door-bg::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.04;
    background-image: radial-gradient(circle, #000000 1px, transparent 1px);
    background-size: 20px 20px;
}

.logo-miraflores {
    max-width: 416px; /* Increased by 30% from 320px */
    width: 91vw; /* Increased by 30% from 70vw */
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.08));
    transition: transform 0.5s ease;
}

/* Pulsing effect on miraflores logo to highlight call to action */
.split-overlay:not(.split-active) .logo-miraflores {
    animation: initialLogoGlow 3s ease-in-out infinite alternate;
}

/* Door animation triggers - Mechanical vault gate style */
.split-active .door-left {
    animation: openLeft 2.4s cubic-bezier(0.25, 0.8, 0.15, 1) forwards;
}

.split-active .door-right {
    animation: openRight 2.4s cubic-bezier(0.25, 0.8, 0.15, 1) forwards;
}

.split-active {
    pointer-events: none; /* Let interaction pass to underlying screen after split */
}


/* Instruction Text Overlay */
.instruction-overlay {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 12;
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none;
}

.instruction-text {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: #4b5563; /* Sleek charcoal gray */
    text-align: center;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    animation: breatheText 2s infinite ease-in-out;
}

.mouse-icon {
    width: 24px;
    height: 40px;
    border: 2px solid #4b5563;
    border-radius: 12px;
    position: relative;
    opacity: 0.8;
}

.mouse-icon .wheel {
    width: 4px;
    height: 8px;
    background-color: var(--color-neon-cyan);
    border-radius: 2px;
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    animation: scrollWheel 1.5s infinite ease-in-out;
}

/* Hide instructions when split starts or when charging */
.split-active .instruction-overlay,
.charging-active .instruction-overlay {
    opacity: 0;
    transform: translate(-50%, 15px);
}


/* ==========================================================================
   VIBRATION & INTENSITY ANIMATIONS (DURING CHARGING)
   ========================================================================== */
/* Vibration removed at user request. Only municipal green aura added on hold */
.charging-active .logo-miraflores {
    filter: 
        drop-shadow(0 0 15px var(--color-municipal-green))
        drop-shadow(0 6px 12px rgba(0, 0, 0, 0.08));
}


/* ==========================================================================
   INTERACTIVE CANVAS (RIPPLES & SVG PROGRESS)
   ========================================================================== */
#interaction-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 20;
}

/* Liquid Ripple Styling */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    background: radial-gradient(circle, rgba(57, 255, 20, 0.05) 0%, rgba(57, 255, 20, 0.02) 40%, rgba(57, 255, 20, 0.06) 70%, transparent 100%);
    border: 1px solid rgba(57, 255, 20, 0.35);
    box-shadow: 
        0 0 15px rgba(57, 255, 20, 0.15),
        inset 0 0 10px rgba(57, 255, 20, 0.08);
    backdrop-filter: blur(1.5px) saturate(1.1);
    animation: waterRipple 1.2s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
    will-change: width, height, opacity;
}

/* Secondary ripple layer for added fluid realism */
.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70%;
    height: 70%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1px dashed rgba(57, 255, 20, 0.25);
    animation: waterRippleInner 1.2s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

/* Circular Hold Progress Ring - Municipal Green theme */
.hold-progress {
    position: absolute;
    transform: translate(-50%, -50%) scale(0.7);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    filter: drop-shadow(0 0 8px var(--color-municipal-green));
}

.hold-progress.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.progress-bg {
    stroke: rgba(0, 104, 55, 0.15); /* Translucent municipal green */
    stroke-width: 4;
    fill: none;
}

.progress-bar {
    stroke: var(--color-municipal-green);
    stroke-width: 4;
    fill: none;
    stroke-dasharray: 251.3; /* 2 * PI * r (r=40) */
    stroke-dashoffset: 251.3;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50px 50px;
    transition: stroke-dashoffset 0.1s linear; /* Smooth micro-increments */
}


/* ==========================================================================
   ANIMATION KEYFRAMES
   ========================================================================== */

/* Water Ripple Animation */
@keyframes waterRipple {
    0% {
        width: 0px;
        height: 0px;
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(0.2);
    }
    100% {
        width: 280px;
        height: 280px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@keyframes waterRippleInner {
    0% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(0.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Pulsing subtle ambient glow on primary logo before ignition */
@keyframes initialLogoGlow {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 0px rgba(57, 255, 20, 0));
    }
    100% {
        transform: scale(1.02);
        filter: drop-shadow(0 8px 25px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 8px rgba(57, 255, 20, 0.25));
    }
}

/* Breathing Hub Logo Animation after powered on */
@keyframes hubPulse {
    0% {
        transform: scale(1);
        filter: 
            grayscale(0%) 
            brightness(100%) 
            drop-shadow(0 0 10px rgba(57, 255, 20, 0.3)) 
            drop-shadow(0 0 35px rgba(57, 255, 20, 0.2))
            drop-shadow(0 0 60px rgba(160, 32, 240, 0.15));
    }
    100% {
        transform: scale(1.02);
        filter: 
            grayscale(0%) 
            brightness(108%) 
            drop-shadow(0 0 18px rgba(57, 255, 20, 0.45)) 
            drop-shadow(0 0 45px rgba(57, 255, 20, 0.25))
            drop-shadow(0 0 80px rgba(160, 32, 240, 0.25));
    }
}

/* Status Indicator Dot Pulsing */
@keyframes dotPulseYellow {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    100% {
        box-shadow: 0 0 12px 4px rgba(245, 158, 11, 0.1);
    }
}

@keyframes dotPulseCyan {
    0% {
        box-shadow: 0 0 0 0 rgba(57, 255, 20, 0.4);
    }
    100% {
        box-shadow: 0 0 15px 4px rgba(57, 255, 20, 0.1);
    }
}

/* Text breathe transition */
@keyframes breatheText {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.85; }
}

/* Scroll wheel animation indicator */
@keyframes scrollWheel {
    0% {
        transform: translate(-50%, 0);
        opacity: 0.1;
    }
    30% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, 14px);
        opacity: 0;
    }
}

/* Vibration keyframes for left door */
@keyframes shakeLeft {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-2px, 1px); }
    40% { transform: translate(-1px, -1px); }
    60% { transform: translate(1px, 1px); }
    80% { transform: translate(-2px, -1px); }
    100% { transform: translate(0px, 0); }
}

/* Vibration keyframes for right door */
@keyframes shakeRight {
    0% { transform: translate(0, 0); }
    20% { transform: translate(2px, -1px); }
    40% { transform: translate(1px, 1px); }
    60% { transform: translate(-1px, -1px); }
    80% { transform: translate(2px, 1px); }
    100% { transform: translate(0px, 0); }
}

/* Mechanical Gate split opening animations */
@keyframes openLeft {
    0% {
        transform: translateX(0);
    }
    6% {
        transform: translateX(6px); /* Mechanical compression/unlock */
    }
    14% {
        transform: translateX(-15px); /* Start moving */
    }
    90% {
        transform: translateX(-102.5%); /* Overshoot */
    }
    100% {
        transform: translateX(-100%); /* Settle open */
    }
}

@keyframes openRight {
    0% {
        transform: translateX(0);
    }
    6% {
        transform: translateX(-6px); /* Mechanical compression/unlock */
    }
    14% {
        transform: translateX(15px); /* Start moving */
    }
    90% {
        transform: translateX(102.5%); /* Overshoot */
    }
    100% {
        transform: translateX(100%); /* Settle open */
    }
}

/* ==========================================================================
   VIDEO HUD & framed video layout
   ========================================================================== */
.hidden {
    display: none !important;
}

.video-call-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 580px;
    max-width: 85vw;
    z-index: 5;
    animation: fadeInScale 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.video-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #050811;
    border: 2px solid var(--color-neon-green);
    box-shadow: 
        0 0 25px rgba(57, 255, 20, 0.2),
        inset 0 0 15px rgba(57, 255, 20, 0.15);
    border-radius: 8px;
    overflow: hidden;
    padding: 3px;
}

video#robot-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.video-label {
    color: var(--color-neon-green);
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.25em;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
    animation: flashGreen 2s infinite ease-in-out;
}

/* HUD corners inside video frame */
.hud-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--color-neon-green);
    pointer-events: none;
    z-index: 10;
    filter: drop-shadow(0 0 3px var(--color-neon-green));
}

.hud-corner.top-left {
    top: 15px;
    left: 15px;
    border-right: none;
    border-bottom: none;
}

.hud-corner.top-right {
    top: 15px;
    right: 15px;
    border-left: none;
    border-bottom: none;
}

.hud-corner.bottom-left {
    bottom: 15px;
    left: 15px;
    border-right: none;
    border-top: none;
}

.hud-corner.bottom-right {
    bottom: 15px;
    right: 15px;
    border-left: none;
    border-top: none;
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes flashGreen {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* Countdown overlay styling */
.countdown-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
}

.countdown-number {
    font-family: var(--font-family);
    font-size: 10rem;
    font-weight: 800;
    color: var(--color-neon-green);
    text-shadow: 
        0 0 25px rgba(57, 255, 20, 0.6),
        0 0 50px rgba(57, 255, 20, 0.3);
    animation: countdownPulse 1s ease-out forwards;
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    85% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        transform: scale(1.15);
        opacity: 0;
    }
}
