/* ============================================================
   CSS 变量
   ============================================================ */
:root {
  --bg-header: #d2f0ff;
  --green-card: #02c351;
  --btn-bg: #000;
  --text-primary: #0a0a0a;
  --text-secondary: rgba(60, 60, 67, 0.55);
  --white: #fff;
}

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

html,
body {
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background-color: var(--bg-header);
}

/* ============================================================
   页面容器
   ============================================================ */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease-out;
}

/* ============================================================
   头部 — 蓝色背景
   ============================================================ */
.header {
  background-color: var(--bg-header);
  padding: clamp(20px, 5.1vw, 28px);
  padding-top: clamp(28px, 7.2vw, 40px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3.1vw, 18px);
}

/* 头像 + 名字行（左右布局） */
.header-top {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2.6vw, 14px);
}

.avatar-img {
  width: clamp(52px, 15.4vw, 68px);
  height: clamp(52px, 15.4vw, 68px);
  border-radius: 50%;
  object-fit: cover;
  background-color: #d9d9d9;
  flex-shrink: 0;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.inviter-name {
  font-size: clamp(14px, 3.6vw, 17px);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

/* 标签胶囊（火焰 + 文字） */
.invite-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 6px;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: 100px;
  width: fit-content;
}

.tag-fire {
  font-size: 13px;
  line-height: 1;
}

.tag-text {
  font-size: clamp(11px, 2.8vw, 12px);
  color: var(--text-primary);
  font-weight: 500;
}

/* 大标题 */
.header-title {
  font-size: clamp(26px, 8.2vw, 36px);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* ============================================================
   主体 — 白色背景
   ============================================================ */
.body {
  flex: 1;
  background-color: var(--white);
  border-radius: clamp(16px, 4.1vw, 24px) clamp(16px, 4.1vw, 24px) 0 0;
  padding: clamp(20px, 5.1vw, 28px) clamp(20px, 5.1vw, 24px);
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 4.6vw, 26px);
}

/* ============================================================
   绿色奖励卡片 — 金额凸显
   ============================================================ */
.reward-card {
  display: flex;
  align-items: center;
  background-color: var(--green-card);
  border-radius: clamp(14px, 3.6vw, 18px);
  padding: clamp(16px, 4.1vw, 22px) clamp(20px, 5.1vw, 26px);
  gap: clamp(12px, 3.1vw, 18px);
}

.reward-left {
  flex: 1;
}

.reward-amount {
  font-size: clamp(36px, 11.3vw, 52px);
  font-weight: 800;
  color: var(--white);
  letter-spacing: -1px;
  line-height: 1;
}

.reward-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.reward-label {
  font-size: clamp(11px, 2.8vw, 13px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
  line-height: 1.3;
}

.reward-label--bold {
  color: var(--white);
  font-size: clamp(13px, 3.3vw, 15px);
  font-weight: 800;
}

.reward-ready {
  font-size: clamp(11px, 2.8vw, 12px);
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
}

/* ============================================================
   步骤列表
   ============================================================ */
.steps-title {
  font-size: clamp(16px, 4.1vw, 19px);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3.6vw, 20px);
}

.step {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3.1vw, 16px);
}

/* 步骤图标（SVG 自带背景，只需控制尺寸和 flex 对齐） */
.step-icon {
  width: clamp(40px, 10.3vw, 48px);
  height: clamp(40px, 10.3vw, 48px);
  flex-shrink: 0;
}

/* 虚线连接器 — 左边距 = icon 宽度一半，使线居中于 icon */
.step-connector {
  margin-left: calc(clamp(40px, 10.3vw, 48px) / 2 - 0.5px);
  line-height: 0;
  height: 28px;
  overflow: hidden;
}

.step-content {
  flex: 1;
}

.step-label {
  font-size: clamp(14px, 3.6vw, 16px);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.step-desc {
  margin-top: 2px;
  font-size: clamp(12px, 3.1vw, 13px);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ============================================================
   底部 footer — CTA 按钮
   ============================================================ */
.footer {
  background-color: var(--white);
  padding: clamp(12px, 3.1vw, 16px) clamp(20px, 5.1vw, 24px);
  padding-bottom: calc(clamp(24px, 6.2vw, 32px) + env(safe-area-inset-bottom, 0px));
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.cta-wrap {
  position: relative;
  width: 100%;
  height: clamp(50px, 13.8vw, 58px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.cta-wrap:active {
  transform: scale(0.98);
}

.cta-progress-bg {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background-color: #1a1a1a;
  overflow: hidden;
}

.cta-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  height: 100%;
  background-color: var(--btn-bg);
  border-radius: 100px;
}

.shimmer {
  position: absolute;
  inset: 0 auto 0 -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.12) 50%, transparent 100%);
  animation: shimmer 2.5s infinite;
}

.cta-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--white);
  font-weight: 700;
  font-size: clamp(15px, 4.1vw, 17px);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* ============================================================
   加载状态
   ============================================================ */
.cta-wrap.loading .cta-progress-fill {
  animation: progressLoading 3s ease-out forwards;
}

/* ============================================================
   呼吸动画
   ============================================================ */
.breath-animation {
  animation: breath 2s ease-in-out infinite;
}

/* ============================================================
   Keyframes
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  to {
    left: 100%;
  }
}

@keyframes breath {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
    opacity: 0.95;
  }
}

@keyframes progressLoading {
  0% {
    width: 10%;
  }
  35% {
    width: 35%;
  }
  65% {
    width: 65%;
  }
  100% {
    width: 100%;
  }
}

/* ============================================================
   性能优化 & 无障碍
   ============================================================ */
.shimmer,
.cta-progress-fill {
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .shimmer,
  .breath-animation,
  .cta-wrap.loading .cta-progress-fill,
  .page {
    animation: none !important;
  }
}

/* ============================================================
   Install Modal (Layer 1 — Custom prompt)
   ============================================================ */
.install-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: rgba(0, 0, 0, 0);
  visibility: hidden;
  pointer-events: none;
  transition: background-color 0.3s ease, visibility 0s 0.3s;
}

.install-modal-overlay.visible {
  background-color: rgba(0, 0, 0, 0.45);
  visibility: visible;
  pointer-events: auto;
  transition: background-color 0.3s ease, visibility 0s 0s;
}

.install-modal-card {
  width: calc(100% - 32px);
  max-width: 360px;
  margin-bottom: 16px;
  background: var(--white);
  border-radius: clamp(16px, 4.1vw, 20px);
  padding: clamp(24px, 6.2vw, 32px) clamp(20px, 5.1vw, 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 3.1vw, 16px);
  text-align: center;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
  will-change: transform, opacity;
}

.install-modal-overlay.visible .install-modal-card {
  transform: translateY(0);
  opacity: 1;
}

.install-modal-icon {
  width: clamp(48px, 12.3vw, 56px);
  height: clamp(48px, 12.3vw, 56px);
  border-radius: clamp(12px, 3.1vw, 14px);
  object-fit: cover;
}

.install-modal-desc {
  font-size: clamp(14px, 3.6vw, 16px);
  color: var(--text-primary);
  line-height: 1.5;
  font-weight: 500;
}

.install-modal-actions {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2.1vw, 12px);
  width: 100%;
  margin-top: clamp(4px, 1vw, 8px);
}

.install-modal-btn {
  width: 100%;
  height: clamp(44px, 11.3vw, 50px);
  border: none;
  border-radius: 100px;
  font-size: clamp(15px, 3.8vw, 17px);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.install-modal-btn--primary {
  background-color: #3DBAED;
  color: var(--white);
}

.install-modal-btn--secondary {
  background-color: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: clamp(13px, 3.3vw, 15px);
}

@media (prefers-reduced-motion: reduce) {
  .install-modal-card,
  .install-modal-overlay {
    transition: none !important;
  }
}
