/* AI controls/state layer: progress, interactions, and motion effects. */
/* ========== 新增 AI 风格特效 ========== */
/* 复古块状光标（正文末尾） */
.ai-block-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  background: rgba(150, 226, 255, 0.94);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: ai-block-cursor-blink 1s step-end infinite;
}
@keyframes ai-block-cursor-blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}
/* 阅读进度条（紫色，更醒目） */
.ai-read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: calc(var(--read-progress, 0) * 100%);
  background: linear-gradient(90deg, rgba(132, 214, 255, 0.92), rgba(94, 196, 255, 0.94));
  box-shadow: 0 0 14px rgba(104, 204, 255, 0.45);
  z-index: 100;
  transition: width 0.08s ease-out;
}
/* 鼠标跟随光斑 */
.ai-mouse-glow {
  position: fixed;
  width: 300px;
  height: 300px;
  left: calc(var(--mouse-x, -9999px) - 150px);
  top: calc(var(--mouse-y, -9999px) - 150px);
  background: radial-gradient(circle, rgba(124, 210, 248, 0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.3s;
}
body.ai-page:not(:hover) .ai-mouse-glow {
  opacity: 0.5;
}
/* 深度模糊：上下边缘虚化 */
.ai-depth-blur {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black 15%,
    black 85%,
    transparent 100%
  );
  backdrop-filter: blur(0);
  transition: backdrop-filter 0.3s;
}
.ai-depth-blur::before {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  mask-image: linear-gradient(to bottom, black 0%, transparent 12%, transparent 88%, black 100%);
  -webkit-mask-image: linear-gradient(
    to bottom,
    black 0%,
    transparent 12%,
    transparent 88%,
    black 100%
  );
}
/* 思考中三连点 */
.ai-thinking-dots {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  gap: 6px;
  z-index: 50;
  opacity: 1;
  animation: ai-thinking-fade 0.8s ease-out 1.2s forwards;
}
.ai-thinking-dots span {
  width: 6px;
  height: 6px;
  background: rgba(150, 226, 255, 0.82);
  border-radius: 50%;
  animation: ai-dot-pulse 0.8s ease-in-out infinite;
}
.ai-thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.ai-thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes ai-thinking-fade {
  to {
    opacity: 0;
    visibility: hidden;
  }
}
@keyframes ai-dot-pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}
/* 故障效果：链接/代码块 hover 极轻微 RGB 分离 */
body.ai-page .ai-content .prose a:hover {
  animation: ai-glitch-link 0.4s ease-out;
}
body.ai-page .ai-content .prose pre:hover {
  animation: ai-glitch-pre 0.35s ease-out;
}
@keyframes ai-glitch-link {
  0%,
  100% {
    text-shadow:
      0 0 10px rgba(100, 255, 220, 0.6),
      0 0 20px rgba(120, 180, 255, 0.3);
  }
  20% {
    text-shadow:
      -0.5px 0 rgba(88, 176, 236, 0.4),
      0.5px 0 rgba(100, 255, 220, 0.4);
  }
  40% {
    text-shadow:
      0.5px 0 rgba(88, 176, 236, 0.3),
      -0.5px 0 rgba(100, 255, 220, 0.3);
  }
  60% {
    text-shadow:
      0 0 10px rgba(100, 255, 220, 0.6),
      0 0 20px rgba(120, 180, 255, 0.3);
  }
}
@keyframes ai-glitch-pre {
  0%,
  100% {
    box-shadow:
      inset 0 0 30px rgba(0, 40, 80, 0.3),
      0 0 20px rgba(100, 220, 255, 0.06);
  }
  30% {
    box-shadow:
      inset 0 0 30px rgba(0, 40, 80, 0.3),
      -1px 0 rgba(84, 170, 230, 0.15),
      1px 0 rgba(80, 255, 200, 0.15);
  }
}
/* 悬浮预览卡 */
body.ai-page .ai-content .prose a.ai-link-preview {
  position: relative;
}
body.ai-page .ai-content .prose a.ai-link-preview::after {
  display: none;
  content: attr(data-preview);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 12px;
  background: rgba(6, 14, 24, 0.95);
  border: 1px solid rgba(100, 255, 180, 0.3);
  border-radius: 6px;
  font-size: 0.75em;
  color: rgba(180, 255, 220, 0.9);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
body.ai-page .ai-content .prose a.ai-link-preview:hover::after {
  display: block;
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-12px);
}
/* 时间戳日志风格 */
.ai-log-date {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
}
.ai-log-label {
  color: rgba(100, 255, 180, 0.7);
  margin-right: 0.25em;
}

/* ========== AI 时代氛围增强 ========== */
/* 元信息终端化 */
.ai-meta-terminal {
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  color: rgba(180, 224, 246, 0.84);
  margin-bottom: 0.62em;
  letter-spacing: 0.04em;
}
.ai-article-author {
  overflow-wrap: anywhere;
}
body.ai-page .ai-content .prose .ai-article-author a,
body.ai-page .ai-content .prose .ai-article-author a:visited {
  display: inline-block;
  transform-origin: center;
  color: inherit;
  padding: 0;
  background: transparent;
  box-shadow: none;
  text-shadow: none;
  text-decoration: none;
  animation: none;
  transition:
    transform 150ms ease,
    color 150ms ease,
    text-shadow 150ms ease;
}
body.ai-page .ai-content .prose .ai-article-author a:hover {
  color: #d0f5ff;
  font-weight: 700;
  transform: scale(1.06);
  background: transparent;
  box-shadow: none;
  text-decoration: none;
  text-shadow: 0 0 6px rgba(142, 220, 248, 0.35);
  animation: none;
}
body.ai-page .ai-content .prose .ai-article-author a:focus-visible {
  outline: 1px solid #8edfff;
  outline-offset: 3px;
}
.ai-system-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}
.ai-system-chip {
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: rgba(186, 232, 252, 0.94);
  background: rgba(8, 18, 30, 0.82);
  border: 1px solid rgba(126, 192, 224, 0.34);
  border-radius: 5px;
  padding: 0.16rem 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* 提示词式标题 */
.ai-prompt-line {
  font-size: 0.86em;
  color: rgba(154, 218, 246, 0.8);
  margin-bottom: 0.4em;
}
.ai-prompt-topic {
  color: rgba(188, 232, 252, 0.88);
  font-style: normal;
}
/* 对话气泡 / Response 区域 */
.ai-response-wrap {
  position: relative;
  border: 1px solid rgba(152, 222, 255, 0.2);
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.54), rgba(16, 8, 16, 0.4));
  border-radius: 8px;
  padding: 0.75rem 0.9rem 0.45rem;
  box-shadow:
    inset 0 0 0 1px rgba(138, 206, 238, 0.12),
    0 8px 26px rgba(0, 0, 0, 0.32);
}
.ai-response-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6em;
  margin-bottom: 0.8em;
}
.ai-response-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(118, 204, 244, 0.62), rgba(132, 214, 255, 0.42));
  border: 1px solid rgba(136, 208, 242, 0.42);
  box-shadow:
    0 0 0 2px rgba(10, 18, 28, 0.64),
    0 0 14px rgba(124, 206, 246, 0.32);
}
.ai-response-label {
  font-size: 0.8em;
  color: rgba(170, 226, 250, 0.92);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ai-response-meta {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 24rem;
  min-width: 0;
  justify-content: flex-end;
  gap: 0.35rem 0.85rem;
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: rgba(188, 226, 248, 0.76);
}
.ai-response-meta strong {
  color: rgba(194, 236, 252, 0.96);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ai-response-meta > span {
  white-space: nowrap;
}
.ai-response-meta > .ai-model-id {
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Regenerate 按钮 */
.ai-regenerate {
  display: block;
  margin: 2em auto 0;
  padding: 0.5em 1.2em;
  font-size: 0.85em;
  font-family: ui-monospace, monospace;
  color: rgba(188, 234, 252, 0.94);
  background: rgba(10, 18, 28, 0.68);
  border: 1px solid rgba(126, 192, 224, 0.34);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ai-regenerate:hover:not(:disabled) {
  background: rgba(126, 192, 224, 0.12);
  box-shadow: 0 0 14px rgba(124, 206, 246, 0.24);
}
.ai-regenerate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.ai-regenerating {
  pointer-events: none;
}
.ai-regenerate-flash {
  animation: ai-flash 0.6s ease-out;
}
@keyframes ai-flash {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
  }
}
/* 首字放大 */
body.ai-page .ai-content .prose .ai-prose-body > p:first-of-type::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: 0.9;
  margin-right: 0.1em;
  color: rgba(160, 226, 252, 0.94);
  text-shadow: 0 0 22px rgba(124, 206, 246, 0.3);
}
