/* ============================================================
   scenes.css — components & scene visuals
   ============================================================ */

/* ---- Brand tiles ---- */
.btile {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; box-shadow: var(--sh-1);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: box-shadow var(--dur-reveal) var(--ease-reveal), transform var(--dur-reveal) var(--ease-reveal);
}
.btile img { display: block; object-fit: contain; }
/* full-bleed raster app-icons fill the tile and inherit its rounding */
.btile img.bleed { object-fit: cover; border-radius: inherit; }
.btile.logo { background: var(--surface); border-color: var(--line); }
.btile img.inv { filter: brightness(0) invert(1); }
.btile.glow {
  box-shadow: 0 4px 14px var(--accent-glow), 0 0 0 1px var(--accent);
  transform: translateZ(0) scale(1.04);
}

/* ============================================================
   Phone
   ============================================================ */
.phone {
  width: 340px; flex: none;
  aspect-ratio: 340 / 712;
  background: #0a0a0c;
  /* 外框 R · 内屏同心：内屏圆角 = 外框 R − padding */
  border-radius: 44px;
  padding: 10px;
  /* Apple 式接触阴影：模糊远大于偏移、负扩散，叠在物理深色边框之上，更像真机悬浮 */
  box-shadow: var(--sh-3), 0 40px 80px -24px rgba(18,20,28,.22), inset 0 0 0 1.5px #1c1c20;
  position: relative;
}
.phone-notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 116px; height: 25px; background: #0a0a0c; border-radius: 0 0 16px 16px;
  z-index: 6;
}
.phone-screen {
  width: 100%; height: 100%; background: var(--surface-3); border-radius: 34px;
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}
/* 屏幕镜面高光：135° 极淡线性高光，浮在内容之上、同心圆角、不挡点击 */
.phone-screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 7;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.14), transparent 42%);
}
.chat-head {
  flex: none; height: 78px; padding: 26px 16px 8px;
  display: flex; align-items: center; gap: 8px;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line);
}
.chat-back { color: var(--accent); font-size: var(--t-h3); line-height: 1; font-weight: 300; }
.chat-title { flex: 1; display: flex; flex-direction: column; align-items: center; }
.ct-name { font-size: var(--t-body); font-weight: 600; color: var(--ink); }
.ct-sub { font-size: var(--t-caption); color: var(--ink-4); }
.chat-dots { color: var(--ink-3); font-size: var(--t-lead); letter-spacing: 1px; }

.entry-switch {
  flex: none; display: flex; gap: 6px; padding: 9px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.entry-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px; border-radius: var(--r-pill); flex: none;
  font-size: var(--t-caption); font-weight: 500; color: var(--ink-3);
  background: transparent; border: 1px solid transparent;
  transition: all var(--dur-ui) var(--ease-ui);
}
.entry-chip.on {
  background: var(--surface); color: var(--ink); border-color: var(--line);
  box-shadow: var(--sh-1);
}
.entry-chip:not(.on):hover { background: var(--surface-3); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 14px 13px 22px;
  display: flex; flex-direction: column; gap: 11px;
  background:
    radial-gradient(120% 60% at 50% 0%, var(--surface-2) 0%, var(--surface-3) 60%);
}
.chat-body::-webkit-scrollbar { width: 0; }

.chat-input {
  flex: none; background: var(--surface-2); border-top: 1px solid var(--line);
}

.bubble-row { display: flex; animation: bubbleIn .5s var(--ease-reveal) both; }
.bubble-row.out { justify-content: flex-end; }
.bubble-row.in { justify-content: flex-start; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
/* 统一一套气泡语言：主圆角 --r-card 胶囊感，尾巴一角收小 5px（保留特征）*/
.bubble {
  max-width: 80%; padding: 10px 13px; border-radius: var(--r-card);
  font-size: var(--t-small); line-height: 1.45; letter-spacing: -.01em;
  box-shadow: var(--sh-1);
}
.bubble.in { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.out { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
/* 真实微信观感：微信绿，保留 */
.bubble.out.wx { background: #95ec69; color: #0d2912; }

/* delivery card inside chat — 中性卡，无彩色边 */
.deliver-card {
  max-width: 88%; background: var(--surface); border-radius: var(--r-card); padding: 13px 14px;
  box-shadow: var(--sh-1); border: 1px solid var(--line);
  animation: cardPop .55s var(--ease-reveal) both;
}
@keyframes cardPop { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }
.dc-title { font-size: var(--t-small); font-weight: 600; margin-bottom: 9px; letter-spacing: -.01em; }
.dc-lines { display: flex; flex-direction: column; gap: 7px; }
.dc-line { display: flex; gap: 8px; font-size: var(--t-small); color: var(--ink-2); line-height: 1.4; }
.dc-tick { color: var(--pos); font-weight: 700; flex: none; }
.dc-sediment {
  margin-top: 11px; padding-top: 11px; border-top: 1px dashed var(--line-2);
  display: flex; align-items: center; gap: 9px; font-size: var(--t-caption); color: var(--ink-3);
}
.dc-sediment .dc-arrow { margin-left: auto; color: var(--accent); font-size: var(--t-body);
  animation: arrowNudge 1.4s var(--ease-reveal) infinite; }
@keyframes arrowNudge { 0%,100% { transform: translate(0,0); } 50% { transform: translate(2px,2px); } }

/* ============================================================
   Task chips (Act 1)
   ============================================================ */
.task-chip {
  display: inline-flex; align-items: center; gap: 9px;
  height: 50px; padding: 0 18px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line);
  font-size: var(--t-body); font-weight: 500; color: var(--ink); letter-spacing: -.01em;
  box-shadow: var(--sh-1);
  transition: all var(--dur-ui) var(--ease-ui);
}
.task-chip:hover:not(:disabled):not(.done) {
  transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--line-2);
}
/* 选中态：--accent 描边 + 极浅底，不用纯色 glow 块 */
.task-chip.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--sh-1); }
.task-chip.done { background: var(--surface-2); color: var(--ink-3); box-shadow: none; }
.task-chip:disabled { cursor: default; }
.task-chip .chip-go { color: var(--ink-4); font-size: var(--t-lead); }
.task-chip.pulse { animation: chipPulse 2s var(--ease-reveal) infinite; }

/* ============================================================
   DoneTick —— 全站统一「完成」徽章（绿圆 + 白勾）。唯一样式来源。
   尺寸默认 18px，可由具体场景覆盖；白勾恒为圆直径的 60%。
   ============================================================ */
.done-tick {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pos); color: #fff;
}
.done-tick > svg { width: 60%; height: 60%; }
@keyframes chipPulse {
  0%,100% { box-shadow: var(--sh-1); }
  50% { box-shadow: 0 0 0 1px var(--accent), 0 0 0 6px var(--accent-050), var(--sh-1); }
}

/* tags — 低饱和小标签：极浅语义底 + 语义文字色 */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill); font-size: var(--t-caption); font-weight: 500;
  white-space: nowrap;
}
.tone-neutral { background: var(--surface-2); color: var(--ink-3); }
.tone-blue { background: var(--accent-050); color: var(--accent-600); }
.tone-amber { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.tone-green { background: color-mix(in srgb, var(--pos) 12%, transparent); color: var(--pos); }
.tone-red { background: color-mix(in srgb, var(--neg) 12%, transparent); color: var(--neg); }

/* ============================================================
   Routing stage
   ============================================================ */
.route-stage {
  position: relative; width: 100%; height: 100%;
  border-radius: var(--r-lg);
  background:
    radial-gradient(80% 90% at 30% 40%, var(--surface) 0%, var(--surface-2) 70%, var(--surface-3) 100%);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.route-grid {
  position: absolute; inset: 0; opacity: .5;
  background-image:
    linear-gradient(rgba(0,0,0,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.025) 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, #000 40%, transparent 100%);
          mask-image: radial-gradient(70% 70% at 50% 50%, #000 40%, transparent 100%);
}
.route-wires { position: absolute; inset: 0; pointer-events: none; }
/* 连线统一：发丝灰底线 + 单一 --accent 高亮线，stroke 1.4，描边动画 --ease-reveal */
.wire-base { fill: none; stroke: var(--line-2); stroke-width: 1.4; opacity: .7; }
.wire-lit {
  fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  transition: stroke-dashoffset .7s var(--ease-draw);
  opacity: .92;
}
.wire-lit.on { stroke-dashoffset: 0; }
/* 流光统一为小光点：底线/高亮线静止，只有点沿路径移动。 */
.wire-dot {
  fill: currentColor; color: var(--accent);
  filter: drop-shadow(0 0 4px currentColor) drop-shadow(0 0 9px currentColor);
  opacity: .96;
}
.wire.dim { opacity: .3; transition: opacity .6s var(--ease-reveal); }
.wire.dim .wire-dot { display: none; }

.route-hub {
  position: absolute; transform: translate(-50%, -50%);
  z-index: 5; transition: transform .4s var(--ease-reveal);
}
.hub-core {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 12px 18px 12px 13px; border-radius: var(--r-card);
  box-shadow: var(--sh-2); position: relative; z-index: 2;
  transition: box-shadow .4s var(--ease-reveal), border-color .4s;
}
.route-hub.running .hub-core,
.route-hub.working .hub-core { border-color: var(--accent); box-shadow: 0 6px 22px var(--accent-glow); }
.route-hub.synth .hub-core { border-color: var(--pos); }
.hub-text { display: flex; flex-direction: column; line-height: 1.2; }
.hub-label { font-size: var(--t-small); font-weight: 600; letter-spacing: -.01em; }
.hub-sub { font-size: var(--t-caption); color: var(--ink-4); }
.hub-ring {
  position: absolute; inset: 50%; width: 70px; height: 70px;
  margin: -35px 0 0 -35px; border-radius: 50%;
  border: 1.5px solid var(--accent); opacity: 0;
  animation: hubRing 2.2s var(--ease-reveal) infinite;
}
.hub-ring.r2 { animation-delay: 1.1s; }
@keyframes hubRing {
  0% { transform: scale(.6); opacity: .5; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* anchor by the ICON center: the box height is just the icon, the label floats
   below absolutely, so the wire endpoint (n.x,n.y) lands dead-center on the tile */
.route-node {
  position: absolute; transform: translate(-50%, -50%);
  width: 50px; height: 50px; z-index: 4;
  transition: opacity .5s var(--ease-reveal), transform .5s var(--ease-reveal);
}
.route-node.dim { opacity: .32; }
.rn-meta {
  position: absolute; top: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  width: 132px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
}
.rn-label { font-size: var(--t-small); font-weight: 500; color: var(--ink-2); letter-spacing: -.01em; }
/* 同 .tag：低饱和小标签 */
.rn-tag {
  font-size: var(--t-caption); padding: 2px 8px; border-radius: var(--r-pill); font-weight: 500;
  background: var(--surface-2); color: var(--ink-3);
}
.rn-tag.t-blue { background: var(--accent-050); color: var(--accent-600); }
.rn-tag.t-amber { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.rn-tag.t-green { background: color-mix(in srgb, var(--pos) 12%, transparent); color: var(--pos); }
.route-node.lit .rn-label { color: var(--ink); }
/* 仅作角标定位 + 出场动画 + 悬浮投影；圆形与白勾由内部 .done-tick 统一绘制 */
.rn-check {
  position: absolute; top: -7px; right: -7px;
  border-radius: 50%;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--pos) 14%, transparent);
  animation: tickPop .4s var(--ease-reveal) both;
}
.rn-check .done-tick { width: 20px; height: 20px; }
@keyframes tickPop { from { transform: scale(0); } to { transform: scale(1); } }

/* ---- directional framing: left = sources flow in · right = results flow out ---- */
.route-side {
  position: absolute; top: 16px; z-index: 6;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--t-caption); font-weight: 600; letter-spacing: -.01em; color: var(--ink-3);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  padding: 6px 13px; border-radius: var(--r-pill); border: 1px solid var(--glass-bd);
  box-shadow: var(--glass-sh); animation: fadeUp .5s var(--ease-reveal) both;
}
.route-side.left  { left: 18px; }
.route-side.right { right: 18px; }
.route-side .rs-arrow {
  font-size: var(--t-small); font-weight: 700; color: var(--accent);
  animation: sideArrow 1.6s var(--ease-reveal) infinite;
}
.route-side.right .rs-arrow { color: var(--ink-3); }
@keyframes sideArrow {
  0%,100% { transform: translateX(0); opacity: .55; }
  50%     { transform: translateX(3px); opacity: 1; }
}

/* ---- proactive lead-in beat: stated plainly before the wires fan out ---- */
.proactive-lead {
  position: absolute; left: 50%; top: 19%; transform: translateX(-50%);
  z-index: 6; width: min(560px, 78%); text-align: center;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.proactive-lead .pl-head {
  font-size: var(--t-small); font-weight: 600; color: var(--accent-600);
  letter-spacing: .02em; animation-delay: .05s;
}
.proactive-lead .pl-body {
  font-size: var(--t-h3); font-weight: 700; line-height: 1.42; color: var(--ink);
  letter-spacing: -.01em; animation-delay: .16s;
}

/* ============================================================
   Mobile — 手机端（375 基准）。只缩放/重排，保留全部动画。
   ============================================================ */
@media (max-width: 600px) {
  /* —— 手机模型：自适应宽度，圆角随之协调 —— */
  .phone { width: min(78vw, 300px); border-radius: 40px; }
  /* 内屏同心圆角 = 外框 40 − padding 10 = 30；刘海宽度收一点 */
  .phone-screen { border-radius: 30px; }
  .phone-notch { width: 104px; height: 22px; }

  /* —— 聊天：窄屏下排版正常、正常换行、不溢出 —— */
  .chat-head { height: 70px; padding: 22px 14px 8px; }
  .chat-body { padding: 12px 11px 18px; gap: 10px; }
  /* 气泡按父容器百分比宽度，单列化后即恢复正常换行 */
  .bubble { max-width: 80%; }
  .deliver-card { max-width: 90%; }
  .entry-switch { padding: 8px 10px; }

  /* —— 路由图：节点/标签/hub 内部缩放，避免标签重叠 —— */
  .route-node { width: 40px; height: 40px; }
  .rn-meta { width: 88px; top: calc(100% + 6px); gap: 3px; }
  .rn-label { font-size: var(--t-caption); }
  .rn-tag { font-size: var(--t-caption); padding: 2px 6px; }
  .rn-check { top: -6px; right: -6px; }
  .rn-check .done-tick { width: 16px; height: 16px; }
  .hub-core { padding: 9px 13px 9px 10px; gap: 8px; }
  .hub-ring { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
  .route-side { top: 12px; padding: 5px 10px; }
  .route-side.left { left: 12px; }
  .route-side.right { right: 12px; }
  .proactive-lead { width: min(560px, 86%); top: 15%; }

  /* —— 共享小组件：窄屏正常 —— */
  .task-chip { height: 46px; padding: 0 15px; font-size: var(--t-small); }
}
