/* 实验小鼠观察箱 —— 界面层样式。三维画面铺满视口，其上只有几枚“贴纸”式的提示，以及左上角的按钮、物种图标和可以展开的论文清单。 */

:root {
  --ink: #3d302f;          /* 与场景描边同色 */
  --paper: #fffdf8;
  --mint: #c6e3dd;         /* 实验室墙面 */
  --bench: #ecefef;        /* 试验台台面在画面上的颜色：场景切换时露出的底色，也是还没有三维场景的物种的背景 */
  --yellow: #ffd45c;       /* 试管架：当前物种的图标 */
  --coral: #ff9d76;        /* 跑轮 */
  --blue: #4a90d9;         /* 水瓶盖 */
  --muted: #7a6b68;
  --tray: #e4f1ee;         /* 论文清单的底色：比墙面浅一档的薄荷色 */
  --font: "HarmonyOS Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--mint);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  background: var(--bench); /* 画布淡出时（切换物种场景）露出来的颜色 */
  touch-action: none;       /* 视角固定：不响应拖拽、缩放手势 */
  user-select: none;
  -webkit-user-select: none;
}
#stage canvas { display: block; width: 100%; height: 100%; outline: none; }
#stage canvas:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }   /* 键盘聚焦时给出可见的焦点框 */
#stage.is-pointing { cursor: pointer; }

/* 写死在页面里的中英文两份文字：只显示当前语言的那一份 */
html[lang="en"] .only-zh, html:not([lang="en"]) .only-en { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* —— 贴纸：白底、深色描边、硬朗的下沉阴影 —— */
.pubs-toggle, .lang-toggle, .species-btn, .species-tip, .pubs, .hint, .organ-tip, .loading, .organ-list button {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

/* —— 左上角：中英文切换、“我的出版物”按钮、物种图标，以及按钮下方展开的论文清单 —— */
.dock {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: 88px;                      /* 清单最长到这里：不压住底部的提示 */
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;              /* 只有按钮、图标和清单本身拦截点击，空着的地方仍然可以点到画面 */
}
.dock-bar {
  position: relative;
  z-index: 2;                        /* 物种名称的提示可以盖在清单上面 */
  flex: none;
  display: flex;
  flex-wrap: wrap;                   /* 窗口窄时，物种图标整排折到第二行 */
  align-items: stretch;
  gap: 10px;
  max-width: 100%;
  pointer-events: none;
}
.dock-bar > *, .pubs { pointer-events: auto; }
.dock button { color: var(--ink); cursor: pointer; }
.dock button:focus-visible, .pub-title:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.pubs-toggle, .lang-toggle, .species-btn {
  font: inherit;
  border-radius: 18px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
@media (hover: hover) {             /* 指上去微微抬起：只在有鼠标的设备上（触屏上“悬停”会粘住不放） */
  .pubs-toggle:hover, .lang-toggle:hover, .species-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
}
.pubs-toggle:active, .lang-toggle:active, .species-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.pubs-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px 11px 18px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.3;
  white-space: nowrap;
}
html[lang="en"] .pubs-toggle { letter-spacing: 0; }
.pubs-toggle .chevron {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}
.pubs-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* 中 / EN：当前语言是深色的那一格 */
.lang-toggle { display: flex; align-items: stretch; gap: 2px; padding: 5px; font-size: 0.8125rem; font-weight: 700; }
.lang-toggle span {
  display: grid;
  place-items: center;
  min-width: 32px;
  padding: 0 7px;
  border-radius: 11px;
  color: var(--muted);
}
.lang-toggle span.is-on { background: var(--ink); color: var(--paper); }

/* 物种图标：一排圆形贴纸，里面是这个物种的头（斑马鱼是整条鱼）。当前物种的那一枚是按下去的黄色 */
.species { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.species-btn {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
}
.species-btn svg { display: block; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }   /* 图标超出圆的部分（颈、肩）裁掉 */
.species-letter { display: grid; place-items: center; width: 100%; height: 100%; font-size: 1.125rem; font-weight: 700; }
.species-btn[aria-pressed="true"],
.species-btn[aria-pressed="true"]:hover {
  background: var(--yellow);
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
/* 物种名称：鼠标停在图标上（或用键盘选到它）时，出现在图标下面 */
.species-tip {
  position: absolute;
  left: 50%;
  top: calc(100% + 11px);
  z-index: 1;
  padding: 3px 11px 4px;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
@media (hover: hover) {
  .species-btn:hover .species-tip { opacity: 1; transform: translate(-50%, 0); }
}
.species-btn:focus-visible .species-tip { opacity: 1; transform: translate(-50%, 0); }

/* 论文清单：一只浅色的“托盘”，里面一篇论文一张卡片 */
.pubs {
  flex: 0 1 auto;
  min-height: 0;
  width: min(24rem, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--tray);
  overflow: hidden;
  animation: pubs-in 0.2s ease both;
}
@keyframes pubs-in { from { opacity: 0; transform: translateY(-8px); } }

/* 清单顶上的一行：现在列的是“全部 · 38 篇”，还是“脑相关 · 35 篇”（这时右边有“显示全部”） */
.pubs-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 12px 9px 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
}
.pubs-head .swatch, .organ-list .swatch {
  flex: none;
  width: 15px;
  height: 15px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.pubs-head button {
  flex: none;
  margin-left: auto;
  padding: 3px 12px 4px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
@media (hover: hover) {
  .pubs-head button:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--ink); }
}
.pubs-head button:active { transform: translateY(2px); box-shadow: none; }
/* 当前物种还没有论文时，清单里的一句说明 */
.pubs-empty { margin: 0; padding: 20px 18px 22px; font-size: 0.875rem; line-height: 1.6; color: var(--muted); text-align: center; }

.pubs-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 12px 12px 14px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
}
.pub {
  flex: none;
  padding: 11px 14px 12px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
}
.pub-title {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
a.pub-title:hover {
  text-decoration: underline;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.pub-summary { margin: 6px 0 0; font-size: 0.8125rem; line-height: 1.65; color: var(--muted); }
.pub-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px 2px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: nowrap;
}
.tag .swatch { flex: none; width: 9px; height: 9px; border: 1.5px solid var(--ink); border-radius: 50%; }
/* 年份：深色底的小牌子，一眼能看出先后 */
.tag-year { background: var(--ink); color: var(--paper); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
/* 物种：与左上角“当前物种”图标同一系的浅黄色 */
.tag-species { background: #ffeeb8; }
/* 作者身份：一作一系是珊瑚色，通讯一系是蓝色，“并 / 共”浅一档 */
.tag-first { background: var(--coral); }
.tag-coFirst { background: #ffd3bf; }
.tag-corresponding { background: #9fcbf0; }
.tag-coCorresponding { background: #d6e9f9; }
.tag-other { border-color: rgba(61, 48, 47, 0.38); color: var(--muted); }

/* —— 底部的提示条：同时是按钮，点它等同于点击小鼠 —— */
.hint {
  position: fixed;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 20px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
@media (hover: hover) {
  .hint:hover { transform: translate(-50%, -2px); box-shadow: 0 5px 0 var(--ink); }
}
.hint:active { transform: translate(-50%, 2px); box-shadow: 0 1px 0 var(--ink); }
.hint:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
/* 小鼠已经被点中时，提示条只是说明文字：不响应点击，也不挡住下面的画面 */
.hint:disabled { color: var(--ink); cursor: default; pointer-events: none; }
.hint:empty { opacity: 0; pointer-events: none; }

.organ-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 8;                        /* 在论文清单之上 */
  padding: 7px 14px 8px;
  border-radius: 14px;
  pointer-events: none;
  white-space: nowrap;
  will-change: transform;
}
.organ-tip strong { display: block; font-size: 1rem; font-weight: 700; }
.organ-tip strong small { margin-left: 0.5em; font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.organ-tip span { display: block; margin-top: 1px; font-size: 0.8125rem; color: var(--muted); }

/* —— 器官名称 —— 默认（画面较窄时）：排在画面底部，一行放不下就折行 */
.organ-list {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;            /* 名称之间的空隙不拦截点击 */
  opacity: 0;
  transition: opacity 0.3s ease;
}
.organ-list.is-open { opacity: 1; }
.organ-list button {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  padding: 5px 14px 6px 9px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.organ-list small { display: none; font-size: 0.75rem; color: var(--muted); }
.organ-list button:hover, .organ-list button.is-active {
  transform: translateY(-3px);
  box-shadow: 0 6px 0 var(--ink);
}
/* 论文清单现在只看这个器官：名称反白 */
.organ-list .is-selected { background: var(--ink); color: var(--paper); }
.organ-list .is-selected small { color: #cfc4c0; }
.organ-list .is-selected .swatch { border-color: var(--paper); }
/* 还没有相关论文的器官：名称是灰色的，不能点击（指上去仍会在小鼠身上标出这个器官） */
.organ-list .is-disabled,
.organ-list .is-disabled:hover,
.organ-list .is-disabled.is-active {
  transform: none;
  border-color: #b3aaa7;
  box-shadow: 0 3px 0 #b3aaa7;
  color: #a39996;
  cursor: default;
}
.organ-list .is-disabled small { color: #b3aaa7; }
.organ-list .is-disabled .swatch { border-color: #b3aaa7; opacity: 0.45; }
.organ-list button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* 宽屏：像解剖图注那样排在小鼠两侧，位置由脚本给出 */
.organ-list.is-atlas {
  inset: 0;
  display: block;
  padding: 0;
}
.organ-list.is-atlas button {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
}
.organ-list.is-atlas small { display: inline; }

.leaders {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.leaders.is-open { opacity: 1; }
.leaders .halo { stroke: var(--paper); stroke-width: 4.5; stroke-linecap: round; opacity: 0.75; }
.leaders .line { stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; }
.leaders .dot { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.leaders .is-active .line { stroke-width: 2.6; }
.leaders .is-active .dot { fill: var(--ink); }

.loading {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px 12px;
  border-radius: 999px;
  font-size: 0.9375rem;
}
.loading.is-error { border-radius: 16px; max-width: min(30rem, calc(100vw - 40px)); line-height: 1.6; }
.loading-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  animation: loading-pulse 0.9s ease-in-out infinite alternate;
}
.loading.is-error .loading-dot { animation: none; background: var(--muted); }
@keyframes loading-pulse { from { transform: scale(0.6); } to { transform: scale(1.15); } }

.credit {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  margin: 0;
  font-size: 0.6875rem;
  color: rgba(61, 48, 47, 0.62);
}
.credit a { color: inherit; }
.credit a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.fallback { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  .dock { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: 104px; }
  .dock-bar { gap: 8px 10px; }
  .pubs { width: 100%; }
  .pubs-toggle { padding: 8px 12px 9px 14px; border-radius: 16px; font-size: 1.0625rem; }
  .lang-toggle { border-radius: 16px; }
  .species { margin-left: 0; }
  .species-btn { width: 44px; height: 44px; }
  .hint { font-size: 0.875rem; white-space: normal; text-align: center; bottom: max(34px, env(safe-area-inset-bottom)); }
  .organ-list { bottom: max(100px, calc(env(safe-area-inset-bottom) + 100px)); }   /* 提示可能折成两行 */
  .credit { left: 0; right: 0; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-dot { animation: none; }
  .hint, .organ-list, .leaders, .organ-list button { transition: none; }
  .pubs { animation: none; }
  .pubs-toggle, .lang-toggle, .species-btn, .species-tip, .pubs-toggle .chevron, .pubs-head button { transition: none; }
}
