/* ========== 全局变量与基础设置 ========== */
:root {
  /* 背景色系（暗色主题，贴合游戏风格） */
  --bg-primary: #0a0a12;
  --bg-secondary: #111122;
  --bg-card: #1a1a32;
  --bg-card-hover: #222244;

  /* 强调色（龙珠风格的橙色与金色） */
  --accent: #ff6b00;
  --accent-hover: #ff8533;
  --accent-glow: rgba(255, 107, 0, 0.3);
  --gold: #ffd700;

  /* 文字颜色 */
  --text: #f0f0f5;
  --text-secondary: #9090a8;
  --text-muted: #606078;

  /* 边框与分隔 */
  --border: #2a2a44;
  --border-focus: #ff6b00;

  /* 成功/错误状态 */
  --success: #22c55e;
  --error: #ef4444;

  /* 圆角 */
  --radius: 8px;
  --radius-lg: 12px;

  /* 最大内容宽度 */
  --max-width: 800px;
}

/* ========== 跳过导航（无障碍：键盘用户可直接跳到生成器） ========== */
.skip-nav {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 200;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
}

.skip-nav:focus {
  top: 8px;
}

/* ========== 键盘 focus 可见样式（WCAG AA） ========== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 输入框已有自定义 focus 样式，不叠加默认 outline */
.code-input:focus-visible {
  outline: none;
}

/* ========== CSS Reset ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========== 基础排版 ========== */
html {
  scroll-behavior: smooth;
  /* 确保在深色背景上不出现白色闪屏 */
  background: var(--bg-primary);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== 通用容器 ========== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* ========== 通用按钮样式 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

/* 主要按钮（橙色填充） */
.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* 轮廓按钮（透明背景） */
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover {
  background: rgba(255, 107, 0, 0.1);
}

/* 大号按钮 */
.btn-large {
  padding: 16px 32px;
  font-size: 1.1rem;
}

/* ========== 顶部导航栏 ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 18, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header .container {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
}

/* Logo 样式 */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

/* 旧版文字 logo 图标（404 页面使用） */
.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 0.75rem;
  border-radius: 6px;
}

/* 新版 SVG logo 图标 */
.logo-icon-img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 1.1rem;
}

.logo-dot {
  color: var(--accent);
}

/* 导航链接：margin-left:auto 将导航和语言切换推到右侧 */
.header nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
}

.header nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.header nav a:hover {
  color: var(--text);
}

/* ========== Hero 区域 ========== */
.hero {
  text-align: center;
  padding: 60px 0 48px;
  /* 微妙的径向渐变背景增加视觉层次 */
  background: radial-gradient(ellipse at top center, rgba(255, 107, 0, 0.08) 0%, transparent 60%);
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  /* 文字渐变效果：橙色到金色 */
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 16px;
}

/* 周年庆徽章 */
.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 24px;
}

/* ========== QR 码生成器区域 ========== */
.generator {
  padding: 48px 0;
}

.generator h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 24px;
}

/* ========== 标签页切换 ========== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tab:hover:not(.active) {
  color: var(--text);
}

.tab-icon {
  font-size: 1.1rem;
}

/* ========== 标签页面板 ========== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-desc {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

/* ========== 输入框样式 ========== */
.inputs-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-group {
  display: flex;
  gap: 8px;
}

.code-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  letter-spacing: 0.5px;
  transition: border-color 0.2s;
}

.code-input::placeholder {
  color: var(--text-muted);
}

.code-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* 输入验证通过时的绿色边框 */
.code-input.valid {
  border-color: var(--success);
}

/* 输入验证失败时的红色边框 */
.code-input.invalid {
  border-color: var(--error);
}

/* 删除输入行按钮 */
.btn-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  padding: 0;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-remove:hover {
  border-color: var(--error);
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* ========== 添加代码按钮 ========== */
.btn-add {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  font-size: 0.9rem;
  border-style: dashed;
}

.add-count {
  color: var(--text-muted);
  font-weight: 400;
}

/* ========== 生成按钮 ========== */
.btn-generate {
  width: 100%;
  margin-top: 24px;
  padding: 16px;
  font-size: 1.1rem;
}

/* ========== 错误消息 ========== */
.error-message {
  margin-top: 12px;
  padding: 0;
  color: var(--error);
  font-size: 0.9rem;
  text-align: center;
  min-height: 0;
  transition: all 0.2s;
}

.error-message:not(:empty) {
  padding: 10px 16px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius);
}

/* ========== QR 码结果区域 ========== */
.qr-results {
  margin-top: 32px;
}

/* 批量下载按钮 */
.btn-download-all {
  width: 100%;
  margin-bottom: 16px;
}

/* QR 码网格布局（min-height 预留空间，减少 CLS 布局偏移） */
.qr-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  min-height: 0;
}

.qr-grid:not(:empty) {
  min-height: 320px;
}

/* QR 码卡片 */
.qr-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  transition: border-color 0.2s;
}

.qr-card:hover {
  border-color: rgba(255, 107, 0, 0.3);
}

/* QR 码图片容器（白色背景确保可扫描性） */
.qr-image-wrapper {
  display: inline-block;
  padding: 16px;
  background: #ffffff;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

/* 确保 qrcodejs 生成的 img 正确显示 */
.qr-image-wrapper img {
  display: block;
}

.qr-image-wrapper canvas {
  display: none;
}

/* 好友代码标签 */
.qr-code-label {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* 单个 QR 码下载按钮 */
.btn-download {
  padding: 8px 20px;
  font-size: 0.85rem;
}

/* ========== 使用指南区域 ========== */
.guide {
  padding: 48px 0;
  background: var(--bg-secondary);
}

.guide h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 32px;
}

/* 步骤网格 */
.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* 单个步骤卡片 */
.guide-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
}

/* 步骤数字圆圈 */
.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 50%;
  margin-bottom: 12px;
}

.guide-step h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.guide-step p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ========== FAQ 区域 ========== */
.faq {
  padding: 48px 0;
}

.faq h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 24px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* FAQ 手风琴项 */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-item summary {
  padding: 16px 20px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
}

/* 移除浏览器默认的 details 三角标记 */
.faq-item summary::-webkit-details-marker {
  display: none;
}

/* 自定义展开/收起箭头 */
.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item summary:hover {
  background: var(--bg-card-hover);
}

.faq-item p {
  padding: 0 20px 16px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

.faq-item code {
  background: rgba(255, 107, 0, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent);
}

/* ========== 页脚 ========== */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-disclaimer {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 8px;
}

/* 导航栏语言下拉框 */
.lang-dropdown {
  position: relative;
}

/* 下拉触发按钮 */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}

.lang-toggle .arrow {
  font-size: 0.6rem;
  transition: transform 0.2s;
}

/* 下拉菜单（hover 或 focus-within 时展开） */
.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  display: none;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 130px;
  padding: 4px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lang-dropdown:hover .lang-menu,
.lang-dropdown:focus-within .lang-menu {
  display: flex;
}

.lang-dropdown:hover .lang-toggle .arrow,
.lang-dropdown:focus-within .lang-toggle .arrow {
  transform: rotate(180deg);
}

.lang-menu a {
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: all 0.15s;
}

.lang-menu a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.lang-menu a.active {
  color: var(--accent);
  background: rgba(255, 107, 0, 0.1);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== 响应式布局 ========== */

/* 平板及以上（≥640px） */
@media (min-width: 640px) {
  .hero h1 {
    font-size: 3rem;
  }

  /* QR 码网格改为两列 */
  .qr-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 步骤网格改为两列 */
  .guide-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 桌面端（≥1024px） */
@media (min-width: 1024px) {
  .container {
    max-width: 900px;
  }

  .hero h1 {
    font-size: 3.2rem;
  }

  /* 步骤网格改为四列 */
  .guide-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* QR 码网格最多三列 */
  .qr-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
