/* ============================================================================
   GoalSkill Mascot - 살아있는 AI 사슴 캐릭터
   ============================================================================ */

/* --- 마스코트 컨테이너 --- */
.mascot-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transition: left 2s ease-in-out, bottom 1.5s ease-in-out;
    will-change: left, bottom;
}

.mascot-inner {
    position: relative;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* --- 캐릭터 이미지 --- */
.mascot-character {
    width: 120px;
    height: 120px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    transition: transform 0.3s ease, filter 0.3s ease;
    image-rendering: auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.mascot-character img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    mix-blend-mode: multiply; /* 흰 배경 GIF를 투명하게 처리 */
}

/* 좌우 반전 (걷는 방향) */
.mascot-character.facing-left {
    transform: scaleX(-1);
}

/* --- Idle 애니메이션 (살짝 위아래 흔들림) --- */
.mascot-state-idle .mascot-character {
    animation: mascotFloat 3s ease-in-out infinite;
}

@keyframes mascotFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.mascot-state-idle .mascot-character.facing-left {
    animation: mascotFloatLeft 3s ease-in-out infinite;
}

@keyframes mascotFloatLeft {
    0%, 100% { transform: scaleX(-1) translateY(0); }
    50% { transform: scaleX(-1) translateY(-8px); }
}

/* --- Walk 애니메이션 --- */
.mascot-state-walk .mascot-character {
    animation: mascotBounceWalk 0.5s ease-in-out infinite;
}

@keyframes mascotBounceWalk {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(3deg); }
    75% { transform: translateY(-5px) rotate(-3deg); }
}

.mascot-state-walk .mascot-character.facing-left {
    animation: mascotBounceWalkLeft 0.5s ease-in-out infinite;
}

@keyframes mascotBounceWalkLeft {
    0%, 100% { transform: scaleX(-1) translateY(0) rotate(0deg); }
    25% { transform: scaleX(-1) translateY(-5px) rotate(-3deg); }
    75% { transform: scaleX(-1) translateY(-5px) rotate(3deg); }
}

/* --- Thinking 애니메이션 --- */
.mascot-state-thinking .mascot-character {
    animation: mascotThink 2s ease-in-out infinite;
}

@keyframes mascotThink {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(-8deg); }
    50% { transform: translateY(-2px) rotate(0deg); }
    75% { transform: translateY(-4px) rotate(8deg); }
}

/* --- Happy 애니메이션 (점프!) --- */
.mascot-state-happy .mascot-character {
    animation: mascotJump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 3;
}

@keyframes mascotJump {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-25px) scale(1.05); }
    60% { transform: translateY(-20px) scale(1.02); }
}

/* --- Sleeping 애니메이션 --- */
.mascot-state-sleeping .mascot-character {
    animation: mascotSleep 4s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15)) brightness(0.85) saturate(0.8);
}

@keyframes mascotSleep {
    0%, 100% { transform: translateY(0) scale(1) rotate(15deg); }
    50% { transform: translateY(3px) scale(0.97) rotate(18deg); }
}

/* --- Surprised 애니메이션 --- */
.mascot-state-surprised .mascot-character {
    animation: mascotSurprise 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 1;
}

@keyframes mascotSurprise {
    0% { transform: scale(1) rotate(0deg); }
    30% { transform: scale(1.15) rotate(-5deg); }
    60% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* --- 말풍선 --- */
.mascot-speech-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(233, 213, 255, 0.5);
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 180px;
    max-width: 260px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(233, 213, 255, 0.3);
    font-family: 'Noto Sans JP', 'M PLUS Rounded 1c', sans-serif;
    font-size: 13px;
    line-height: 1.6;
    color: #334155;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    z-index: 10000;
    word-break: break-word;
}

.mascot-speech-bubble.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* 말풍선 꼬리 (삼각형) */
.mascot-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(255, 255, 255, 0.95);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.05));
}

/* 말풍선 텍스트 타이핑 효과 */
.mascot-speech-text {
    overflow: hidden;
}

/* 말풍선 액션 버튼 (테마 변경 등) */
.mascot-action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.mascot-action-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.mascot-action-btn.primary {
    background: linear-gradient(135deg, #c4b5fd, #e9d5ff);
    color: #5b21b6;
}

.mascot-action-btn.primary:hover {
    background: linear-gradient(135deg, #a78bfa, #c4b5fd);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.3);
}

.mascot-action-btn.secondary {
    background: rgba(241, 245, 249, 0.8);
    color: #64748b;
}

.mascot-action-btn.secondary:hover {
    background: rgba(226, 232, 240, 0.8);
}

/* --- ZZZ (졸기 이펙트) --- */
.mascot-zzz {
    position: absolute;
    top: -10px;
    right: -5px;
    font-size: 18px;
    opacity: 0;
    pointer-events: none;
}

.mascot-state-sleeping .mascot-zzz {
    animation: zzzFloat 2.5s ease-in-out infinite;
}

@keyframes zzzFloat {
    0% { opacity: 0; transform: translateY(0) scale(0.6); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-30px) scale(1.2); }
}

/* --- 이모지 리액션 (반응 이펙트) --- */
.mascot-reaction {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    pointer-events: none;
    opacity: 0;
    z-index: 10001;
}

.mascot-reaction.active {
    animation: reactionPop 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes reactionPop {
    0% { opacity: 0; transform: translateX(-50%) translateY(0) scale(0); }
    30% { opacity: 1; transform: translateX(-50%) translateY(-20px) scale(1.3); }
    60% { opacity: 1; transform: translateX(-50%) translateY(-30px) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-45px) scale(0.8); }
}

/* --- 하이라이트 오버레이 (가이드 모드) --- */
.mascot-highlight-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.mascot-highlight-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.mascot-highlight-target {
    position: relative;
    z-index: 9999;
    box-shadow: 0 0 0 4px rgba(233, 213, 255, 0.8), 0 0 20px rgba(196, 181, 253, 0.5);
    border-radius: 12px;
    animation: highlightPulse 2s ease-in-out infinite;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(233, 213, 255, 0.8), 0 0 20px rgba(196, 181, 253, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(233, 213, 255, 1), 0 0 30px rgba(196, 181, 253, 0.8); }
}

/* --- 파티클 이펙트 (클릭 시) --- */
.mascot-particle {
    position: absolute;
    pointer-events: none;
    font-size: 16px;
    z-index: 10001;
    animation: particleFly 1s ease-out forwards;
}

@keyframes particleFly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0.3); }
}

/* --- 테마 변경 트랜지션 --- */
body.theme-transitioning {
    transition: background 1.5s ease-in-out !important;
}

body.theme-transitioning * {
    transition: background-color 1.5s ease-in-out,
                color 0.8s ease-in-out,
                border-color 1s ease-in-out !important;
}

/* --- 날씨 테마들 --- */
body.theme-rainy {
    background: linear-gradient(135deg, #c7d2fe 0%, #ddd6fe 50%, #e0e7ff 100%) !important;
}

body.theme-sunny {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fffbeb 100%) !important;
}

body.theme-cloudy {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 50%, #f1f5f9 100%) !important;
}

body.theme-snowy {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 50%, #f0f9ff 100%) !important;
}

body.theme-night {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%) !important;
}

body.theme-night .sidebar,
body.theme-night .sidebar-collapsed {
    background: rgba(30, 27, 75, 0.9) !important;
}

body.theme-night .sidebar-nav-item,
body.theme-night .chat-log-item,
body.theme-night .sidebar-section-title {
    color: #a5b4fc !important;
}

body.theme-night .message.bot .bubble {
    background-color: #3730a3 !important;
    color: #e0e7ff !important;
}

body.theme-night .chat-input-bar {
    background: rgba(30, 27, 75, 0.85) !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
}

body.theme-night .chat-input {
    color: #e0e7ff !important;
    background: rgba(49, 46, 129, 0.6) !important;
}

/* --- 드래그 시 커서 --- */
.mascot-inner.dragging {
    cursor: grabbing !important;
}

.mascot-inner.dragging .mascot-character {
    transform: scale(1.1) !important;
    animation: none !important;
    filter: drop-shadow(0 8px 20px rgba(0,0,0,0.25));
}

/* --- 호버 이펙트 --- */
.mascot-inner:hover .mascot-character {
    filter: drop-shadow(0 6px 16px rgba(0,0,0,0.2)) brightness(1.05);
}

/* --- 입장 애니메이션 --- */
.mascot-container.entering {
    animation: mascotEnter 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes mascotEnter {
    0% { opacity: 0; transform: translateY(100px) scale(0.5); }
    60% { opacity: 1; transform: translateY(-10px) scale(1.05); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- 반응형 --- */
@media (max-width: 768px) {
    .mascot-character {
        width: 80px;
        height: 80px;
    }
    
    .mascot-speech-bubble {
        min-width: 140px;
        max-width: 200px;
        font-size: 12px;
        padding: 10px 12px;
    }
}
