/* ============================================================================
 * rb-effects.css —— react-bits 组件移植（vanilla，无 React）
 * ----------------------------------------------------------------------------
 * ## 来源与授权
 * ```
 * https://reactbits.dev   开源组件库（JS-CSS 变体，deps 为空）
 * 本项目前端是 **Vue 3 编译产物**，没有 React 运行时
 * ⇒ ⛔ 不能直接 import 它们的 .jsx
 * ⇒ ★ 只搬 **CSS**（可直接用）+ **把 canvas/DOM 逻辑重写成 vanilla**
 * ```
 *
 * ## 移植清单（4 个）
 * ```
 * ① SpotlightCard  → .rb-spotlight       卡片聚光灯跟随指针
 * ② StarBorder     → .rb-starborder      星轨沿卡片描边（canvas）
 * ③ GradientText   → .rb-gradient-text   渐变文字 + 外发光
 * ④ GlareHover     → .rb-glare           悬停光泽扫过
 * ```
 *
 * ## 三条纪律
 * ```
 * ① ⛔ 不写死颜色 —— 全部用本站 CSS 变量（--brand-* / --rk-* / --mv-*）
 *    ⇒ 深浅色主题自动跟随
 * ② ⛔ 不改动被装饰元素的布局（只用 position:absolute 的覆盖层 + isolation）
 * ③ ⛔ 找不到目标元素 ⇒ JS 静默跳过，CSS 类不生效 ⇒ 零副作用
 * ```
 * ========================================================================== */

/* ─────────────────────────── ① SpotlightCard ─────────────────────────── */
/* 移植自 reactbits SpotlightCard.css（980 B），改了 3 处：
 *   · --spotlight-card-surface / -shadow / -border 由本站变量提供
 *   · 去掉固定 padding / border-radius（让被装饰元素自己决定）
 *   · 加 isolation 保证伪层不溢出到别处
 */
.rb-spotlight {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.rb-spotlight > .rb-spotlight__light,
.rb-spotlight > .rb-spotlight__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
}

.rb-spotlight > .rb-spotlight__light {
  z-index: 0;
}

.rb-spotlight > .rb-spotlight__edge {
  z-index: 2;
  padding: 1px;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
}

/* 内容必须浮在光层之上 */
.rb-spotlight > *:not(.rb-spotlight__light):not(.rb-spotlight__edge) {
  position: relative;
  z-index: 1;
}

/* ─────────────────────────── ② StarBorder ─────────────────────────── */
/* 移植自 reactbits StarBorder.css（1070 B）
 * ★ 只搬外壳，画光的部分在 JS 里用 canvas 重写（原版是 React + canvas）
 */
.rb-starborder {
  position: relative;
  isolation: isolate;
}

.rb-starborder > .rb-starborder__canvas {
  position: absolute;
  top: -48px;
  left: -48px;
  z-index: 3;
  width: calc(100% + 96px);
  height: calc(100% + 96px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}

.rb-starborder.rb-on > .rb-starborder__canvas {
  opacity: 1;
}

/* ─────────────────────────── ③ GradientText ─────────────────────────── */
/* 移植自 reactbits GradientText.css（1237 B）
 * ★ 原版靠 JS 每帧重写 background-image 来做流动
 * ★ 这里改成 CSS @keyframes 移动 background-position
 *   ⇒ 零 JS、零 rAF、零功耗（站长说过功耗不是优先级，但能省就省）
 */
.rb-gradient-text {
  position: relative;
  display: inline-block;
  isolation: isolate;
  background-image: var(--rb-gt);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: rb-gt-flow var(--rb-gt-speed, 8s) linear infinite;
}

.rb-gradient-text::after {
  content: attr(data-rb-text);
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--rb-gt);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: blur(.28em) saturate(1.35);
  opacity: var(--rb-gt-glow, 0);
  pointer-events: none;
  user-select: none;
  animation: inherit;
}

@keyframes rb-gt-flow {
  0%   { background-position:   0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ─────────────────────────── ④ GlareHover ─────────────────────────── */
/* 移植自 reactbits GlareHover.css（1045 B）
 * ★ 原版用 JS 每帧算 33 个 color-mix 停靠点
 * ★ 这里用一个倾斜的线性渐变 + transform 位移，视觉等价、成本低一个数量级
 */
.rb-glare {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.rb-glare > .rb-glare__band {
  position: absolute;
  top: -60%;
  left: -60%;
  z-index: 4;
  width: 60%;
  height: 220%;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-140%) rotate(18deg);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, .06) 28%,
    rgba(255, 255, 255, .42) 50%,
    rgba(255, 255, 255, .06) 72%,
    transparent 100%
  );
  mix-blend-mode: screen;
  transition: opacity .2s ease;
}

.rb-glare.rb-on > .rb-glare__band {
  opacity: 1;
  animation: rb-glare-sweep .78s cubic-bezier(.32, .06, .24, 1) 1 forwards;
}

@keyframes rb-glare-sweep {
  0%   { transform: translateX(-140%) rotate(18deg); }
  100% { transform: translateX(340%)  rotate(18deg); }
}

/* ─────────────────────────── 无障碍 / 省电 ─────────────────────────── */
/* ★ prefers-reduced-motion 时全部退化到静态：
 *   渐变文字停在第一帧、光泽不扫、星轨不画（JS 也会跳过）
 */
@media (prefers-reduced-motion: reduce) {
  .rb-gradient-text,
  .rb-gradient-text::after {
    animation: none;
    background-position: 0% 50%;
  }
  .rb-glare > .rb-glare__band {
    animation: none;
    opacity: 0;
  }
  .rb-starborder > .rb-starborder__canvas {
    display: none;
  }
  .rb-spotlight > .rb-spotlight__light,
  .rb-spotlight > .rb-spotlight__edge {
    transition: none;
  }
}
