/* ========== 大厂动效：极光边界 + CTA ========== */

/* ---------- 通用弹簧曲线（Linear / Apple） ---------- */
:root {
  --sx-exp: cubic-bezier(0.22, 1, 0.36, 1);
  --sx-spring: cubic-bezier(0.34, 1.28, 0.44, 1);
  --sx-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

/* CTA 三按钮：进入学习居中强调 */
.cta-actions {
  gap: 14px;
}

.cta-actions .cta-start {
  min-width: 168px;
  box-shadow: 0 16px 40px rgba(154, 68, 35, 0.32);
  transform: scale(1.04);
}

.cta-actions .cta-start:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 22px 50px rgba(154, 68, 35, 0.4);
}

/* ═══ CTA「学完本章 / 进行下一章学习」→ 悬停散开 / 浮现下一章 ═══ */
.cta-title .cta-go {
  position: relative;
  display: block;
  cursor: pointer;
  outline: none;
  min-height: 1.15em;
  /* 渐变字重绘 + 展开动画并存 */
  transition: filter 0.45s ease;
}

.cta-title .cta-go .word {
  display: inline-block;
  position: relative;
  transition:
    letter-spacing 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.55s ease 0.05s,
    filter 0.55s ease,
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: letter-spacing, opacity, filter, transform;
}

/* 入场裁切完成后再放开 overflow，避免散开被剪掉 */
.cta-title.is-in .cta-go .word {
  overflow: visible;
}

/* ---------- 故障抖动诱饵：空闲态轻微「漏电」 ---------- */
.cta-title .cta-go .word::before,
.cta-title .cta-go .word::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  font: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
}

.cta-title .cta-go .word::before {
  color: rgba(200, 96, 53, 0.85);
  text-shadow: 1.5px 0 rgba(200, 96, 53, 0.7);
  animation: cta-glitch-a 1.8s linear infinite;
}

.cta-title .cta-go .word::after {
  color: rgba(31, 111, 92, 0.75);
  text-shadow: -1.5px 0 rgba(80, 180, 160, 0.55);
  animation: cta-glitch-b 1.8s linear infinite;
  animation-delay: -0.6s;
}

.cta-title .cta-go .word {
  animation: cta-jitter 1.8s linear infinite;
}

/* 悬停 / 聚焦：故障停止，进入散开态 */
.cta-title .cta-go:hover .word,
.cta-title .cta-go:focus-visible .word {
  animation: none;
}

.cta-title .cta-go:hover .word::before,
.cta-title .cta-go:hover .word::after,
.cta-title .cta-go:focus-visible .word::before,
.cta-title .cta-go:focus-visible .word::after {
  animation: none;
  opacity: 0 !important;
}

@keyframes cta-jitter {
  0% {
    transform: translate3d(-1px, 0, 0) skewX(-0.6deg);
  }
  20% {
    transform: translate3d(1.5px, -1px, 0) skewX(0.8deg);
    filter: hue-rotate(-6deg);
  }
  40% {
    transform: translate3d(-1.5px, 1px, 0) skewX(-1deg);
  }
  60% {
    transform: translate3d(1px, 0, 0) skewX(0.5deg);
    filter: hue-rotate(5deg) contrast(1.08);
  }
  80% {
    transform: translate3d(-0.5px, -1px, 0) skewX(-0.4deg);
  }
  100% {
    transform: translate3d(-1px, 0, 0) skewX(-0.6deg);
  }
}

@keyframes cta-glitch-a {
  0% {
    opacity: 0.55;
    transform: translate(-2px, 0);
    clip-path: inset(0 0 62% 0);
  }
  15% {
    opacity: 0.75;
    transform: translate(2px, -1px);
    clip-path: inset(30% 0 25% 0);
  }
  30% {
    opacity: 0.45;
    transform: translate(-3px, 1px);
    clip-path: inset(8% 0 55% 0);
  }
  45% {
    opacity: 0.8;
    transform: translate(2px, 0);
    clip-path: inset(45% 0 15% 0);
  }
  60% {
    opacity: 0.5;
    transform: translate(-1px, -1px);
    clip-path: inset(15% 0 48% 0);
  }
  75% {
    opacity: 0.7;
    transform: translate(3px, 1px);
    clip-path: inset(35% 0 30% 0);
  }
  90% {
    opacity: 0.4;
    transform: translate(-2px, 0);
    clip-path: inset(5% 0 58% 0);
  }
  100% {
    opacity: 0.55;
    transform: translate(-2px, 0);
    clip-path: inset(0 0 62% 0);
  }
}

@keyframes cta-glitch-b {
  0% {
    opacity: 0.5;
    transform: translate(2px, 0);
    clip-path: inset(28% 0 38% 0);
  }
  15% {
    opacity: 0.7;
    transform: translate(-2px, 1px);
    clip-path: inset(0 0 50% 0);
  }
  30% {
    opacity: 0.45;
    transform: translate(3px, -1px);
    clip-path: inset(42% 0 18% 0);
  }
  45% {
    opacity: 0.75;
    transform: translate(-1px, 0);
    clip-path: inset(12% 0 52% 0);
  }
  60% {
    opacity: 0.5;
    transform: translate(2px, 1px);
    clip-path: inset(50% 0 12% 0);
  }
  75% {
    opacity: 0.65;
    transform: translate(-3px, -1px);
    clip-path: inset(22% 0 40% 0);
  }
  90% {
    opacity: 0.4;
    transform: translate(1px, 0);
    clip-path: inset(8% 0 55% 0);
  }
  100% {
    opacity: 0.5;
    transform: translate(2px, 0);
    clip-path: inset(28% 0 38% 0);
  }
}

/* 轻微呼吸 + 下划光，进一步「招手」 */
.cta-title .cta-go .word {
  text-underline-offset: 0.18em;
}

.cta-title.is-in .cta-go .word {
  text-decoration: underline;
  text-decoration-color: rgba(184, 85, 47, 0.22);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.22em;
}

.cta-title .cta-go:hover .word {
  text-decoration-color: transparent;
}

/* 悬停热区光晕 */
.cta-title .cta-go::before {
  content: "";
  position: absolute;
  inset: -8% -6%;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center,
    rgba(184, 85, 47, 0.12),
    transparent 70%
  );
  opacity: 0;
  transform: scale(0.85);
  transition:
    opacity 0.4s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: -1;
}

.cta-title .cta-go:hover::before,
.cta-title .cta-go:focus-visible::before {
  opacity: 1;
  transform: scale(1);
}

.cta-title .cta-go:hover .word,
.cta-title .cta-go:focus-visible .word {
  letter-spacing: 0.55em;
  opacity: 0;
  filter: blur(3px);
  transform: scaleX(1.08);
}

/* 悬停第二行时，第一行「学完本章」轻轻退后 */
.cta-title:has(.cta-go:hover) .line:not(.cta-go),
.cta-title:has(.cta-go:focus-visible) .line:not(.cta-go) {
  opacity: 0.28;
  transform: translateY(-4px) scale(0.97);
  transition:
    opacity 0.5s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.cta-title .line:not(.cta-go) {
  transition:
    opacity 0.5s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.cta-next-name {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 92vw;
  opacity: 0;
  transform: translate(-50%, calc(-50% + 18px)) scale(0.94);
  pointer-events: none;
  transition:
    opacity 0.5s ease 0.12s,
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.12s;
}

.cta-title .cta-go:hover .cta-next-name,
.cta-title .cta-go:focus-visible .cta-next-name {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.cta-next-kicker {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.36em;
  color: var(--accent, #b8552f);
  text-transform: uppercase;
  opacity: 0.9;
}

.cta-next-title {
  font-size: clamp(24px, 3.8vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent, #b8552f), var(--accent-deep, #8f3a26) 55%, var(--accent, #c86035));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.cta-next-cta {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-3, #8b7e6c);
  opacity: 0.85;
}

.cta-title .cta-go:hover .cta-next-cta,
.cta-title .cta-go:focus-visible .cta-next-cta {
  animation: cta-nudge 1.6s ease-in-out infinite;
}

@keyframes cta-nudge {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cta-title .cta-go .word,
  .cta-title .cta-go .word::before,
  .cta-title .cta-go .word::after,
  .cta-next-name,
  .cta-title .line:not(.cta-go),
  .cta-next-cta {
    transition: none !important;
    animation: none !important;
  }

  .cta-title .cta-go:hover .word,
  .cta-title .cta-go:focus-visible .word {
    letter-spacing: inherit;
    opacity: 0.22;
    filter: none;
    transform: none;
    text-decoration-color: rgba(184, 85, 47, 0.35);
  }

  .cta-title .cta-go .word::before,
  .cta-title .cta-go .word::after {
    opacity: 0 !important;
    display: none;
  }

  .cta-title .cta-go:hover .cta-next-name,
  .cta-title .cta-go:focus-visible .cta-next-name {
    transform: translate(-50%, -50%);
  }

  .cta-title:has(.cta-go:hover) .line:not(.cta-go) {
    opacity: 0.35;
    transform: none;
  }
}

/* ═══════════════════════════════════════════════
   极光边界 Aurora Rail
   大厂风格：近隐形 → 磁吸展开 → 弹簧面板
   ═══════════════════════════════════════════════ */
.sx-edge {
  --e: 0;
  --my: 0.5;
  position: fixed;
  top: 0;
  bottom: 0;
  width: 96px;
  z-index: 210;
  pointer-events: none;
  overflow: hidden;
  opacity: calc(0.22 + var(--e) * 0.78);
  transition: opacity 0.45s var(--sx-soft);
}

.sx-edge.armed {
  pointer-events: auto;
  cursor: pointer;
}

/* 外缘光洗：保留渐变深浅临界点 */
.sx-edge.left {
  left: 0;
  background: linear-gradient(
    90deg,
    rgba(184, 85, 47, calc(var(--e) * 0.2)),
    rgba(184, 85, 47, calc(var(--e) * 0.05)) 42%,
    rgba(184, 85, 47, 0) 78%
  );
}

.sx-edge.right {
  right: 0;
  background: linear-gradient(
    270deg,
    rgba(31, 111, 92, calc(var(--e) * 0.18)),
    rgba(31, 111, 92, calc(var(--e) * 0.04)) 42%,
    rgba(31, 111, 92, 0) 78%
  );
}

/* 极光层：三条柔光长条，极慢呼吸 */
.sx-edge-aurora {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sx-edge-aurora i {
  position: absolute;
  top: -10%;
  height: 120%;
  border-radius: 999px;
  filter: blur(18px);
  opacity: calc(0.1 + var(--e) * 0.55);
  transition: opacity 0.5s var(--sx-soft);
  animation: sx-breathe 9s ease-in-out infinite;
}

.sx-edge-aurora i:nth-child(1) {
  width: 28px;
  animation-delay: 0s;
}

.sx-edge-aurora i:nth-child(2) {
  width: 48px;
  opacity: calc(0.06 + var(--e) * 0.32);
  animation-delay: -3s;
  animation-duration: 12s;
}

.sx-edge-aurora i:nth-child(3) {
  width: 18px;
  opacity: calc(0.08 + var(--e) * 0.4);
  animation-delay: -6s;
  animation-duration: 7.5s;
}

.sx-edge.left .sx-edge-aurora i {
  left: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(200, 96, 53, 0.85) 22%,
    rgba(232, 168, 124, 0.95) 50%,
    rgba(200, 96, 53, 0.85) 78%,
    transparent 100%
  );
}

.sx-edge.left .sx-edge-aurora i:nth-child(2) {
  left: 14px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(184, 85, 47, 0.45) 35%,
    rgba(184, 85, 47, 0.2) 65%,
    transparent
  );
}

.sx-edge.left .sx-edge-aurora i:nth-child(3) {
  left: 0;
  background: linear-gradient(
    180deg,
    transparent 15%,
    rgba(255, 220, 180, 0.7) 50%,
    transparent 85%
  );
}

.sx-edge.right .sx-edge-aurora i {
  right: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(31, 111, 92, 0.85) 22%,
    rgba(153, 246, 228, 0.95) 50%,
    rgba(31, 111, 92, 0.85) 78%,
    transparent 100%
  );
}

.sx-edge.right .sx-edge-aurora i:nth-child(2) {
  right: 14px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(31, 111, 92, 0.4) 35%,
    rgba(31, 111, 92, 0.18) 65%,
    transparent
  );
}

.sx-edge.right .sx-edge-aurora i:nth-child(3) {
  right: 0;
  background: linear-gradient(
    180deg,
    transparent 15%,
    rgba(180, 255, 240, 0.65) 50%,
    transparent 85%
  );
}

@keyframes sx-breathe {
  0%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  50% {
    transform: translateY(-2.5%) scaleY(1.04);
  }
}

/* 发光芯线：大厂标志性 1–2px 光带 */
.sx-edge-core {
  position: absolute;
  top: 8%;
  bottom: 8%;
  width: 2px;
  border-radius: 2px;
  pointer-events: none;
  opacity: calc(0.2 + var(--e) * 0.8);
  box-shadow:
    0 0 calc(6px + var(--e) * 18px) calc(1px + var(--e) * 2px),
    0 0 calc(16px + var(--e) * 40px) calc(2px + var(--e) * 4px);
  transition: opacity 0.35s var(--sx-soft);
}

.sx-edge.left .sx-edge-core {
  left: 10px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(232, 168, 124, 0.95) 30%,
    #fff1e4 50%,
    rgba(232, 168, 124, 0.95) 70%,
    transparent
  );
  box-shadow:
    0 0 calc(8px + var(--e) * 22px) rgba(232, 168, 124, calc(0.25 + var(--e) * 0.55)),
    0 0 calc(24px + var(--e) * 48px) rgba(200, 96, 53, calc(0.12 + var(--e) * 0.28));
}

.sx-edge.right .sx-edge-core {
  right: 10px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(153, 246, 228, 0.9) 30%,
    #ecfeff 50%,
    rgba(153, 246, 228, 0.9) 70%,
    transparent
  );
  box-shadow:
    0 0 calc(8px + var(--e) * 22px) rgba(153, 246, 228, calc(0.22 + var(--e) * 0.5)),
    0 0 calc(24px + var(--e) * 48px) rgba(31, 111, 92, calc(0.1 + var(--e) * 0.26));
}

/* 磁吸光斑：跟随鼠标 Y（弹簧 --my） */
.sx-edge-spot {
  position: absolute;
  left: 50%;
  width: 120px;
  height: 180px;
  transform: translate(-50%, -50%);
  top: calc(var(--my) * 100%);
  border-radius: 50%;
  pointer-events: none;
  opacity: calc(var(--e) * 0.85);
  filter: blur(22px);
  transition: opacity 0.35s var(--sx-soft);
}

.sx-edge.left .sx-edge-spot {
  background: radial-gradient(
    circle,
    rgba(255, 200, 150, 0.55),
    rgba(200, 96, 53, 0.15) 55%,
    transparent 70%
  );
  left: 16px;
}

.sx-edge.right .sx-edge-spot {
  background: radial-gradient(
    circle,
    rgba(153, 246, 228, 0.5),
    rgba(31, 111, 92, 0.12) 55%,
    transparent 70%
  );
  right: 16px;
  left: auto;
  transform: translate(50%, -50%);
}

/* 竖排标签 */
.sx-edge .label {
  position: absolute;
  top: 50%;
  left: 22px;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.32em;
  font-weight: 800;
  color: rgba(184, 85, 47, calc(0.1 + var(--e) * 0.75));
  opacity: calc(0.35 + var(--e) * 0.65);
  transition: color 0.3s, opacity 0.3s;
  pointer-events: none;
}

.sx-edge.right .label {
  left: auto;
  right: 22px;
  transform: translateY(-50%) rotate(180deg);
  color: rgba(31, 111, 92, calc(0.1 + var(--e) * 0.7));
}

/* 隐藏旧实现残留 */
.sx-edge .glow,
.sx-edge .rail,
.sx-edge .arrows,
.sx-edge-canvas {
  display: none;
}

@media (max-width: 720px) {
  .sx-edge {
    display: none;
  }
}

/* ═══════════════════════════════════════════════
   遮罩式页面转场（最稳定）
   全屏元素遮挡，无花哨文案
   ═══════════════════════════════════════════════ */
.sx-mask {
  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    165deg,
    #1a1510 0%,
    #2a221a 45%,
    #1a1510 100%
  );
  transform: scaleY(0.08);
  transform-origin: bottom;
  transition:
    transform 0.55s var(--sx-exp),
    opacity 0.4s var(--sx-soft);
}

.sx-mask.in {
  opacity: 1;
  transform: scaleY(1);
  pointer-events: auto;
}

.sx-mask.out {
  opacity: 0;
  transform: scaleY(0.06);
  transform-origin: top;
  transition:
    transform 0.55s var(--sx-exp),
    opacity 0.45s var(--sx-soft);
}

/* 进度芯线：极简，不写大字 */
.sx-mask-bar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(180px, 40vw);
  height: 2px;
  transform: translate(-50%, -50%);
  background: rgba(247, 241, 232, 0.12);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s;
}

.sx-mask.in .sx-mask-bar {
  opacity: 1;
}

.sx-mask-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #c86035, #e8a87c);
  border-radius: 2px;
  animation: sx-mask-load 0.7s var(--sx-exp) forwards;
}

@keyframes sx-mask-load {
  to {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════
   丝滑滚动（Lenis-like）
   ═══════════════════════════════════════════════ */
html.sx-smooth {
  scroll-behavior: auto;
}

html.sx-smooth body {
  /* 由 JS 驱动 window.scrollTo，原生滚动条保留 */
}

/* 侧栏面板：弹簧入场（大厂 glass sheet） */
.sx-side {
  transition:
    transform 0.62s var(--sx-spring),
    opacity 0.38s var(--sx-soft),
    visibility 0.38s;
}

.sx-side.open {
  transform: none;
}

/* 主题扩展提示 */
.sx-ext-hint {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--sx-ink-3, rgba(247, 241, 232, 0.4));
  text-transform: none;
}
