/* tcjudge — iPad 橫放優先。桌機能用,但版面是為 1024~1180 寬、768~834 高長的。
   配色只有深藍與中性灰。**沒有金色 token,這是刻意的** ——
   使用者三次明講不要金色裝飾(課程站的金條、這裡的金邊、清單的左緣條)。
   把 --gold 留在 :root 等於留一個地雷給下一個人踩,所以整個移除。
   要強調就用字重、深淺或位置,不要靠一條顏色。 */

:root {
  --navy: #12203a;
  --navy-2: #1b2d4d;
  --ink: #1c2333;
  --muted: #5c6472;
  --ink-2: #3f4756;      /* 次級文字。比 --muted 深,給刻度數字這種要讀的小字用 */
  --faint: #717781;      /* 「未評」「—」這種弱化但仍須讀得到的字:4.5:1 過關 */
  --line: #e3e6ec;
  --paper-2: #eef1f6;    /* 表頭、次級底 */
  --sel: #e7ebf2;        /* 清單選取列 */
  --tick: #c2c9d4;       /* 未選中的刻度點(裝飾:資訊由下方數字承載) */
  --on-dark: #fff;              /* 深藍底上的主文字 */
  --on-dark-2: #b9c2d4;         /* 深藍底上的次級文字 */
  --on-dark-3: #9fb0cc;         /* 深藍底上的弱化文字 */
  --on-dark-err: #ffb4a2;       /* 深藍底上的錯誤字 */
  --on-dark-warn: #ffd9a3;      /* 深藍底上的待送出提示 */
  --on-dark-line: rgba(255,255,255,.18);
  --on-dark-fill: rgba(255,255,255,.08);
  --on-dark-fill-2: rgba(255,255,255,.16);
  --on-dark-fill-3: rgba(255,255,255,.24);
  --toast-line: #f0d9b5;
  --bg: #f5f6f8;
  --paper: #fff;
  --warn: #a8621c;
  --warn-bg: #fdf3e6;
  --ease: cubic-bezier(.22,.61,.36,1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* 字級。CSS 的長度單位 rem 是相對 html 的 font-size,所以改這一個值
   就能把全站文字一起放大縮小,不必逐條調整。
   刻意只縮放「字」不縮放「觸控目標」—— 拉條軌道、按鈕高度都是 px,
   S 不會讓手指變難按,XL 也不會把版面撐爆。 */
html[data-size="s"]  { font-size: 15px; }
html[data-size="m"]  { font-size: 17px; }
html[data-size="l"]  { font-size: 19px; }
html[data-size="xl"] { font-size: 22px; }

* { box-sizing: border-box; }

/* [hidden] 的 UA 樣式(display:none)優先度是最低的,任何 .class{display:flex|grid}
   都蓋得掉它 —— 元素於是「看不見卻仍佔位、仍吃得到點擊」,變成隱形障礙物。
   這個專案的 .gate / .sheet / .tabpanel 全都踩過。讓 hidden 永遠是真的。 */
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%;
  /* clip 不是 hidden:hidden 會製造一個可程式捲動的容器,
     長隊名撐破版面時反而讓內容「捲得到但看不到」。 */
  overflow-x: clip;
  /* 全螢幕 App 不該有橡皮筋回彈 —— 評審拖拉條時最容易誤觸發 */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  /* 刻意用系統字,不載 webfont:iPad 上是蘋方、Windows 是微軟正黑。
     零載入、零 FOUT,會場網路掛掉也不受影響。
     先前排在最前面的 "Noto Sans TC" 這個站從來沒有載入過 —— 宣告一個永遠
     fallback 掉的名字只會誤導後人,所以移除。 */
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Segoe UI",
               "Microsoft JhengHei", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink);
  /* 評審不需要選取文字,關掉可以避免長按拖曳時跳出選取泡泡 */
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* 焦點環。主控台是鍵盤操作的(設定分頁有 16 隊 × 3 個輸入框),
   沒有它等於盲打。**刻意不加過渡** —— 焦點環淡入是很明顯的 AI 痕跡,
   而且鍵盤使用者需要的是「立刻」知道自己在哪。 */
:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  border-radius: 4px;
}
/* 深藍底上的元件要用亮色環,不然環跟底同色等於沒有 */
.gate :focus-visible, .bar :focus-visible, .abar :focus-visible {
  outline-color: var(--on-dark);
}

/* ---------- ① 進場 ---------- */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--navy);   /* 原本是兩個幾乎同色的深藍漸層 —— 看不出來,也沒在做事 */
  color: var(--on-dark); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}
.gate-inner { text-align: center; width: min(420px, 86vw); }
.gate-eyebrow { margin: 0 0 6px; color: var(--on-dark-3); font-size: .84rem; letter-spacing: .08em; }
.gate-title { margin: 0 0 6px; font-size: 1.7rem; font-weight: 700; }
.gate-hint { margin: 0 0 26px; color: var(--on-dark-2); font-size: .92rem; min-height: 1.3em; }
.gate-hint.err { color: var(--on-dark-err); }

.pin { display: flex; gap: 14px; justify-content: center; margin-bottom: 30px; }
.pin i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--on-dark-fill-3); background: transparent;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease);
}
.pin i.on { background: var(--on-dark); border-color: var(--on-dark); transform: scale(1.12); }
.pin.shake { animation: shake .38s var(--ease); }
@keyframes shake {
  20% { transform: translateX(-9px); } 45% { transform: translateX(8px); }
  70% { transform: translateX(-5px); } 100% { transform: translateX(0); }
}

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.keypad button {
  height: 68px; border-radius: 16px; border: 1px solid var(--on-dark-line);
  background: var(--on-dark-fill); color: var(--on-dark); font-size: 1.5rem; font-weight: 500;
  transition: background .12s var(--ease), transform .08s var(--ease);
}
.keypad button:active { background: var(--on-dark-fill-3); transform: scale(.96); }

/* ---------- ② 主畫面 ---------- */
.app { height: 100%; display: flex; flex-direction: column;
       padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }

.bar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--navy); color: var(--on-dark);
  transition: background .2s var(--ease);
}
/* 補評別組時整條換色 —— 常駐而不是一閃即逝的提示,因為它要防的是「一直沒注意到」 */
.bar.away { background: var(--warn); }
.bar-tag {
  font-size: .74rem; padding: 3px 9px; border-radius: 999px;
  background: var(--on-dark-fill-2); letter-spacing: .04em;
}
.bar-team { font-weight: 700; font-size: 1.02rem; }
.bar-jump { font-size: .84rem; opacity: .95; }
.bar-jump button {
  margin-left: 8px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--on-dark-fill-3); background: var(--on-dark-fill); color: var(--on-dark);
}
.bar-right { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: .82rem; opacity: .9; }

/* 字級切換。做在頁首而不是藏在設定裡 —— 評審不會為了調字去翻選單,
   而看不清楚是當場就要解決的事。 */
.sizer { display: flex; gap: 2px; background: var(--on-dark-fill); border-radius: 8px; padding: 2px; }
.sizer button {
  min-width: 34px; height: 30px; border: 0; border-radius: 6px;
  background: transparent; color: var(--on-dark); font-size: 12px; line-height: 1; opacity: .7;
}
.sizer button[aria-pressed="true"] { background: var(--on-dark-fill-3); opacity: 1; font-weight: 700; }
.bar-saved { min-width: 8.5em; text-align: right; font-variant-numeric: tabular-nums; }
.bar-saved.pending { color: var(--on-dark-warn); }

.stage { flex: 1; display: grid; grid-template-columns: 268px 1fr; min-height: 0; }

/* ---------- 左欄:隊伍清單 ---------- */
.side {
  background: var(--paper); border-right: 1px solid var(--line);
  padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.tl-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; min-height: 46px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; color: var(--ink);
}
.tl-row:not(:disabled):active { background: var(--bg); }
.tl-row:disabled { opacity: .38; }
.tl-no {
  flex: none; min-width: 2.1em; font-variant-numeric: tabular-nums;
  color: var(--muted); font-size: .84rem;
}
.tl-name { flex: 1; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-st { flex: none; font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-row.done .tl-st { color: var(--ink); }
/* 目前正在評的那一列:只用底色與字重,**不加左緣色條**。
   使用者三次明講不要那種邊條(課程站的金條、這裡的金邊、清單的左緣條),
   而且底色本身已經足夠指出「我在這裡」,色條只是多出來的裝飾。 */
.tl-row.viewing { background: var(--sel); font-weight: 700; }
/* 台上那一組:一個小圓點。跟「我在看的」分開表示,兩者不一定相同 */
.tl-row.onstage .tl-no::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn); margin-right: 5px; vertical-align: middle;
}

.pane { display: flex; flex-direction: column; min-height: 0; padding: 14px 24px 16px; }

/* ---------- 右欄頂部:隊伍身分 ---------- */
.thead { flex: none; display: flex; align-items: baseline; gap: 16px; }
.thead-id h2 { margin: 0; font-size: 1.3rem; line-height: 1.25; }
.thead-id p { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }
.thead-prog { margin-left: auto; color: var(--muted); font-size: .84rem; white-space: nowrap; }
.thead-prog b { color: var(--ink); font-size: 1.05rem; }
.mems { flex: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 4px; }
.mem { font-size: .86rem; color: var(--ink); white-space: nowrap; }
.mem i { font-style: normal; font-size: .74rem; color: var(--muted); margin-left: 5px; }
.tabs { flex: none; display: flex; gap: 4px; padding: 10px 0 0; }
.tabs button {
  padding: 9px 22px; border: 0; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--muted); font-size: .95rem;
}
.tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); font-weight: 500; }
.tabpanel {
  flex: 1; min-height: 0; background: var(--paper);
  border-radius: 0 12px 12px 12px; padding: 22px 26px;
  display: flex; flex-direction: column;
  /* XL 字級下四項可能擠不下。寧可讓它捲,也不要把「下一隊」按鈕切掉看不到。 */
  overflow-y: auto;
}
/* 一旦需要捲動,space-evenly 的大留白就沒有意義,改成靠攏 */
#criteria { flex: 1 0 auto; }

/* ---------- 評分拉條 ---------- */
/* 四條拉條平均攤在可用高度裡,不要全部擠在上面、下面留一大塊空白。
   iPad 高度變動時(直放/橫放、有沒有 Safari 網址列)也不必改數字。 */
#criteria { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: space-evenly; }
.crit { padding: 4px 0; }
.crit-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 2px; }
.crit-label { font-size: 1.02rem; font-weight: 500; }
.crit-val {
  margin-left: auto; font-size: 1.45rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--ink);
  min-width: 1.3em; text-align: right;
}
.crit.empty .crit-val { color: var(--faint); font-weight: 500; }   /* #9aa3b2 只有 2.54:1,讀不到 */

/* 觸控範圍刻意比看得到的軌道高很多 —— 手指按偏 20px 照樣有效 */
.track {
  position: relative; height: 52px; display: flex; align-items: center;
  margin: 0 13px;              /* 讓 0% 與 100% 的把手不會被切掉半顆 */
  touch-action: none;          /* 不加這行,垂直拖曳會變成捲頁面 */
}
.track-line {
  position: absolute; left: 0; right: 0; height: 4px; border-radius: 999px;
  background: var(--line);
}
.track-fill {
  position: absolute; left: 0; height: 4px; border-radius: 999px; background: var(--navy);
  transition: width .14s var(--ease);
}
.crit.empty .track-fill { width: 0 !important; }
.tick {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  /* 未選中的刻度點是裝飾:它下面就是同位置的數字 1–5,資訊由數字承載,
     所以不受 3:1 非文字對比的約束。選中的點是 --navy,本來就夠深。 */
  background: var(--tick); transform: translateX(-50%);
}
.tick.on { background: var(--navy); }

/* 刻度數字跟刻度點共用同一個 left%,才不會兩套座標系各排各的。 */
.tick-n {
  position: absolute; top: 33px; transform: translateX(-50%);
  font-size: 1rem; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
/* 選中的那個數字再重一級。刻度點只有 9px,數字才是真正在讀的東西 */
.crit .tick-n.on { color: var(--ink); font-weight: 700; }

/* 未評 = 沒有把手。這是「空」與「1 分」唯一的差別(1 分的把手就停在最左邊),
   所以把手必須夠實心夠明顯,不能只靠顏色深淺。 */
.knob {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); border: 0;
  box-shadow: 0 1px 4px rgba(18,32,58,.28);
  transform: translateX(-50%);
  transition: left .14s var(--ease), transform .12s var(--ease);
}
.crit.empty .knob { opacity: 0; pointer-events: none; }
.knob.grab { transform: translateX(-50%) scale(1.18); }

.comment { display: block; margin-top: auto; padding-top: 14px; }
.comment span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.comment textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; resize: none; background: var(--bg);
  -webkit-user-select: text; user-select: text;
}
.next-wrap { flex: none; display: flex; justify-content: flex-end; padding-top: 14px; }
.btn-next {
  min-width: 168px; height: 54px; border-radius: 14px; border: 0;
  background: var(--navy); color: var(--on-dark); font-size: 1.02rem; font-weight: 500;
  transition: transform .08s var(--ease), opacity .15s var(--ease);
}
.btn-next:active { transform: scale(.97); }
.btn-next:disabled { opacity: .35; }

/* ---------- 簡報 ---------- */
.deck { flex: 1; min-height: 0; display: flex; align-items: center; gap: 10px; }
/* 翻頁鈕用 SVG 不用 ◀ ▶ ——
   U+25C0 / U+25B6 在 iOS 上有 emoji 呈現變體,很可能直接渲染成彩色三角形,
   跟整頁的中性灰藍完全不搭,而且大小不受 font-size 控制。 */
.deck-nav {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg);
  display: grid; place-items: center;
}
.deck-nav svg {
  width: 20px; height: 20px; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.deck-nav:disabled { opacity: .3; }
.deck-view {
  flex: 1; height: 100%; display: grid; place-items: center;
  background: var(--bg); border-radius: 10px; overflow: hidden;
}
.deck-view img { max-width: 100%; max-height: 100%; object-fit: contain; }
.deck-empty { color: var(--muted); font-size: .92rem; }
.deck-page { flex: none; text-align: center; margin: 8px 0 0; color: var(--muted); font-size: .82rem; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%);
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--toast-line);
  padding: 10px 18px; border-radius: 999px; font-size: .88rem; z-index: 60;
  box-shadow: 0 6px 20px rgba(18,32,58,.12);
}

/* 直放的 iPad:左欄改成上方橫條,免得兩欄各自太窄 */
@media (max-width: 900px), (orientation: portrait) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 18px; }
  
  
  .pane { padding: 0 16px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  /* 不一刀切成 none —— 那是跳接,比原本更生硬(課程站踩過兩次)。
     也不再用 `*`:那會打到拉條把手的 left 過渡,讓開了「減少動態」的評審
     拖曳手感跟別人不一樣。只點名真正會位移或閃動的那幾個。 */
  .pin.shake { animation: none; }
  .usk i::after { animation: none; }
  .bar, .keypad button, .tl-row, .knob { transition-duration: .08s; }
  .prog i, .track-fill { transition-duration: .1s; }
}
