/* 布局：场景铺满；左上读数，右上摄像头与手势表，底部整条时间刻度。
   颜色只编码两件事：蓝 = 空间，琥珀 = 时间。 */
/* 字体：英文和数字用 Orbitron Medium（SIL OFL 1.1），中文用庞门正道细线体（作者声明免费商用），放在 vendor/fonts。
   每种字体只有一个字重：Orbitron 是可变字体，固定在 500；细线体只有一种，声明成所有字重都用它，浏览器就不会自己加粗 */
@font-face { font-family: "Orbitron"; src: url("../vendor/fonts/Orbitron-wght.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "PangMenZhengDao XiXian"; src: url("../vendor/fonts/PangMenZhengDao-XiXian.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  /* 配色系（页面设计按这一组走，各颜色用在哪里还没定；目前只有"时间"色换成了橘黄）：深蓝黑 #142C38、灰蓝 #376375、橘黄 #DF9856、浅薄荷 #CDE3CE、卡其 #B8AB8C */
  --navy: #142c38; --slate: #376375; --orange: #df9856; --mint: #cde3ce; --khaki: #b8ab8c;
  --space: #8fd0ff; --time: var(--orange); --ink: #ebe4d2; --dim: rgba(235, 228, 210, .62);
  --ground: #04060b; --plate: rgba(9, 13, 22, .72); --rule: rgba(235, 228, 210, .16);
  --display: "Orbitron", "PangMenZhengDao XiXian", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --body: "Orbitron", "PangMenZhengDao XiXian", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --num: "Orbitron", "PangMenZhengDao XiXian", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; font-synthesis: none; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ground); color: var(--ink); font: 14px/1.6 var(--body); }
#scene, #overlay { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#scene { cursor: grab; touch-action: none; }
#scene.grabbing { cursor: grabbing; }
#overlay { pointer-events: none; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; }
#fade.run { animation: fade .7s ease-out; }
@keyframes fade { from { opacity: 1; } to { opacity: 0; } }

header { position: fixed; left: 0; top: 0; padding: 26px 140px 80px 32px; pointer-events: none; text-shadow: 0 0 6px #000, 0 0 2px #000; background: radial-gradient(ellipse at top left, rgba(4, 6, 11, .82) 35%, transparent 70%); }
h1 { margin: 0 0 18px; font: 600 24px/1.3 var(--display); letter-spacing: .06em; }
#info { margin-top: 22px; width: 300px; padding: 14px 16px; background: var(--plate); border-left: 2px solid var(--space); border-radius: 0 3px 3px 0; opacity: 0; transform: translateX(-8px); transition: opacity .35s, transform .35s; }
#info.on { opacity: 1; transform: none; }
#info h2 { margin: 0; font: 600 22px/1.3 var(--display); letter-spacing: .06em; }
/* 标题行就是下拉开关：收起时只剩名字 */
#info-toggle { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: baseline; gap: 10px; cursor: pointer; pointer-events: auto; font: inherit; letter-spacing: inherit; color: var(--ink); }
#info-toggle:focus-visible { outline: 2px solid var(--space); outline-offset: 4px; }
#info-toggle .caret { margin-left: auto; font: 11px var(--body); color: var(--dim); transition: transform .25s; align-self: center; }
#info-toggle[aria-expanded="false"] .caret { transform: rotate(-90deg); }
#info-name { white-space: nowrap; } /* 标题不折行，副标题可以折 */
#info h2 small { font: 13px var(--body); color: var(--dim); letter-spacing: 0; }
#info dl { margin: 8px 0 0; display: grid; gap: 4px; max-height: 60vh; overflow: hidden; transition: max-height .35s ease, opacity .25s ease, margin .35s ease; }
#info.collapsed dl { max-height: 0; opacity: 0; margin-top: 0; }
#info dl div { display: grid; grid-template-columns: 92px 1fr; gap: 8px; }
#info dt { font-size: 13px; }
#info dd { font: 14px/1.45 var(--body); color: var(--ink); }
dt { color: var(--dim); font-size: 13px; }
dd { margin: 0; font: 17px/1.3 var(--num); font-variant-numeric: tabular-nums; color: var(--space); }

aside { position: fixed; right: 28px; top: 24px; width: 300px; display: grid; gap: 10px; justify-items: end; }
nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
button { font: 13px/1 var(--body); color: var(--ink); background: var(--plate); border: 1px solid var(--rule); padding: 9px 12px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--dim); }
button:focus-visible, #strip:focus-visible { outline: 2px solid var(--space); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: wait; }
#pip { display: none; position: relative; width: 208px; background: #000; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
#pip.on { display: block; }
#video { display: block; width: 100%; transform: scaleX(-1); opacity: .62; }
#pip-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
body[data-domain="space"] #pip.on { border-color: var(--space); }
body[data-domain="time"] #pip.on { border-color: var(--time); }
#status { margin: 0; max-width: 100%; text-align: right; color: var(--dim); text-shadow: 0 0 6px #000; opacity: .7; }
#status[data-domain="space"] { color: var(--space); }
#status[data-domain="time"] { color: var(--time); }
#legend { margin: 0; padding: 0; list-style: none; width: 100%; background: var(--plate); border-radius: 3px; font-size: 13px;
  max-height: 0; overflow: hidden; opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: max-height .35s ease, opacity .25s ease, transform .3s ease, padding .35s ease; }
#legend.open { max-height: calc(100vh - 360px); overflow-y: auto; opacity: 1; transform: none; padding: 4px 0; pointer-events: auto; }
/* 设置菜单：竖排，右边灰字是快捷键（取自按钮的 title） */
#btn-settings .caret { display: inline-block; margin-left: 2px; font-size: 10px; transition: transform .25s; }
#btn-settings[aria-expanded="true"] { border-color: var(--dim); }
#btn-settings[aria-expanded="true"] .caret { transform: rotate(180deg); }
#settings { display: grid; min-width: 180px; padding: 4px; background: var(--plate); border: 1px solid var(--rule); border-radius: 3px; }
#settings button { display: flex; justify-content: space-between; gap: 18px; padding: 9px 10px; background: none; border-color: transparent; text-align: left; }
#settings button:hover { background: rgba(235, 228, 210, .08); border-color: transparent; }
#settings button::after { content: attr(title); color: var(--dim); font-size: 11px; }
#settings button[aria-pressed="true"], #settings button[aria-expanded="true"] { color: var(--slate); } /* 选中的选项：配色系的灰蓝 */
/* 当前星群的选项和通用选项之间一条线（每个星群都有自己的选项） */
#settings .sep { margin-top: 4px; border-top: 1px solid var(--rule); border-radius: 0; }
#settings .sep:hover { border-color: var(--rule) transparent transparent; }

#legend li { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; padding: 3px 12px 3px 6px; }
#legend li + li { border-top: 1px solid var(--rule); }
#legend canvas { display: block; width: 84px; height: 36px; }
#legend p { margin: 0; line-height: 1.4; color: var(--dim); }
/* 每条手势的第一行（手势名）用配色系的浅薄荷；伸出食指（时间）保持橘黄 */
#legend b { display: block; font-weight: 600; color: var(--mint); }
#legend .time b { color: var(--time); }
@media (prefers-reduced-motion: reduce) { #legend, #btn-settings .caret { transition: none; } }

#caption { position: fixed; left: 0; right: 0; top: 13%; margin: 0 auto; width: fit-content; max-width: 60vw; font: 600 26px/1.4 var(--display); letter-spacing: .04em; text-align: center; text-shadow: 0 0 14px #000, 0 0 4px #000; pointer-events: none; }

footer { position: fixed; left: 0; right: 0; bottom: 0; pointer-events: none; background: linear-gradient(transparent, rgba(4, 6, 11, .78) 38%, rgba(4, 6, 11, .92)); }
#now { display: flex; gap: 14px; justify-content: center; align-items: baseline; font-family: var(--num); font-variant-numeric: tabular-nums; color: var(--time); text-shadow: 0 0 8px #000; }
#date { font-size: 28px; letter-spacing: .02em; }
/* 日期往下压到时间轴画布上方的空处，离指针近一点 */
#now { margin-bottom: -20px; position: relative; }
#strip-wrap { height: 92px; pointer-events: auto; }
#strip { display: block; width: 100%; height: 100%; cursor: ew-resize; touch-action: none; }
#strip:focus { outline-offset: -3px; }

#intro { position: fixed; left: 32px; bottom: 170px; width: min(430px, calc(100vw - 64px)); }
#intro .panel { background: rgba(9, 13, 22, .8); border: 1px solid var(--rule); border-radius: 4px; padding: 24px 26px; backdrop-filter: blur(10px); }
#intro h2 { margin: 0 0 18px; font: 600 28px/1.3 var(--display); letter-spacing: .04em; }
#intro p { margin: 0 0 16px; }
#intro .row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
#intro .note { margin: 0; color: var(--dim); font-size: 13px; }
#intro-error { color: #ffb4a0; }
.primary { background: var(--slate); color: var(--ink); border-color: var(--slate); font-weight: 600; } /* 开启摄像头：配色系的灰蓝，字用浅色 */
.primary:hover { background: #437587; border-color: #437587; }
#load { position: fixed; left: 0; top: 0; height: 2px; width: 100%; background: var(--space); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
@media (prefers-reduced-motion: reduce) { #fade.run { animation: none; } #load, #info, #info dl, #info-toggle .caret { transition: none; } }
#galaxy { position: fixed; left: 0; right: 0; top: 20px; margin: 0 auto; width: fit-content; max-width: 56vw; padding: 7px 14px 8px; display: grid; justify-items: center; gap: 2px; background: var(--plate); border-top: 2px solid #ffd9a0; border-radius: 0 0 3px 3px; text-align: center; pointer-events: none; }
#galaxy[hidden] { display: none; }
#galaxy .row { display: flex; align-items: baseline; gap: 12px; }
#galaxy b { font: 600 17px/1.3 var(--display); letter-spacing: .08em; color: #ffd9a0; }
#galaxy span { font: 14px/1.3 var(--num); font-variant-numeric: tabular-nums; color: var(--time); }
#galaxy small { font-size: 12px; color: var(--dim); }
#galaxy button { pointer-events: auto; padding: 4px 8px; font-size: 11.5px; align-self: center; }

/* 星群选择：画在银河系导览图上，不模糊。名字排成一排（位置由 dock.js 每帧算），引线画在 overlay 上；
   --g（0–1）是离选择位置多近：越近越大，并冒出方块图标；选中的那个加一个框 */
#dock { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0; transition: opacity .3s ease; }
#dock.open { opacity: 1; }
body.docking #overlay { z-index: 21; }
.dock-row { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; outline: none; }
.dock-row li { --g: 0; --i: 0; position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px 6px;
  transform: translate(-50%, -100%); border: 1px solid transparent; border-radius: 12px; pointer-events: auto; cursor: pointer;
  transition: border-color .18s, background-color .18s; }
.dock-row .icon { display: block; width: calc(84px * var(--i)); height: calc(84px * var(--i)); opacity: var(--i);
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, .9)); } /* 没有底色，浮在银河系上；加一点黑色阴影免得和背后的星点混在一起 */
.dock-row svg { display: block; width: 100%; height: 100%; }
.dock-row .name { font: 600 calc(15px * (1 + .3 * var(--g)))/1.25 var(--display); letter-spacing: .06em; color: var(--ink); white-space: nowrap; text-shadow: 0 0 8px #000, 0 0 3px #000; }
.dock-row .name { text-align: center; }
.dock-row .en { display: block; font-weight: 400; font-size: .6em; letter-spacing: .03em; opacity: .7; } /* 英文名：中文下面另起一行，细一点、淡一点 */
.dock-row .sub { display: none; } /* 选择状态里不显示距离（距离在下方的说明和进入后的信息卡里） */
.dock-row li[aria-selected="true"] { border-color: rgba(235, 228, 210, .6); background: rgba(9, 13, 22, .55); }
.dock-row li.current .name::before { content: '● '; font-size: .55em; vertical-align: middle; color: var(--time); }
.dock-row li.launch .icon { animation: dock-launch .26s ease-out; }
/* 确认后镜头飞过去：只留选中的那个 */
#dock.launching .dock-row li:not(.launch), #dock.launching .dock-foot { opacity: 0; transition: opacity .25s; }
@keyframes dock-launch { 40% { transform: translateY(-14%) scale(1.06); } 100% { transform: none; } }
.dock-foot { position: absolute; left: 0; right: 0; bottom: 26px; display: grid; justify-items: center; gap: 10px; }
/* 不在选择状态时：名字更安静一点 */
#dock:not(.selecting) .dock-row .name { opacity: .85; }
.dock-desc { margin: 0; min-height: 1.6em; font-size: 15px; color: var(--ink); text-shadow: 0 0 8px #000; }
.dock-hint { margin: 0; display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--dim); text-shadow: 0 0 6px #000; }
.dock-back { pointer-events: auto; padding: 4px 10px; font-size: 12px; }
/* 选择时藏起星群自己的界面 */
body.docking footer, body.docking #photo-credit, body.docking #galaxy, body.docking #caption,
body.docking .solar-only, body.docking .orion-only, body.docking .stars-only, body.docking .crab-only { display: none !important; }
@media (prefers-reduced-motion: reduce) { #dock, .dock-row li { transition: none; } .dock-row li.launch .icon { animation: none; } }
/* 只属于某个星群的按钮，在别的星群里藏起来（!important：压过设置菜单里按钮的 display: flex） */
body:not([data-realm="solar"]) .solar-only { display: none !important; }
body:not([data-realm="orion"]) .orion-only { display: none !important; }
body:not([data-realm="orion"]):not([data-realm="dipper"]):not([data-realm="pleiades"]) .stars-only { display: none !important; }
body:not([data-realm="crab"]) .crab-only { display: none !important; }
/* 照片署名：照片显示时一直可见（CC BY 4.0 要求署名清楚可读） */
#photo-credit { position: fixed; right: 28px; bottom: 132px; margin: 0; max-width: min(460px, 60vw); padding: 6px 10px; background: var(--plate); border-radius: 3px; font-size: 12px; line-height: 1.45; color: var(--dim); text-align: right; pointer-events: auto; }
#photo-credit b { color: var(--ink); font-weight: 600; }
#photo-credit a { color: var(--dim); }
/* 昴星团暂时没有时间变化，不显示时间轴 */
body[data-realm="pleiades"] footer { display: none; }

/* 演示：右上角临时的"退出演示"按钮；结尾在设置菜单里圈出按钮的框和说明 */
#btn-demo-exit { border-color: var(--orange); color: var(--orange); }
.demo-ring { position: fixed; z-index: 40; border: 2px solid var(--orange); border-radius: 6px; pointer-events: none; animation: demo-ring 1.2s ease-in-out infinite; }
.demo-note { position: fixed; z-index: 40; transform: translateY(-50%); font: 500 15px/1.3 var(--body); color: var(--orange); white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 8px #000, 0 0 3px #000; animation: demo-note .4s ease-out; }
@keyframes demo-ring { 50% { box-shadow: 0 0 0 4px rgba(223, 152, 86, .25); } }
@keyframes demo-note { from { opacity: 0; transform: translate(8px, -50%); } }

/* 关于：居中的面板，背后压暗；点面板外面、按 Esc 或"关闭"收起。参考文献按学术格式（悬挂缩进、编号） */
#about { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; background: rgba(2, 4, 8, .55); }
#about .panel { width: min(620px, calc(100vw - 48px)); max-height: calc(100vh - 80px); overflow: auto; background: var(--plate); border: 1px solid var(--rule); border-radius: 4px; padding: 24px 28px; backdrop-filter: blur(10px); }
#about h2 { margin: 0 0 6px; font: 600 24px/1.3 var(--display); letter-spacing: .04em; }
#about .authors { margin: 0 0 18px; color: var(--ink); font-size: 14px; }
#about h3 { margin: 16px 0 8px; font: 600 15px/1.3 var(--display); letter-spacing: .06em; color: var(--ink); }
#about .refs { margin: 0 0 4px; padding-left: 1.8em; display: grid; gap: 6px; font: 12px/1.55 var(--body); color: var(--dim); }
#about .refs li { padding-left: .2em; }
#about .refs i { font-style: italic; }
#about-close { margin-top: 18px; }

/* 手势教学：字幕下面的进度条（做对的时候往前走） */
#tut-progress { position: fixed; left: 50%; top: calc(13% + 52px); width: 240px; height: 3px; margin-left: -120px; border-radius: 2px; background: rgba(235, 228, 210, .18); pointer-events: none; }
#tut-progress > div { height: 100%; width: 0; border-radius: 2px; background: #8fd0ff; transition: width .12s linear; }
body.docking.tutoring #caption { display: block !important; } /* 教学时银河系导览图里也显示字幕（平时导览图会藏起字幕） */
