/* =========================================================
   MBTI 人格实验室 · base.css
   设计令牌 / 主题变量 / 基础布局 / 顶栏 / 按钮 / 通用
   ========================================================= */

/* ---------- 设计令牌：深色（默认） ---------- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;

  --bg-0: #070b14;
  --bg-1: #0d1424;
  --bg-2: #111a30;

  --card: rgba(255, 255, 255, 0.045);
  --card-strong: rgba(255, 255, 255, 0.075);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-hover-border: rgba(255, 255, 255, 0.2);

  --text-1: #f2f5fb;
  --text-2: #a6b2c8;
  --text-3: #64748f;

  --accent-1: #7c6ff0;
  --accent-2: #4f8ef7;
  --accent-3: #f97316;
  --grad-main: linear-gradient(135deg, #7c6ff0 0%, #4f8ef7 100%);
  --grad-warm: linear-gradient(135deg, #f97316 0%, #f43f5e 100%);

  --glow: 0 8px 32px rgba(94, 106, 210, 0.35);
  --glow-soft: 0 4px 24px rgba(94, 106, 210, 0.18);
  --shadow: 0 10px 40px rgba(2, 6, 18, 0.55);

  --topbar-bg: rgba(9, 13, 26, 0.62);
  --footer-border: rgba(255, 255, 255, 0.06);

  --track: rgba(255, 255, 255, 0.08);
  --sel-bg: rgba(255, 255, 255, 0.06);

  --orb-1: rgba(124, 111, 240, 0.22);
  --orb-2: rgba(79, 142, 247, 0.16);
  --orb-3: rgba(249, 115, 22, 0.12);
  --orb-4: rgba(236, 72, 153, 0.13);
}

/* ---------- 设计令牌：浅色 ---------- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg-0: #eef1f8;
  --bg-1: #e4e9f5;
  --bg-2: #f8fafd;

  --card: rgba(255, 255, 255, 0.72);
  --card-strong: rgba(255, 255, 255, 0.92);
  --card-border: rgba(23, 37, 84, 0.08);
  --card-hover-border: rgba(99, 102, 241, 0.4);

  --text-1: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;

  --accent-1: #6d5ae0;
  --accent-2: #3b82f6;
  --accent-3: #ea580c;
  --grad-main: linear-gradient(135deg, #6d5ae0 0%, #3b82f6 100%);
  --grad-warm: linear-gradient(135deg, #f97316 0%, #e11d48 100%);

  --glow: 0 10px 36px rgba(109, 90, 224, 0.28);
  --glow-soft: 0 6px 22px rgba(109, 90, 224, 0.16);
  --shadow: 0 12px 40px rgba(16, 24, 40, 0.12);

  --topbar-bg: rgba(248, 250, 253, 0.66);
  --footer-border: rgba(16, 24, 40, 0.08);

  --track: rgba(16, 24, 40, 0.08);
  --sel-bg: rgba(16, 24, 40, 0.05);

  --orb-1: rgba(124, 111, 240, 0.18);
  --orb-2: rgba(59, 130, 246, 0.14);
  --orb-3: rgba(249, 115, 22, 0.1);
  --orb-4: rgba(236, 72, 153, 0.1);
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.5s ease, color 0.5s ease;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
kbd {
  display: inline-block; padding: 1px 7px; margin: 0 2px;
  border-radius: 6px; font-size: 12px; font-family: inherit;
  background: var(--card-strong); border: 1px solid var(--card-border);
  box-shadow: 0 2px 0 var(--card-border);
}

::selection { background: rgba(124, 111, 240, 0.45); color: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-1), var(--accent-2));
  border-radius: 8px; border: 2px solid var(--bg-0);
}
::-webkit-scrollbar-thumb:hover { filter: brightness(1.15); }

/* 焦点可见性 */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- 背景层 ---------- */
#bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; pointer-events: none;
}

.orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); will-change: transform;
}
.orb-1 { width: 46vw; height: 46vw; top: -16vw; left: -12vw; background: var(--orb-1); animation: orbFloat1 26s ease-in-out infinite alternate; }
.orb-2 { width: 38vw; height: 38vw; top: 30vh; right: -14vw; background: var(--orb-2); animation: orbFloat2 32s ease-in-out infinite alternate; }
.orb-3 { width: 30vw; height: 30vw; bottom: -10vw; left: 22vw; background: var(--orb-3); animation: orbFloat3 30s ease-in-out infinite alternate; }
.orb-4 { width: 22vw; height: 22vw; bottom: 8vh; right: 18vw; background: var(--orb-4); animation: orbFloat1 24s ease-in-out infinite alternate-reverse; }

.noise {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.6'/></svg>");
}

/* ---------- 布局 ---------- */
.container { width: min(1080px, 92vw); margin: 0 auto; }

main#app {
  position: relative; z-index: 2;
  padding: 108px 0 40px;
  min-height: calc(100vh - 200px);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--card-border);
  transition: box-shadow 0.3s ease, background 0.5s ease;
}
.topbar.scrolled { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { border-radius: 10px; filter: drop-shadow(0 2px 8px rgba(124, 111, 240, 0.5)); transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.08); }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: 0.5px; }
.brand-name em { font-style: normal; background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent; }

.topnav { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  border: 1px solid transparent;
  transition: all 0.25s ease;
}
.nav-btn span { font-size: 15px; }
.nav-btn:hover { color: var(--text-1); background: var(--sel-bg); transform: translateY(-1px); }
.nav-btn.active { color: var(--text-1); background: var(--card-strong); border-color: var(--card-border); box-shadow: var(--glow-soft); }
.nav-btn.icon-btn { padding: 9px; width: 40px; height: 40px; justify-content: center; }
.nav-btn .ico-moon { display: none; }
.nav-btn .ico-sun { display: block; }
:root[data-theme="light"] .nav-btn .ico-moon { display: block; }
:root[data-theme="light"] .nav-btn .ico-sun { display: none; }

/* ---------- 按钮 ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 14px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.3px;
  border: 1px solid transparent;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--grad-main); color: #fff;
  box-shadow: var(--glow);
}
.btn-primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
  transform: translateX(-120%);
}
.btn-primary:hover { box-shadow: var(--glow), 0 0 0 1px rgba(255,255,255,0.08) inset; transform: translateY(-2px); }
.btn-primary:hover::after { animation: shimmer 1.1s ease; }

.btn-ghost {
  background: var(--card); color: var(--text-1);
  border-color: var(--card-border); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: var(--card-strong); border-color: var(--card-hover-border); transform: translateY(-2px); }

.btn-warm { background: var(--grad-warm); color: #fff; box-shadow: 0 8px 28px rgba(244, 63, 94, 0.35); }
.btn-warm:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(244, 63, 94, 0.45); }

.btn-lg { padding: 15px 30px; font-size: 16px; border-radius: 16px; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

/* 涟漪 */
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0); animation: rippleAnim 0.6s ease-out forwards;
  pointer-events: none;
}
:root[data-theme="light"] .ripple { background: rgba(109, 90, 224, 0.28); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, background 0.5s ease;
}
.card-hover:hover {
  transform: translateY(-6px);
  border-color: var(--card-hover-border);
  box-shadow: var(--glow-soft);
}
.glass {
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---------- 页脚 ---------- */
.footer {
  position: relative; z-index: 2;
  text-align: center; padding: 34px 16px 40px;
  border-top: 1px solid var(--footer-border);
  color: var(--text-3); font-size: 13px;
}
.footer-sub { margin-top: 4px; font-size: 12px; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 14px;
  background: var(--card-strong); border: 1px solid var(--card-hover-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glow-soft);
  font-size: 14px; font-weight: 600; color: var(--text-1);
  animation: toastIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: min(88vw, 420px);
}
.toast.hide { animation: toastOut 0.35s ease forwards; }
.toast .t-ico { font-size: 18px; }

/* ---------- 无障碍 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
