/* ============================================
   AI钓鱼反诈实战演练 — 全局设计系统
   基于 docs/ui-ux-design.md + DESIGN.md
   手机端优先 (375-428px)
   ============================================ */

/* ---- CSS 自定义属性 (Design Tokens) ---- */
:root {
  /* 配色 */
  --bg-page:         #FAF8F5;
  --bg-card:         #FFFFFF;
  --primary:         #1E40AF;
  --primary-hover:   #17358A;
  --primary-light:   #DBEAFE;
  --danger:          #DC2626;
  --danger-hover:    #B91C1C;
  --danger-light:    #FEE2E2;
  --success:         #059669;
  --success-light:   #D1FAE5;
  --warning:         #D97706;
  --warning-light:   #FEF3C7;
  --text-heading:    #111827;
  --text-body:       #4B5563;
  --text-caption:    #9CA3AF;
  --border:          #E5E7EB;
  --modal-bg:        #1A1A2E;

  /* 字体 */
  --font-display: 'Noto Serif SC', serif;
  --font-body:    'Noto Sans SC', sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', monospace;

  /* 字号 */
  --text-d1:  2.125rem;   /* 34px — 揭露弹窗标题 */
  --text-d2:  1.8125rem;  /* 29px — 页面主标题 */
  --text-h1:  1.5rem;     /* 24px — 区块标题 */
  --text-h2:  1.25rem;    /* 20px — 卡片标题 */
  --text-h3:  1.0625rem;  /* 17px — 题目/案例标题 */
  --text-body-size: 0.9375rem; /* 15px — 正文 */
  --text-cap: 0.8125rem;  /* 13px — 辅助说明 */
  --text-sm:  0.6875rem;  /* 11px — 标签 */
  --text-stepper: 0.8125rem; /* 13px — 进度条标签 (DESIGN.md规格) */

  /* 黄金比例间距 (8px基元 × φ) */
  --space-2xs: 0.5rem;    /* 8px */
  --space-xs:  0.75rem;   /* 12px */
  --space-sm:  1rem;      /* 16px */
  --space-md:  1.25rem;   /* 20px */
  --space-lg:  2rem;      /* 32px */
  --space-xl:  3.25rem;   /* 52px */
  --space-2xl: 5.25rem;   /* 84px */

  /* 圆角 */
  --radius-pill:   999px;
  --radius-card:   16px;
  --radius-modal:  20px;
  --radius-chip:   6px;
  --radius-field:  10px;
  --radius-option: 12px;
  --radius-video:  12px;

  /* 阴影 */
  --shadow-card:   0 1px 3px rgba(0,0,0,0.04);
  --shadow-btn:    0 2px 8px rgba(30,64,175,0.15);
  --shadow-modal:  0 20px 40px rgba(0,0,0,0.15);

  /* 过渡 */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body-size);
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-body);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ---- 容器 ---- */
.container {
  width: 100%;
  max-width: 375px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ---- 字体层级 ---- */
.display-1, .d1 {
  font-family: var(--font-display);
  font-size: var(--text-d1);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-heading);
  text-wrap: balance;
}

.display-2, .d2 {
  font-family: var(--font-display);
  font-size: var(--text-d2);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-heading);
  text-wrap: balance;
}

h1, .h1 {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-heading);
  text-wrap: balance;
}

h2, .h2 {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-heading);
  text-wrap: balance;
}

h3, .h3 {
  font-family: var(--font-body);
  font-size: var(--text-h3);
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-heading);
}

p {
  margin-bottom: var(--space-sm);
  max-width: 65ch;
}

.caption {
  font-size: var(--text-cap);
  color: var(--text-caption);
}

.small {
  font-size: var(--text-sm);
  color: var(--text-caption);
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-height: 48px;
  padding: 0.875rem 2rem;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-body-size);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn--danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn--danger:hover {
  background: var(--danger-hover);
}

.btn--danger:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.btn--ghost {
  background: transparent;
  color: var(--primary);
  min-height: 44px;
  padding: 0.625rem 1.25rem;
}

.btn--ghost:hover {
  background: var(--primary-light);
}

.btn--disabled,
.btn:disabled {
  background: var(--border);
  color: var(--text-caption);
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--block {
  width: 100%;
}

/* ---- 卡片 ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: var(--space-sm);
  overflow: hidden;
}

/* ---- 弹窗/Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.70);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--modal-bg);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 335px;
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
  text-align: center;
  transform: translateY(30px) scale(0.95);
  transition: transform 350ms var(--ease-spring),
              opacity var(--duration-slow) var(--ease-out);
  opacity: 0;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal__icon-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  animation: modalIconIn 300ms var(--ease-spring) 400ms both;
}

.modal__icon-circle i {
  font-size: 2rem;
  color: #FFFFFF;
}

.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-d1);
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.3;
  margin-bottom: var(--space-xs);
  animation: modalFadeUp 250ms var(--ease-out) 550ms both;
}

.modal__body {
  font-size: var(--text-body-size);
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
  animation: modalFadeUp 200ms var(--ease-out) 650ms both;
}

.modal__cta {
  animation: modalFadeUp 250ms var(--ease-out) 750ms both;
}

@keyframes modalIconIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes modalFadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- 警告提示条 ---- */
.alert-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 52px;
  padding: var(--space-xs) var(--space-md);
  background: var(--warning-light);
  color: var(--warning);
  font-size: var(--text-cap);
  font-weight: 500;
  border-bottom: 1px solid rgba(217, 119, 6, 0.15);
}

.alert-bar i {
  font-size: 1rem;
  flex-shrink: 0;
}

/* ---- 进度步骤条 ---- */
.progress-stepper {
  position: sticky;
  top: 52px;
  z-index: 99;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-md);
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stepper__node {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  position: relative;
}

.stepper__node:last-child {
  flex: none;
}

.stepper__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--duration-normal) var(--ease-out);
  background: var(--border);
}

.stepper__dot--done {
  background: var(--success);
}

.stepper__dot--current {
  background: var(--primary);
}

.stepper__line {
  flex: 1;
  height: 8px;
  margin: 0;
  border-radius: var(--radius-pill);
  transition: background var(--duration-normal) var(--ease-out);
  background: var(--border);
  min-width: 40px;
}

.stepper__line--done {
  background: var(--success);
}

.stepper__label {
  font-size: var(--text-stepper);
  font-weight: 500;
  color: var(--text-caption);
  margin-left: 6px;
  white-space: nowrap;
  transition: color var(--duration-normal) var(--ease-out);
}

.stepper__node--current .stepper__label {
  color: var(--primary);
}

.stepper__node--done .stepper__label {
  color: var(--success);
}

/* ---- 进度圆点指示器 (答题) ---- */
.quiz-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: var(--space-lg);
}

.quiz-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--duration-normal) var(--ease-out);
}

.quiz-dot--done {
  background: var(--success);
}

.quiz-dot--current {
  background: var(--primary);
}

/* ---- 选项按钮 ---- */
.option {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-height: 56px;
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-xs);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-option);
  font-family: var(--font-body);
  font-size: var(--text-body-size);
  color: var(--text-heading);
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
  user-select: none;
  -webkit-user-select: none;
}

.option:active {
  transform: scale(0.99);
}

.option:hover {
  border-color: var(--primary);
}

.option--correct {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}

.option--wrong {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.option--reveal {
  border-color: var(--success);
  background: var(--success-light);
}

.option__letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  font-weight: 600;
  font-size: var(--text-cap);
  color: var(--text-caption);
  flex-shrink: 0;
}

.option--correct .option__letter,
.option--reveal .option__letter {
  background: var(--success);
  color: #FFFFFF;
}

.option--wrong .option__letter {
  background: var(--danger);
  color: #FFFFFF;
}

.option__icon {
  margin-left: auto;
  font-size: 1.125rem;
  flex-shrink: 0;
}

/* ---- 紧急退出按钮 ---- */
.exit-link {
  display: block;
  width: 100%;
  text-align: center;
  padding: var(--space-xs) 0;
  min-height: 44px;
  background: transparent;
  border: none;
  color: var(--text-caption);
  font-family: var(--font-body);
  font-size: var(--text-cap);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.exit-link:hover {
  color: var(--text-body);
}

/* ---- 完成页 ---- */
.completion {
  text-align: center;
  padding: var(--space-2xl) var(--space-md) var(--space-xl);
}

.completion__icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  line-height: 1;
}

.completion__stats {
  margin: var(--space-lg) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-items: center;
  font-size: var(--text-cap);
  color: var(--text-body);
}

.completion__stats i {
  margin-right: var(--space-2xs);
  color: var(--success);
}

/* ---- 实用工具类 ---- */
.text-center { text-align: center; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
html body .hidden { display: none; }

/* ---- 视频完成按钮脉冲 ---- */
@keyframes pulse-once {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.btn--pulse {
  animation: pulse-once 600ms var(--ease-out);
}

/* ---- 链接重置 (钓鱼页用) ---- */
a[href]:not(.btn) {
  color: var(--primary);
  text-decoration: none;
}

/* ---- 减少动效 ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}
