/* ============================================================
   大屏 · 双皮肤（tokens.css）
   ============================================================ */
@import url('./tokens.css');

html, body { width: 100%; height: 100%; overflow: hidden; }
body { user-select: none; }

.screen {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  padding: clamp(16px, 2.4vh, 32px) clamp(18px, 2.4vw, 40px);
  gap: clamp(12px, 1.8vh, 24px);
  max-width: 2400px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand .title {
  font-size: clamp(15px, 2vh, 22px);
  font-weight: 500;
  color: var(--on);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand .title b { font-weight: 600; }
.brand .sub {
  display: none;
}
.header-right {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.4vw, 22px);
  flex-shrink: 0;
  font-size: clamp(12px, 1.5vh, 16px);
  color: var(--on-2);
}
.phase {
  color: var(--on);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--divider);
}
.clock {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  letter-spacing: 0.02em;
  min-width: 7.5ch;
  text-align: right;
}
.mode-chip, .sse-chip, .theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  font-size: clamp(11px, 1.35vh, 14px);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--supply);
  flex-shrink: 0;
}
.mode-chip[data-mode="manual"] .dot { background: var(--demand); }
.mode-chip[data-mode="offline"] .dot { background: var(--danger); }
.sse-chip .dot { background: var(--danger); }
.sse-chip .dot[data-on="1"] { background: var(--supply); }

/* ---------- Main ---------- */
.main {
  display: grid;
  grid-template-columns: minmax(280px, 38%) minmax(0, 62%);
  gap: clamp(12px, 1.6vw, 28px);
  min-height: 0;
}
.col {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 18px);
  min-height: 0;
}

/* 数字人 */
.avatar-box {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-1);
  border: 1px solid var(--divider);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-1);
}
.avatar-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.5vh, 32px);
  background:
    radial-gradient(circle at 50% 42%, var(--primary-soft), transparent 55%);
}
.host-mark {
  position: relative;
  width: clamp(72px, 12vh, 140px);
  height: clamp(72px, 12vh, 140px);
  display: grid;
  place-items: center;
}
.host-mark .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--outline);
}
.host-mark .ring.pulse {
  animation: ringPulse 3.4s var(--ease) infinite;
}
@keyframes ringPulse {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.55); opacity: 0; }
}
.host-mark .core {
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: var(--hero-glow);
}
.avatar-fallback .label {
  font-size: clamp(11px, 1.4vh, 14px);
  letter-spacing: 0.22em;
  color: var(--on-3);
  font-weight: 500;
}
.avatar-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(11px, 1.3vh, 13px);
  color: var(--on-2);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--divider);
}
.avatar-badge .live {
  color: var(--live);
  font-weight: 600;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.avatar-badge .live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live);
  animation: livePulse 1.8s var(--ease) infinite;
}
@keyframes livePulse {
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* 字幕 + 二维码 */
.subtitle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
}
.subtitle {
  padding: clamp(14px, 2vh, 22px) clamp(14px, 1.4vw, 22px);
  font-size: clamp(14px, 1.9vh, 20px);
  line-height: 1.55;
  color: var(--on);
  min-height: clamp(88px, 12vh, 140px);
  display: flex;
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.subtitle .cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--primary);
  margin-left: 3px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

.qr-card {
  width: clamp(96px, 13vh, 140px);
  background: #fff;
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-1);
}
.qr-card img {
  width: 100%;
  aspect-ratio: 1;
}
.qr-card .cap {
  font-size: clamp(10px, 1.2vh, 12px);
  color: #0e0f12;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding-bottom: 2px;
}

/* ---------- 右栏：匹配 + 墙 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-head .meta {
  font-size: clamp(11px, 1.25vh, 13px);
  color: var(--on-3);
  font-variant-numeric: tabular-nums;
}

.match-zone { flex: 0 0 auto; }

.match-card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--match-border);
  border-radius: var(--radius-xl);
  padding: clamp(18px, 2.6vh, 32px) clamp(16px, 2vw, 32px);
  box-shadow: var(--shadow-hero);
  min-height: clamp(160px, 22vh, 280px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
[data-theme="stage"] .match-card {
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
}
.match-card.pop {
  animation: cardIn 0.55s var(--ease-out);
}
.match-card.pop::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--primary);
  opacity: 0;
  animation: ringOnce 0.9s var(--ease) forwards;
  pointer-events: none;
}
@keyframes cardIn {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes ringOnce {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

.match-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(10px, 1.6vw, 28px);
}
.match-node .role {
  font-size: clamp(10px, 1.2vh, 12px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-3);
  margin-bottom: 8px;
  font-weight: 500;
}
.match-node .table-no {
  font-size: clamp(28px, 4.6vh, 52px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--on);
  margin-bottom: 6px;
}
.match-node.demand .table-no { color: var(--demand); }
.match-node.supply .table-no { color: var(--supply); }
.match-node .table-no small {
  font-size: 0.38em;
  font-weight: 500;
  margin-left: 4px;
  letter-spacing: 0;
  opacity: 0.85;
}
.match-node .who {
  font-size: clamp(16px, 2.2vh, 24px);
  font-weight: 600;
  color: var(--on);
  line-height: 1.2;
}
.match-node .org {
  font-size: clamp(12px, 1.4vh, 14px);
  color: var(--on-2);
  margin-top: 4px;
}
.match-node .what {
  margin-top: 12px;
  font-size: clamp(13px, 1.55vh, 16px);
  color: var(--on-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.match-arrow {
  width: clamp(40px, 5vw, 72px);
  display: grid;
  place-items: center;
  position: relative;
}
.match-arrow svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.match-arrow .line {
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
}
.match-card.pop .match-arrow .line {
  animation: drawLine 0.7s var(--ease-out) 0.1s forwards;
}
@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}
.match-arrow .head {
  fill: var(--primary);
  opacity: 0;
}
.match-card.pop .match-arrow .head {
  animation: fadeIn 0.3s var(--ease) 0.55s forwards;
}
@keyframes fadeIn { to { opacity: 1; } }

.match-reason {
  margin-top: clamp(14px, 2vh, 22px);
  padding-top: clamp(12px, 1.6vh, 18px);
  border-top: 1px solid var(--divider);
  font-size: clamp(12px, 1.45vh, 15px);
  color: var(--on-2);
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.match-reason .k {
  color: var(--primary);
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.match-empty {
  text-align: center;
  color: var(--on-3);
  font-size: clamp(13px, 1.6vh, 17px);
  padding: 28px 12px;
  line-height: 1.7;
}
.match-empty strong {
  color: var(--on-2);
  font-weight: 500;
}

/* 匹配履历 ticker */
.match-ticker {
  margin-top: 12px;
  padding: 10px 12px 8px;
  background: var(--surface-1);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.match-ticker .sec-label { margin-bottom: 8px; }
.ticker-track {
  display: flex;
  gap: 8px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.ticker-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  font-size: clamp(11px, 1.3vh, 13px);
  color: var(--on-2);
  white-space: nowrap;
  animation: tickIn 0.4s var(--ease);
}
.ticker-item b { color: var(--on); font-weight: 600; }
.ticker-item .arrow { color: var(--primary); }
.ticker-item:first-child {
  border-color: var(--primary-ring);
  background: var(--primary-soft);
  color: var(--on);
}
@keyframes tickIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

/* 供需墙 */
.wall {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 14px 16px 8px;
  box-shadow: var(--shadow-1);
}
.wall-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(180deg, #000 78%, transparent 100%);
}
.wall-list {
  position: relative;
}
.wall-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1.1fr) minmax(0, 2fr);
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--divider);
  font-size: clamp(12px, 1.55vh, 16px);
}
.wall-item:first-child { animation: rowIn 0.4s var(--ease); }
@keyframes rowIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.wall-item .tag {
  font-size: clamp(10px, 1.2vh, 12px);
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}
.wall-item .tbl {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--on);
  min-width: 3.2em;
}
.wall-item .name {
  font-weight: 500;
  color: var(--on);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall-item .txt {
  color: var(--on-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall-item.new .name { color: var(--primary); }
.wall-item.new {
  background: linear-gradient(90deg, var(--primary-soft), transparent 60%);
  border-radius: 8px;
}

/* ---------- Footer KPI ---------- */
.footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-1);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.stat {
  padding: clamp(12px, 2vh, 22px) 8px;
  text-align: center;
  position: relative;
}
.stat + .stat { border-left: 1px solid var(--divider); }
.stat .num {
  font-size: clamp(28px, 4.2vh, 48px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--on);
  display: inline-block;
  transition: transform 0.35s var(--ease-out), color 0.2s var(--ease);
}
.stat .num.rolling {
  animation: numRoll 0.55s var(--ease-out);
}
@keyframes numRoll {
  0% { transform: translateY(0.35em); opacity: 0.2; }
  55% { transform: translateY(-0.08em); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}
.stat.matched .num { color: var(--supply); }
.stat.pending .num { color: var(--demand); }
.stat .lbl {
  margin-top: 8px;
  font-size: clamp(11px, 1.3vh, 14px);
  color: var(--on-2);
  letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
  .match-card.pop,
  .match-card.pop::after,
  .match-arrow .line,
  .match-arrow .head,
  .wall-item:first-child,
  .ticker-item,
  .stat .num.rolling,
  .host-mark .ring.pulse,
  .avatar-badge .live::before,
  .subtitle .cursor {
    animation: none !important;
  }
}

/* 启声音遮罩 */
.audio-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.audio-gate.hidden { display: none; }
.audio-gate .panel {
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  text-align: center;
  box-shadow: var(--shadow-2);
  max-width: 420px;
}
.audio-gate h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 10px;
}
.audio-gate p {
  color: var(--on-2);
  font-size: 14px;
  margin-bottom: 22px;
  line-height: 1.6;
}
