/**
 * 🌟 星空智庫 (Starry Wisdom Hub) - Zone 2 Design System
 * 專為 2 歲幼兒設計，融入精英素養教育理念
 */

/* ========================================
   Core Design Tokens
======================================== */
:root {
    /* 星空智庫主色系 */
    --swh-forest-green: #2D4A3E;
    --swh-cream: #FFFDD0;
    --swh-forest-light: #3D5A4E;
    --swh-forest-dark: #1D3A2E;

    /* 強調色 */
    --swh-star-gold: #FFD700;
    --swh-aurora-pink: #FFB6C1;
    --swh-night-blue: #1A2B3C;
    --swh-glow-teal: #4DD0E1;

    /* 功能色 */
    --swh-success: #7DC95E;
    --swh-gentle-pink: #FFCDD2;
    /* 失敗時溫暖粉色 */
    --swh-neutral: #B8C9BE;

    /* 霧面玻璃效果 */
    --swh-glass-bg: rgba(255, 253, 208, 0.85);
    --swh-glass-border: rgba(45, 74, 62, 0.2);
    --swh-glass-shadow: 0 8px 32px rgba(45, 74, 62, 0.15);
    --swh-glass-blur: blur(12px);

    /* 星空智庫專用間距 */
    --swh-spacing-xs: 4px;
    --swh-spacing-sm: 8px;
    --swh-spacing-md: 16px;
    --swh-spacing-lg: 24px;
    --swh-spacing-xl: 32px;

    /* 觸控友善尺寸 (≥80px) */
    --swh-touch-min: 80px;
    --swh-touch-large: 100px;
}

/* ========================================
   Zone Container
======================================== */
.zone-starry-wisdom {
    background: linear-gradient(135deg,
            var(--swh-forest-dark) 0%,
            var(--swh-forest-green) 50%,
            var(--swh-forest-light) 100%);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* 星空背景裝飾 */
.zone-starry-wisdom::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20% 30%, var(--swh-star-gold) 50%, transparent 50%),
        radial-gradient(3px 3px at 40% 70%, var(--swh-cream) 50%, transparent 50%),
        radial-gradient(2px 2px at 60% 20%, var(--swh-star-gold) 50%, transparent 50%),
        radial-gradient(2px 2px at 80% 60%, var(--swh-cream) 50%, transparent 50%),
        radial-gradient(3px 3px at 10% 80%, var(--swh-star-gold) 50%, transparent 50%),
        radial-gradient(2px 2px at 90% 10%, var(--swh-cream) 50%, transparent 50%);
    animation: starTwinkle 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes starTwinkle {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* ========================================
   霧面玻璃卡片 (Glassmorphism)
======================================== */
.swh-glass-card {
    background: var(--swh-glass-bg);
    backdrop-filter: var(--swh-glass-blur);
    -webkit-backdrop-filter: var(--swh-glass-blur);
    border: 1px solid var(--swh-glass-border);
    border-radius: 24px;
    box-shadow: var(--swh-glass-shadow);
    padding: var(--swh-spacing-lg);
    position: relative;
    z-index: 1;
}

.swh-glass-card-dark {
    background: rgba(45, 74, 62, 0.75);
    backdrop-filter: var(--swh-glass-blur);
    -webkit-backdrop-filter: var(--swh-glass-blur);
    border: 1px solid rgba(255, 253, 208, 0.2);
    border-radius: 24px;
    box-shadow: var(--swh-glass-shadow);
    padding: var(--swh-spacing-lg);
    color: var(--swh-cream);
}

/* ========================================
   遊戲通用組件
======================================== */
.swh-game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--swh-spacing-md);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: var(--swh-spacing-lg);
    position: relative;
    z-index: 1;
}

.swh-game-prompt {
    font-size: 24px;
    font-weight: 700;
    color: var(--swh-cream);
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: var(--swh-spacing-sm);
}

/* ========================================
   幼兒友善按鈕 (≥80x80px)
======================================== */
.swh-btn {
    min-width: var(--swh-touch-min);
    min-height: var(--swh-touch-min);
    padding: var(--swh-spacing-md) var(--swh-spacing-lg);
    font-size: 24px;
    font-weight: 700;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--swh-spacing-sm);
}

.swh-btn-primary {
    background: linear-gradient(135deg,
            var(--swh-star-gold) 0%,
            #FFC107 100%);
    color: var(--swh-forest-dark);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.swh-btn-primary:hover,
.swh-btn-primary:active {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

.swh-btn-secondary {
    background: var(--swh-glass-bg);
    color: var(--swh-forest-dark);
    border: 2px solid var(--swh-forest-green);
}

/* ========================================
   互動物件 (可點擊/拖放)
======================================== */
.swh-interactive {
    min-width: var(--swh-touch-min);
    min-height: var(--swh-touch-min);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: none;
}

.swh-interactive:hover,
.swh-interactive:active {
    transform: scale(1.1);
}

.swh-interactive.selected {
    box-shadow: 0 0 0 4px var(--swh-star-gold);
}

/* 發光動畫 (5秒無動作提示) */
.swh-glow-hint {
    animation: glowPulse 1s ease-in-out infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.9);
    }
}

/* 跳動動畫提示 */
.swh-bounce-hint {
    animation: bounceHint 0.5s ease-in-out infinite;
}

@keyframes bounceHint {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ========================================
   Willo 角色容器
======================================== */
.swh-willo-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 150px;
    height: 150px;
    pointer-events: none;
    z-index: 100;
}

.swh-willo-container canvas {
    width: 100%;
    height: 100%;
    background: transparent;
}

/* Willo 出現動畫 */
.swh-willo-appear {
    animation: willoAppear 0.5s ease-out;
}

@keyframes willoAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(50px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========================================
   遊戲區域樣式
======================================== */

/* 🎮 遊戲一：微光發現家 */
.swh-insight-explorer {
    background: linear-gradient(135deg,
            var(--swh-forest-green) 0%,
            #3D5A4E 100%);
    border-radius: 24px;
    padding: var(--swh-spacing-lg);
    min-height: 350px;
    position: relative;
    overflow: hidden;
}

.swh-library-scene {
    width: 100%;
    height: 300px;
    position: relative;
}

.swh-golden-key {
    position: absolute;
    width: 60px;
    height: 60px;
    font-size: 40px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
}

.swh-golden-key:hover {
    transform: scale(1.2);
}

/* 🎮 遊戲二：雲端建築師 */
.swh-resilience-architect {
    background: linear-gradient(180deg,
            #1A2B3C 0%,
            #2D4A5E 50%,
            var(--swh-forest-green) 100%);
    border-radius: 24px;
    padding: var(--swh-spacing-lg);
    min-height: 400px;
    position: relative;
}

.swh-cloud-platform {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 60px;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(200, 200, 255, 0.7) 100%);
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: cloudBreathe 3s ease-in-out infinite;
}

@keyframes cloudBreathe {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
    }

    50% {
        transform: translateX(-50%) scale(1.05);
    }
}

.swh-block {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    cursor: grab;
    transition: all 0.3s ease;
    touch-action: none;
    box-shadow:
        inset 3px 3px 10px rgba(255, 255, 255, 0.4),
        inset -3px -3px 10px rgba(0, 0, 0, 0.2),
        0 5px 15px rgba(0, 0, 0, 0.3);
}

.swh-block.snapped {
    animation: snapEffect 0.3s ease;
}

@keyframes snapEffect {
    0% {
        transform: scale(1.2);
    }

    50% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

/* 失敗時的溫暖粉色背景 */
.swh-gentle-fail {
    background-color: var(--swh-gentle-pink) !important;
    transition: background-color 0.5s ease;
}

/* 🎮 遊戲三：星際守護者 */
.swh-resource-steward {
    display: flex;
    flex-direction: column;
    gap: var(--swh-spacing-lg);
}

.swh-planets-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--swh-spacing-md);
}

.swh-planet {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.swh-planet-toys {
    background: linear-gradient(135deg,
            #FF9A8B 0%,
            #FF6B95 100%);
}

.swh-planet-fruits {
    background: linear-gradient(135deg,
            #56ab2f 0%,
            #a8e063 100%);
}

.swh-planet.highlight {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

.swh-conveyor {
    width: 100%;
    height: 100px;
    background: linear-gradient(90deg,
            #555 0px,
            #777 2px,
            #555 4px);
    background-size: 4px 100%;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--swh-spacing-md);
    animation: conveyorMove 2s linear infinite;
}

@keyframes conveyorMove {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 40px 0;
    }
}

.swh-item {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: grab;
    touch-action: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 錯誤時彈回動畫 */
.swh-bounce-back {
    animation: bounceBack 0.5s ease-out;
}

@keyframes bounceBack {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-20px);
    }

    50% {
        transform: translateX(10px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* 🎮 遊戲四：星願收集瓶 */
.swh-wish-bottle {
    width: 150px;
    height: 250px;
    background: linear-gradient(180deg,
            rgba(200, 230, 255, 0.3) 0%,
            rgba(150, 200, 255, 0.5) 100%);
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px 30px 60px 60px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 0 30px rgba(255, 255, 255, 0.3),
        0 10px 40px rgba(0, 0, 0, 0.2);
}

/* 流光效果 */
.swh-wish-bottle::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent 40%,
            rgba(255, 255, 255, 0.4) 50%,
            transparent 60%);
    animation: bottleShine 3s linear infinite;
}

@keyframes bottleShine {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.swh-star-slot {
    width: 60px;
    height: 60px;
    border: 3px dashed rgba(255, 215, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--swh-spacing-sm);
}

.swh-star-slot.filled {
    border-color: var(--swh-star-gold);
    background: rgba(255, 215, 0, 0.2);
}

.swh-collectible-star {
    width: 80px;
    height: 80px;
    font-size: 50px;
    cursor: grab;
    touch-action: none;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
    transition: transform 0.2s ease;
}

.swh-collectible-star:hover {
    transform: scale(1.2) rotate(15deg);
}

/* 全螢幕流星動畫 */
.swh-meteor-shower {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.swh-meteor {
    position: absolute;
    width: 4px;
    height: 80px;
    background: linear-gradient(180deg,
            rgba(255, 215, 0, 0) 0%,
            rgba(255, 215, 0, 1) 100%);
    border-radius: 50%;
    animation: meteorFall 1s linear forwards;
}

@keyframes meteorFall {
    0% {
        transform: translateY(-100vh) translateX(0) rotate(45deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) translateX(-100px) rotate(45deg);
        opacity: 0;
    }
}

/* 🎮 遊戲五：時光果實管理員 */
.swh-sop-logic {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--swh-spacing-lg);
}

.swh-seed {
    width: 100px;
    height: 100px;
    font-size: 60px;
    animation: seedGlow 2s ease-in-out infinite;
}

@keyframes seedGlow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3) drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
    }
}

.swh-tool {
    width: var(--swh-touch-min);
    height: var(--swh-touch-min);
    font-size: 50px;
    background: var(--swh-glass-bg);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.swh-tool.locked {
    opacity: 0.4;
    filter: grayscale(1);
    cursor: not-allowed;
}

.swh-tool.unlocked {
    opacity: 1;
    filter: none;
    cursor: pointer;
}

.swh-tool:not(.locked):hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* 虛線光圈提示 */
.swh-guide-circle {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 3px dashed var(--swh-star-gold);
    border-radius: 50%;
    animation: guideCirclePulse 1s ease-in-out infinite;
    pointer-events: none;
}

@keyframes guideCirclePulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* 鑽石果實 */
.swh-diamond-fruit {
    font-size: 80px;
    animation: diamondSparkle 0.5s ease-out;
}

@keyframes diamondSparkle {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   專區選單卡片
======================================== */
.swh-zone-header {
    background: linear-gradient(135deg,
            var(--swh-forest-green) 0%,
            var(--swh-forest-light) 100%);
    color: var(--swh-cream);
    padding: var(--swh-spacing-lg);
    border-radius: 20px;
    margin-bottom: var(--swh-spacing-lg);
    text-align: center;
}

.swh-zone-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: var(--swh-spacing-sm);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.swh-zone-subtitle {
    font-size: 16px;
    opacity: 0.9;
}

.swh-game-card {
    background: var(--swh-glass-bg);
    backdrop-filter: var(--swh-glass-blur);
    border-radius: 20px;
    padding: var(--swh-spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--swh-spacing-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-height: 150px;
}

.swh-game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(45, 74, 62, 0.3);
    border-color: var(--swh-star-gold);
}

.swh-game-card-icon {
    font-size: 48px;
}

.swh-game-card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--swh-forest-dark);
    text-align: center;
}

.swh-game-card-attribute {
    font-size: 12px;
    color: var(--swh-forest-green);
    background: rgba(45, 74, 62, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
}

/* ========================================
   數據追蹤 UI (家長報告)
======================================== */
.swh-analytics-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--swh-forest-green);
    color: var(--swh-cream);
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 10px;
    opacity: 0.7;
}

/* ========================================
   響應式設計
======================================== */
@media (max-width: 480px) {
    .swh-game-prompt {
        font-size: 20px;
    }

    .swh-btn {
        min-width: 70px;
        min-height: 70px;
        font-size: 20px;
    }

    .swh-planet {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }

    .swh-wish-bottle {
        width: 120px;
        height: 200px;
    }
}