/* 兑换页专用样式：页面骨架、步骤条、卡密输入、号码卡片、短信卡片和动效。
   按钮、输入框、提示条等基础样式在 /static/shared/style.css。 */

:root {
  --hero-grad: linear-gradient(135deg, #0f766e 0%, #14b8a6 55%, #2dd4bf 100%);
}

body.redeem-page {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(20, 184, 166, 0.14), transparent 60%),
    var(--page-bg);
  display: block;
  padding: 0;
}

/* ---------- 背景光斑 ---------- */

.bg-orbs {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

.orb {
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  position: absolute;
  will-change: transform;
}

.orb-a {
  animation: orbFloat 18s ease-in-out infinite;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.55), transparent 65%);
  height: 420px;
  left: -120px;
  top: -80px;
  width: 420px;
}

.orb-b {
  animation: orbFloat 22s ease-in-out infinite reverse;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.4), transparent 65%);
  height: 380px;
  right: -140px;
  top: 160px;
  width: 380px;
}

.orb-c {
  animation: orbFloat 26s ease-in-out infinite 3s;
  background: radial-gradient(circle, rgba(167, 243, 208, 0.5), transparent 65%);
  bottom: -160px;
  height: 460px;
  left: 30%;
  width: 460px;
}

@keyframes orbFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(40px, 30px, 0) scale(1.08); }
}

/* ---------- 页面骨架 ---------- */

.redeem-shell {
  margin: 0 auto;
  max-width: 880px;
  padding: 44px 20px 56px;
  position: relative;
  width: 100%;
  z-index: 1;
}

.redeem-hero {
  animation: fadeInDown 0.5s var(--ease);
  margin-bottom: 26px;
  text-align: center;
}

.brand-row {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  margin-bottom: 14px;
}

.brand-mark {
  align-items: center;
  background: var(--hero-grad);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.3);
  color: #ffffff;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand-name {
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.redeem-hero h1 {
  background: var(--hero-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 8px;
}

.redeem-hero p {
  color: var(--text-soft);
  font-size: 16px;
}

/* ---------- 步骤条 ---------- */

.stepper {
  animation: fadeUp 0.5s var(--ease) 0.05s both;
  display: flex;
  list-style: none;
  margin: 0 auto 22px;
  max-width: 640px;
  padding: 0;
}

.step {
  align-items: center;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.step:not(:first-child)::before {
  background: var(--line-strong);
  content: "";
  height: 2px;
  left: -50%;
  position: absolute;
  right: 50%;
  top: 17px;
  transition: background 0.4s ease;
  z-index: 0;
}

.step.is-done:not(:first-child)::before,
.step.is-current:not(:first-child)::before {
  background: var(--accent);
}

.step-dot {
  align-items: center;
  background: #ffffff;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-dim);
  display: inline-flex;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  position: relative;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.3s var(--ease-bounce);
  width: 36px;
  z-index: 1;
}

.step-dot i {
  font-style: normal;
}

.step-check {
  display: none;
}

.step-label {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.step.is-current .step-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 6px var(--accent-glow);
  color: var(--accent-strong);
  transform: scale(1.08);
}

.step.is-current .step-label {
  color: var(--accent-strong);
}

.step.is-done .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.step.is-done .step-num {
  display: none;
}

.step.is-done .step-check {
  display: inline;
}

.step.is-done .step-label {
  color: var(--text);
}

.stepper[data-state="expired"] .step.is-current .step-dot {
  border-color: var(--red);
  box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.14);
  color: var(--red);
}

.stepper[data-state="expired"] .step.is-current .step-label {
  color: var(--red);
}

/* ---------- 卡密输入 ---------- */

.redeem-card {
  animation-delay: 0.1s;
  animation-fill-mode: both;
  padding: 30px 34px 26px;
}

.key-label {
  color: var(--text);
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.key-row {
  align-items: stretch;
  display: flex;
  gap: 12px;
}

.key-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
}

.key-icon {
  color: var(--text-dim);
  left: 16px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: color 0.2s ease;
}

.key-input-wrap:focus-within .key-icon {
  color: var(--accent-strong);
}

.key-input {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.12em;
  min-height: 56px;
  padding: 0 48px 0 48px;
  text-transform: uppercase;
  width: 100%;
}

.key-input::placeholder {
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: none;
}

.key-input:focus {
  box-shadow: 0 0 0 5px var(--accent-glow);
}

.key-input.is-invalid {
  animation: shakeX 0.4s ease;
  border-color: var(--red);
  box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.12);
}

.key-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.key-row .btn-lg {
  flex: 0 0 auto;
  min-height: 56px;
  min-width: 140px;
}

.redeem-card .status {
  margin-top: 14px;
  min-height: 24px;
}

.key-tips {
  border-top: 1px dashed var(--line);
  color: var(--text-dim);
  display: grid;
  font-size: 13px;
  gap: 6px;
  line-height: 1.6;
  list-style: none;
  margin-top: 16px;
  padding: 14px 0 0;
}

.key-tips li {
  padding-left: 20px;
  position: relative;
}

.key-tips li::before {
  color: var(--accent);
  content: "✓";
  font-weight: 800;
  left: 2px;
  position: absolute;
}

.key-tips strong {
  color: var(--text-soft);
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- 工作区 ---------- */

.redeem-page .workspace {
  gap: 18px;
  margin-top: 18px;
}

.redeem-page .workspace.is-entering .panel {
  animation: popIn 0.45s var(--ease) both;
}

.redeem-page .workspace.is-entering .sms-panel {
  animation-delay: 0.08s;
}

.task-panel,
.sms-panel {
  padding: 26px 28px;
}

.task-head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.task-title h2 {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
}

.task-title p {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
}

.task-head-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge.is-bump {
  animation: badgeBump 0.4s var(--ease-bounce);
}

@keyframes badgeBump {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.task-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.info-tile {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
}

.info-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.info-value {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.info-value[data-kind="warn"] { color: var(--orange); }
.info-value[data-kind="danger"] { color: var(--red); }
.info-value[data-kind="ok"] { color: var(--green); }

/* 号码卡片：按状态换颜色。 */
.phone-box {
  background: linear-gradient(180deg, #ffffff, #f7fbfa);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: 16px 18px;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.phone-box[data-state="waiting"] {
  background: linear-gradient(180deg, #ffffff, #effcf9);
  border-color: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-glow);
}

.phone-box[data-state="locked"] {
  background: linear-gradient(180deg, #ffffff, #fffaf0);
  border-color: #f5c66b;
}

.phone-box[data-state="done"] {
  background: linear-gradient(180deg, #ffffff, #effdf5);
  border-color: #6ee7b7;
}

.phone-box[data-state="expired"] {
  background: linear-gradient(180deg, #ffffff, #fef3f2);
  border-color: #fca5a5;
}

.phone-top {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.phone-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.phone-tag {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
}

.phone-tag[data-kind="warn"] { background: #fef3c7; color: #92400e; }
.phone-tag[data-kind="ok"] { background: #d1fae5; color: #065f46; }
.phone-tag[data-kind="danger"] { background: #fee2e2; color: #991b1b; }

.phone-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: space-between;
}

.phone-number {
  color: var(--text);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.phone-box[data-state="empty"] .phone-number {
  color: var(--text-dim);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
}

.phone-number.is-fresh {
  animation: numberFlash 1.2s ease;
}

@keyframes numberFlash {
  0% { color: var(--accent-strong); text-shadow: 0 0 18px rgba(20, 184, 166, 0.5); transform: scale(1.03); }
  100% { color: var(--text); text-shadow: none; transform: scale(1); }
}

.phone-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.copy-link {
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  min-height: 0;
  padding: 0;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.copy-link:hover:not(:disabled) {
  background: none;
  color: var(--accent-strong);
}

.phone-sub {
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.55;
  min-height: 0;
}

.phone-sub:empty {
  display: none;
}

.task-actions {
  gap: 10px;
}

.task-actions .btn-lg {
  min-width: 160px;
}

.cooldown {
  background: #e6efed;
  border-radius: 999px;
  height: 5px;
  margin-top: 14px;
  overflow: hidden;
}

.cooldown[hidden] {
  display: none;
}

.cooldown i {
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  display: block;
  height: 100%;
  transition: width 1s linear;
  width: var(--p, 0%);
}

.redeem-page .hint {
  color: var(--text-dim);
  font-size: 13.5px;
  margin-top: 10px;
}

/* ---------- 短信面板 ---------- */

.poll-indicator {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  min-height: 32px;
  padding: 4px 12px 4px 10px;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.pulse {
  background: #94a3b8;
  border-radius: 50%;
  display: inline-block;
  height: 9px;
  position: relative;
  width: 9px;
}

.poll-indicator[data-state="polling"] {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.poll-indicator[data-state="polling"] .pulse {
  background: #10b981;
}

.poll-indicator[data-state="polling"] .pulse::after {
  animation: pulseRing 1.6s ease-out infinite;
  border: 2px solid #10b981;
  border-radius: 50%;
  content: "";
  inset: -4px;
  position: absolute;
}

.poll-indicator[data-state="retrying"] {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.poll-indicator[data-state="retrying"] .pulse {
  animation: blink 1s ease-in-out infinite;
  background: #f59e0b;
}

.poll-indicator[data-state="done"] {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.poll-indicator[data-state="done"] .pulse {
  background: #10b981;
}

.poll-indicator[data-state="stopped"] .pulse,
.poll-indicator[data-state="idle"] .pulse {
  background: #cbd5e1;
}

.poll-indicator[data-state="error"] {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.poll-indicator[data-state="error"] .pulse {
  background: #ef4444;
}

@keyframes pulseRing {
  0% { opacity: 0.9; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(2.2); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.redeem-page .message-list {
  gap: 12px;
}

.redeem-page .message-list.empty {
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--text-dim);
  padding: 0;
}

.message-empty {
  align-items: center;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 18px;
  text-align: center;
}

.message-empty svg {
  color: #a9bdb9;
}

.message-empty p {
  font-size: 14px;
  line-height: 1.6;
}

.redeem-page .message {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.redeem-page .message.is-new {
  animation: popIn 0.5s var(--ease-bounce), messageGlow 2.4s ease;
  border-color: #6ee7b7;
}

@keyframes messageGlow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: var(--shadow-sm); }
}

.message-code-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: space-between;
}

.message-code {
  color: var(--accent-deep);
  cursor: pointer;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  margin: 0;
  user-select: all;
}

.message-code.no-code {
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}

.message-meta {
  align-items: center;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  font-size: 12.5px;
  gap: 6px 12px;
}

.message-meta .message-index {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-strong);
  font-weight: 700;
  padding: 1px 8px;
}

.message-text {
  background: var(--surface-soft);
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 10px 12px;
}

.redeem-page .notice {
  margin: 14px 0 0;
}

/* ---------- 页脚 ---------- */

.redeem-footer {
  align-items: center;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  font-size: 12.5px;
  gap: 8px 14px;
  justify-content: center;
  margin-top: 30px;
}

.footer-clock {
  font-variant-numeric: tabular-nums;
}

.footer-clock:empty {
  display: none;
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .redeem-shell {
    padding: 26px 14px 40px;
  }

  .redeem-hero {
    margin-bottom: 20px;
  }

  .redeem-hero h1 {
    font-size: 34px;
  }

  .stepper {
    margin-bottom: 16px;
  }

  .step-label {
    font-size: 11.5px;
  }

  .step-dot {
    height: 32px;
    width: 32px;
  }

  .step:not(:first-child)::before {
    top: 15px;
  }

  .redeem-card,
  .task-panel,
  .sms-panel {
    padding: 22px 18px;
  }

  .key-row {
    flex-direction: column;
  }

  .key-input {
    font-size: 18px;
    letter-spacing: 0.1em;
  }

  /* 公共窄屏规则把按钮拉满，这里的小按钮保持内容宽度。 */
  .task-head-actions .btn,
  .copy-btn,
  .key-clear,
  .copy-link {
    width: auto;
  }

  .task-head-actions {
    width: 100%;
  }

  .task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-grid .info-tile:last-child {
    grid-column: 1 / -1;
  }

  .phone-number {
    font-size: 26px;
  }

  .task-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-actions .btn-lg,
  .task-actions .btn:nth-child(4) {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .message-code {
    font-size: 30px;
  }
}

@media (max-width: 400px) {
  .step-label {
    font-size: 10.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb {
    animation: none;
  }

  .poll-indicator[data-state="polling"] .pulse::after {
    animation: none;
    display: none;
  }
}
