@charset "UTF-8";
/**
 * 巫師系統樣式
 * 包含經典版和聰明版巫師的動畫、定位樣式
 */

/* ========================================
   通用巫師容器定位系統
   ======================================== */

.wizard-fixed-container {
    position: fixed;
    z-index: 40;
    width: 100px;
    height: 100px;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    transition: top 0.3s ease, bottom 0.3s ease, left 0.3s ease, right 0.3s ease, transform 0.2s ease;
}

.wizard-fixed-container:active {
    cursor: grabbing;
}

.wizard-fixed-container.dragging {
    cursor: grabbing;
    transition: none;
    transform: scale(1.1);
    z-index: 100;
}

/* 螢幕四個角落 */
.wizard-fixed-container[data-position="bottom-right"] {
    right: 1rem;
    bottom: 6rem;
    left: auto;
    top: auto;
}

.wizard-fixed-container[data-position="bottom-left"] {
    left: 1rem;
    bottom: 6rem;
    right: auto;
    top: auto;
}

.wizard-fixed-container[data-position="top-right"] {
    right: 1rem;
    top: 5rem;
    left: auto;
    bottom: auto;
}

.wizard-fixed-container[data-position="top-left"] {
    left: 1rem;
    top: 5rem;
    right: auto;
    bottom: auto;
}

/* 左右中間 */
.wizard-fixed-container[data-position="middle-right"] {
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    left: auto;
    bottom: auto;
}

.wizard-fixed-container[data-position="middle-left"] {
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    right: auto;
    bottom: auto;
}

/* 聊天視窗內的左上和左下 */
.wizard-fixed-container[data-position="chat-top-left"] {
    left: 1rem;
    top: 5rem;
    right: auto;
    bottom: auto;
}

.wizard-fixed-container[data-position="chat-bottom-left"] {
    left: 1rem;
    bottom: 6rem;
    right: auto;
    top: auto;
}

/* 響應式尺寸 - sm */
@media (min-width: 640px) {
    .wizard-fixed-container {
        width: 120px;
        height: 120px;
    }

    .wizard-fixed-container[data-position="bottom-right"] {
        right: 1.5rem;
        bottom: 7rem;
    }

    .wizard-fixed-container[data-position="bottom-left"] {
        left: 1.5rem;
        bottom: 7rem;
    }

    .wizard-fixed-container[data-position="top-right"] {
        right: 1.5rem;
        top: 5rem;
    }

    .wizard-fixed-container[data-position="top-left"] {
        left: 1.5rem;
        top: 5rem;
    }

    .wizard-fixed-container[data-position="middle-right"] {
        right: 1.5rem;
    }

    .wizard-fixed-container[data-position="middle-left"] {
        left: 1.5rem;
    }

    .wizard-fixed-container[data-position="chat-top-left"] {
        left: 1.5rem;
        top: 5rem;
    }

    .wizard-fixed-container[data-position="chat-bottom-left"] {
        left: 1.5rem;
        bottom: 7rem;
    }
}

/* 響應式尺寸 - lg */
@media (min-width: 1024px) {
    .wizard-fixed-container {
        width: 140px;
        height: 140px;
    }

    .wizard-fixed-container:hover:not(.dragging) {
        transform: scale(1.05);
    }

    .wizard-fixed-container[data-position="middle-right"]:hover:not(.dragging),
    .wizard-fixed-container[data-position="middle-left"]:hover:not(.dragging) {
        transform: translateY(-50%) scale(1.05);
    }

    .wizard-fixed-container[data-position="bottom-right"] {
        right: 2.5rem;
        bottom: 8rem;
    }

    .wizard-fixed-container[data-position="bottom-left"] {
        left: 2.5rem;
        bottom: 8rem;
    }

    .wizard-fixed-container[data-position="top-right"] {
        right: 2.5rem;
        top: 6rem;
    }

    .wizard-fixed-container[data-position="top-left"] {
        left: 2.5rem;
        top: 6rem;
    }

    .wizard-fixed-container[data-position="middle-right"] {
        right: 2.5rem;
    }

    .wizard-fixed-container[data-position="middle-left"] {
        left: 2.5rem;
    }

    /* 聊天視窗內：考慮 sidebar 寬度 (18rem = 288px) */
    .wizard-fixed-container[data-position="chat-top-left"] {
        left: calc(18rem + 3rem);
        top: 6rem;
    }

    .wizard-fixed-container[data-position="chat-bottom-left"] {
        left: calc(18rem + 3rem);
        bottom: 8rem;
    }
}

/* 響應式尺寸 - xl */
@media (min-width: 1280px) {
    .wizard-fixed-container {
        width: 160px;
        height: 160px;
    }

    .wizard-fixed-container[data-position="bottom-right"] {
        right: 3rem;
        bottom: 9rem;
    }

    .wizard-fixed-container[data-position="bottom-left"] {
        left: 3rem;
        bottom: 9rem;
    }

    .wizard-fixed-container[data-position="top-right"] {
        right: 3rem;
        top: 6rem;
    }

    .wizard-fixed-container[data-position="top-left"] {
        left: 3rem;
        top: 6rem;
    }

    .wizard-fixed-container[data-position="middle-right"] {
        right: 3rem;
    }

    .wizard-fixed-container[data-position="middle-left"] {
        left: 3rem;
    }

    .wizard-fixed-container[data-position="chat-top-left"] {
        left: calc(18rem + 3.5rem);
        top: 6rem;
    }

    .wizard-fixed-container[data-position="chat-bottom-left"] {
        left: calc(18rem + 3.5rem);
        bottom: 9rem;
    }
}

/* ========================================
   拖曳提示區域 (Drop Zones)
   ======================================== */

.wizard-drop-zone {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    border: 2px dashed rgba(99, 102, 241, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    z-index: 39;
}

.wizard-drop-zone.visible {
    opacity: 1;
}

.wizard-drop-zone.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.7);
    transform: scale(1.2);
}

/* 螢幕四角的 drop zone */
.wizard-drop-zone[data-position="bottom-right"] {
    right: 0.5rem;
    bottom: 5.5rem;
}

.wizard-drop-zone[data-position="bottom-left"] {
    left: 0.5rem;
    bottom: 5.5rem;
}

.wizard-drop-zone[data-position="top-right"] {
    right: 0.5rem;
    top: 4.5rem;
}

.wizard-drop-zone[data-position="top-left"] {
    left: 0.5rem;
    top: 4.5rem;
}

/* 左右中間的 drop zone */
.wizard-drop-zone[data-position="middle-right"] {
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.wizard-drop-zone[data-position="middle-left"] {
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.wizard-drop-zone[data-position="middle-right"].active,
.wizard-drop-zone[data-position="middle-left"].active {
    transform: translateY(-50%) scale(1.2);
}

/* 聊天視窗內的 drop zone */
.wizard-drop-zone[data-position="chat-top-left"] {
    left: 0.5rem;
    top: 4.5rem;
}

.wizard-drop-zone[data-position="chat-bottom-left"] {
    left: 0.5rem;
    bottom: 5.5rem;
}

@media (min-width: 1024px) {
    .wizard-drop-zone[data-position="bottom-right"] {
        right: 2rem;
        bottom: 7.5rem;
    }

    .wizard-drop-zone[data-position="bottom-left"] {
        left: 2rem;
        bottom: 7.5rem;
    }

    .wizard-drop-zone[data-position="top-right"] {
        right: 2rem;
        top: 5.5rem;
    }

    .wizard-drop-zone[data-position="top-left"] {
        left: 2rem;
        top: 5.5rem;
    }

    .wizard-drop-zone[data-position="middle-right"] {
        right: 2rem;
    }

    .wizard-drop-zone[data-position="middle-left"] {
        left: 2rem;
    }

    .wizard-drop-zone[data-position="chat-top-left"] {
        left: calc(18rem + 2.5rem);
        top: 5.5rem;
    }

    .wizard-drop-zone[data-position="chat-bottom-left"] {
        left: calc(18rem + 2.5rem);
        bottom: 7.5rem;
    }
}

/* ========================================
   經典版巫師 (阿呆巫師) 動畫
   ======================================== */

#wizard-wrapper-classic {
    transform-origin: bottom center;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 12px rgba(91, 94, 166, 0.3));
}

/* 呼吸 (Idle) */
#wizard-wrapper-classic[data-state="idle"] {
    animation: wizard-breathe 3s ease-in-out infinite;
}

@keyframes wizard-breathe {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(1.02);
    }
}

/* 思考 (Thinking) */
#wizard-wrapper-classic[data-state="thinking"] {
    animation: wizard-think 1.2s ease-in-out infinite;
}

@keyframes wizard-think {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(1.03);
    }
}

/* 說話 & 聆聽 (Speaking & Listening) */
#wizard-wrapper-classic[data-state="speaking"],
#wizard-wrapper-classic[data-state="listening"] {
    transform: scaleY(1);
}

/* 經典版燈泡 */
#wizard-wrapper-classic .wizard-idea-bulb {
    transform-origin: bottom left;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    opacity: 0;
    transform: scale(0.5);
}

#wizard-wrapper-classic[data-state="thinking"] .wizard-idea-bulb {
    opacity: 1;
    transform: scale(1);
    animation: bulb-float 1.5s ease-in-out infinite;
}

#wizard-wrapper-classic[data-state="thinking"] .bulb-rays {
    animation: rays-flash 1s infinite alternate;
}

@keyframes bulb-float {

    0%,
    100% {
        transform: scale(1) translateY(0);
    }

    50% {
        transform: scale(1) translateY(-3px);
    }
}

@keyframes rays-flash {
    0% {
        opacity: 0.5;
        stroke-width: 2;
    }

    100% {
        opacity: 1;
        stroke-width: 4;
    }
}

/* 經典版聆聽耳朵 */
#wizard-wrapper-classic .wizard-listen-ear {
    transform-origin: center;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    opacity: 0;
    transform: scale(0.5);
}

#wizard-wrapper-classic[data-state="listening"] .wizard-listen-ear {
    opacity: 1;
    transform: scale(1);
    animation: ear-pulse 1.2s ease-in-out infinite;
}

@keyframes ear-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* 經典版嘴巴動畫 */
#wizard-wrapper-classic .wizard-mouth {
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.2s;
}

#wizard-wrapper-classic[data-state="speaking"] .wizard-mouth {
    animation: mouth-talk 0.2s infinite;
}

@keyframes mouth-talk {

    0%,
    100% {
        transform: scaleY(0.8);
    }

    50% {
        transform: scaleY(1.5);
    }
}

/* 經典版眨眼動畫 */
#wizard-wrapper-classic .wizard-eyelids {
    transform-box: fill-box;
    transform-origin: top;
    animation: blink 4s infinite;
}

@keyframes blink {

    0%,
    92%,
    100% {
        transform: scaleY(0);
    }

    95% {
        transform: scaleY(1);
    }

    96% {
        transform: scaleY(0.2);
    }
}

/* ========================================
   聰明版巫師 (外部 SVG) 動畫
   ======================================== */

#wizard-wrapper-smart {
    position: relative;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* 移除 scale，改用容器大小控制 */
}

/* 呼吸 (Idle) */
#wizard-wrapper-smart[data-state="idle"] {
    animation: smart-wizard-breathe 3s ease-in-out infinite;
}

@keyframes smart-wizard-breathe {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(1.02);
    }
}

/* 思考 (Thinking) */
#wizard-wrapper-smart[data-state="thinking"] {
    animation: smart-wizard-think 1.2s ease-in-out infinite;
}

@keyframes smart-wizard-think {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(1.03);
    }
}

/* 說話 & 聆聽 */
#wizard-wrapper-smart[data-state="speaking"],
#wizard-wrapper-smart[data-state="listening"] {
    transform: scaleY(1);
}

/* 聰明版部件基礎樣式 */
.wizard-part-smart {
    position: absolute;
    transition: transform 0.3s ease-out;
}

/* 聰明版燈泡 */
#wizard-wrapper-smart .wizard-idea-bulb-smart {
    transform-origin: bottom left;
    transition: opacity 0.3s ease-out;
    opacity: 0;
}

#wizard-wrapper-smart[data-state="thinking"] .wizard-idea-bulb-smart {
    opacity: 1;
    animation: bulb-smart-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#wizard-wrapper-smart[data-state="thinking"] .bulb-rays-smart {
    animation: rays-smart-flash 1s infinite alternate;
}

@keyframes bulb-smart-pop {
    0% {
        transform: scale(0) rotate(-45deg) translate(-20px, 20px);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotate(15deg) translate(0, 0);
        opacity: 1;
    }
}

@keyframes rays-smart-flash {
    0% {
        opacity: 0.5;
        stroke-width: 2;
    }

    100% {
        opacity: 1;
        stroke-width: 4;
    }
}

/* 聰明版聆聽耳朵 */
#wizard-wrapper-smart .wizard-listening-ear-smart {
    transform-origin: center right;
    transition: opacity 0.3s ease-out;
    opacity: 0;
}

#wizard-wrapper-smart[data-state="listening"] .wizard-listening-ear-smart {
    opacity: 1;
    animation: ear-smart-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes ear-smart-pop {
    0% {
        transform: scale(0) translate(20px, 0);
        opacity: 0;
    }

    100% {
        transform: scale(1) translate(0, 0);
        opacity: 1;
    }
}

/* 聰明版聲波動畫 */
#wizard-wrapper-smart[data-state="listening"] .wave-smart-1 {
    animation: wave-smart-pulse 1.2s infinite 0s;
}

#wizard-wrapper-smart[data-state="listening"] .wave-smart-2 {
    animation: wave-smart-pulse 1.2s infinite 0.2s;
}

#wizard-wrapper-smart[data-state="listening"] .wave-smart-3 {
    animation: wave-smart-pulse 1.2s infinite 0.4s;
}

.ear-waves-smart path {
    opacity: 0;
}

@keyframes wave-smart-pulse {
    0% {
        opacity: 0;
        transform: translateX(5px);
    }

    50% {
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-5px);
    }
}

/* 聰明版嘴巴動畫 */
#wizard-wrapper-smart .wizard-mouth-smart {
    transform-origin: center;
    transition: transform 0.2s;
}

#wizard-wrapper-smart[data-state="speaking"] .wizard-mouth-smart {
    animation: mouth-smart-talk 0.35s infinite;
}

@keyframes mouth-smart-talk {

    0%,
    100% {
        transform: scaleY(0.7);
    }

    50% {
        transform: scaleY(1.6);
    }
}

/* 聰明版眼睛容器 */
.wizard-eye-container-smart {
    position: relative;
    overflow: hidden;
}

/* 聰明版眼珠 (可追蹤移動) */
.wizard-eye-container-smart .wizard-pupil {
    position: absolute;
    top: 25%;
    left: 25%;
    width: 40%;
    height: auto;
    z-index: 2;
    transition: transform 0.05s linear;
    pointer-events: none;
}

/* 聰明版眼皮眨眼 */
.wizard-eyelid-smart {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    transform-origin: top;
    animation: blink-smart 4s infinite;
    pointer-events: none;
}

@keyframes blink-smart {

    0%,
    92%,
    100% {
        transform: scaleY(0);
    }

    95% {
        transform: scaleY(1);
    }

    96% {
        transform: scaleY(0.2);
    }
}

/* 聰明版星星閃爍 (Thinking 時) */
#wizard-wrapper-smart[data-state="thinking"] .wizard-star-smart {
    animation: star-smart-twinkle 0.8s ease-in-out infinite alternate;
}

@keyframes star-smart-twinkle {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    100% {
        transform: scale(1.15);
        filter: brightness(1.3);
    }
}

/* 聰明版眉毛動畫 (Thinking 時) */
#wizard-wrapper-smart[data-state="thinking"] .wizard-brow-left-smart {
    transform: translateY(-2px) rotate(-5deg);
}

#wizard-wrapper-smart[data-state="thinking"] .wizard-brow-right-smart {
    transform: translateY(-2px) rotate(5deg);
}

/* 作怪狀態眉毛 */
#wizard-wrapper-smart[data-state="playful"] .wizard-brow-left-smart {
    animation: brow-wiggle-left 0.6s ease-in-out infinite;
}

#wizard-wrapper-smart[data-state="playful"] .wizard-brow-right-smart {
    animation: brow-wiggle-right 0.6s ease-in-out infinite;
}

@keyframes brow-wiggle-left {

    0%,
    100% {
        transform: rotate(0deg) translateY(0);
    }

    50% {
        transform: rotate(-8deg) translateY(-8%);
    }
}

@keyframes brow-wiggle-right {

    0%,
    100% {
        transform: rotate(0deg) translateY(0);
    }

    50% {
        transform: rotate(8deg) translateY(-8%);
    }
}

/* 作怪狀態嘴巴 */
#wizard-wrapper-smart[data-state="playful"] .wizard-mouth-smart {
    animation: mouth-playful 1s ease-in-out infinite;
}

@keyframes mouth-playful {

    0%,
    100% {
        transform: scaleY(1) scaleX(1);
    }

    25% {
        transform: scaleY(0.6) scaleX(1.3);
    }

    50% {
        transform: scaleY(1.2) scaleX(0.8);
    }

    75% {
        transform: scaleY(0.8) scaleX(1.2);
    }
}

/* ========================================
   Accessibility: Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {

    #wizard-wrapper-classic,
    #wizard-wrapper-smart,
    .wizard-mouth,
    .wizard-mouth-smart,
    .wizard-eyelids,
    .wizard-eyelid-smart,
    .wizard-idea-bulb,
    .wizard-idea-bulb-smart,
    .wizard-listen-ear,
    .wizard-listening-ear-smart,
    .wizard-star-smart,
    .wizard-brow-left-smart,
    .wizard-brow-right-smart {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   巫師切換按鈕樣式 (Debug 用)
   ======================================== */

.wizard-switch-panel {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    background: rgba(30, 41, 59, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    font-size: 12px;
    color: white;
    display: none;
    /* 預設隱藏，debug 時顯示 */
}

.wizard-switch-panel.visible {
    display: block;
}

.wizard-switch-panel h4 {
    margin: 0 0 8px;
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wizard-switch-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.wizard-switch-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
}

.wizard-switch-btn.active {
    background: rgba(99, 102, 241, 0.5);
    border-color: #6366f1;
}

.wizard-switch-btn .model-tag {
    display: inline-block;
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin-left: 6px;
}