/* ============================================================
 * 郴州市第六中学 · 地球公转自转模拟（课堂版）
 * 响应式样式（手机端 + 电脑端双端适配）
 * ============================================================ */

/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 学校主题色 + 尺寸/间距设计令牌 */
:root {
    --school-blue: #1E5CB3;
    --school-blue-light: #4a8ad6;
    --school-red: #C0282D;

    --panel-bg: #111;
    --panel-border: #333;
    --text-muted: #cccccc;

    /* 布局令牌 */
    --sidebar-width: 300px;
    --canvas-max: 900px;
    --header-h: 52px;
    --gap: 20px;
    --radius: 8px;

    /* 触控目标最小尺寸（手机端） */
    --touch: 46px;
}

/* 页面背景和文字颜色 —— 纵向排布：头部 + 主体 */
html {
    scroll-behavior: smooth;
}

body {
    background-color: #000;
    color: white;
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    /* 防止 iOS 双击缩放导致的横向溢出 */
    overflow-x: hidden;
}

/* ============================================================
 * 主容器：桌面端 = 画布 + 侧栏 双列
 * ============================================================ */
.main-container {
    flex: 1;
    display: flex;
    gap: var(--gap);
    align-items: flex-start;
    justify-content: center;
    padding: var(--gap);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* 画布容器 —— 自适应缩放，永不溢出 */
.canvas-container {
    position: relative;
    flex: 1 1 auto;
    max-width: var(--canvas-max);
    min-width: 0; /* 允许在 flex 中收缩 */
    display: flex;
    justify-content: center;
}

/* 主画布：内部分辨率固定 900×700，用 CSS 等比缩放显示 */
#simulationCanvas {
    display: block;
    width: 100%;
    max-width: var(--canvas-max);
    height: auto;          /* 保持 900:700 比例 */
    border: 1px solid #ffffff;
    border-radius: 5px;
    background: #000;
}

/* 日食/月食小窗口 —— 相对画布定位，随画布缩放 */
#eclipseCanvas {
    display: none;
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 26%;             /* 相对画布宽度，随之缩放 */
    height: auto;
    max-width: 230px;
    border: 1px solid #666;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10;
}

/* ============================================================
 * 控制面板 —— 桌面端为可滚动侧栏
 * ============================================================ */
#controlsPanel {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    align-self: stretch;
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.08);
    /* 侧栏跟随滚动并可独立滚动 */
    position: sticky;
    top: var(--gap);
    max-height: calc(100vh - var(--header-h) - var(--gap) * 2);
    overflow-y: auto;
}

#controlsPanel h3 {
    margin-bottom: 15px;
    color: var(--school-blue);
    text-align: center;
    font-size: 18px;
    text-shadow: 0 0 10px rgba(30, 92, 179, 0.5);
}

/* ============================================================
 * 按钮 —— 科技感 + 学校主题色（默认桌面样式）
 * ============================================================ */
button {
    background: linear-gradient(45deg, var(--school-blue), #144a8f);
    border: 1px solid var(--school-blue);
    color: white;
    padding: 10px 20px;
    margin: 5px 0;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.25s ease;
    box-shadow: 0 2px 10px rgba(30, 92, 179, 0.35);
    position: relative;
    overflow: hidden;
    width: 100%;          /* 面板内按钮占满一列，视觉整齐 */
    min-height: 42px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button:hover {
    background: linear-gradient(45deg, #2a70cc, var(--school-blue));
    box-shadow: 0 4px 20px rgba(30, 92, 179, 0.55);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(30, 92, 179, 0.35);
}

button:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

button:hover:before {
    left: 100%;
}

/* 下拉选框 —— 科技感 + 学校主题色 */
select {
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border: 1px solid var(--school-blue);
    color: white;
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    width: 100%;
    min-height: 42px;
    transition: all 0.25s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(30, 92, 179, 0.25);
}

select:hover {
    border-color: var(--school-blue-light);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5), 0 2px 15px rgba(30, 92, 179, 0.45);
}

select:focus {
    border-color: var(--school-blue);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5), 0 0 20px rgba(30, 92, 179, 0.65);
}

select option {
    background-color: #1a1a1a;
    color: white;
    padding: 5px;
}

/* range 输入 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 5px;
    background: linear-gradient(to right, #333, #666);
    outline: none;
    margin: 10px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--school-blue), #2a70cc);
    cursor: pointer;
    border: 2px solid var(--school-blue);
    box-shadow: 0 0 10px rgba(30, 92, 179, 0.55);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--school-blue), #2a70cc);
    cursor: pointer;
    border: 2px solid var(--school-blue);
    box-shadow: 0 0 10px rgba(30, 92, 179, 0.55);
}

/* 速度下拉的 label（区别于 checkbox label） */
.control-group > label[for] {
    display: block;
    margin: 8px 0 4px 0;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: bold;
}

/* 控制组 */
.control-group {
    margin-bottom: 18px;
    padding: 15px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
    transition: border-color 0.25s ease, background 0.25s ease;
}

.control-group:hover {
    border-color: #555;
    background: rgba(255, 255, 255, 0.05);
}

.control-group h4 {
    color: #6ba3e8;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(30, 92, 179, 0.35);
    padding-bottom: 5px;
}

/* 复选框 label */
label {
    display: flex;
    align-items: center;
    margin: 8px 0;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    min-height: 28px;
}

label:hover {
    color: #ffffff;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: var(--school-blue);
    flex-shrink: 0;
}

/* ============================================================
 * 信息面板（实时状态）—— 桌面端固定右上角
 * ============================================================ */
#infoPanel {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    right: 10px;
    background: rgba(17, 17, 17, 0.9);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 10px 12px;
    min-width: 150px;
    z-index: 1500;
    backdrop-filter: blur(4px);
}

#infoPanel h4 {
    color: var(--school-blue);
    margin: 0 0 8px 0;
    font-size: 14px;
    text-align: center;
}

#realTimeInfo {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#realTimeInfo span {
    color: var(--text-muted);
    font-size: 12px;
    font-family: monospace;
}

/* 快捷键信息 */
.shortcut-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.shortcut-info span {
    color: #aaaaaa;
    font-size: 11px;
    padding: 2px 0;
}

/* 天体信息 */
#celestialInfo {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#celestialInfo div {
    color: var(--text-muted);
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid var(--panel-border);
}

#celestialInfo div:last-child {
    border-bottom: none;
}

/* ============================================================
 * 手机端控件：切换按钮 + 遮罩（桌面隐藏）
 * ============================================================ */
.mobile-controls-toggle {
    display: none;              /* 桌面隐藏，手机端由媒体查询显示 */
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2600;
    width: auto;
    min-width: 0;
    padding: 0 20px;
    height: 52px;
    border-radius: 26px;
    font-size: 15px;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: 0 4px 18px rgba(30, 92, 179, 0.6);
}

.controls-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2400;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.controls-backdrop.show {
    display: block;
    opacity: 1;
}

/* ============================================================
 * 学校品牌头（课堂版）
 * ============================================================ */
#schoolHeader {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #162d5e 0%, var(--school-blue) 50%, #163a70 100%);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 3px solid var(--school-red);
    box-shadow: 0 2px 15px rgba(30, 92, 179, 0.4);
    position: sticky;
    top: 0;
    z-index: 2000;
    text-align: center;
}

#schoolHeader .school-logo {
    font-size: 22px;
    flex-shrink: 0;
}

#schoolHeader .school-accent {
    color: var(--school-red);
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================================
 * 四季成因面板
 * ============================================================ */
.seasons-btn {
    background: linear-gradient(45deg, var(--school-red), #9b2025) !important;
    border-color: var(--school-red) !important;
    box-shadow: 0 2px 10px rgba(192, 40, 45, 0.35) !important;
    text-transform: none !important;
}

.seasons-btn:hover {
    box-shadow: 0 4px 20px rgba(192, 40, 45, 0.6) !important;
    transform: translateY(-2px);
}

.seasons-panel {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - var(--header-h) - 30px);
    overflow-y: auto;
    background: linear-gradient(160deg, rgba(17, 20, 28, 0.97), rgba(25, 32, 45, 0.97));
    border: 2px solid var(--school-blue);
    border-radius: 12px;
    box-shadow:
        0 8px 35px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(30, 92, 179, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    z-index: 3000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    color: #e8eef5;
    font-family: 'Microsoft YaHei', 'Arial', sans-serif;
    -webkit-overflow-scrolling: touch;
}

.seasons-panel.hidden {
    display: none;
}

.seasons-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(30, 92, 179, 0.3);
    background: linear-gradient(90deg, rgba(30, 92, 179, 0.15), transparent);
    border-radius: 10px 10px 0 0;
    position: sticky;
    top: 0;
    backdrop-filter: blur(6px);
}

.seasons-panel-header h4 {
    margin: 0;
    font-size: 16px;
    color: var(--school-blue);
    text-shadow: 0 0 8px rgba(30, 92, 179, 0.4);
}

.seasons-close-btn {
    background: rgba(192, 40, 45, 0.15) !important;
    border: 1px solid var(--school-red) !important;
    color: var(--school-red) !important;
    width: auto !important;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 4px 12px !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.seasons-close-btn:hover {
    background: var(--school-red) !important;
    color: white !important;
    transform: none !important;
}

.seasons-close-btn:before {
    display: none !important;
}

.seasons-panel-body {
    padding: 16px 18px 18px 18px;
    line-height: 1.75;
    font-size: 14px;
}

.seasons-intro {
    margin-bottom: 12px;
    color: #cdd8ea;
}

.seasons-points {
    list-style: none;
    padding: 0;
    margin: 0 0 14px 0;
}

.seasons-points li {
    position: relative;
    padding-left: 22px;
    margin-bottom: 11px;
    color: #d0dae8;
}

.seasons-points li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--school-blue);
    box-shadow: 0 0 6px rgba(30, 92, 179, 0.55);
}

.highlight-value {
    color: var(--school-blue);
    font-weight: bold;
    font-size: 15px;
    text-shadow: 0 0 6px rgba(30, 92, 179, 0.4);
}

.seasons-tip-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(30, 92, 179, 0.12), rgba(192, 40, 45, 0.08));
    border-left: 3px solid var(--school-red);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.65;
    color: #bfcce0;
}

/* ============================================================
 * 动画与工具提示
 * ============================================================ */
@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(0, 170, 255, 0.5); }
    50% { box-shadow: 0 0 20px rgba(0, 170, 255, 0.8); }
    100% { box-shadow: 0 0 5px rgba(0, 170, 255, 0.5); }
}

.glow-effect {
    animation: glow 2s infinite;
}

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid var(--school-blue);
    font-size: 12px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* 自定义滚动条 */
#controlsPanel::-webkit-scrollbar,
.seasons-panel::-webkit-scrollbar {
    width: 8px;
}

#controlsPanel::-webkit-scrollbar-track,
.seasons-panel::-webkit-scrollbar-track {
    background: #111;
    border-radius: 4px;
}

#controlsPanel::-webkit-scrollbar-thumb,
.seasons-panel::-webkit-scrollbar-thumb {
    background: var(--school-blue);
    border-radius: 4px;
}

#controlsPanel::-webkit-scrollbar-thumb:hover,
.seasons-panel::-webkit-scrollbar-thumb:hover {
    background: var(--school-blue-light);
}

/* ============================================================
 * 响应式断点
 * ============================================================ */

/* 超宽屏（≥1440px）：画布更大、侧栏更宽，提升信息密度 */
@media (min-width: 1440px) {
    :root {
        --sidebar-width: 340px;
        --canvas-max: 1000px;
    }
}

/* 平板 / 中屏（≤1100px）：改为纵向堆叠，画布在上、控制在下 */
@media (max-width: 1100px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }

    .canvas-container {
        width: 100%;
        max-width: var(--canvas-max);
    }

    #controlsPanel {
        position: static;
        flex: none;
        width: 100%;
        max-width: 640px;
        max-height: none;
        overflow: visible;
    }

    /* 平板下控制组两列排布，提升信息密度 */
    #controlsPanel .control-group {
        break-inside: avoid;
    }

    .controls-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        align-items: start;
    }

    #infoPanel {
        top: calc(var(--header-h) + 8px);
        right: 8px;
        min-width: 130px;
        padding: 8px 10px;
    }
}

/* 手机端（≤768px）：底部抽屉式控制面板 + 触控优化 */
@media (max-width: 768px) {
    :root {
        --gap: 12px;
    }

    #schoolHeader {
        font-size: 13px;
        letter-spacing: 1px;
        padding: 9px 12px;
        gap: 8px;
    }

    #schoolHeader .school-logo {
        font-size: 18px;
    }

    .main-container {
        padding: 10px;
        gap: 10px;
    }

    .canvas-container {
        width: 100%;
    }

    /* 控制面板 → 底部抽屉，默认收起 */
    #controlsPanel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 78vh;
        overflow-y: auto;
        border-radius: 18px 18px 0 0;
        border: 1px solid var(--panel-border);
        border-bottom: none;
        box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.7);
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
        z-index: 2500;
        -webkit-overflow-scrolling: touch;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    #controlsPanel.open {
        transform: translateY(0);
    }

    /* 抽屉顶部拖动提示条 */
    #controlsPanel::before {
        content: '';
        display: block;
        width: 44px;
        height: 5px;
        border-radius: 3px;
        background: #555;
        margin: 0 auto 12px;
    }

    /* 单列布局，触控按钮加大 */
    .controls-grid {
        display: block;
    }

    button,
    select {
        min-height: var(--touch);
        font-size: 15px;
    }

    .control-group label {
        min-height: 40px;    /* 复选框行更易点 */
        font-size: 15px;
    }

    input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    /* 手机端隐藏键盘快捷键组（无实体键盘） */
    .shortcuts-group {
        display: none;
    }

    /* 显示手机端切换按钮 */
    .mobile-controls-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    /* 实时状态面板：缩小为顶部左侧小胶囊 */
    #infoPanel {
        top: auto;
        bottom: 80px;
        left: 10px;
        right: auto;
        min-width: 0;
        padding: 6px 10px;
        opacity: 0.92;
    }

    #infoPanel h4 {
        display: none;      /* 手机端省空间，仅留数值 */
    }

    #realTimeInfo {
        flex-direction: row;
        gap: 10px;
    }

    /* 四季成因面板：手机端近全屏 */
    .seasons-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
    }
}

/* 极小屏（≤380px）微调 */
@media (max-width: 380px) {
    #schoolHeader {
        font-size: 12px;
    }

    #schoolHeader .school-accent {
        display: none;
    }
}

/* 横屏手机：抽屉高度收敛，避免遮挡画布 */
@media (max-width: 900px) and (orientation: landscape) {
    #controlsPanel {
        max-height: 88vh;
    }
}

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
