/* style.css - 优化和响应式适配 */

/* 字体基础设置 */
body {
    margin: 0;
    background-color: #080b10;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    color: #d1eaff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* 解决小屏下的拖动问题 */
    overflow: hidden; 
}

/* Canvas：默认占据整个视口 */
canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* 桌面端/默认状态 */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s;
}

/* 工具提示框 */
#tooltip {
    position: fixed; 
    padding: 10px;
    background: rgba(40, 44, 52, 0.95);
    border: 1px solid #00c8ff;
    border-radius: 5px;
    color: #e6f7ff;
    font-size: 0.9em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    transform: translate(15px, 15px);
    z-index: 50; 
    max-width: 250px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

#tooltip p {
    margin: 3px 0;
    line-height: 1.4;
}
#tooltip strong {
    color: #00c8ff;
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

/* 顶部容器：用于布局标题和语言切换 */
#top-bar-container {
    position: absolute;
    top: 20px;
    left: 0; 
    right: 0;
    display: flex;
    justify-content: center; /* 确保标题居中 */
    align-items: flex-start; /* 保持顶部对齐 */
    z-index: 35;
    pointer-events: none;
    padding: 0 20px; /* 增加左右内边距 */
}

/* 标题栏样式：保持居中 */
#header {
    pointer-events: auto;
    padding: 8px 15px;
    background: rgba(10, 20, 30, 0.8);
    border: 2px solid #00c8ff; 
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.5); 
    border-radius: 5px;
    text-align: center;
    min-width: 300px;
    transition: opacity 0.3s;
    /* 在弹性布局中占据中心位置，不需要额外的 margin 调整 */
}
#header h1 {
    margin: 0;
    font-size: 1.4em;
    color: #ffffff;
    letter-spacing: 2px;
    text-shadow: 0 0 5px #00c8ff;
    font-family: 'Consolas', 'Courier New', monospace; 
}

/* 语言切换容器：移至最右上角，使用绝对定位 */
#language-switcher-container {
    pointer-events: auto;
    position: absolute; 
    right: 20px; 
    top: 0; 
    z-index: 90; 
    display: block; 
}

#language-toggle {
    padding: 10px 18px; 
    background: rgba(40, 44, 52, 0.95); 
    border: 2px solid #00c8ff;
    border-radius: 10px; 
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.3);
    color: #e6f7ff; 
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Consolas', monospace;
    transition: all 0.2s ease;
    min-width: 150px; 
    text-align: center;
}

#language-toggle:hover {
    background: rgba(0, 150, 255, 0.2);
    box-shadow: 0 0 12px rgba(0, 200, 255, 0.7);
}

/* 自定义下拉菜单内容 Box */
#language-dropdown {
    display: none; 
    position: absolute;
    top: 100%; 
    right: 0;
    width: 100%; 
    margin-top: 5px; 
    background-color: rgba(10, 20, 30, 0.95); 
    border: 1px solid #00c8ff;
    border-radius: 8px;
    overflow: hidden; 
    box-shadow: 0 4px 15px rgba(0, 200, 255, 0.5);
    min-width: 150px;
}

/* 下拉菜单中的链接/选项样式 */
#language-dropdown a {
    color: #d1eaff;
    padding: 10px 18px;
    text-decoration: none;
    display: block;
    font-size: 0.95em;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.2s, color 0.2s;
}

/* 悬停时的样式 */
#language-dropdown a:hover {
    background-color: rgba(0, 200, 255, 0.2); 
    color: #ffffff;
}

/* 选中的当前语言样式 */
#language-dropdown a.active {
    background-color: #00c8ff;
    color: #080b10; 
    font-weight: bold;
}

/* 控制面板及返回按钮容器 (底部居中) */
#bottom-bar-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 30px; 
    align-items: center;
    z-index: 10;
    pointer-events: auto; /* 确保可以点击 */
}

/* 重置按钮和返回按钮基础样式合并 */
#resetButton, #backButton {
    padding: 10px 20px;
    border-radius: 10px;
    color: #ffffff;
    font-size: 1.0em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

#backButton {
    display: none; 
    background: rgba(0, 150, 255, 0.1);
    border: 2px solid #00c8ff;
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.5);
}
#backButton:hover {
    background: rgba(0, 150, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.8);
}

#resetButton {
    background: rgba(255, 69, 0, 0.1); 
    border: 2px solid #FF4500;
    box-shadow: 0 0 10px rgba(255, 69, 0, 0.5);
}

#resetButton:hover {
    background: rgba(255, 69, 0, 0.3);
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.8);
}


#controls {
    padding: 12px 25px;
    background: rgba(40, 44, 52, 0.95); 
    border-radius: 10px;
    display: flex;
    gap: 30px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: bold;
    color: #00c8ff;
    min-width: 60px;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    height: 8px;
    background: #555;
    outline: none;
    opacity: 0.8;
    transition: opacity .2s;
    border-radius: 4px;
}

.slider:hover {
    opacity: 1;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00c8ff;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 200, 255, 0.8);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00c8ff;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 200, 255, 0.8);
}

#speedValue, #zoomValue {
    width: 40px;
    text-align: right;
    color: #fff;
    font-family: 'Consolas', monospace;
}

/* 侧边信息面板样式：基础（桌面端） */
#sidebar-info {
    position: absolute;
    top: 50%;
    right: 20px; 
    transform: translateY(-50%);
    width: 300px; 
    max-height: 80vh;
    padding: 20px;
    background: rgba(10, 20, 30, 0.9); 
    border: 2px solid #00c8ff; 
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.5);
    border-radius: 8px;
    z-index: 40; 
    opacity: 0; 
    pointer-events: none;
    transition: opacity 0.5s ease;
    overflow-y: auto; 
}

#sidebar-info.visible {
    opacity: 1;
    pointer-events: auto;
}

/* 隐藏侧边栏滚动条 */
#sidebar-info::-webkit-scrollbar {
    display: none;
}

#sidebar-info h2 {
    color: #ffffff;
    font-size: 1.8em;
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(0, 200, 255, 0.5);
    font-family: 'Consolas', monospace;
}

.info-section {
    margin-bottom: 15px;
    padding: 10px;
    border-left: 3px solid #00c8ff;
    background: rgba(0, 200, 255, 0.05);
    color: #d1eaff;
}

.info-section strong {
    display: block;
    color: #00c8ff;
    margin-bottom: 5px;
    font-size: 1.1em;
}

.info-section p {
    margin: 5px 0;
    font-size: 0.9em;
}


/* ------------------------------------ */
/* 加载动画样式 */
/* ------------------------------------ */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #080b10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s; 
}

.spinner {
    border: 8px solid rgba(255, 255, 255, 0.2);
    border-top: 8px solid #00c8ff; 
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#loading-text {
    color: #00c8ff;
    font-size: 1.5em;
    text-shadow: 0 0 5px #00c8ff;
    font-family: 'Consolas', monospace;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ------------------------------------ */
/* 底部版权声明 */
/* ------------------------------------ */
#footer-copyright {
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75em;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    white-space: nowrap;
}

#footer-copyright a {
    color: #00c8ff;
    text-decoration: none;
    transition: color 0.3s;
}

#footer-copyright a:hover {
    color: #fff;
    text-decoration: underline;
}

/* ------------------------------------ */
/* 媒体查询：小屏幕/移动设备适配 (max-width: 768px) */
/* ------------------------------------ */
@media (max-width: 768px) {
    
    /* 调整主体字体大小 */
    body {
        font-size: 14px;
    }
    
    /* --- 关键：Canvas 尺寸调整 --- */
    /* Canvas 高度为视口高度减去信息面板固定高度 250px */
    canvas {
        height: calc(100vh - 250px); 
    }

    /* 顶部容器和标题 */
    #top-bar-container {
        top: 10px;
        padding: 0 10px;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    #header {
        min-width: 80%;
    }

    #header h1 {
        font-size: 1.2em;
    }

    /* 语言切换移动到顶部，使其不与标题重叠 */
    #language-switcher-container {
        position: static; 
        right: auto;
        top: auto;
    }

    #language-toggle {
        padding: 8px 15px;
        font-size: 0.9em;
        min-width: 120px;
    }

    /* 底部容器：解决按钮挤压问题 */
    #bottom-bar-container {
        bottom: 250px; /* 移动到信息面板上方 (250px) */
        left: 50%;
        transform: translateX(-50%);
        gap: 15px;
        width: 95%; 
        flex-wrap: wrap; /* 允许换行，解决挤压 */
        justify-content: center;
        z-index: 60;
    }
    
    /* 控制面板：纵向堆叠控制项 */
    #controls {
        padding: 10px 15px;
        gap: 10px; 
        flex-direction: column; 
        width: 100%; 
        max-width: 300px;
        margin: 0 auto; 
    }

    .control-group {
        justify-content: space-between;
    }
    
    .slider {
        width: 100px;
    }
    
    #resetButton, #backButton {
        padding: 8px 15px;
        font-size: 0.9em;
    }

    /* --- 关键：信息面板固定在底部，可滚动 --- */
    #sidebar-info {
        width: 100%; /* 占据整个宽度 */
        height: 250px; /* 固定高度 */
        max-height: 250px;
        top: auto;
        bottom: 0; /* 底部对齐 */
        right: auto;
        left: 0; /* 左对齐 */
        transform: none; /* 移除 transform 动画 */
        padding: 15px;
        font-size: 0.9em;
        border-radius: 0; /* 移除圆角 */
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        border-width: 2px 0 0 0; /* 仅顶部边框 */
        opacity: 0; /* 默认隐藏 */
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 50; 
        overflow-y: scroll; /* 允许内容超出时滚动 */
    }
    
    /* 展开状态 */
    #sidebar-info.visible {
        opacity: 1; 
        pointer-events: auto;
    }
    
    /* 移除切换按钮样式 */
    #sidebar-toggle {
        display: none !important;
    }
    
    /* 工具提示框字体和最大宽度调整 */
    #tooltip {
        font-size: 0.8em;
        max-width: 180px;
    }
    
    /* 底部版权声明的位置调整 */
    #footer-copyright {
        bottom: 225px; /* 位于信息面板上方 */
    }
}