/* ==========================================================================
   UI-Venus-2 project page — demos.css
   Trajectory Demos section: domain tabs, case strip, and the replay stage —
   screenshot device on the left, dark reasoning console on the right.
   Action markers are drawn over the screenshot from normalized (0–999)
   trajectory coordinates.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Domain tabs + case strip
   -------------------------------------------------------------------------- */

.demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}
.demo-tab {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.demo-tab:hover { color: var(--venus-deep); border-color: var(--venus-bright); }
.demo-tab[aria-selected="true"] {
  background: var(--venus);
  border-color: var(--venus);
  color: #fff;
}
.demo-tab:disabled {
  cursor: default;
  color: var(--tbd-ink);
  border-style: dashed;
  background: var(--tbd-bg);
}
.demo-tab:disabled:hover { border-color: var(--tbd-line); }
.demo-tab .tbd { font-size: 9.5px; padding: 1px 6px; margin-left: 6px; }

.case-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.case-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.case-chip:hover { border-color: var(--venus-bright); transform: translateY(-1px); }
.case-chip[aria-selected="true"] {
  background: var(--ice);
  border-color: var(--venus);
  color: var(--venus-deep);
}
.case-chip .case-meta {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.case-chip[aria-selected="true"] .case-meta { color: var(--venus); }

/* --------------------------------------------------------------------------
   Stage shell + goal bar
   -------------------------------------------------------------------------- */

.demo-stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  outline-offset: -2px;
}

.demo-goal {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 22px;
  background: var(--ice);
  border-bottom: 1px solid var(--line);
}
.demo-goal-label {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--venus-deep);
  border: 1px solid rgba(59, 139, 244, 0.45);
  border-radius: 6px;
  padding: 3px 8px;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.6);
}
.demo-goal-text { flex: 1; min-width: 0; }
.demo-goal-en { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.5; }
.demo-goal-zh { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
/* --------------------------------------------------------------------------
   Stage body: device + console
   -------------------------------------------------------------------------- */

.demo-body {
  display: flex;
  align-items: stretch;
  gap: 26px;
  padding: 26px;
}

.demo-device {
  flex: 0 0 auto;
  margin-inline: auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Device chrome variants (phone bezel / browser bar / captcha bar) */
.frame-chrome { display: none; }

.device-shell {
  background: var(--code-bg);
  border-radius: 18px;
  padding: 8px;
  box-shadow: var(--shadow-soft);
  max-width: 100%;
}
.demo-device[data-frame="phone"] .device-shell {
  border-radius: 30px;
  padding: 9px;
}
.demo-device[data-frame="phone"] .demo-screen { border-radius: 22px; }

.frame-browser {
  align-items: center;
  gap: 6px;
  padding: 4px 6px 10px;
}
.demo-device[data-frame="browser"] .frame-browser,
.demo-device[data-frame="desktop"] .frame-browser { display: flex; }
.frame-browser .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}
.frame-browser .frame-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(220, 233, 250, 0.75);
  background: rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  padding: 3px 10px;
  margin-left: 4px;
}

.frame-captcha {
  justify-content: space-between;
  align-items: center;
  padding: 3px 6px 9px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(220, 233, 250, 0.75);
}
.demo-device[data-frame="captcha"] .frame-captcha { display: flex; }
.frame-captcha .frame-captcha-ok { color: var(--sky); letter-spacing: 0.04em; }

/* --------------------------------------------------------------------------
   Screen: crossfading screenshots + overlay
   -------------------------------------------------------------------------- */

.demo-screen {
  position: relative;
  aspect-ratio: var(--ar, 0.45);
  /* width must resolve without percentages: the shrink-to-fit parent chain
     would treat them as circular and collapse to 0 */
  width: min(calc(var(--shot-h, 600px) * var(--ar, 0.45)), var(--shot-w-max, 580px));
  border-radius: 10px;
  overflow: hidden;
  background: #0a1a38;
}
.demo-body {
  --shot-h: min(600px, 62vh);
  --shot-w-max: min(580px, calc(100vw - 500px));
}

.shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
}
.shot.active {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s ease, transform 0.5s cubic-bezier(0.22, 0.9, 0.3, 1);
  z-index: 2;
}
/* pre-positions for the incoming shot (no transition yet) */
.shot.enter-r { transform: translateX(4%) scale(1.012); }
.shot.enter-l { transform: translateX(-4%) scale(1.012); }
/* outgoing shot */
.shot.exit-l, .shot.exit-r {
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 0.9, 0.3, 1);
  z-index: 1;
}
.shot.exit-l { transform: translateX(-2.5%) scale(0.992); }
.shot.exit-r { transform: translateX(2.5%) scale(0.992); }

.buffer-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--sky);
  background: rgba(12, 30, 58, 0.82);
  border: 1px solid rgba(126, 196, 248, 0.45);
  border-radius: 6px;
  padding: 3px 8px;
  animation: bufferPulse 1.1s ease-in-out infinite;
}
@keyframes bufferPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.screen-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(220, 233, 250, 0.65);
  background:
    linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%)
    0 0 / 220% 100% no-repeat,
    #0a1a38;
  animation: demoShimmer 1.6s linear infinite;
  z-index: 3;
}
@keyframes demoShimmer {
  from { background-position: 120% 0, 0 0; }
  to { background-position: -120% 0, 0 0; }
}

/* ---- Action overlay ------------------------------------------------------ */

.shot-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

/* Tap / click marker — echoes the page's grounding crosshair ring */
.mk {
  position: absolute;
  transform: translate(-50%, -50%);
}
.mk-tap .ring {
  display: block;
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--venus-bright);
  border-radius: 50%;
  background: rgba(59, 139, 244, 0.22);
  box-shadow: 0 0 0 4px rgba(13, 34, 71, 0.35), 0 0 0 5.5px rgba(126, 196, 248, 0.9);
  animation: mkPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.mk-tap .ripple {
  position: absolute;
  inset: -14px;
  border: 2px solid rgba(126, 196, 248, 0.95);
  border-radius: 50%;
  opacity: 0;
  animation: mkRipple 1.5s ease-out 0.25s infinite;
}
.mk-tap .ripple.r2 { animation-delay: 0.75s; }
@keyframes mkPop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes mkRipple {
  from { transform: scale(0.45); opacity: 0.9; }
  to { transform: scale(1.25); opacity: 0; }
}

.mk-num {
  position: absolute;
  top: -21px;
  left: 18px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  background: var(--venus);
  border: 1.5px solid #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding-inline: 4px;
  box-shadow: 0 2px 8px rgba(12, 30, 58, 0.45);
}
.mk-label {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: #fff;
  background: rgba(12, 30, 58, 0.78);
  border-radius: 5px;
  padding: 2px 7px;
}

/* Drag / swipe: SVG path + rotated arrowhead */
.drag-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.drag-svg .trail {
  fill: none;
  stroke: rgba(12, 30, 58, 0.4);
  stroke-width: 7;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.drag-svg .line {
  fill: none;
  stroke: var(--sky);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 7 9;
  vector-effect: non-scaling-stroke;
  animation: dragFlow 1.1s linear infinite;
}
@keyframes dragFlow { to { stroke-dashoffset: -16; } }
.mk-dot {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--venus-bright);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(12, 30, 58, 0.35);
  animation: mkPop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.mk-arrow {
  display: block;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 14px solid var(--sky);
  filter: drop-shadow(0 0 3px rgba(12, 30, 58, 0.6));
  animation: mkPop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) 0.3s both;
}

/* Scroll marker: dark badge with drifting chevrons in the scroll direction —
   the badge keeps it visible on light screenshots */
.mk-scroll { color: #fff; }
.mk-scroll .scroll-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(12, 30, 58, 0.85);
  border: 1.5px solid rgba(126, 196, 248, 0.65);
  box-shadow: 0 4px 16px rgba(12, 30, 58, 0.55);
  overflow: hidden;
  animation: mkPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.mk-scroll .chev-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  animation: scrollDrift 1.3s ease-in-out infinite;
}
/* standalone `rotate` so it composes with the badge's pop animation */
.mk-scroll[data-dir="up"] .scroll-badge { rotate: 180deg; }
.mk-scroll[data-dir="left"] .scroll-badge { rotate: 90deg; }
.mk-scroll[data-dir="right"] .scroll-badge { rotate: -90deg; }
.mk-scroll .chev {
  width: 13px;
  height: 13px;
  border-right: 3px solid var(--sky);
  border-bottom: 3px solid var(--sky);
  transform: rotate(45deg);
}
.mk-scroll .chev + .chev { opacity: 0.55; margin-top: -9px; }
@keyframes scrollDrift {
  0%, 100% { translate: 0 -4px; }
  50% { translate: 0 5px; }
}

/* Non-spatial actions surface as a toast pinned to the screen bottom */
.action-toast {
  position: absolute;
  left: 50%;
  bottom: 4.5%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 88%;
  font-size: 12.5px;
  line-height: 1.45;
  color: #fff;
  background: rgba(12, 30, 58, 0.88);
  border: 1px solid rgba(126, 196, 248, 0.45);
  border-radius: 10px;
  padding: 8px 13px;
  box-shadow: 0 8px 24px -8px rgba(12, 30, 58, 0.7);
  animation: toastUp 0.4s cubic-bezier(0.2, 1.2, 0.4, 1) 0.28s both;
}
.action-toast .toast-kind {
  flex: none;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--sky);
  border: 1px solid rgba(126, 196, 248, 0.5);
  border-radius: 5px;
  padding: 2px 6px;
}
.action-toast .toast-text {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.action-toast.ok { border-color: rgba(126, 248, 197, 0.55); }
.action-toast.ok .toast-kind { color: #7ef8c5; border-color: rgba(126, 248, 197, 0.55); }
@keyframes toastUp {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --------------------------------------------------------------------------
   Reasoning console
   -------------------------------------------------------------------------- */

.demo-console {
  flex: 1 1 340px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--code-bg);
  border-radius: 14px;
  padding: 18px 20px 16px;
  /* match the device height so long reasoning scrolls instead of
     stretching the stage */
  height: max(460px, calc(var(--shot-h, 600px) + 36px));
  align-self: center;
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.step-count {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(220, 233, 250, 0.6);
}
.step-count b { color: #fff; font-weight: 600; }
.action-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--sky);
  border: 1px solid rgba(126, 196, 248, 0.45);
  border-radius: 6px;
  padding: 3px 9px;
  white-space: nowrap;
}

.console-think {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: 12px;
}
.console-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(220, 233, 250, 0.5);
  margin-bottom: 7px;
}
.think-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.7;
  color: #c3d5ee;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  padding-right: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 196, 248, 0.35) transparent;
}
.think-body::-webkit-scrollbar { width: 6px; }
.think-body::-webkit-scrollbar-thumb {
  background: rgba(126, 196, 248, 0.35);
  border-radius: 3px;
}
.think-body.anim { animation: thinkIn 0.4s ease both; }
@keyframes thinkIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.console-action {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.16);
}
.console-action code {
  display: block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--code-ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: 108px;
  overflow-y: auto;
  scrollbar-width: thin;
  margin-top: 2px;
}
.console-action code .n { color: var(--sky); }
.console-action code.anim { animation: thinkIn 0.35s ease 0.08s both; }

/* ---- Transport ----------------------------------------------------------- */

.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.t-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--code-ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.t-btn:hover { background: rgba(255, 255, 255, 0.16); }
.t-btn:disabled { opacity: 0.35; cursor: default; }
.t-btn:disabled:hover { background: rgba(255, 255, 255, 0.07); }
.t-btn svg { width: 14px; height: 14px; display: block; }
.t-play {
  background: var(--venus-bright);
  border-color: var(--venus-bright);
  color: #fff;
}
.t-play:hover { background: var(--venus); }

.tick-rail {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1px;
  height: 30px;
  min-width: 0;
}
.tick {
  flex: 1;
  min-width: 1px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: background 0.15s ease, height 0.15s ease;
}
.tick:hover { background: rgba(126, 196, 248, 0.7); height: 14px; }
.tick.done { background: rgba(59, 139, 244, 0.6); }
.tick.cur {
  background: var(--venus-bright);
  height: 16px;
  box-shadow: 0 0 8px rgba(59, 139, 244, 0.8);
}

/* Fallback / error note inside the stage */
.demo-fallback {
  display: grid;
  place-items: center;
  min-height: 300px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
}
.demo-fallback code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--ice);
  border-radius: 6px;
  padding: 2px 7px;
}

/* --------------------------------------------------------------------------
   Responsive + reduced motion
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .demo-body {
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    --shot-h: 58vh;
    --shot-w-max: calc(100vw - 92px);
  }
  .demo-console { height: auto; align-self: stretch; }
  .think-body { max-height: 260px; flex: none; }
  .demo-goal { flex-wrap: wrap; padding: 14px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .shot, .shot.active, .shot.exit-l, .shot.exit-r { transition: none; transform: none; }
  .mk-tap .ring, .mk-tap .ripple, .mk-dot, .mk-arrow, .drag-svg .line,
  .mk-scroll .chev-box, .action-toast, .think-body.anim, .console-action code.anim,
  .screen-loading { animation: none; }
  .mk-tap .ripple { opacity: 0.5; transform: scale(0.8); }
}
