/* ==========================================================================
 * tcx-loader.css — 全站 TCX Pulse Orbit 加载动画体系
 *
 * 设计源：previews/tcx-loading-pulse-orbit-system-preview.html
 * 一份 CSS 通过 4 个变量驱动 5 个尺寸：
 *   --ring-size · --tcx-size · --dot-size · --arc-duration
 *
 * 5 个尺寸：
 *   .size-xl  (240px) 全屏遮罩中心
 *   .size-l   (140px) 块级加载（空状态、Tab 内容首次加载）
 *   .size-m   (88px)  区域加载（Modal、Tab 切换、表格上方）
 *   .size-s   (32px)  行内辅助（无 TCX 文字）
 *   .size-xs  (18px)  按钮内（最小 + .minimal + .solid）
 *
 * 修饰类：
 *   .no-text  · 隐藏中心 TCX 文字
 *   .minimal  · 去掉虚线背景环 + 头部光点（仅留扫掠弧）
 *   .solid    · 用 currentColor 渲染弧，关闭发光（按钮内自动跟随文字色）
 * ========================================================================== */

/* -------- 核心结构 -------- */
.tcx-loader {
  --ring-size: 88px;
  --tcx-size: 0.92rem;
  --dot-size: 7px;
  --arc-duration: 1.6s;
  position: relative;
  display: inline-block;
  width: var(--ring-size);
  height: var(--ring-size);
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 0;
}

.tcx-loader .ring-bg {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(34, 211, 238, 0.18);
}

.tcx-loader .ring-arc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    transparent 0deg,
    transparent 280deg,
    #22d3ee 320deg,
    #818cf8 350deg,
    transparent 360deg
  );
  -webkit-mask: radial-gradient(circle, transparent 0%, transparent 46%, #000 48%, #000 50%, transparent 52%);
          mask: radial-gradient(circle, transparent 0%, transparent 46%, #000 48%, #000 50%, transparent 52%);
  filter: drop-shadow(0 0 8px #22d3ee);
  animation: tcx-loader-spin var(--arc-duration) linear infinite;
}

.tcx-loader .head-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  animation: tcx-loader-spin var(--arc-duration) linear infinite;
}

.tcx-loader .head-dot::after {
  content: "";
  position: absolute;
  width: var(--dot-size);
  height: var(--dot-size);
  left: calc(var(--dot-size) * -0.5);
  top: calc(var(--ring-size) / 2 - var(--dot-size) * 0.5);
  border-radius: 50%;
  background: #22d3ee;
  box-shadow:
    0 0 6px #22d3ee,
    0 0 14px #22d3ee,
    0 0 24px rgba(34, 211, 238, 0.6);
}

@keyframes tcx-loader-spin {
  to { transform: rotate(360deg); }
}

.tcx-loader .tcx-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.14em;
  font-family: "Audiowide", "Orbitron", "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: var(--tcx-size);
  letter-spacing: 0.12em;
  line-height: 1;
  pointer-events: none;
}

.tcx-loader .tcx-text > span {
  display: inline-block;
  color: rgba(165, 243, 252, 0.4);
  animation: tcx-loader-strobe var(--arc-duration) linear infinite;
}

.tcx-loader .tcx-text > span:nth-child(1) { animation-delay: 0s; }
.tcx-loader .tcx-text > span:nth-child(2) { animation-delay: calc(var(--arc-duration) / 3); }
.tcx-loader .tcx-text > span:nth-child(3) { animation-delay: calc(var(--arc-duration) * 2 / 3); }

@keyframes tcx-loader-strobe {
  0% {
    color: rgba(165, 243, 252, 0.4);
    text-shadow: 0 0 4px rgba(165, 243, 252, 0.2);
  }
  15% {
    color: #fff;
    text-shadow:
      0 0 4px #fff,
      0 0 14px #22d3ee,
      0 0 30px #22d3ee,
      0 0 48px #818cf8;
  }
  35%, 100% {
    color: rgba(165, 243, 252, 0.4);
    text-shadow: 0 0 4px rgba(165, 243, 252, 0.2);
  }
}

/* -------- 尺寸预设 -------- */
.tcx-loader.size-xl { --ring-size: 120px; --tcx-size: 1.4rem;  --dot-size: 7px; --arc-duration: 2s; }
.tcx-loader.size-l  { --ring-size: 80px;  --tcx-size: 0.95rem; --dot-size: 6px; --arc-duration: 1.8s; }
.tcx-loader.size-m  { --ring-size: 56px;  --tcx-size: 0.7rem;  --dot-size: 5px; --arc-duration: 1.6s; }
.tcx-loader.size-s  { --ring-size: 20px;  --dot-size: 4px;     --arc-duration: 1.4s; }
.tcx-loader.size-xs { --ring-size: 12px;  --dot-size: 3px;     --arc-duration: 1.2s; }

/* size-xs 弧线偏窄，调整 mask 让弧更清晰 */
.tcx-loader.size-xs .ring-arc {
  -webkit-mask: radial-gradient(circle, transparent 0%, transparent 38%, #000 40%, #000 52%, transparent 54%);
          mask: radial-gradient(circle, transparent 0%, transparent 38%, #000 40%, #000 52%, transparent 54%);
}

/* -------- 修饰类 -------- */
.tcx-loader.no-text .tcx-text { display: none; }

.tcx-loader.minimal .ring-bg,
.tcx-loader.minimal .head-dot { display: none; }

/* solid: 用 currentColor 渲染光弧，关闭发光 —— 按钮内场景 */
.tcx-loader.solid .ring-arc {
  background: conic-gradient(
    from -90deg,
    transparent 0deg,
    transparent 280deg,
    currentColor 360deg
  );
  filter: none;
}
.tcx-loader.solid .head-dot::after { display: none; }

/* -------- 容器辅助类 -------- */
/* 块级布局：loader 在上，caption 在下 */
.tcx-loader-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 1.2rem 0.5rem;
}

.tcx-loader-caption {
  font-size: 0.82rem;
  color: rgba(226, 232, 240, 0.72);
  letter-spacing: 0.02em;
  text-align: center;
}

/* 行内布局：loader + text 横排 */
.tcx-loader-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  vertical-align: middle;
  color: rgba(226, 232, 240, 0.72);
  font-size: 0.85rem;
}

/* -------- 全屏遮罩 -------- */
.tcx-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  background: rgba(10, 15, 28, 0.92);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tcx-loader-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tcx-loader-overlay .tcx-loader-overlay-sub {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: rgba(226, 232, 240, 0.55);
  text-transform: uppercase;
}

/* -------- 无障碍：用户启用了 reduced motion -------- */
@media (prefers-reduced-motion: reduce) {
  .tcx-loader .ring-arc,
  .tcx-loader .head-dot,
  .tcx-loader .tcx-text > span {
    animation-duration: 3s;
  }
  .tcx-loader-overlay { transition: none; }
}
