/**
 * 用户端样式：手机扫码后打开的取号与排队进度页面。
 *
 * 视觉核心是一张「纸质号票」——带撕裂虚线与打孔缺口，
 * 号码使用大字号等宽字体，模拟票据打印的观感。
 */

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  /* 极淡的纸纹：用重复线性渐变模拟纤维质感，避免纯色背景的平淡 */
  background-image: repeating-linear-gradient(
      92deg,
      rgba(140, 131, 119, 0.045) 0 1px,
      transparent 1px 3px
    ),
    repeating-linear-gradient(
      2deg,
      rgba(140, 131, 119, 0.035) 0 1px,
      transparent 1px 4px
    );
  display: flex;
  flex-direction: column;
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px calc(20px + env(safe-area-inset-bottom));
}

/* ── 顶栏 ───────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand__name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__clock {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

/* ── 主舞台 ─────────────────────────────────────────────────────── */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 4px 0 12px;
}

/* 每种页面状态（取号态 / 持号态）为一组纵向排列的内容块 */
.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: view-fade var(--dur) var(--ease) both;
}

@keyframes view-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── 号票卡片 ───────────────────────────────────────────────────── */
.ticket {
  position: relative;
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: 26px 22px 24px;
  box-shadow: var(--shadow-card);
  animation: ticket-rise var(--dur-slow) var(--ease) both;
}

@keyframes ticket-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ticket__eyebrow {
  text-align: center;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

/* 号码显示区：等宽大字号，逐字符入场模拟翻牌 */
.ticket__number {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.04em;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(66px, 21vw, 104px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ticket__number--placeholder {
  color: var(--rule);
  letter-spacing: 0.06em;
}

.ticket__digits {
  display: inline-flex;
  align-items: baseline;
}

.ticket__digit {
  display: inline-block;
  animation: digit-print 460ms var(--ease) both;
  animation-delay: calc(var(--index, 0) * 60ms);
}

@keyframes digit-print {
  from {
    opacity: 0;
    transform: translateY(-0.3em) rotateX(60deg);
    filter: blur(5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

.ticket__caption {
  margin-top: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-faint);
}

/* ── 撕裂虚线与打孔缺口 ─────────────────────────────────────────── */
.perf {
  position: relative;
  height: 0;
  margin: 26px 0;
  border-top: 2px dashed var(--rule);
}

.perf::before,
.perf::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--paper);
  transform: translateY(-50%);
}

/* 圆心正落在卡片左右边缘上：卡片内边距 22px + 缺口半径 13px */
.perf::before {
  left: -35px;
}

.perf::after {
  right: -35px;
}

/* ── 票根信息栅格 ───────────────────────────────────────────────── */
.stub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 10px;
}

.stub-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.stub-cell__label {
  color: var(--ink-faint);
  font-size: 10px;
}

.stub-cell__value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stub-cell__value--text {
  font-family: var(--font-cjk);
  font-size: 15px;
  font-weight: 600;
}

.stub-cell--wide {
  grid-column: 1 / -1;
}

/* ── 登记表单 ───────────────────────────────────────────────────── */
.ticket--form {
  padding: 24px 22px 22px;
}

.ticket--form .ticket__eyebrow {
  margin-bottom: 18px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 货物类型与数量并排，节省纵向空间 */
.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ── 带单位的输入框（货物数量：个） ─────────────────────────────── */
.input-with-unit {
  position: relative;
  display: block;
}

.input-with-unit .input {
  padding-right: 40px;
  text-align: right;
  font-size: 18px;
  font-weight: 700;
}

.input-with-unit__unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}

/* 数字框去掉浏览器自带的上下箭头，避免误触 */
.input[type='number']::-webkit-outer-spin-button,
.input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ── 提交按钮：居中，不占满整行 ─────────────────────────────────── */
.form-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.form-actions .btn--take {
  width: auto;
  min-width: 62%;
  padding-left: 34px;
  padding-right: 34px;
}

/* ── 车牌专用输入框：外观是一块蓝底白字的车牌 ───────────────────── */
.plate-field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 66px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 2px solid #ffffff;
  background: linear-gradient(180deg, #1f5fbf 0%, #17458f 100%);
  box-shadow: 0 2px 0 rgba(22, 19, 15, 0.16), 0 10px 22px -12px rgba(23, 69, 143, 0.85);
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease);
}

.plate-field:focus-within,
.plate-field.is-open {
  box-shadow: 0 0 0 3px rgba(226, 83, 31, 0.28), 0 10px 22px -12px rgba(23, 69, 143, 0.85);
}

.plate-field.is-invalid {
  border-color: #ffd2c6;
  background: linear-gradient(180deg, #c4432a 0%, #9c2f1b 100%);
}

.plate-field__cells {
  display: flex;
  gap: 5px;
  pointer-events: none;
}

.plate-cell {
  display: grid;
  place-items: center;
  width: 34px;
  height: 46px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

/* 已填入的字符：白底蓝字，与真实车牌一致 */
.plate-cell--filled {
  color: #17458f;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9);
}

/* 新能源号牌的第 8 位：虚线描边提示可选 */
.plate-cell--ghost {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  border: 1px dashed rgba(255, 255, 255, 0.5);
  width: 24px;
}

/* 覆盖在上层的真实输入框：透明但可聚焦，兼顾表单语义与桌面端键入 */
.plate-field__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  cursor: pointer;
  /* 保证移动端不会弹出系统键盘 */
  font-size: 16px;
}

/* 光标位置提示：聚焦时给最后一个空格一个闪烁的边 */
.plate-field.is-open .plate-cell--ghost {
  border-color: var(--accent);
}

/* 校验失败的输入框：红色描边 + 淡红底 */
.input.is-invalid {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: 0 0 0 3px rgba(226, 83, 31, 0.12);
}

.form-hint {
  margin: 14px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.ticket--form .btn--take {
  margin-top: 18px;
}

/* ── 号票上的车牌号 ─────────────────────────────────────────────── */
.ticket__plate {
  margin-top: 6px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.ticket--called .ticket__plate {
  color: #fff;
}

/* ── 到号响铃开关 ───────────────────────────────────────────────── */
.sound-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  min-height: 46px;
  border-radius: var(--radius);
  border: 1px dashed var(--rule);
  color: var(--ink-faint);
  font-size: 14px;
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.sound-toggle__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rule);
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.sound-toggle.is-on {
  color: var(--signal-green);
  border-color: rgba(31, 122, 77, 0.35);
  border-style: solid;
  background: var(--signal-green-tint);
}

.sound-toggle.is-on .sound-toggle__dot {
  background: var(--signal-green);
  box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.16);
}

.ticket--called .sound-toggle {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.14);
}

.ticket--called .sound-toggle.is-on .sound-toggle__dot {
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

/* ── 状态徽标 ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge--waiting {
  color: var(--signal-amber);
  background: var(--signal-amber-tint);
}

.badge--called {
  color: #fff;
  background: var(--accent);
}

.badge--done {
  color: var(--signal-green);
  background: var(--signal-green-tint);
}

.badge--muted {
  color: var(--signal-grey);
  background: var(--paper-sunk);
}

/* ── 被叫号状态：整张票切换为高饱和强调色并呼吸 ─────────────────── */
.ticket--called {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(226, 83, 31, 0.5), var(--shadow-card);
  animation: ticket-rise var(--dur-slow) var(--ease) both,
    called-pulse 2s var(--ease) infinite 620ms;
}

@keyframes called-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(226, 83, 31, 0.5), var(--shadow-card);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(226, 83, 31, 0), var(--shadow-card);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(226, 83, 31, 0), var(--shadow-card);
  }
}

.ticket--called .ticket__eyebrow,
.ticket--called .ticket__caption,
.ticket--called .stub-cell__label {
  color: rgba(255, 255, 255, 0.72);
}

.ticket--called .ticket__number,
.ticket--called .stub-cell__value {
  color: #fff;
}

.ticket--called .perf {
  border-top-color: rgba(255, 255, 255, 0.35);
}

.ticket--called .perf::before,
.ticket--called .perf::after {
  background: var(--paper);
}

.ticket--called .badge {
  color: var(--accent-deep);
  background: #fff;
}

.called-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 18px;
  padding: 13px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.18);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  animation: banner-blink 1.4s var(--ease) infinite;
}

@keyframes banner-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.62;
  }
}

/* ── 当前叫号航显小牌 ───────────────────────────────────────────── */
.board-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px;
  border-radius: var(--radius);
  background: var(--board);
  color: var(--board-text);
  box-shadow: var(--shadow-card);
}

.board-mini__main {
  min-width: 0;
}

.board-mini__label {
  color: var(--board-dim);
  font-size: 10px;
}

.board-mini__value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--board-amber);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.board-mini__stat {
  text-align: right;
}

.board-mini__stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.board-mini__stat-label {
  color: var(--board-dim);
  font-size: 10px;
  margin-top: 3px;
}

/* ── 操作按钮 ───────────────────────────────────────────────────── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn--take {
  padding: 19px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 12px 26px -12px rgba(226, 83, 31, 0.9);
}

.btn--take:hover:not(:disabled) {
  background: var(--accent-deep);
}

/* 非服务时间：改为中性灰底，避免半透明橙色带来的低对比度 */
.btn--take:disabled {
  opacity: 1;
  color: var(--ink-faint);
  background: var(--paper-sunk);
  box-shadow: none;
}

.btn--quiet {
  color: var(--ink-faint);
  font-size: 14.5px;
  /* 移动端点击区不小于 44px，避免误触 */
  padding: 13px;
  min-height: 44px;
  border-radius: var(--radius-sm);
}

.btn--quiet:hover {
  color: var(--accent-deep);
  background: rgba(226, 83, 31, 0.07);
}

/* ── 非服务时间提示 ─────────────────────────────────────────────── */
.closed-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--signal-amber-tint);
  border: 1px solid rgba(176, 116, 10, 0.2);
  color: #7a5207;
  font-size: 13.5px;
  line-height: 1.55;
}

.closed-note strong {
  font-weight: 700;
}

/* ── 页脚说明 ───────────────────────────────────────────────────── */
.footnote {
  padding: 18px 4px 6px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.7;
}

.footnote__rule {
  display: inline-block;
  padding: 0 8px;
  color: var(--rule);
}

/* ══ 车牌专用键盘 ═════════════════════════════════════════════════
   固定在屏幕底部，采用与系统键盘相近的浅灰底 + 白色键帽，
   省份面板与字母数字面板互斥显示，避免一次占据过多屏幕高度。 */
.plate-pad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: #e7e3d8;
  border-top: 1px solid var(--rule);
  box-shadow: 0 -10px 34px -14px rgba(22, 19, 15, 0.45);
  animation: pad-rise var(--dur) var(--ease) both;
}

@keyframes pad-rise {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

.plate-pad__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 9px;
}

.plate-pad__title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-faint);
}

.plate-pad__close {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 6px;
}

.plate-pad__panel {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.pad-row {
  display: flex;
  gap: 5px;
  margin-bottom: 6px;
  width: 100%;
}

.pad-row:last-child {
  margin-bottom: 0;
}

.pad-key {
  flex: 1 1 0;
  min-width: 0;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--paper-raised);
  box-shadow: 0 1px 0 rgba(22, 19, 15, 0.3);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.pad-key:active {
  background: var(--paper-sunk);
  transform: translateY(1px);
}

/* 省份键：每行 8 个，共 4 行放得下全部 31 个简称 */
.pad-key--province {
  flex: 0 0 calc((100% - 5px * 7) / 8);
  height: 44px;
  font-family: var(--font-cjk);
  font-size: 17px;
}

.pad-key--action,
.pad-key--confirm {
  font-family: var(--font-cjk);
  font-size: 15px;
  flex: 1.4 1 0;
}

.pad-key--confirm {
  flex: 2 1 0;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 0 var(--accent-deep);
}

.pad-key--confirm:active {
  background: var(--accent-deep);
}

/* 键盘弹出时给页面底部留出空间，保证车牌框不会被遮挡 */
body.pad-open .app {
  padding-bottom: calc(var(--pad-height, 300px) + 24px);
}

/* ── 首次加载骨架 ───────────────────────────────────────────────── */
.skeleton {
  height: 300px;
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, var(--paper-sunk) 30%, #f2eee4 50%, var(--paper-sunk) 70%);
  background-size: 220% 100%;
  animation: skeleton-sweep 1.4s linear infinite;
}

@keyframes skeleton-sweep {
  from {
    background-position: 130% 0;
  }
  to {
    background-position: -30% 0;
  }
}
