/*
  画面の見た目（詳細設計書_PWAアプリ 第3章）。
  現場作業者が説明書なしで操作できること（NFR-10）、説明はアイコン中心で
  英文は最小限にすること（NFR-05／FR-A-09）を前提に、要素を大きく・少なくする。
*/

:root {
  --bg: #12161c;
  --surface: #1b212a;
  --line: #2c343f;
  --text: #f2f5f8;
  --muted: #97a2b0;
  --accent: #2f7df6;
  --danger: #e2564a;
  --ok: #38a169;
  --radius: 12px;
  --tap: 56px; /* 手袋でも押せる大きさを確保する */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* 画面はステートマシンが1枚だけ表示する（第3.1章） */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 20px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  justify-content: center;
}
.screen.active { display: flex; }
.screen[data-screen="S3"].active { justify-content: flex-start; }

.title { font-size: 24px; font-weight: 700; margin: 0; text-align: center; }
.label { font-size: 15px; color: var(--muted); margin: 0; text-align: center; }
.note  { font-size: 13px; color: var(--muted); margin: 0; text-align: center; }
.hint  { font-size: 16px; color: var(--muted); margin: 0; text-align: center; }

.stack { display: flex; flex-direction: column; gap: 16px; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  min-height: 48px;
  padding: 10px 12px;
  font-size: 17px; /* iOS で入力時に拡大されないよう16px以上にする */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field textarea { min-height: 96px; font-family: Consolas, monospace; font-size: 13px; }

.button {
  min-height: var(--tap);
  padding: 0 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); }
.button.large { min-height: 72px; font-size: 22px; }
.button.link {
  min-height: 40px;
  padding: 0;
  font-size: 16px;
  font-weight: 400;
  background: none;
  border: none;
  color: var(--muted);
}
.button:disabled { opacity: 0.5; }

/* --- S2 案内 ---------------------------------------------------------- */

.guide { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 24px; }
.guide li { display: flex; align-items: center; gap: 16px; }
.guide-icon { flex: 0 0 56px; color: var(--accent); }
.guide-icon svg { width: 56px; height: 56px; display: block; }

.verify { border-top: 1px solid var(--line); padding-top: 12px; font-size: 14px; color: var(--muted); }
.verify summary { min-height: 40px; cursor: pointer; }
.verify > *:not(summary) { margin-top: 12px; }
.verify code { font-size: 12px; }

/* --- S3 読み取り ------------------------------------------------------ */

.bar { display: flex; align-items: center; justify-content: space-between; }
.countdown { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; }
.countdown.urgent { color: var(--danger); }

.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide-frame {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
}

.progress { display: flex; align-items: center; justify-content: center; gap: 12px; }
.dots { display: flex; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.dot.filled { background: var(--ok); border-color: var(--ok); }
.count { font-variant-numeric: tabular-nums; color: var(--muted); }

/* 4枚表示の配置図。①=左上 ②=右上 ③=左下 ④=右下（エミュレータ設計書 第6.2章） */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; max-width: 260px; margin: 0 auto; }
.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.cell.done { color: var(--ok); border-color: var(--ok); }
.cell.next { color: var(--text); border-color: var(--accent); background: rgba(47, 125, 246, 0.18); }

/* --- S4 送信中 -------------------------------------------------------- */

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 動きが苦手な利用者と、光感受性への配慮 */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* --- S5 結果 ---------------------------------------------------------- */

.result-icon { color: var(--ok); text-align: center; }
.result-icon.warn { color: var(--danger); }
.result-icon svg { width: 64px; height: 64px; }

/* 機械への手入力が前提のため、等幅・特大・区切り表示にする（第3.5章） */
.password {
  margin: 0;
  text-align: center;
  font-family: Consolas, "SF Mono", monospace;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.12em;
  word-break: break-all;
}

.message { margin: 0; text-align: center; font-size: 18px; }
.message.error { color: var(--danger); }
.serial { margin: 0; text-align: center; font-family: Consolas, monospace; color: var(--muted); }

@media (min-width: 600px) {
  #app { max-width: 520px; margin: 0 auto; width: 100%; }
}
