/*
 * Ported from doc/diagrams/原型-員工健康填報.html (kiosk 原型 v2).
 *
 * Deliberately a plain stylesheet rather than a Tailwind/Vite bundle: this
 * system is sold and deployed standalone, and a health form should not need a
 * node toolchain to render.
 *
 * One stylesheet for every size. There are no breakpoints to speak of: the
 * roster is an auto-fill grid and the type is clamp()ed, so an iPad in either
 * orientation and a phone are the same layout at different widths. The single
 * media query narrows the grid to two columns on a phone, where auto-fill would
 * otherwise leave the buttons too small to hit.
 */
:root {
  --ink: #1a1f2e;
  --sub: #5a6478;
  --line: #dfe3ec;
  --bg: #f4f6fa;
  --pri: #1d6ae5;
  --pribg: #eef4fe;
  --done: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

/*
 * The browser's own `[hidden] { display: none }` sits in the user-agent origin,
 * so any `display` set below — `.emp` is `flex` — beats it and the element
 * stays on screen with the attribute set. The search box hides buttons that way,
 * which made a filtered roster show names that did not match. Author origin,
 * and !important so no later rule can win it back.
 */
[hidden] {
  display: none !important;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 14px 40px;
}

/* ── 首頁 ── */

.home-head {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  padding: 14px 0 10px;
}

.home-head h1 { font-size: clamp(17px, 2.5vw, 21px); margin: 0 0 8px; }
.home-head .today { font-weight: 400; color: var(--sub); font-size: 0.75em; }

.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.progress-row b { font-size: clamp(14px, 2vw, 16px); white-space: nowrap; }

.pbar { flex: 1; height: 10px; background: #e3e8f2; border-radius: 5px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--done); border-radius: 5px; transition: width 0.3s; }

.search {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
}

.group { margin-top: 18px; }
.group h2 {
  font-size: clamp(13px, 1.8vw, 15px);
  color: var(--sub);
  margin: 0 0 8px;
  border-left: 3px solid var(--pri);
  padding-left: 8px;
}

/* ~6 columns on a landscape iPad, ~4 portrait, 2 on a phone — no breakpoints. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); } }

.emp {
  /* 56px is the standing-at-a-desk touch target from the requirements. */
  min-height: 56px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: clamp(15px, 2vw, 17px);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  text-align: center;
  text-decoration: none;
}

.emp small { font-weight: 400; font-size: 11.5px; color: var(--sub); }
.emp:active { background: var(--pribg); }

/* Done is green AND ticked. Colour alone is not readable by everyone, so the
   ✓ is not decoration — it is the second half of the encoding. */
.emp.done { background: var(--done); border-color: var(--done); color: #fff; }
.emp.done small { color: #d3ecd9; }
.emp.done .ck { font-size: 12px; }

.footnote { margin-top: 26px; font-size: 11.5px; color: var(--sub); text-align: center; line-height: 1.7; }
.no-match, .empty { color: var(--sub); font-size: 14px; text-align: center; margin-top: 24px; }
.empty code { background: #e7ebf3; border-radius: 4px; padding: 1px 5px; }

/* ── 填報 / 完成 共用 ── */

.panel {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(20, 30, 60, 0.10);
  padding: 20px 18px 26px;
  margin: 14px auto 0;
}
.panel.narrow { max-width: 520px; }
.panel-title { font-size: 19px; margin: 0 0 8px; }

.who-big { background: var(--pribg); border-radius: 12px; padding: 14px 16px; margin-bottom: 6px; }
.who-big b { font-size: clamp(20px, 3vw, 24px); }
.who-big div { font-size: 13px; color: var(--sub); margin-top: 2px; }

.backlink {
  display: inline-block;
  background: none;
  border: 0;
  color: var(--pri);
  font-size: 14px;
  padding: 8px 0;
  cursor: pointer;
  text-decoration: none;
}

label.f { display: block; font-size: 14px; color: var(--sub); margin: 14px 0 4px; }

input[type=text], input[type=password], input[type=number], textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  /* 16px: anything smaller and iOS zooms the whole page on focus. */
  font-size: 16px;
}

textarea { resize: vertical; min-height: 52px; }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
  text-align: center;
  text-decoration: none;
}
.btn.pri { background: var(--pri); color: #fff; }
.btn.ghost { background: #eef2f9; color: var(--pri); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--sub); margin-top: 8px; line-height: 1.7; }
.fine { font-size: 12.5px; }

.errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-top: 14px;
}
.errors ul { margin: 0; padding-left: 18px; }

/*
 * The correction banner. Amber rather than red: filling the form in again is a
 * thing the system offers, not a thing that has gone wrong.
 */
.notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: var(--warn);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 14px;
}
/*
 * Direct child only. The banner's own heading is a `<b>`, but so is the
 * emphasis inside its 13px paragraph — a descendant selector blew that up to
 * 15px mid-sentence.
 */
.notice > b { font-size: 15px; }
.notice p { margin: 6px 0 0; font-size: 13px; line-height: 1.7; color: var(--ink); }

.fever { color: var(--danger); font-size: 13px; font-weight: 700; display: none; margin-top: 6px; }
.fever.show { display: block; }

.sym { border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; margin-top: 8px; }
.sym-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.sym-row span { font-size: 16px; }
.sym > div + div { border-top: 1px solid var(--line); }

.note-box { display: none; padding: 0 0 12px; }
.note-box.show { display: block; }

.sw { position: relative; width: 48px; height: 28px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw i { position: absolute; inset: 0; background: #d6dbe6; border-radius: 28px; transition: 0.15s; }
.sw i:before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.sw input:checked + i { background: var(--warn); }
.sw input:checked + i:before { transform: translateX(20px); }

/* ── 簽名 ── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal.show { display: flex; }

.sheet { background: #fff; border-radius: 16px; width: 100%; max-width: 420px; padding: 18px; }
.sheet .sign-name { font-size: 22px; font-weight: 800; margin: 0 0 2px; }
.sheet .sub { font-size: 12.5px; color: var(--sub); margin-bottom: 10px; }
/*
 * Above the signature window (z-index 50), not level with it: the idle warning
 * appears while that window may be open, and 「繼續填寫」 has to be reachable —
 * otherwise reading the summary for a minute silently throws the form away.
 */
#idle-modal { z-index: 60; }

.sheet.idle { text-align: center; }
.sheet.idle h2 { margin: 4px 0 6px; }
.sheet.idle p { color: var(--sub); font-size: 14px; }
.sheet.idle p b { color: var(--pri); }

.summary {
  background: #f6f8fc;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  margin-bottom: 10px;
  line-height: 1.6;
  text-align: left;
}
.summary b { color: var(--ink); }
.summary .fever-mark { color: var(--danger); }

#pad {
  width: 100%;
  height: 190px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  touch-action: none;
  background: #fbfcfe;
}
@media (max-width: 480px) { #pad { height: 160px; } }

.row2 { display: flex; gap: 10px; }
.row2 .btn { margin-top: 12px; }

/* ── 完成頁 ── */

.done-view { text-align: center; padding: 26px 10px 8px; }
.done-view .big { font-size: 56px; }
.done-view h2 { margin: 10px 0 2px; font-size: 22px; }
.done-view p { color: var(--sub); font-size: 14px; margin: 4px 0; }

.countdown { font-size: 13px; color: var(--sub); margin-top: 14px; }
.countdown b { color: var(--pri); }
