/* 主選單與量表頁的樣式。沿用 styles.css 的色票，只加這兩頁需要的版面。 */

.home {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

/* 分頁列，照圖文選單的三個分頁（專管／行政／專業人員）。
   黃色 highlight 只留在導航層（Roy 2026-08 視覺拍板），內容格不上色。 */
.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 0;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tab {
  flex: 1;
  padding: 10px 4px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.tab-on {
  background: var(--pale-soft);
  color: var(--brand-dark);
  box-shadow: inset 0 -3px 0 var(--pale);
}
.tab:active { background: #f1f5f9; }

.menu {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* 每張卡同尺寸（Roy 2026-10-05：「所有的卡片大小必須一致並且對齊」）。原本說明折成兩行的
   那格會把整列撐高，各列高度不一。改成內容固定行數：名稱一行、說明固定佔兩行（多的切掉）、
   「開啟」一行，所以每張卡一樣高。不用 grid-auto-rows:1fr，因為攤開版的組名列也是 li，會被撐成卡片高。 */
.tile-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-desc {
  min-height: 2.8em;  /* 兩行 × line-height 1.4 */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
/* 「開啟」與「開發中」標籤同一個行高，開發中的卡才不會高出 3px（實測 128 vs 131） */
.tile-go, .tile-tag { height: 22px; line-height: 22px; box-sizing: border-box; }
.tile-tag { padding-top: 0; padding-bottom: 0; }

.tile {
  width: 100%;
  min-height: 116px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.tile:active { background: #f1f5f9; }

.tile-name { font-size: 18px; font-weight: 700; }

/* 專管頁三欄（Roy 2026-10-15「專管全頁面選單排列方式與 LINE 圖文選單排列順序要相同」）。
   手機一欄只剩約 105px，放不下說明，照圖文選單只留名稱置中；開發中的灰標籤照留。 */
.menu.menu-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.menu-3 .tile { min-height: 84px; padding: 10px 6px; align-items: center; justify-content: center; text-align: center; }
.menu-3 .tile-name { white-space: normal; font-size: 16px; line-height: 1.3; }
.menu-3 .tile-desc, .menu-3 .tile-go { display: none; }
.menu-3 .tile-tag { align-self: center; }
.tile-desc { font-size: 14px; color: var(--muted); line-height: 1.4; flex: 1; }

.tile-go {
  align-self: flex-start;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
}

/* 開發中的格子刻意做得明顯不同：整塊變淡、標籤用灰底。
   若只是拿掉連結，使用者會以為壞掉而重複點。 */
.tile-soon { background: #fafbfc; border-style: dashed; }
.tile-soon .tile-name { color: var(--muted); }
.tile-soon .tile-desc { color: #9aa4ae; }

.tile-tag {
  align-self: flex-start;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--grey-soft);
  color: var(--muted);
}

.foot {
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 20px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(31, 41, 51, .94);
  color: #fff;
  font-size: 15px;
  line-height: 1.5;
  z-index: 20;
}

/* --- 量表頁 ------------------------------------------------------------ */

.scale-wrap { padding: 16px; max-width: 640px; margin: 0 auto; }

.scale-intro {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.scale-intro h2 { margin: 0 0 6px; font-size: 18px; }
.scale-intro .src { font-size: 13px; color: var(--muted); margin-top: 8px; }

.person-list { list-style: none; margin: 0; padding: 0; }
.person {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}
.person-name { font-size: 17px; font-weight: 700; }
.person-meta { font-size: 14px; color: var(--muted); }

.pill {
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-none { background: var(--grey-soft); color: var(--muted); }
.pill-good { background: var(--ok-soft); color: var(--ok); }
.pill-mild { background: var(--pale-soft); color: #8a6d1f; }
.pill-mod { background: var(--warn-soft); color: var(--warn); }
.pill-severe { background: var(--danger-soft); color: var(--danger); }

.q {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}
.q-text { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.q-note { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.q-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

/* 選項文字長時改成一行一個。心情溫度計是「輕微」兩個字，
   巴氏量表是「需要協助保持平衡、整理衣物或使用衛生紙」整句，
   同一種格線裝不下這兩者。 */
.q-options-stacked { grid-template-columns: 1fr; gap: 8px; }

.opt-wide {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  padding: 12px 14px;
  font-size: 15px;
}
.opt-wide strong {
  display: inline-block;
  min-width: 28px;
  font-size: 15px;
}

.opt {
  padding: 10px 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  color: var(--ink);
  cursor: pointer;
}
.opt strong { display: block; font-size: 16px; }
.opt[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 第 6 題單獨判讀，版面上也要跟前五題分開，否則會被當成總分的一部分 */
.q-supplementary { border-color: #d8c39a; background: #fffdf7; }

.result {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.result .score { font-size: 40px; font-weight: 900; line-height: 1; }
.result .band { font-size: 18px; font-weight: 700; margin-top: 6px; }
.result .advice { margin-top: 8px; line-height: 1.6; }
.result .alert {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
  line-height: 1.6;
}

.history { margin-top: 16px; }
.history table { width: 100%; border-collapse: collapse; background: #fff; }
.history th, .history td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 15px;
  text-align: left;
}

/* --- 實測型量表的示意動畫與碼表 ---------------------------------------- */

/* 用 SVG 加 CSS 動畫而不是 GIF：GIF 在手機上會糊、檔案又大，
   而這段動畫只是幾條線，用向量畫永遠是清晰的，也不必多存一個檔案。 */
.demo {
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}
.demo svg { width: 100%; height: auto; display: block; }

/* 2026-08-14 重畫。第一版有四個毛病，根因都是同一類：
   對 SVG 元素套用需要「旋轉中心」或「翻轉軸」的 transform。
   SVG 的 transform-origin 各瀏覽器解讀不同，群組只包一條線時 bbox 又極窄，
   結果腿飛出身體、左右翻轉時整個人位移出畫面。

   改法：只用 translate（位移是絕對的，沒有中心點問題），
   坐姿與站姿畫成兩個獨立圖形用 opacity 硬切，不靠變形去「壓低成坐著」。 */

/* 坐在椅子上的小人：只有開頭與結尾出現 */
.tug-sitter { animation: tug-sitter-vis 9s steps(1, end) infinite; }
@keyframes tug-sitter-vis {
  0%,     16% { opacity: 1; }
  17%,    77% { opacity: 0; }
  78%,   100% { opacity: 1; }
}

/* 站起來走路的小人：起身到坐下之間出現，並在這段期間來回位移 */
.tug-walker {
  animation: tug-walker-vis 9s steps(1, end) infinite,
             tug-walker-move 9s ease-in-out infinite;
}
@keyframes tug-walker-vis {
  0%,     16% { opacity: 0; }
  17%,    77% { opacity: 1; }
  78%,   100% { opacity: 0; }
}
/* 位移上限 152：小人起點 x=80，最遠約 232，折返線在 252、畫布寬 320。
   刻意停在線的左側而不是壓在線上——站在線上會把「折返點」那三個字擋住。 */
@keyframes tug-walker-move {
  0%,    22% { transform: translateX(0); }
  45%,   50% { transform: translateX(152px); }
  72%,  100% { transform: translateX(0); }
}

/* 走動時身體輕微起伏。腿不做關節動作——那需要旋轉中心，正是上一版壞掉的地方。 */
.tug-bob { animation: tug-bob 0.6s ease-in-out infinite alternate; }
@keyframes tug-bob {
  from { transform: translateY(0); }
  to   { transform: translateY(-2px); }
}

.demo-caption { font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }

.stopwatch {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
}
.sw-time {
  font-size: 46px;
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;  /* 數字等寬，跳動時版面不會左右晃 */
  color: var(--ink);
}
.sw-time.running { color: var(--brand); }
.sw-buttons { display: flex; gap: 8px; margin-top: 10px; }
.sw-buttons button { flex: 1; }

/* 分級對照表：使用者要看得到「幾分算什麼」，否則分級只是一個他無法檢查的結論 */
.bands { width: 100%; border-collapse: collapse; margin-top: 8px; }
.bands td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  font-size: 14px;
  vertical-align: top;
}
.bands td:first-child { white-space: nowrap; color: var(--muted); }

/* 量表清單的分組標題：同一件事的不同工具排在一起 */
.group-head {
  font-size: 13px;
  color: var(--muted);
  padding: 10px 4px 4px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.person-list .group-head:first-child { border-top: none; margin-top: 0; }

/* 填寫畫面最上方的一行式分級說明 */
.band-strip {
  margin-top: 10px;
  padding: 8px 10px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
}
.group-note {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* 單獨判讀的題目（肌少症的指圈與小腿圍），與總分分開列 */
.section-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
  margin-top: 8px;
}
.section-alert b { color: var(--danger); }

/* 同意書改版提醒。做成整條可點，手機上小連結很難按中。 */
.resign-banner {
  display: block;
  background: var(--warn-soft);
  border: 1px solid var(--pale);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
}

/* 待審紅點（Roy 2026-09-08）：交辦事務／我的交辦格子右上角「等我按 N」 */
.tile { position: relative; }
/* 提醒類一行（Roy 2026-09-11）：放在提示句下面、格子上面 */
.home-rem { margin: 0 0 10px; padding: 8px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.home-rem a { color: var(--brand); text-decoration: none; font-weight: 700; white-space: nowrap; }
.home-rem .sep { color: var(--line); }
.tile-badge { position: absolute; top: 8px; right: 8px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
