/* ==========================================================================
   Kantumi - Flor de Kantuta Compañera (Mascota Viva Estilo Planta PvZ) 🌸🌱
   Silueta transparente sin fondo, balanceo botánico, expresiones vivas y piececitos de pistilo
   ========================================================================== */

/* Contenedor Flotante Global (Fijo en todas las vistas) */
.kantumi-fairy-companion,
.kantumi-plant-companion {
    position: fixed;
    bottom: 16px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none; /* No bloquea el juego */
    max-width: 360px;
}

/* ==========================================================================
   Burbuja de Diálogo Flotante (Consejos de la Flor Kantumi)
   ========================================================================== */
.kantumi-speech-bubble {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
    border-radius: 22px;
    padding: 16px 20px;
    border: 3px solid #ffb703;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12), 0 0 16px rgba(255, 183, 3, 0.25);
    margin-bottom: 8px;
    position: relative;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(12px) scale(0.94);
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 310px;
}

.kantumi-speech-bubble.is-active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Flechita apuntando a la cabeza de Kantumi */
.kantumi-speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -13px;
    right: 60px;
    width: 0;
    height: 0;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-top: 13px solid #ffb703;
}

.kantumi-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -9px;
    right: 62px;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 10px solid #ffffff;
}

.bubble-fairy-header,
.bubble-plant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    border-bottom: 1px dashed #fed7aa;
    padding-bottom: 4px;
}

.fairy-title-label,
.plant-title-role {
    font-size: 0.75rem;
    color: #94a3b8;
}

.kantumi-bubble-text {
    font-family: var(--font-body);
    font-size: 1.02rem;
    line-height: 1.42;
    color: #1e293b;
    font-weight: 600;
}

.kantumi-click-hint {
    font-size: 0.76rem;
    color: #94a3b8;
    margin-top: 6px;
    font-style: italic;
}

/* ==========================================================================
   Personaje Vivo de Kantuta Guardiana (Avatar Ilustrado con Marco Botánico)
   ========================================================================== */
.kantumi-living-character {
    position: relative;
    width: 145px;
    height: 185px;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    transform-origin: center bottom;
    animation: plantIdleSway 3.4s ease-in-out infinite alternate;
    filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.22));
    transition: transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.kantumi-living-character:hover {
    transform: scale(1.08) translateY(-6px);
}

.kantumi-living-character:active {
    transform: scale(0.96) translateY(2px);
}

/* Balanceo rítmico alegre tipo plantita */
@keyframes plantIdleSway {
    0% {
        transform: translateY(0px) rotate(-1.8deg) scale(1, 1);
    }
    50% {
        transform: translateY(-8px) rotate(2deg) scale(1.03, 0.97);
    }
    100% {
        transform: translateY(-2px) rotate(-1deg) scale(0.99, 1.01);
    }
}

/* Sombra botánica suave en el piso */
.plant-ground-shadow {
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 95px;
    height: 16px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.28) 0%, rgba(15, 23, 42, 0) 72%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    animation: plantShadowPulse 3.4s ease-in-out infinite alternate;
}

@keyframes plantShadowPulse {
    0% {
        transform: translateX(-50%) scaleX(1) scaleY(1);
        opacity: 0.28;
    }
    50% {
        transform: translateX(-50%) scaleX(0.88) scaleY(0.82);
        opacity: 0.18;
    }
    100% {
        transform: translateX(-50%) scaleX(0.96) scaleY(0.95);
        opacity: 0.26;
    }
}

/* Kantumi Libre (Sin marco ni fondo) */
.kantuta-avatar-frame {
    position: relative;
    width: 138px;
    height: 165px;
    overflow: visible;
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    z-index: 2;
    transition: all 0.3s ease;
}

.kantumi-living-character:hover .kantuta-avatar-frame {
    /* Se mantiene vacío ya que no hay marco para iluminar */
}

/* Imagen de la Flor Kantuta */
.kantuta-guardian-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 25%;
    display: block;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.kantumi-living-character:hover .kantuta-guardian-image {
    transform: scale(1.07);
}

/* Efecto de brillo de luz mágico diagonal */
.kantuta-shine-overlay {
    position: absolute;
    top: 0;
    left: -130%;
    width: 80%;
    height: 100%;
    background: linear-gradient(
        120deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.45) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-25deg);
    animation: guardianShineSweep 5.5s infinite ease-in-out;
    pointer-events: none;
    z-index: 3;
}

@keyframes guardianShineSweep {
    0%, 75% { left: -130%; }
    100% { left: 170%; }
}

/* Destellos / Partículas flotantes alrededor de la guardiana */
.kantuta-sparkle-dot {
    position: absolute;
    pointer-events: none;
    font-size: 0.95rem;
    z-index: 6;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
    animation: sparkleFloat 2.6s infinite ease-in-out alternate;
}

.kantuta-sparkle-dot.s1 {
    top: 6px;
    right: 8px;
    animation-delay: 0.2s;
}

.kantuta-sparkle-dot.s2 {
    bottom: 24px;
    left: 6px;
    font-size: 0.85rem;
    animation-delay: 1.3s;
}

@keyframes sparkleFloat {
    0% { transform: translateY(0px) rotate(0deg) scale(0.9); opacity: 0.75; }
    100% { transform: translateY(-7px) rotate(12deg) scale(1.2); opacity: 1; }
}

/* Animación de habla / parloteo */
.kantumi-living-character.is-talking .kantuta-avatar-frame {
    animation: guardianTalkingPulse 0.22s infinite alternate ease-in-out;
}

@keyframes guardianTalkingPulse {
    0% { transform: scale(1) translateY(0px); }
    100% { transform: scale(1.03) translateY(-3px); }
}

/* Parpadeo / Guiño visual */
.kantumi-living-character.is-blinking .kantuta-guardian-image {
    filter: brightness(1.15) contrast(1.05);
}

/* Expresiones del Avatar */
.expr-wink .kantuta-avatar-frame {
    transform: rotate(3deg);
}

.expr-worried .kantuta-avatar-frame {
    /* Sin borde rojo ya que no hay marco, agregamos un brillo sutil */
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.5));
}

/* Etiqueta flotante con su nombre */
.kantumi-name-ribbon {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #d90429, #f77f00);
    color: white;
    font-family: var(--font-heading);
    font-size: 0.76rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25), 0 0 10px rgba(247, 127, 0, 0.4);
    white-space: nowrap;
    z-index: 10;
    border: 1.5px solid #fff3b0;
    letter-spacing: 0.3px;
}

/* Saltos y giros de alegría botánica */
.kantumi-living-character.mood-dance {
    animation: plantJoyfulHop 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes plantJoyfulHop {
    0% { transform: translateY(0px) scale(1, 1) rotate(0deg); }
    25% { transform: translateY(8px) scale(1.12, 0.88) rotate(0deg); }
    50% { transform: translateY(-28px) scale(0.92, 1.1) rotate(-8deg); }
    75% { transform: translateY(-16px) scale(1.05, 0.95) rotate(6deg); }
    100% { transform: translateY(0px) scale(1, 1) rotate(0deg); }
}

.kantumi-living-character.mood-excited {
    animation: plantExcitedBounce 0.55s infinite ease-in-out;
}

@keyframes plantExcitedBounce {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    50% { transform: translateY(-16px) scale(1.04, 0.94); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 700px) {
    .kantumi-fairy-companion,
    .kantumi-plant-companion {
        bottom: 4px;
        right: 4px;
        max-width: min(48vw, 168px);
    }
    .kantumi-living-character {
        width: 58px;
        height: 76px;
    }
    .kantumi-speech-bubble {
        max-width: min(48vw, 168px);
        max-height: 44px;
        overflow-y: auto;
        padding: 5px 8px;
        border-width: 2px;
        border-radius: 14px;
        margin-bottom: 2px;
    }
    .kantumi-bubble-text {
        font-size: 0.72rem;
        line-height: 1.25;
    }
}
