/* ==========================================================================
   CAPTAIN SUPERLAC — 3D CSS Bot
   Pure CSS/JS animated character replacing the WebM video FAB.
   ========================================================================== */

/* ─── Scene Container ─── */
#ai-trigger {
    perspective: 500px !important;
    transform-style: preserve-3d !important;
}

.captain-bot {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(5deg) rotateY(-5deg);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: captain-float 4s ease-in-out infinite;
    cursor: pointer;
    filter: drop-shadow(0 12px 24px rgba(46, 125, 50, 0.25));
}

.captain-bot:hover {
    filter: drop-shadow(0 16px 32px rgba(46, 125, 50, 0.4));
}

/* ─── Float Animation ─── */
@keyframes captain-float {
    0%, 100% { transform: rotateX(5deg) rotateY(-5deg) translateY(0px); }
    25% { transform: rotateX(3deg) rotateY(-3deg) translateY(-4px) rotateZ(0.5deg); }
    50% { transform: rotateX(5deg) rotateY(-5deg) translateY(-8px); }
    75% { transform: rotateX(7deg) rotateY(-7deg) translateY(-4px) rotateZ(-0.5deg); }
}

/* ─── Head ─── */
.captain-head {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(145deg, #F5D5A0, #E8C088);
    box-shadow:
        inset 0 -4px 8px rgba(0,0,0,0.12),
        inset 0 4px 8px rgba(255,255,255,0.3),
        0 4px 16px rgba(0,0,0,0.15);
    z-index: 10;
    transform-style: preserve-3d;
}

/* Face features container */
.captain-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transform: translateZ(8px);
}

/* ─── Eyes ─── */
.captain-eyes {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 2;
}

.captain-eye {
    width: 12px;
    height: 14px;
    background: #2D1B0E;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    animation: captain-blink 4s ease-in-out infinite;
}

.captain-eye::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    opacity: 0.9;
}

@keyframes captain-blink {
    0%, 42%, 46%, 100% { transform: scaleY(1); }
    44% { transform: scaleY(0.05); }
}

/* ─── Eyebrows ─── */
.captain-eyebrows {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 22px;
}

.captain-eyebrow {
    width: 14px;
    height: 4px;
    background: #5D3A1A;
    border-radius: 2px;
    transform: rotate(-5deg);
}

.captain-eyebrow:last-child {
    transform: rotate(5deg);
}

/* ─── Nose ─── */
.captain-nose {
    position: absolute;
    top: 34px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 6px;
    background: #D4A574;
    border-radius: 50%;
    z-index: 2;
}

/* ─── Mustache ─── */
.captain-mustache {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    z-index: 2;
}

.captain-mustache-half {
    width: 14px;
    height: 8px;
    border-bottom: 3px solid #3D2209;
    border-radius: 0 0 50% 50%;
}

.captain-mustache-half:first-child {
    border-radius: 0 0 50% 0;
}

.captain-mustache-half:last-child {
    border-radius: 0 0 0 50%;
}

/* ─── Mouth ─── */
.captain-mouth {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 5px;
    border-bottom: 2.5px solid #8B4513;
    border-radius: 0 0 50% 50%;
    z-index: 2;
}

/* ─── Hat (Painter Cap) ─── */
.captain-hat {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%) translateZ(4px);
    width: 56px;
    height: 30px;
    z-index: 15;
}

.captain-hat-brim {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 10px;
    background: linear-gradient(180deg, #2E7D32, #1B5E20);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.captain-hat-crown {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 22px;
    background: linear-gradient(180deg, #388E3C, #2E7D32);
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.2);
}

.captain-hat-badge {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #FFD700, #FFA000);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 2px rgba(255,255,255,0.5);
}

/* ─── Body (Paint Bucket Shape) ─── */
.captain-body {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 48px;
    background: linear-gradient(180deg, #2E7D32, #1B5E20);
    border-radius: 8px 8px 16px 16px;
    box-shadow:
        inset 0 2px 6px rgba(255,255,255,0.15),
        inset 0 -4px 8px rgba(0,0,0,0.2),
        0 4px 12px rgba(0,0,0,0.2);
    transform-style: preserve-3d;
    z-index: 5;
}

/* Body logo S */
.captain-body-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(4px);
    font-size: 22px;
    font-weight: 900;
    color: #FFD700;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    font-family: 'Outfit', sans-serif;
    line-height: 1;
}

/* Bucket handle */
.captain-handle {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 16px;
    border: 3px solid #9E9E9E;
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    z-index: 4;
}

/* Paint drip */
.captain-paint-drip {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 6px;
    background: rgba(255, 215, 0, 0.3);
    border-radius: 0 0 20px 20px;
    z-index: 6;
}

/* ─── Arms ─── */
.captain-arm {
    position: absolute;
    bottom: 24px;
    width: 12px;
    height: 32px;
    background: linear-gradient(180deg, #2E7D32, #1B5E20);
    border-radius: 6px;
    z-index: 4;
    transform-origin: top center;
    transition: transform 0.3s ease;
}

.captain-arm-left {
    left: 6px;
    transform: rotate(15deg);
}

.captain-arm-right {
    right: 6px;
    transform: rotate(-15deg);
}

/* Hands */
.captain-hand {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: #F5D5A0;
    border-radius: 50%;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1);
}

/* ─── Paint Brush (Right Hand) ─── */
.captain-brush {
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #8D6E63, #6D4C41);
    border-radius: 2px;
}

.captain-brush::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 8px;
    background: linear-gradient(180deg, #2196F3, #1565C0);
    border-radius: 0 0 4px 4px;
}

/* ─── Shadow on ground ─── */
.captain-shadow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 10px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.15) 0%, transparent 70%);
    border-radius: 50%;
    animation: captain-shadow-pulse 4s ease-in-out infinite;
}

@keyframes captain-shadow-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.6; }
    50% { transform: translateX(-50%) scale(0.85); opacity: 0.3; }
}

/* ─── Glowing Ring ─── */
.captain-glow {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(76, 175, 80, 0.2);
    animation: captain-glow-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes captain-glow-pulse {
    0%, 100% {
        border-color: rgba(76, 175, 80, 0.1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
    50% {
        border-color: rgba(76, 175, 80, 0.3);
        box-shadow: 0 0 20px 4px rgba(76, 175, 80, 0.15);
    }
}

/* ─── State: Thinking ─── */
.captain-bot.state-thinking .captain-eye {
    animation: none;
    transform: scaleY(0.3);
}

.captain-bot.state-thinking .captain-mouth {
    height: 8px;
    width: 8px;
    border: 2.5px solid #8B4513;
    border-radius: 50%;
    top: 46px;
}

.captain-bot.state-thinking .captain-arm-right {
    animation: captain-think-arm 1.5s ease-in-out infinite;
}

@keyframes captain-think-arm {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(-35deg); }
}

/* Thinking gear above head */
.captain-thinking-gear {
    position: absolute;
    top: -20px;
    right: -5px;
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 20;
}

.captain-bot.state-thinking .captain-thinking-gear {
    opacity: 1;
    animation: captain-spin 2s linear infinite;
}

@keyframes captain-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ─── State: Talking ─── */
.captain-bot.state-talking .captain-mouth {
    animation: captain-talk 0.3s ease-in-out infinite alternate;
}

@keyframes captain-talk {
    0% { height: 3px; border-radius: 0 0 50% 50%; }
    100% { height: 8px; border-radius: 0 0 40% 40%; }
}

.captain-bot.state-talking .captain-arm-left {
    animation: captain-talk-left-arm 1s ease-in-out infinite;
}

.captain-bot.state-talking .captain-arm-right {
    animation: captain-talk-right-arm 1s ease-in-out infinite 0.5s;
}

@keyframes captain-talk-left-arm {
    0%, 100% { transform: rotate(15deg); }
    50% { transform: rotate(5deg); }
}

@keyframes captain-talk-right-arm {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(-25deg); }
}

/* ─── State: Waving ─── */
.captain-bot.state-waving .captain-arm-right {
    animation: captain-wave 0.6s ease-in-out 3;
    transform-origin: top center;
}

@keyframes captain-wave {
    0%, 100% { transform: rotate(-15deg); }
    25% { transform: rotate(-60deg); }
    75% { transform: rotate(-45deg); }
}

/* ─── State: Idle (default) ─── */
.captain-bot.state-idle .captain-eye {
    animation: captain-blink 4s ease-in-out infinite;
}

/* ─── Click Squash ─── */
.captain-bot.squashing {
    animation: captain-squash 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes captain-squash {
    0% { transform: rotateX(5deg) rotateY(-5deg) scaleY(1) scaleX(1); }
    30% { transform: rotateX(5deg) rotateY(-5deg) scaleY(0.88) scaleX(1.12); }
    60% { transform: rotateX(5deg) rotateY(-5deg) scaleY(1.05) scaleX(0.95); }
    100% { transform: rotateX(5deg) rotateY(-5deg) scaleY(1) scaleX(1); }
}

/* ─── Notification Badge ─── */
.captain-badge {
    position: absolute;
    top: -2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: #E53935;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 6px rgba(229, 57, 53, 0.4);
}

.captain-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* ─── Particle Effects ─── */
.captain-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 30;
}

.captain-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    opacity: 0;
}

.captain-bot.state-talking .captain-particle {
    animation: captain-particle-float 2s ease-out infinite;
}

@keyframes captain-particle-float {
    0% { opacity: 0; transform: translateY(0) scale(0.5); }
    20% { opacity: 0.8; }
    100% { opacity: 0; transform: translateY(-30px) scale(0) translateX(10px); }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    .captain-bot {
        width: 90px;
        height: 90px;
    }
    .captain-head {
        width: 54px;
        height: 54px;
    }
    .captain-eyes {
        top: 20px;
        gap: 12px;
    }
    .captain-eye {
        width: 9px;
        height: 11px;
    }
    .captain-eyebrows {
        top: 14px;
        gap: 16px;
    }
    .captain-nose {
        top: 26px;
    }
    .captain-mustache {
        top: 30px;
    }
    .captain-mouth {
        top: 36px;
    }
    .captain-body {
        width: 42px;
        height: 36px;
    }
    .captain-body-logo {
        font-size: 16px;
    }
    .captain-hat {
        width: 42px;
        height: 22px;
        top: -6px;
    }
    .captain-hat-brim {
        width: 48px;
        height: 8px;
    }
    .captain-hat-crown {
        width: 34px;
        height: 18px;
    }
    .captain-hat-badge {
        width: 12px;
        height: 12px;
    }
    .captain-arm {
        width: 10px;
        height: 24px;
        bottom: 18px;
    }
    .captain-arm-left { left: 3px; }
    .captain-arm-right { right: 3px; }
    .captain-hand {
        width: 11px;
        height: 11px;
    }
    .captain-shadow {
        width: 38px;
        height: 8px;
    }
}
