/**
 * =============================================================================
 * GLASS BUTTONS
 * =============================================================================
 * 玻璃质感按钮 (全站统一)
 *
 * 结构: <a class="btn btn-primary">文字 <span class="btn-icon">↗</span></a>
 *       ↗ 图标只用于跳转外部网站的按钮
 *
 * 材质:
 * - 默认:  透明液态玻璃 (高光边缘 + 背景模糊增饱和;Chrome/Edge 中带边缘折射)
 * - .btn-primary: 墨绿"黑曜石"玻璃,内部透出一缕品牌青绿光
 * - .btn-on-dark: 深色背景上的透明玻璃
 *
 * 交互 (配合 js/interactions.js):
 * - 鼠标跟随光斑:  ::before 使用 --mx / --my 定位径向高光
 * - 边框流光:      ::after 仅在边框区域显示跟随鼠标的亮边
 * - 磁吸位移:      --tx / --ty 让按钮轻微跟随指针
 * - 光泽扫过:      悬停时一道高光从左向右划过
 * - 点击涟漪:      JS 插入 .btn-ripple 元素
 */

.btn {
  --tx: 0px;
  --ty: 0px;
  --spot: rgba(255, 255, 255, 0.75);  /* 光斑颜色 */
  --rim: rgba(14, 156, 154, 0.85);    /* 边框流光颜色 */
  --sheen: rgba(255, 255, 255, 0.85); /* 扫光颜色 */
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 50px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  white-space: nowrap;

  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);

  /* 透明液态玻璃:上亮下透的填充 */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 255, 255, 0.22) 100%);
  box-shadow:
    var(--glass-rim),                         /* 高光边缘 (定义见 reset.css) */
    0 0 0 1px rgba(15, 37, 34, 0.07),         /* 极细外轮廓 */
    0 2px 4px -1px rgba(15, 60, 52, 0.1),     /* 近处阴影 */
    0 14px 30px -14px rgba(15, 60, 52, 0.35); /* 远处柔和投影 */
  backdrop-filter: blur(10px) saturate(220%) brightness(1.06);
  -webkit-backdrop-filter: blur(10px) saturate(220%) brightness(1.06);

  transform: translate3d(var(--tx), var(--ty), 0);
  transition:
    transform 0.5s var(--ease-out),
    box-shadow 0.4s ease;
}

/* 有图标时右侧收紧 */
.btn:has(.btn-icon) {
  padding-right: 8px;
}

/* 鼠标跟随光斑 + 光泽扫过 */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(120px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 70%),
    linear-gradient(105deg, transparent 40%, var(--sheen) 50%, transparent 60%) no-repeat;
  background-size: 100% 100%, 250% 100%;
  background-position: 0 0, 160% 0;
  opacity: 0;
  transition: opacity 0.35s ease, background-position 0s;
}

.btn:hover::before {
  opacity: 1;
  background-position: 0 0, -60% 0;
  transition: opacity 0.35s ease, background-position 1s var(--ease-out);
}

/* 边框流光:只在 1px 边框内显示跟随鼠标的亮色 */
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: radial-gradient(70px circle at var(--mx, 50%) var(--my, 50%), var(--rim), transparent 75%);
  -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);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.btn:hover::after {
  opacity: 1;
}

.btn:hover {
  transform: translate3d(var(--tx), calc(var(--ty) - 2px), 0);
  box-shadow:
    var(--glass-rim),
    0 0 0 1px rgba(15, 37, 34, 0.08),
    0 4px 8px -2px rgba(15, 60, 52, 0.12),
    0 22px 40px -16px rgba(15, 60, 52, 0.45);
}

.btn:active {
  transform: translate3d(var(--tx), var(--ty), 0) scale(0.97);
  transition-duration: 0.12s;
}

/* 右侧圆形图标:一颗小玻璃珠 */
.btn-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.25));
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.95),
    inset 0 -1px 0.5px rgba(255, 255, 255, 0.4),
    0 0 0 1px rgba(15, 37, 34, 0.06),
    0 2px 6px -2px rgba(15, 60, 52, 0.25);
  transition: transform 0.5s var(--ease-out), background 0.3s ease;
}

.btn:hover .btn-icon {
  transform: rotate(45deg);
}

/* ===== 变体:主按钮 (墨绿黑曜石玻璃) ===== */
.btn-primary {
  --spot: rgba(110, 230, 195, 0.4);
  --rim: rgba(200, 235, 90, 0.95);
  --sheen: rgba(255, 255, 255, 0.2);
  color: #fff;
  background:
    radial-gradient(120% 90% at 50% 120%, rgba(52, 174, 123, 0.55), transparent 60%), /* 底部透出的翠绿光 */
    linear-gradient(180deg, rgba(44, 82, 75, 0.94) 0%, rgba(13, 34, 31, 0.97) 100%);  /* 墨绿玻璃本体 */
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.4),        /* 顶边高光 */
    inset 0 -1px 0.5px rgba(160, 240, 210, 0.35),      /* 底边青绿反光 */
    inset 0 10px 18px -12px rgba(255, 255, 255, 0.35), /* 顶部内发光 */
    0 0 0 1px rgba(8, 24, 22, 0.9),                    /* 深色外轮廓 */
    0 2px 4px -1px rgba(8, 24, 22, 0.3),               /* 近处阴影 */
    0 16px 32px -14px rgba(8, 40, 36, 0.65);           /* 远处投影 */
}

.btn-primary:hover {
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.5),
    inset 0 -1px 0.5px rgba(160, 240, 210, 0.5),
    inset 0 10px 18px -12px rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(8, 24, 22, 0.9),
    0 4px 8px -2px rgba(8, 24, 22, 0.3),
    0 22px 44px -16px rgba(14, 140, 125, 0.7);
}

.btn-primary .btn-icon {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06));
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.btn-primary:hover .btn-icon {
  background: linear-gradient(135deg, var(--teal), var(--emerald));
}

/* ===== 变体:深色背景上的透明玻璃 ===== */
.btn-on-dark {
  --spot: rgba(188, 212, 55, 0.3);
  --rim: rgba(255, 255, 255, 0.95);
  --sheen: rgba(255, 255, 255, 0.22);
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.55),
    inset 0 -1px 0.5px rgba(255, 255, 255, 0.2),
    inset 0 10px 18px -12px rgba(255, 255, 255, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 16px 32px -16px rgba(0, 0, 0, 0.6);
}

.btn-on-dark:hover {
  box-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.7),
    inset 0 -1px 0.5px rgba(255, 255, 255, 0.3),
    inset 0 10px 18px -12px rgba(255, 255, 255, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.16),
    0 22px 40px -16px rgba(0, 0, 0, 0.7);
}

/* ===== 尺寸 ===== */
.btn-sm {
  height: 40px;
  gap: 8px;
  padding: 0 18px;
  font-size: 14px;
}

.btn-sm:has(.btn-icon) {
  padding-right: 5px;
}

.btn-sm .btn-icon {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.btn-lg {
  height: 58px;
  padding: 0 32px;
  font-size: 16px;
}

.btn-lg:has(.btn-icon) {
  padding-right: 9px;
}

.btn-lg .btn-icon {
  width: 40px;
  height: 40px;
  font-size: 17px;
}

/* ===== 点击涟漪 ===== */
.btn-ripple {
  position: absolute;
  z-index: -1;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  pointer-events: none;
  background: var(--spot);
  animation: btn-ripple 0.7s var(--ease-out) forwards;
}

@keyframes btn-ripple {
  to {
    transform: scale(28);
    opacity: 0;
  }
}

/* ===== 手机 ===== */
@media (max-width: 650px) {
  .btn-lg {
    height: 52px;
    padding: 0 24px;
    font-size: 15px;
  }

  .btn-lg .btn-icon {
    width: 36px;
    height: 36px;
  }
}
