/* 太阳系动态运转模拟 — UI 样式
   配色沿用 galaxy 站: 深空黑背景 + 唯一强调色(亮蓝 #5fd0ff)
   禁纯黑 #000000 / 禁纯白 #ffffff */

:root {
    --bg:          #08090c;
    --bg-panel:    rgba(14, 16, 21, 0.82);
    --border:      rgba(255, 255, 255, 0.09);
    --border-str:  rgba(255, 255, 255, 0.16);

    --text:        #e8e9ec;
    --text-dim:    #8a8f98;
    --text-faint:  #5d626b;

    --accent:      #5fd0ff;
    --accent-dim:  rgba(95, 208, 255, 0.16);
    --accent-line: rgba(95, 208, 255, 0.4);

    --warm:        #ffd2a1;
    --sun:         #ffd27a;

    --radius:      10px;
    --radius-sm:   6px;

    --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
            -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

#scene {
    position: fixed;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}
#scene:active { cursor: grabbing; }

/* ---------------------------------------------------------- 载入态 */

#boot {
    position: fixed;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 14px;
    justify-items: center;
    background: var(--bg);
    z-index: 50;
    transition: opacity 0.6s ease;
}
#boot.hidden { opacity: 0; pointer-events: none; }

.boot-ring {
    width: 42px; height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.boot-text { font-size: 13px; color: var(--text-dim); letter-spacing: 0.04em; }
#boot-error { color: #ff8080; font-size: 13px; max-width: 80vw; text-align: center; }

/* ---------------------------------------------------------- 标题 */

#title {
    position: fixed;
    top: 26px;
    left: 30px;
    z-index: 10;
    pointer-events: none;
}
#title h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
#title p {
    margin: 5px 0 0;
    font-size: 12px;
    color: var(--text-faint);
    font-family: var(--mono);
    letter-spacing: 0.03em;
}
#title .title-note { margin-top: 3px; font-size: 11px; color: rgba(95, 208, 255, 0.62); }

.back-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--text-dim);
    text-decoration: none;
    border-bottom: 1px solid var(--border-str);
    padding-bottom: 1px;
    pointer-events: auto;
    transition: color 0.18s ease, border-color 0.18s ease;
}
.back-link:hover { color: var(--accent); border-color: var(--accent-line); }

/* ---------------------------------------------------------- 节气面板 (左上角) */

#term-bar {
    position: fixed;
    top: 132px;
    left: 30px;
    z-index: 15;
    width: 268px;
    padding: 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
    display: flex;
    align-items: center;
    gap: 12px;
}

.term-now { flex: 0 0 auto; }
.term-now-label, .term-next-label {
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    font-family: var(--mono);
}
.term-now-name {
    font-size: 22px;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.15;
    margin-top: 3px;
}
.term-now-meta {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--mono);
    margin-top: 2px;
}

.term-ring {
    position: relative;
    flex: 0 0 74px;
    width: 74px;
    height: 74px;
}
#term-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.term-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 4;
}
.term-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.2s linear;
}
.term-ring-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
}
.term-ring-degree { font-size: 12.5px; color: var(--text); }
.term-ring-label { font-size: 7.5px; color: var(--text-faint); font-family: var(--mono); }

.term-next {
    flex: 0 0 auto;
    text-align: right;
}
.term-next-name {
    font-size: 14px;
    color: var(--text);
    margin-top: 3px;
    line-height: 1.2;
}
.term-next-meta {
    font-size: 9.5px;
    color: var(--text-faint);
    font-family: var(--mono);
    margin-top: 2px;
}

/* ---------------------------------------------------------- 右侧面板 */

#info-panel {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 300px;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    z-index: 20;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}
#info-panel.collapsed {
    transform: translateX(calc(100% + 30px));
    opacity: 0;
    pointer-events: none;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
}
.panel-head span {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-family: var(--mono);
}

.panel-body { padding: 4px 0 8px; }

.sec {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sec:last-child { border-bottom: none; }

.sec-title {
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    font-family: var(--mono);
    margin-bottom: 9px;
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 3px 0;
    font-size: 12.5px;
}
.row .k { color: var(--text-dim); white-space: nowrap; }
.row .v {
    font-family: var(--mono);
    color: var(--text);
    text-align: right;
    font-size: 12px;
}
.row .v.accent { color: var(--accent); }
.row .v.warm { color: var(--warm); }

/* 天体档案 */

.body-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}
.body-dot {
    width: 13px; height: 13px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 9px currentColor;
}
.body-title { min-width: 0; flex: 1; }
.body-name { font-size: 16px; font-weight: 600; line-height: 1.2; }
.body-latin {
    font-size: 10.5px;
    font-style: italic;
    color: var(--accent);
    font-family: var(--mono);
    margin-top: 1px;
}
.body-tag {
    font-size: 9.5px;
    font-family: var(--mono);
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid var(--border-str);
    color: var(--text-dim);
    flex-shrink: 0;
}
.tag-planet { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }
.tag-dwarf  { color: var(--warm);   border-color: rgba(255, 210, 161, 0.4); }
.tag-star   { color: var(--sun);    border-color: rgba(255, 210, 122, 0.45); }

.body-note {
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.stat {
    background: rgba(255, 255, 255, 0.02);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat-k { font-size: 9.5px; color: var(--text-faint); }
.stat-v { font-size: 11px; color: var(--text); }

.moon-list-head {
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    font-family: var(--mono);
    margin: 12px 0 7px;
}
.moon-list { display: flex; flex-direction: column; gap: 9px; }
.moon-row { display: flex; gap: 8px; }
.moon-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.moon-main { min-width: 0; flex: 1; }
.moon-name { font-size: 12.5px; font-weight: 600; }
.moon-latin {
    font-size: 9.5px;
    font-style: italic;
    color: var(--accent);
    font-family: var(--mono);
    margin-left: 4px;
}
.moon-meta { font-size: 9.5px; color: var(--text-faint); margin-top: 1px; }
.moon-note { font-size: 10.5px; color: var(--text-dim); line-height: 1.5; margin-top: 3px; }

/* 节气列表 */

.term-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.term-row {
    background: rgba(255, 255, 255, 0.02);
    padding: 5px 7px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    cursor: pointer;
    transition: background 0.16s ease;
}
.term-row:hover { background: rgba(95, 208, 255, 0.08); }
.term-row.active {
    background: var(--accent-dim);
    box-shadow: inset 2px 0 0 var(--accent);
}
.term-row-name { font-size: 11.5px; color: var(--text); }
.term-row.active .term-row-name { color: var(--accent); font-weight: 600; }
.term-row-lon { font-size: 9px; color: var(--text-faint); }
.term-row-date { font-size: 8.5px; color: var(--text-faint); opacity: 0.75; }

/* ---------------------------------------------------------- 按钮 */

.btn-row { display: flex; gap: 6px; margin-top: 4px; }

.btn {
    flex: 1;
    padding: 7px 6px;
    font-size: 12px;
    font-family: var(--font);
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.075); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.active {
    background: var(--accent-dim);
    border-color: var(--accent-line);
    color: var(--accent);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 图例 */

.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    color: var(--text-dim);
}
.legend-swatch { width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0; }

/* ---------------------------------------------------------- 天体标签 */

#label-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 8;
    overflow: hidden;
}
.body-label {
    position: absolute;
    top: 0; left: 0;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.02em;
    /* ⚠️ 标签必须有自己的底衬, 否则和轨道线叠在一起完全读不出来
       (截图评审: "标签与轨道线重叠, 辨识度不足")。
       半透明深色圆角块 + 细描边, 与深空背景不冲突。 */
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(6, 9, 14, 0.62);
    border: 1px solid rgba(120, 170, 210, 0.13);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.label-sun {
    color: var(--sun);
    font-size: 12px;
    font-weight: 600;
    background: rgba(30, 18, 4, 0.55);
    border-color: rgba(255, 200, 100, 0.22);
}
.label-planet { color: #c3cedb; }
.label-sel {
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
    background: rgba(6, 20, 32, 0.78);
    border-color: rgba(95, 208, 255, 0.45);
}
.label-moon {
    color: #93a3b3;
    font-size: 9.5px;
    font-family: var(--mono);
    background: rgba(6, 9, 14, 0.5);
    border-color: rgba(120, 170, 210, 0.08);
    padding: 0 4px;
}

/* ---------------------------------------------------------- 底部控制条 */

#controls {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

#speed-options { display: flex; gap: 5px; }

.scale-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 13px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease;
    font-family: var(--font);
}
.scale-btn:hover { background: rgba(255, 255, 255, 0.075); }
.scale-btn:active { transform: translateY(1px); }
.scale-btn.active { background: var(--accent-dim); border-color: var(--accent-line); }
.scale-main { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.scale-btn.active .scale-main { color: var(--accent); }
.scale-sub { font-size: 10px; color: var(--text-faint); font-family: var(--mono); }
.scale-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ctrl-sep { width: 1px; height: 30px; background: var(--border); }

.icon-btn {
    width: 34px; height: 34px;
    display: grid;
    place-items: center;
    font-size: 14px;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.075); color: var(--text); }
.icon-btn.paused { color: var(--accent); border-color: var(--accent-line); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#panel-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 21;
    width: 34px; height: 34px;
    display: grid;
    place-items: center;
    color: var(--text-dim);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, color 0.18s ease;
}
#info-panel.collapsed ~ #panel-toggle { opacity: 1; pointer-events: auto; }
#panel-toggle:hover { color: var(--accent); }

/* ---------------------------------------------------------- 提示 */

#hint {
    position: fixed;
    bottom: 92px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    font-size: 11.5px;
    color: var(--text-faint);
    font-family: var(--mono);
    letter-spacing: 0.04em;
    pointer-events: none;
    text-align: center;
    transition: opacity 0.6s ease;
}
#hint.fade { opacity: 0; }

/* ---------------------------------------------------------- 移动端 */

@media (max-width: 820px) {
    #title { top: 16px; left: 18px; }
    #title h1 { font-size: 16px; }
    #title p { font-size: 11px; }

    #term-bar {
        top: 108px;
        left: 12px;
        right: 12px;
        width: auto;
        padding: 10px 12px;
    }
    .term-now-name { font-size: 18px; }
    .term-ring { flex: 0 0 60px; width: 60px; height: 60px; }

    #info-panel {
        top: auto;
        bottom: 92px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: 44dvh;
        transform: translateY(0);
    }
    #info-panel.collapsed { transform: translateY(calc(100% + 100px)); }
    #panel-toggle { top: 16px; right: 16px; }

    #controls {
        bottom: 16px;
        left: 12px;
        right: 12px;
        transform: none;
        flex-wrap: wrap;
        justify-content: center;
        gap: 9px;
    }
    .scale-btn { padding: 5px 9px; }
    .scale-main { font-size: 11.5px; }

    #hint { bottom: auto; top: 78px; font-size: 10.5px; }
}

/* ---------------------------------------------------------- 降级 */

@media (prefers-reduced-motion: reduce) {
    .boot-ring { animation: none; }
    * { transition-duration: 0.01ms !important; }
}

@media (prefers-reduced-transparency: reduce) {
    #info-panel, #controls, #panel-toggle, #term-bar {
        background: rgba(12, 14, 18, 0.96);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
