/* ==========================================================================
   多邻国 Super 家庭版兑换 —— 设计令牌与基础样式
   --------------------------------------------------------------------------
   设计规范见 docs/UI-设计规范.md
   配色经 WCAG 2.2 AA 校验：
     · 品牌绿 #58CC02 底 + 深墨字 #1F2A00 = 7.24:1 (AAA)
     · 蓝色按钮底 #0B76AE + 白字         = 4.98:1 (AA)
     · 正文 #2C2C2A / 次要 #666666 / 提示 #767676
   ========================================================================== */

:root {
  /* ---- 品牌主色阶（多邻国绿）---- */
  --green-50:  #f2fbe6;
  --green-100: #e3f7c8;
  --green-200: #c9ee9b;
  --green-400: #7bd800;
  --green-500: #58cc02;   /* 品牌主色 */
  --green-600: #4caf00;
  --green-700: #3e8e00;   /* 按压态 / 深色按钮底 */
  --green-900: #173404;

  /* ---- 蓝色阶（辅助）---- */
  --blue-50:  #e6f1fb;
  --blue-100: #b5d4f4;
  --blue-500: #1cb0f6;
  --blue-700: #0b76ae;   /* 蓝色按钮底（白字 4.98:1）*/
  --blue-900: #042c53;

  /* ---- 语义色 ---- */
  --red-600:  #b3261e;   /* 错误文字 6.54:1 */
  --red-700:  #8c1e18;
  --red-50:   #fcebeb;
  --red-100:  #f7c1c1;

  --amber-700: #8a6d00;  /* 警告文字 4.92:1 */
  --amber-50:  #faeeda;

  --purple-600: #534ab7;
  --purple-50:  #eeedfe;

  /* ---- 中性色阶 ---- */
  --ink:          #2c2c2a;  /* 正文标题 11.9:1 */
  --ink-secondary:#666666;  /* 次要文字 5.74:1 */
  --ink-tertiary: #767676;  /* 提示文字 4.54:1 */
  --ink-disabled: #b4b2a9;  /* 禁用态，不承载信息 */
  --line:         #e5e5e5;
  --line-strong:  #d3d1c7;
  --surface:      #ffffff;
  --surface-sunken: #f7f7f7;

  /* ---- 圆角 ---- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* ---- 阴影（Duolingo 风格硬阴影）---- */
  --shadow-card: 0 2px 0 rgba(0, 0, 0, .06);
  --shadow-pop:  0 10px 40px rgba(0, 0, 0, .18);

  /* ---- 字体 ---- */
  --font-sans: "Nunito", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---- 间距（8px 基线）---- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-sunken);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

/* 数字等宽，避免刷新时数值跳动 */
.num, .stat-value, .plan-months, .case-ms, .kv-v.mono {
  font-variant-numeric: tabular-nums;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.3px;
  color: var(--green-700);
}

.brand .duo-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-500);
  display: grid;
  place-items: center;
  color: #1f2a00;          /* 品牌绿底用深墨字，7.24:1 */
  font-size: 20px;
  font-weight: 800;
  flex: none;
}

.brand-sub {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-secondary);
  font-weight: 700;
}

/* ---------- 布局（移动优先）---------- */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-10);
}

@media (min-width: 768px) {
  .wrap { max-width: 720px; padding: var(--sp-8) var(--sp-6) var(--sp-12); }
}

@media (min-width: 1200px) {
  .wrap { max-width: 1240px; }
}

/* ---------- 步骤条 ---------- */
.stepper { display: flex; align-items: center; gap: 6px; margin-bottom: var(--sp-5); }

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-disabled);
  position: relative;
}

.step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-tertiary);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  border: 2px solid var(--line);
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.step.active .step-dot { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.step.active { color: var(--blue-700); }
.step.done .step-dot { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.step.done { color: var(--green-700); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-5);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--sp-4);
}

.card-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.2px; }
.card-desc { color: var(--ink-secondary); font-size: 14px; margin: 0 0 var(--sp-5); }

/* ---------- 表单 ---------- */
.field { margin-bottom: var(--sp-4); }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-secondary);
  margin-bottom: 7px;
  letter-spacing: .4px;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;                 /* 触控目标 ≥44px */
  padding: 13px 14px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 4px rgba(11, 118, 174, .16);
}

.field input::placeholder { color: var(--ink-tertiary); font-weight: 500; }

.field input.code-input {
  letter-spacing: 2px;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 16px;
}

.field input[disabled] { background: var(--surface-sunken); color: var(--ink-tertiary); }

.hint { font-size: 12.5px; color: var(--ink-tertiary); margin-top: 7px; line-height: 1.5; }

/* 字段级错误：图标 + 文字，不仅靠颜色传达 */
.field-error {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--red-600);
  margin-top: 6px;
}
.field-error.show { display: flex; }
.field-error svg { width: 14px; height: 14px; flex: none; }

.input-invalid { border-color: var(--red-600) !important; }
.input-invalid:focus { box-shadow: 0 0 0 4px rgba(179, 38, 30, .14) !important; }

/* ---------- 按钮 ---------- */
.btn {
  width: 100%;
  min-height: 48px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: .3px;
  color: #1f2a00;              /* 品牌绿底深墨字 7.24:1 */
  background: var(--green-500);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--green-700);
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.btn:hover { background: var(--green-400); transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-700); }
.btn:focus-visible { outline: 3px solid var(--blue-500); outline-offset: 2px; }

.btn.blue {
  color: #fff;
  background: var(--blue-700);
  box-shadow: 0 4px 0 #095a85;
}
.btn.blue:hover { background: #0e86c4; }
.btn.blue:active { box-shadow: 0 1px 0 #095a85; }

.btn.danger {
  color: #fff;
  background: var(--red-600);
  box-shadow: 0 4px 0 var(--red-700);
}
.btn.danger:hover { background: #c8322a; }
.btn.danger:active { box-shadow: 0 1px 0 var(--red-700); }

.btn.ghost {
  background: transparent;
  color: var(--ink-secondary);
  box-shadow: none;
  border: 2px solid var(--line-strong);
  padding: 12px 18px;
}
.btn.ghost:hover { background: var(--surface-sunken); color: var(--ink); }
.btn.ghost:active { transform: none; box-shadow: none; }
.btn.ghost:focus-visible { outline: 3px solid var(--blue-500); outline-offset: 2px; }

.btn:disabled {
  background: var(--line);
  color: var(--ink-tertiary);
  cursor: not-allowed;
  box-shadow: 0 4px 0 var(--line-strong);
  transform: none;
}

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- 标签切换 ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--line);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-5);
}

.tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background-color .2s ease, color .2s ease;
}

.tab.active { background: var(--surface); color: var(--blue-700); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.tab:focus-visible { outline: 3px solid var(--blue-500); outline-offset: 1px; }

/* ---------- 提示条 ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--sp-4);
  display: none;
  line-height: 1.5;
}
.alert.show { display: block; }
.alert.error { background: var(--red-50); color: var(--red-600); border: 2px solid var(--red-100); }
.alert.success { background: var(--green-50); color: var(--green-700); border: 2px solid var(--green-100); }
.alert.info { background: var(--blue-50); color: var(--blue-900); border: 2px solid var(--blue-100); }
.alert.warn { background: var(--amber-50); color: var(--amber-700); border: 2px solid #fac775; }

/* ---------- 结果页 ---------- */
.result-hero { text-align: center; padding: 8px 0 4px; }

.result-badge {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--green-500);
  display: grid;
  place-items: center;
  margin: 0 auto var(--sp-4);
  box-shadow: 0 6px 0 var(--green-700);
}
.result-badge svg { width: 42px; height: 42px; }

.result-title { font-size: 25px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.4px; }
.result-sub { color: var(--ink-secondary); font-size: 14.5px; margin: 0 0 var(--sp-5); }

.plan-card {
  border: 2px solid var(--green-600);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  text-align: center;
  margin-bottom: var(--sp-4);
  background: linear-gradient(180deg, var(--green-50) 0%, var(--surface) 100%);
}

.plan-months { font-size: 34px; font-weight: 800; color: var(--green-700); line-height: 1.1; }
.plan-label { font-size: 13px; color: var(--ink-secondary); font-weight: 700; }

.kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.kv:last-child { border-bottom: none; }
.kv-k { color: var(--ink-secondary); font-weight: 600; flex: none; }
.kv-v { font-weight: 800; text-align: right; word-break: break-word; }
.kv-v.mono { font-family: var(--font-mono); font-size: 13.5px; }

.countdown { font-size: 12.5px; color: var(--ink-secondary); text-align: center; margin-top: 10px; font-weight: 600; }

/* ---------- 杂项 ---------- */
.hidden { display: none !important; }

.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(31, 42, 0, .35);
  border-top-color: #1f2a00;
  border-radius: 50%;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 7px;
  animation: spin .7s linear infinite;
}
.btn.blue .spinner, .btn.danger .spinner { border-top-color: #fff; border-color: rgba(255,255,255,.4); }
@keyframes spin { to { transform: rotate(360deg); } }

.footer {
  text-align: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-8);
  color: var(--ink-tertiary);
  font-size: 12.5px;
  line-height: 1.7;
}
.footer a { color: var(--ink-secondary); text-decoration: none; border-bottom: 1px solid var(--line-strong); }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-tertiary);
  font-size: 12.5px; font-weight: 700;
  margin: var(--sp-5) 0;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: var(--line); }

.notice-box {
  background: var(--blue-50);
  border: 2px solid var(--blue-100);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.65;
  margin-bottom: var(--sp-4);
}
.notice-box b { color: var(--ink); }

/* ---------- 减弱动效（可访问性）---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover, .btn:active { transform: none; }
}
