/* ============================================================
   房间号入场层 · Apple 皮肤（#landingOverlay）
   取代 entry.css / apple.css 里旧的 .landing-card 皮肤：
   入场层现在只有一句标题、一行状态、一块深色读数板和动作区。

   令牌只作用在 #landingOverlay 内，不写 :root ——
   雷达页自己有一套 --paper / --ink / --accent，不能被这层覆盖。
   加载顺序：必须在 apple.css 之后。
   ============================================================ */

#landingOverlay {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --fg: #1d1d1f;
  --fg-2: #424245;
  --muted: #6e6e73;
  --meta: #86868b;
  --border: #d2d2d7;
  --border-soft: #e8e8ed;
  --accent: #0071e3;
  --accent-on: #ffffff;
  --accent-hover: #0077ed;
  --accent-active: #0066cc;
  --success: #16a34a;
  --warn: #eab308;
  --danger: #dc2626;

  --font-display: "SF Pro Display", "SF Pro Icons", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "SF Pro Text", "SF Pro Icons", "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Monaco, Consolas, monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 17px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --elev-raised: 0 12px 32px rgba(0, 0, 0, .08);
  --focus-ring: 0 0 0 4px color-mix(in oklab, var(--accent), transparent 65%);
  --motion-fast: 150ms;
  --motion-base: 220ms;
  --ease-standard: cubic-bezier(.28, 0, .22, 1);

  overflow-y: auto;
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#landingOverlay *,
#landingOverlay *::before,
#landingOverlay *::after { box-sizing: border-box; }

#landingOverlay [hidden] { display: none !important; }
#landingOverlay p { margin: 0; }
#landingOverlay button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
}
#landingOverlay :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
#landingOverlay ::selection { background: color-mix(in oklab, var(--accent), transparent 80%); }

#landingOverlay .sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 卡片壳 + 单列主体 ─────────────────────────────────────────
   整层只有一张卡：白面浮在 #f5f5f7 上，发丝边 + 一层极浅投影。
   卡内自上而下：标题 → 消息行 → 读数板 → 动作位。 */
#landingOverlay .gate {
  --verify: 1400ms;            /* 与脚本 VERIFY_MS 同一节拍 */
  --lit: 320ms;                /* 单格点亮时长 */
  --step: 180ms;               /* 格与格的间隔 */
  --lead: 90ms;                /* 首格起步，与读取线对齐 */
  --beam: 1080ms;              /* 读取线走完整块读数板 */

  width: min(420px, 100%);
  margin: auto;                /* flex 容器里配合 overflow-y:auto，矮屏也不会切掉顶部 */
  padding: var(--space-8) 34px var(--space-8);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-raised);
}

#landingOverlay .gate-title {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.026em;
  color: var(--fg);
}
#landingOverlay .gate-title.is-swap { animation: gate-title-in 300ms var(--ease-standard) both; }
@keyframes gate-title-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* 读数板上方一行：整层唯一的一条消息通道（失败原因 / 公告），
   输入、校验、已接入三态留空。行高固定，出消息时读数板不移位 */
#landingOverlay .gate-note {
  margin-top: 10px;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: var(--text-xs);
  line-height: 18px;
  text-align: center;
  color: var(--muted);
}
#landingOverlay .gate-note.is-error {
  color: color-mix(in oklab, var(--danger), var(--fg) 30%);
  font-weight: 500;
}
#landingOverlay .gate-note.is-swap { animation: gate-note-in 260ms var(--ease-standard) both; }
@keyframes gate-note-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
#landingOverlay .gate-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--meta); flex: none;
}
#landingOverlay .gate-dot.is-bad { background: var(--danger); }

/* ── 六位房间号：整页唯一的深色读数板 ─────────────────────────── */
#landingOverlay .gate-plate {
  --plate-line: rgba(255, 255, 255, .14);
  --plate-dim: rgba(255, 255, 255, .30);

  position: relative;
  margin-top: var(--space-2);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  height: 68px;
  background: var(--fg);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--motion-fast) var(--ease-standard),
              height 320ms var(--ease-standard);
}
#landingOverlay .gate-plate:focus-within { box-shadow: var(--focus-ring); }
/* 校验中和已接入不再显示焦点环：此时读数板只作为读数，不接受输入 */
#landingOverlay .gate-plate.is-checking,
#landingOverlay .gate-plate.is-checking:focus-within,
#landingOverlay .gate-plate.is-done:focus-within { box-shadow: none; }

#landingOverlay .gate-cell { position: relative; display: flex; }
#landingOverlay .gate-cell + .gate-cell::before {
  content: "";
  position: absolute;
  left: 0; top: 32%; bottom: 32%;
  width: 1px;
  background: var(--plate-line);
}
#landingOverlay .gate-cell::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  height: 2px; border-radius: 2px;
  background: transparent;
  transition: background var(--motion-fast) var(--ease-standard);
}
#landingOverlay .gate-cell:focus-within::after { background: var(--accent); }
#landingOverlay .gate-plate.is-done .gate-cell::after { background: transparent; }

#landingOverlay .gate-box {
  flex: 1 1 auto;
  width: 100%; min-width: 0;
  padding: 0;
  background: transparent; border: 0; outline: 0;
  appearance: none;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 28px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  color: var(--bg);
  caret-color: transparent;
  border-radius: 0;
  transition: font-size 320ms var(--ease-standard),
              opacity 160ms var(--ease-standard);
}
#landingOverlay .gate-box::placeholder { color: var(--plate-dim); }
#landingOverlay .gate-box:disabled { color: var(--bg); opacity: 1; -webkit-text-fill-color: var(--bg); }
/* flat.css 给所有输入框加了 !important 的焦点描边；这里读数板用「格下沿 + 板身光圈」
   表示焦点，单格的方框描边会切碎深色读数板 */
#landingOverlay .gate-box:focus-visible { outline: none !important; outline-offset: 0 !important; }
#landingOverlay .gate-plate.is-locked { pointer-events: none; }
#landingOverlay .gate-plate.is-locked .gate-cell::after { background: transparent; }

/* 数字逐位落位：上浮、散焦归位 */
#landingOverlay .gate-box.is-in { animation: gate-digit-in 300ms var(--ease-standard) both; }
@keyframes gate-digit-in {
  from { opacity: 0; transform: translateY(12px) scale(.86); filter: blur(3px); }
  55%  { opacity: 1; }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ── 校验中：一条读取线自左掠过，扫到哪一格，哪一格亮起 ───────── */
#landingOverlay .gate-plate.is-checking { background: color-mix(in oklab, var(--fg), var(--accent) 7%); }

#landingOverlay .gate-cell:nth-of-type(1) { --i: 0; }
#landingOverlay .gate-cell:nth-of-type(2) { --i: 1; }
#landingOverlay .gate-cell:nth-of-type(3) { --i: 2; }
#landingOverlay .gate-cell:nth-of-type(4) { --i: 3; }
#landingOverlay .gate-cell:nth-of-type(5) { --i: 4; }
#landingOverlay .gate-cell:nth-of-type(6) { --i: 5; }

#landingOverlay .gate-plate.is-checking .gate-cell {
  animation: gate-cell-glow var(--lit) var(--ease-standard) both;
  animation-delay: calc(var(--i) * var(--step) + var(--lead));
}
@keyframes gate-cell-glow {
  0%   { background-color: transparent; }
  30%  { background-color: color-mix(in oklab, var(--accent) 26%, transparent); }
  100% { background-color: color-mix(in oklab, var(--accent) 7%, transparent); }
}

#landingOverlay .gate-plate.is-checking .gate-box {
  animation: gate-digit-lit var(--lit) var(--ease-standard) both;
  animation-delay: calc(var(--i) * var(--step) + var(--lead));
}
@keyframes gate-digit-lit {
  0%   { opacity: .24; text-shadow: none; }
  32%  { opacity: 1; text-shadow: 0 0 16px color-mix(in oklab, var(--accent) 75%, transparent); }
  100% { opacity: 1; text-shadow: 0 0 8px color-mix(in oklab, var(--accent) 35%, transparent); }
}

#landingOverlay .gate-plate.is-checking .gate-cell::after {
  background: var(--accent);
  animation: gate-cell-line var(--lit) var(--ease-standard) both;
  animation-delay: calc(var(--i) * var(--step) + var(--lead));
}
@keyframes gate-cell-line {
  0%   { opacity: 0; transform: scaleX(.25); }
  30%  { opacity: 1; transform: scaleX(1); }
  100% { opacity: .72; transform: scaleX(1); }
}

#landingOverlay .gate-beam {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms linear;
}
#landingOverlay .gate-plate.is-checking .gate-beam { opacity: 1; }
#landingOverlay .gate-beam::before,
#landingOverlay .gate-beam::after { content: ""; position: absolute; }
#landingOverlay .gate-beam::before {           /* 柔光带 */
  top: 0; bottom: 0; left: 0; width: 62%;
  background: linear-gradient(90deg,
    transparent,
    color-mix(in oklab, var(--accent) 20%, transparent) 38%,
    color-mix(in oklab, var(--accent) 46%, transparent) 64%,
    transparent);
  transform: translateX(-100%);
}
#landingOverlay .gate-beam::after {            /* 前沿细线 */
  top: 0; bottom: 0; left: 0; width: 2px;
  background: color-mix(in oklab, var(--accent) 45%, var(--bg) 55%);
  box-shadow: 0 0 14px 1px color-mix(in oklab, var(--accent) 55%, transparent);
}
#landingOverlay .gate-plate.is-checking .gate-beam::before { animation: gate-sweep var(--beam) linear both; }
#landingOverlay .gate-plate.is-checking .gate-beam::after { animation: gate-sweep-line var(--beam) linear both; }
@keyframes gate-sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(162%); }
}
@keyframes gate-sweep-line {
  from { left: 0; }
  to   { left: 100%; }
}

/* 接入成功：读数板放大并落一条绿色基线 */
#landingOverlay .gate-plate.is-done { height: 88px; }
#landingOverlay .gate-plate.is-done .gate-box { font-size: 34px; letter-spacing: .03em; }
#landingOverlay .gate-plate.is-done::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  height: 2px; border-radius: 2px;
  background: color-mix(in oklab, var(--success), transparent 35%);
  transform-origin: left center;
  animation: gate-line-in 460ms var(--ease-standard) both;
}
@keyframes gate-line-in { from { transform: scaleX(0); } to { transform: none; } }

/* ── 动作位：固定 50px，输入态放按钮，校验/已接入换一句状态 ─── */
#landingOverlay .gate-action {
  margin-top: var(--space-5);
  height: 50px;
}

#landingOverlay .gate-cta {
  width: 100%; height: 50px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 15px; font-weight: 600;
  letter-spacing: .01em;
  transition: background var(--motion-fast) var(--ease-standard),
              transform var(--motion-fast) var(--ease-standard);
}
#landingOverlay .gate-cta:hover { background: var(--accent-hover); }
#landingOverlay .gate-cta:active { background: var(--accent-active); transform: translateY(1px); }

#landingOverlay .gate-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: var(--text-xs);
  line-height: 18px;
  color: var(--muted);
  animation: gate-state-in 260ms var(--ease-standard) both;
}
@keyframes gate-state-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

#landingOverlay .gate-shake { animation: gate-shake .34s var(--ease-standard); }
@keyframes gate-shake {
  20%, 80% { transform: translateX(3px); }
  40%, 60% { transform: translateX(-3px); }
}

@media (max-width: 480px) {
  #landingOverlay .gate {
    padding: var(--space-6) var(--space-5) var(--space-6);
    border-radius: var(--radius-md);
  }
  #landingOverlay .gate-title { font-size: 23px; }
  #landingOverlay .gate-plate { height: 62px; }
  #landingOverlay .gate-box { font-size: 25px; }
  #landingOverlay .gate-plate.is-done { height: 80px; }
  #landingOverlay .gate-plate.is-done .gate-box { font-size: 31px; }
}

@media (prefers-reduced-motion: reduce) {
  #landingOverlay *,
  #landingOverlay *::before,
  #landingOverlay *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  #landingOverlay .gate-plate.is-checking .gate-beam { display: none; }
  /* 关掉动效后不留半亮：六格直接停在点亮的终态 */
  #landingOverlay .gate-plate.is-checking .gate-cell,
  #landingOverlay .gate-plate.is-checking .gate-box,
  #landingOverlay .gate-plate.is-checking .gate-cell::after { animation-delay: 0ms !important; }
}
