/* =============================================
   AI 模型深度原理 - 5大动画模块样式
   ============================================= */

/* ---------- Pipeline Overview ---------- */
.model-pipeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1100px;
}

.pipeline-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px;
  background: rgba(255,255,255,0.02);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.05);
}
.pipeline-nav-btn {
  flex: 1;
  min-width: 120px;
  padding: 14px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}
.pipeline-nav-btn .step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 2px;
  transition: var(--transition);
}
.pipeline-nav-btn.active {
  background: rgba(0, 212, 255, 0.08);
  color: var(--neon-blue);
}
.pipeline-nav-btn.active .step-num {
  background: var(--neon-blue);
  color: var(--bg-dark);
  border-color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0,212,255,0.4);
}
.pipeline-nav-btn.completed .step-num {
  background: rgba(34,211,238,0.2);
  border-color: var(--neon-green);
  color: var(--neon-green);
}
.pipeline-nav-btn:hover { background: rgba(255,255,255,0.04); }

.pipeline-stage {
  display: none;
  animation: stage-in 0.5s ease;
}
.pipeline-stage.active { display: block; }

@keyframes stage-in {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Stage Card Wrapper ---------- */
.stage-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  overflow: hidden;
}
.stage-header {
  padding: 20px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.stage-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stage-header-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.stage-header-title { font-weight: 700; font-size: 1.05rem; color: var(--text-bright); }
.stage-header-sub { font-size: 0.8rem; color: var(--text-dim); }
.stage-body { padding: 28px; }
.stage-desc {
  font-size: 0.92rem;
  color: var(--text-dim);
  line-height: 1.8;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  border-left: 3px solid var(--neon-blue);
}
.stage-desc strong { color: var(--text-bright); }
.stage-desc .hl { color: var(--neon-blue); font-weight: 600; }

.stage-action-btn {
  padding: 12px 28px;
  border: 1px solid rgba(0,212,255,0.3);
  border-radius: 10px;
  background: rgba(0,212,255,0.1);
  color: var(--neon-blue);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.stage-action-btn:hover { background: rgba(0,212,255,0.18); box-shadow: var(--glow-blue); }
.stage-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.stage-action-btn.purple { border-color: rgba(168,85,247,0.3); background: rgba(168,85,247,0.1); color: var(--neon-purple); }
.stage-action-btn.purple:hover { background: rgba(168,85,247,0.18); box-shadow: var(--glow-purple); }
.stage-action-btn.pink { border-color: rgba(244,114,182,0.3); background: rgba(244,114,182,0.1); color: var(--neon-pink); }
.stage-action-btn.pink:hover { background: rgba(244,114,182,0.18); box-shadow: var(--glow-pink); }
.stage-action-btn.green { border-color: rgba(34,211,238,0.3); background: rgba(34,211,238,0.1); color: var(--neon-green); }
.stage-action-btn.green:hover { background: rgba(34,211,238,0.18); }

/* ---------- 1. Tokenization ---------- */
.token-input-area {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
}
.token-text-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.token-text-input:focus { border-color: var(--neon-blue); }

.token-display {
  min-height: 100px;
  padding: 20px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  position: relative;
}
.token-original {
  font-size: 1.4rem;
  color: var(--text-bright);
  margin-bottom: 16px;
  letter-spacing: 2px;
  min-height: 40px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.token-original .char-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  transition: all 0.4s;
  position: relative;
}
.token-arrow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  color: var(--neon-blue);
  font-size: 1.2rem;
  opacity: 0;
  transition: opacity 0.5s;
}
.token-arrow-row.visible { opacity: 1; }

.token-result {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 50px;
  align-items: flex-start;
}
.token-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  opacity: 0;
  transform: translateY(15px) scale(0.8);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.token-chip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.token-chip .tok-id {
  font-size: 0.6rem;
  font-weight: 600;
  opacity: 0.6;
  letter-spacing: 0.5px;
}
.tok-color-0 { background: rgba(0,212,255,0.15); color: var(--neon-blue); border: 1px solid rgba(0,212,255,0.25); }
.tok-color-1 { background: rgba(168,85,247,0.15); color: var(--neon-purple); border: 1px solid rgba(168,85,247,0.25); }
.tok-color-2 { background: rgba(244,114,182,0.15); color: var(--neon-pink); border: 1px solid rgba(244,114,182,0.25); }
.tok-color-3 { background: rgba(34,211,238,0.15); color: var(--neon-green); border: 1px solid rgba(34,211,238,0.25); }
.tok-color-4 { background: rgba(251,146,60,0.15); color: var(--neon-orange); border: 1px solid rgba(251,146,60,0.25); }
.tok-color-5 { background: rgba(250,204,21,0.15); color: #facc15; border: 1px solid rgba(250,204,21,0.25); }

/* ---------- 2. Embedding / Vector Space ---------- */
.vector-canvas-wrap {
  position: relative;
  width: 100%;
  height: 420px;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
  margin-bottom: 16px;
}
#vectorCanvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.vector-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.6);
  border-radius: 8px;
  font-size: 0.72rem;
  backdrop-filter: blur(10px);
}
.vector-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.vector-info-panel {
  padding: 14px 18px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05);
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.8;
  min-height: 60px;
}
.vector-info-panel .vec-word { color: var(--neon-blue); font-weight: 700; }
.vector-info-panel .vec-nums { color: var(--neon-purple); font-family: 'Courier New', monospace; font-size: 0.78rem; }

/* ---------- 3. Attention Mechanism ---------- */
.attention-demo-area {
  margin-bottom: 20px;
}
.attention-sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 16px;
}
.attn-word {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--text-main);
  position: relative;
}
.attn-word:hover { border-color: rgba(168,85,247,0.4); }
.attn-word.selected {
  border-color: var(--neon-purple);
  background: rgba(168,85,247,0.12);
  color: var(--neon-purple);
  box-shadow: 0 0 16px rgba(168,85,247,0.25);
}
.attn-word .attn-weight {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--neon-purple);
  color: white;
  font-size: 0.55rem;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
}
.attn-word.has-weight .attn-weight { display: flex; }

.attention-canvas-wrap {
  width: 100%;
  height: 180px;
  position: relative;
  margin-bottom: 16px;
}
#attentionCanvas {
  width: 100%;
  height: 100%;
}
.attention-explanation {
  padding: 14px 18px;
  background: rgba(168,85,247,0.06);
  border-radius: 10px;
  border: 1px solid rgba(168,85,247,0.1);
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.8;
  min-height: 50px;
}
.attention-explanation .hl-purple { color: var(--neon-purple); font-weight: 700; }

/* ---------- 4. Probability ---------- */
.prob-sentence-display {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 20px;
  margin-bottom: 20px;
  color: var(--text-bright);
  line-height: 1.6;
}
.prob-sentence-display .filled { color: var(--text-main); }
.prob-blank {
  display: inline-block;
  min-width: 60px;
  padding: 4px 12px;
  border-bottom: 3px solid var(--neon-pink);
  color: var(--neon-pink);
  margin: 0 4px;
  animation: blink-border 1.2s ease-in-out infinite;
}
@keyframes blink-border { 0%,100% { border-color: var(--neon-pink); } 50% { border-color: transparent; } }
.prob-chosen .prob-blank {
  animation: none;
  border-color: var(--neon-green);
  color: var(--neon-green);
}

.prob-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.prob-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.5s;
}
.prob-bar-row.visible {
  opacity: 1;
  transform: translateX(0);
}
.prob-word {
  min-width: 70px;
  text-align: right;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-bright);
}
.prob-bar-track {
  flex: 1;
  height: 32px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.prob-bar-fill {
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  width: 0%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.prob-bar-fill.bar-1 { background: linear-gradient(90deg, rgba(244,114,182,0.6), var(--neon-pink)); }
.prob-bar-fill.bar-2 { background: linear-gradient(90deg, rgba(168,85,247,0.5), var(--neon-purple)); }
.prob-bar-fill.bar-3 { background: linear-gradient(90deg, rgba(0,212,255,0.4), var(--neon-blue)); }
.prob-bar-fill.bar-4 { background: linear-gradient(90deg, rgba(34,211,238,0.3), var(--neon-green)); }
.prob-bar-fill.bar-5 { background: linear-gradient(90deg, rgba(251,146,60,0.3), var(--neon-orange)); }

.prob-bar-row.winner { transform: scale(1.02); }
.prob-bar-row.winner .prob-word { color: var(--neon-pink); }
.prob-bar-row.winner .prob-bar-fill { box-shadow: 0 0 20px rgba(244,114,182,0.3); }

.prob-explanation {
  padding: 16px 20px;
  background: rgba(244,114,182,0.05);
  border-radius: 10px;
  border: 1px solid rgba(244,114,182,0.1);
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.8;
}

/* ---------- 5. Full Pipeline ---------- */
.pipeline-full-demo {
  position: relative;
}
.full-pipeline-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.fp-step {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  opacity: 0.2;
  transition: all 0.6s;
}
.fp-step.active { opacity: 1; }
.fp-step.done { opacity: 0.85; }
.fp-step-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  flex-shrink: 0;
}
.fp-step-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  transition: all 0.5s;
}
.fp-step.active .fp-step-icon {
  border-color: var(--neon-blue);
  box-shadow: var(--glow-blue);
  background: rgba(0,212,255,0.08);
}
.fp-step.done .fp-step-icon {
  background: rgba(34,211,238,0.08);
  border-color: rgba(34,211,238,0.3);
}
.fp-step-connector {
  width: 2px;
  flex: 1;
  min-height: 10px;
  background: rgba(255,255,255,0.04);
  transition: background 0.5s;
}
.fp-step.done .fp-step-connector { background: rgba(34,211,238,0.2); }
.fp-step-content { flex: 1; }
.fp-step-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; color: var(--text-bright); }
.fp-step-desc { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 8px; }
.fp-step-visual {
  padding: 12px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.04);
  font-size: 0.82rem;
  line-height: 1.7;
  display: none;
  overflow-x: auto;
}
.fp-step.active .fp-step-visual,
.fp-step.done .fp-step-visual { display: block; animation: msg-in 0.5s ease; }
.fp-mini-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}
.fp-mini-tok {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}
.fp-mini-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}
.fp-mini-bar-label { min-width: 50px; font-size: 0.78rem; font-weight: 600; }
.fp-mini-bar-track {
  flex: 1;
  height: 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  overflow: hidden;
}
.fp-mini-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .pipeline-nav-btn { min-width: 80px; padding: 10px 6px; font-size: 0.68rem; }
  .pipeline-nav-btn .step-num { width: 18px; height: 18px; font-size: 0.6rem; }
  .vector-canvas-wrap { height: 300px; }
  .prob-sentence-display { font-size: 1rem; }
  .token-text-input { font-size: 0.9rem; }
  .attn-word { padding: 8px 12px; font-size: 0.9rem; }
  .token-input-area { flex-direction: column; }
}
