﻿/* 手电筒映射课堂 —— 视觉与设计稿一致：奶油底、深紫描边、硬阴影、圆角。
   动态部分（光束、牌的颜色、手电筒角度）由 ui.js 写行内样式，这里只管静态外观。 */

/* 标题字体自托管：只含 94 个用得到的字符，9.7KB。
   这样整个页面**零外部请求** —— 教室断网、国内取不到 Google Fonts 都照常好看。

   ⚠ 改了章节标题、颜色名或任何走 --display 的文案，都要重新生成这个文件，
     否则新字会静默掉回退字体。做法见 app/tools/collect-display-chars.js 顶部的注释。 */
@font-face {
  font-family: 'ZCOOL KuaiLe';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/zcool-kuaile-subset.woff2') format('woff2');
}

:root {
  --ink: #463A63;
  --muted: #8A7CAE;
  --line: 3px solid #463A63;
  --shadow: 6px 7px 0 rgba(70, 58, 99, .18);
  --shadow-hard: 3px 4px 0 #463A63;
  --stage-w: 1180px;
  --stage-h: 640px;
  --k: 1;
  /* 标题字体。字体文件是自托管的，回退链留着兜底：万一 woff2 没部署上去，
     退到本机自带的圆润/琥珀体，观感不至于垮掉。 */
  --display: "ZCOOL KuaiLe", "STHupo", "华文琥珀", "Yuanti SC", "Microsoft YaHei", sans-serif;
  --body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

/* 英文界面换字体，而不是去给那个 woff2 补拉丁字母：
   ZCOOL KuaiLe 的子集里只有中文、数字和几个标点，英文字母本来就取不到，
   硬用会一个字一个字地掉回退字体，粗细和字宽全对不齐。
   正文同理 —— 中文那条链在 Windows 上会落到微软雅黑的拉丁字形，不好看。 */
html[data-lang="en"] {
  --display: "Nunito", "Quicksand", "Trebuchet MS", Verdana, system-ui, sans-serif;
  --body: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: #FFF3E2;
  font-family: var(--body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

img { user-select: none; -webkit-user-drag: none; }

button, select { font-family: inherit; color: var(--ink); }

:focus-visible { outline: 3px solid #FF9EC0; outline-offset: 2px; }

@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulseGlow { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }

/* ---------------- 页面骨架 ---------------- */

.page {
  min-height: 100vh;
  padding: 22px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  background: radial-gradient(circle at 12% 0%, #FFE9C9 0%, #FFF3E2 45%, #FFEFF4 100%);
}

.topbar {
  width: 100%;
  max-width: 1500px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
  width: 56px; height: 56px;
  border-radius: 20px;
  background: #FFD166;
  border: var(--line);
  box-shadow: 4px 5px 0 var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  animation: floaty 3.2s ease-in-out infinite;
}

.brand-title {
  margin: 0;
  font-family: var(--display);
  font-size: 38px;
  font-weight: 400;
  line-height: 1.05;
}

.brand-sub { margin: 4px 0 0; font-size: 15px; color: var(--muted); }

.tabs {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 640px;
}

.tab {
  padding: 9px 14px;
  border-radius: 999px;
  border: var(--line);
  background: #fff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(70, 58, 99, .35);
}
.tab:hover { background: #FFF3E2; }
.tab.active { background: #FF9EC0; box-shadow: var(--shadow-hard); }

.ghost-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 14px; font-weight: 900;
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(70, 58, 99, .35);
}
.ghost-btn:hover { background: #FFF3E2; }

/* 全屏和切语言并排放在顶栏右上角。原来 .topbar 是 space-between 的三段，
   多一个按钮会把间距搅乱，所以这两个包成一格。 */
/* margin-left:auto：英文标签比中文宽，顶栏排不下时这一格会整块换到下一行，
   space-between 会把它甩到最左边（贴在标题底下）。推到右边才对得上原来的位置。 */
.topbar-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.layout {
  width: 100%;
  max-width: 1500px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.card {
  background: #fff;
  border: var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.card-title { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 400; }
.card-title.small { font-size: 18px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------------- 舞台 ---------------- */

.stage-card {
  flex: 1 1 760px;
  min-width: 0;
  border-radius: 28px;
  box-shadow: 8px 9px 0 rgba(70, 58, 99, .18);
  padding: 16px;
}

.stage-fit { position: relative; width: 100%; overflow: hidden; }

.stage {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #241E3D 0%, #191333 100%);
  touch-action: none;
  user-select: none;
  transform-origin: top left;
  transform: scale(var(--k));
}
.stage.bright { background: radial-gradient(ellipse at 50% 40%, #3A3260 0%, #191333 100%); }
.stage.locked { cursor: not-allowed; }

.beams { position: absolute; inset: 0; pointer-events: none; }

.layer { position: absolute; inset: 0; pointer-events: none; }

.axis {
  position: absolute;
  top: 14px;
  font-size: 13px;
  letter-spacing: 2px;
  color: #A79BD6;
  font-weight: 700;
}
.axis-left { left: 22px; }
.axis-right { right: 22px; }

.lock-pill {
  position: absolute;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  z-index: 9;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  border: var(--line);
  font-weight: 900;
  font-size: 14px;
  color: var(--ink);
}
.lock-pill.hidden { display: none; }

.image-pill {
  position: absolute;
  left: 50%; top: 14px;
  transform: translateX(-50%);
  z-index: 9;
  padding: 7px 18px;
  border-radius: 999px;
  background: #FFD166;
  border: var(--line);
  font-weight: 900;
  font-size: 14px;
  color: var(--ink);
}
.image-pill.hidden { display: none; }

/* 「看像集」：舞台上只留数字牌，手电筒和光线全部收起来。
   牌本来贴在右边（x=880，宽 160），单独留在角落太偏，所以顺手挪到舞台正中。 */
.board-layer { transition: transform .35s ease; }
.stage.image-only .beams,
.stage.image-only .torch-layer,
.stage.image-only .axis-left { display: none; }
.stage.image-only .board-layer { transform: translateX(-370px); }

.stage-hint { margin: 12px 4px 0; font-size: 14px; line-height: 1.6; color: var(--muted); }

/* 舞台内的手电筒与数字牌（位置、颜色由 JS 计算，这里定形状） */

.torch-tag {
  position: absolute;
  width: 30px; height: 30px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px;
  border-width: 3px; border-style: solid;
}

.torch-box { position: absolute; pointer-events: none; }
.torch-box img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45)); }

/* 两块透明热区，位置和大小由 ui.js 按筒身尺寸算（灯多时会保底放大，见 placeHotspot） */
.torch-head, .torch-switch {
  position: absolute;
  border-radius: 999px;
  touch-action: none;
}
.stage.live .torch-head { pointer-events: auto; cursor: grab; }
.stage.live .torch-head:active { cursor: grabbing; }
.stage.live .torch-switch { pointer-events: auto; cursor: pointer; }

.torch-halo {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity .25s;
}
.torch-halo.on { animation: pulseGlow 1.8s ease-in-out infinite; }

.torch-dot { position: absolute; width: 10px; height: 10px; border-radius: 999px; pointer-events: none; }

.torch-ring {
  position: absolute;
  border-radius: 22px;
  border: 2px dashed rgba(255, 255, 255, .55);
  pointer-events: none;
}
.torch-ring.hidden { display: none; }

.board {
  position: absolute;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, box-shadow .2s;
}
.board-num { font-family: var(--display); font-weight: 900; }
.board-badge {
  position: absolute;
  right: -12px; top: -12px;
  width: 30px; height: 30px;
  border-radius: 999px;
  background: #FFD166;
  border: var(--line);
  color: var(--ink);
  font-weight: 900; font-size: 16px;
  align-items: center; justify-content: center;
}

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

.side {
  flex: 1 1 330px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;

  /* 面板比舞台高的时候自己滚，舞台留在原地不动 —— 上课边讲边翻名册/结果表时，
     投影上的画面不会跟着跑。限高由 ui.js 按舞台卡片的实际高度设（见 fitSide），
     两栏窄到换行、面板掉到舞台下面时会清掉，那时候整页滚才对。
     右下留出 8px 是给卡片的硬阴影（--shadow 是 6px 7px），
     不然贴着滚动容器的边会被切掉一条。 */
  overflow-y: auto;
  padding: 0 8px 8px 0;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;      /* 滑到底不要接着把整页带下去 */
  scrollbar-width: thin;
  scrollbar-color: #C9BFE4 transparent;
}

.side::-webkit-scrollbar { width: 10px; }
.side::-webkit-scrollbar-track { background: transparent; }
.side::-webkit-scrollbar-thumb {
  background: #C9BFE4;
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: 999px;
}
.side::-webkit-scrollbar-thumb:hover { background: #A79BD6; background-clip: content-box; }

.chapter-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 13px;
  font-weight: 900;
  background: #fff;
}
.chip-yellow { background: #FFD166; }
.chip-green { background: #B7F0D8; }
.chip-pink { background: #FFC7D8; }

.chapter-title { font-family: var(--display); font-size: 26px; }

.chapter-desc { margin: 12px 0 0; font-size: 16px; line-height: 1.75; color: #5A4E7A; text-wrap: pretty; }

.goal {
  margin-top: 14px;
  background: #FFF0F5;
  border: 2px dashed #FFA8C6;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.6;
  color: #B0577E;
}

.console { display: flex; flex-direction: column; gap: 16px; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 900;
  background: #FFF3E2;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
}
.timer.urgent { color: #E4557F; }

.counters { display: flex; gap: 12px; }

.counter { flex: 1; border-radius: 18px; padding: 10px 12px; border-width: 2px; border-style: solid; }
.counter-pre { background: #F3F0FF; border-color: #D9D0FF; }
.counter-img { background: #EAFBF5; border-color: #B6EBDC; }
.counter-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.counter-img .counter-label { color: #5FA995; }
.counter-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.counter-num { font-size: 26px; font-weight: 900; }

.step {
  width: 34px; height: 34px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 20px; font-weight: 900;
  cursor: pointer;
  box-shadow: 2px 3px 0 var(--ink);
}
.step:hover { background: #FFF3E2; }
.step:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

.controls { display: flex; gap: 10px; }

.big-btn {
  flex: 1 1 0;
  padding: 12px 10px;
  border-radius: 16px;
  border: var(--line);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  background: #fff;
}
.btn-start { background: #B7F0D8; }
.btn-end { background: #FFC7D8; }
.btn-reset { flex: 0 0 auto; padding: 12px 14px; }
.btn-image { width: 100%; background: #E7DEFF; }
.btn-image.on { background: #FFD166; }
.big-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.duration { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); font-weight: 700; }
.duration select {
  flex: 1;
  padding: 7px 10px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.duration select:disabled { opacity: .45; cursor: not-allowed; }

.status {
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  background: #F3F0FF;
  color: var(--muted);
}
.status.playing { background: #FFF7E3; color: #B08A3C; }
.status.pass { background: #E7FBF1; color: #3E9B74; }
.status.fail { background: #FFEFF3; color: #C25A83; }

.results { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.result-row { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.result-dot { width: 16px; height: 16px; border-radius: 999px; flex: 0 0 auto; border: 2px solid var(--ink); }
.result-label { font-weight: 900; width: 56px; flex: 0 0 auto; }
.result-text { font-weight: 700; }
.result-text.ok { color: #4A9E7E; }
.result-text.bad { color: #C96A8E; }

/* ---------------- 第 7 章 颜色密码门 ---------------- */

/* 舞台换成一扇门。门层盖在最上面，手电筒和数字牌那两层直接不画。 */
.door-layer { pointer-events: none; }
.door-layer.hidden { display: none; }
.stage.door-mode .torch-layer,
.stage.door-mode .board-layer,
.stage.door-mode .beams,
.stage.door-mode .axis { display: none; }

.door-frame {
  position: absolute;
  left: 50%; top: 40px;
  transform: translateX(-50%);
  width: 340px; height: 512px;
  border: 8px solid #6B5F91;
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  background: rgba(20, 14, 40, .35);
  perspective: 1400px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  z-index: 3;
}
.door {
  position: absolute; inset: 0;
  border-radius: 12px 12px 0 0;
  border: 3px solid #2A2248;
  background: linear-gradient(180deg, #4A3E70 0%, #3A3060 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .4);
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 1s cubic-bezier(.55, .05, .25, 1);
}
.door.open { transform: rotateY(-74deg); }
.door-handle {
  position: absolute; right: 14px; top: 52%;
  width: 16px; height: 46px;
  border-radius: 999px;
  border: 2px solid #2A2248;
  background: linear-gradient(180deg, #FFE49A, #D9A93F);
}
.door-title {
  position: absolute; left: 0; right: 0; top: 30px;
  text-align: center;
  font-family: var(--display);
  font-size: 22px; letter-spacing: 2px;
  color: #FFE9C9;
}
.door-pad {
  position: absolute; left: 24px; right: 24px; top: 74px;
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px;
  border: 3px solid #6B5F91;
  border-radius: 18px;
  background: rgba(0, 0, 0, .28);
}
.door-slot {
  height: 46px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, .55);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-size: 22px;
  color: rgba(40, 28, 60, .85);
}
.door-verdict {
  position: absolute; left: 24px; right: 24px; bottom: 22px;
  padding: 9px 12px;
  border-radius: 14px;
  text-align: center;
  font-size: 14px; font-weight: 900; line-height: 1.4;
  background: rgba(255, 255, 255, .16);
  color: #EFE6FF;
}
.door-verdict.ok { background: rgba(183, 240, 216, .95); color: #2F7B5C; }
.door-verdict.bad { background: rgba(255, 199, 216, .95); color: #B24A70; }

/* 开门后从门缝里透出来的光 */
.door-glow {
  position: absolute;
  left: 50%; top: 46px;
  transform: translateX(-50%);
  width: 320px; height: 500px;
  border-radius: 14px 14px 0 0;
  background: radial-gradient(ellipse at 50% 60%, #FFF6D8 0%, #FFD166 45%, rgba(255, 209, 102, 0) 78%);
  opacity: 0;
  transition: opacity .8s .25s;
  z-index: 2;
}
.door-glow.on { opacity: 1; }
.door-open-text {
  position: absolute; left: 50%; top: 230px;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 42px; white-space: nowrap;
  color: var(--ink);
  opacity: 0;
  transition: opacity .6s .7s;
  z-index: 4;
}
.door-open-text.on { opacity: 1; }

/* 谁开了门 */
.door-progress {
  position: absolute;
  left: 24px; right: 24px; bottom: 18px;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  z-index: 5;
}
.door-who {
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid #6B5F91;
  background: rgba(20, 14, 40, .6);
  color: #D8CEF5;
  font-size: 14px; font-weight: 900;
}
.door-who.ok { background: #B7F0D8; border-color: var(--ink); color: #2F7B5C; }
.door-none { color: #8A7CAE; font-size: 14px; font-weight: 700; }

/* 右侧的对应表（钥匙） */
.door-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.door-tools.hidden { display: none; }
.ghost-btn.tiny { padding: 5px 10px; font-size: 12px; border-width: 2px; }
/* 「抄过来」是这一章最常按的一个，给它整整一行，别和另外两个挤在一起 */
.ghost-btn.tiny.wide { flex: 1 1 100%; background: #FFF0F5; border-color: #FFA8C6; color: #B0577E; }
.ghost-btn.tiny.wide:hover:not(:disabled) { background: #FFE1EC; }
.ghost-btn.tiny:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.door-copy-hint {
  margin: 8px 0 0;
  font-size: 12px; line-height: 1.55;
  color: #B0577E;
}
.door-copy-hint.none { color: var(--muted); }
.door-copy-hint.hidden { display: none; }

.key-row { display: flex; align-items: center; gap: 8px; }
.key-dot { width: 20px; height: 20px; border-radius: 7px; border: 2px solid var(--ink); flex: 0 0 auto; }
.key-name { width: 34px; flex: 0 0 auto; font-weight: 900; font-size: 15px; }
.key-arrow { color: #C3B9E0; font-weight: 900; }
.key-cells { display: flex; gap: 5px; flex-wrap: wrap; }
.key-cell {
  width: 30px; height: 30px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 900;
  cursor: pointer;
}
.key-cell.on { box-shadow: 2px 3px 0 var(--ink); }
.key-note {
  margin-top: 4px;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13px; font-weight: 700; line-height: 1.55;
}
.key-note.ok { background: #E7FBF1; color: #3E9B74; }
.key-note.bad { background: #FFEFF3; color: #C25A83; }

.net-card { padding: 16px 20px; }
.net-hint { margin: 10px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.net-card .chip.live { background: #B7F0D8; }
.net-card .chip.down { background: #FFC7D8; }

/* 每人几支灯：沿用控制台那两个计数器的样子，换成粉色，跟"分配"这件事对上 */
.counter-per { margin-top: 12px; background: #FFF0F5; border-color: #FFA8C6; }
.counter-per .counter-label { color: #B0577E; }
.counter-per.hidden { display: none; }
.per-hint { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: #B0577E; }

/* 名册：谁拿了哪几支、什么颜色 */
.roster { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.roster.hidden { display: none; }
.roster-empty { font-size: 13px; color: var(--muted); }
.roster-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.roster-row.off { opacity: .45; }
.roster-dots { display: flex; gap: 3px; flex: 0 0 auto; }
.roster-dots i {
  display: block;
  width: 13px; height: 13px;
  border-radius: 999px;
  border: 2px solid var(--ink);
}
.roster-name {
  font-weight: 900;
  flex: 0 0 auto;
  max-width: 84px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.roster-owns { color: var(--muted); }
.roster-owns.none { color: #C96A8E; }

/* ---------------- 投影全屏：只留舞台 ---------------- */

body.presenting .side,
body.presenting .brand-sub,
body.presenting .stage-hint { display: none; }
body.presenting .page { padding: 12px 16px 16px; }
body.presenting .stage-card { flex: 1 1 100%; }
body.presenting .brand-title { font-size: 28px; }
body.presenting .brand-icon { width: 42px; height: 42px; font-size: 22px; border-radius: 14px; }

@media (max-width: 900px) {
  .page { padding: 14px 12px 28px; }
  .brand-title { font-size: 28px; }
  .tabs { justify-content: flex-start; }
  .card { padding: 16px 16px; }
  .stage-card { padding: 10px; }
}
