/* Apple-style motion system */
:root {
  --ease-apple: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-apple-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --duration-fast: 0.28s;
  --duration-normal: 0.48s;
  --duration-slow: 0.62s;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0.01ms;
    --duration-normal: 0.01ms;
    --duration-slow: 0.01ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #1e293b;
  background-color: #FBFBFD;
}

/* ── Inputs ── */
.apple-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #F5F5F7;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  font-size: 15px;
  transition:
    background var(--duration-fast) var(--ease-apple),
    border-color var(--duration-fast) var(--ease-apple),
    box-shadow var(--duration-fast) var(--ease-apple),
    transform var(--duration-fast) var(--ease-spring);
}

.apple-input::placeholder { color: #94a3b8; }

.apple-input:focus {
  outline: none;
  background: white;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
  transform: scale(1.005);
}

/* ── Buttons ── */
.apple-button,
.btn-press {
  transition:
    transform var(--duration-fast) var(--ease-spring),
    background var(--duration-fast) var(--ease-apple),
    box-shadow var(--duration-fast) var(--ease-apple),
    opacity var(--duration-fast) var(--ease-apple);
  will-change: transform;
}

.apple-button {
  width: 100%;
  padding: 1rem;
  background: #0071E3;
  color: white;
  border-radius: 1rem;
  font-weight: 500;
  font-size: 1.125rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px 0 rgba(0, 118, 227, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.apple-button:hover:not(:disabled) {
  background: #0077ED;
  box-shadow: 0 6px 20px 0 rgba(0, 118, 227, 0.32);
  transform: translateY(-1px);
}

.apple-button:active:not(:disabled),
.btn-press:active:not(:disabled) {
  transform: scale(0.97) translateY(0);
  box-shadow: 0 2px 8px 0 rgba(0, 118, 227, 0.2);
}

.apple-button:disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.apple-button.is-loading {
  pointer-events: none;
}

/* ── Layout ── */
.mesh-gradient {
  background-color: #fbfbfd;
  background-image:
    radial-gradient(at 0% 0%, hsla(210, 100%, 98%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(220, 100%, 97%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(240, 100%, 98%, 1) 0, transparent 50%);
}

.apple-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20fill%3D%22none%22%20viewBox%3D%220%200%2020%2020%22%3E%3Cpath%20stroke%3D%22%236B7280%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%221.5%22%20d%3D%22m6%208%204%204%204-4%22%2F%3E%3C%2Fsvg%3E");
  background-size: 1.25rem 1.25rem;
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
}

/* ── Page enter（不阻塞点击：默认可见，仅做位移动效）── */
.page-enter {
  animation: pageEnter var(--duration-slow) var(--ease-apple) both;
}

.hero-stagger > * {
  animation: heroFadeUp var(--duration-slow) var(--ease-apple) both;
}
.hero-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.hero-stagger > *:nth-child(2) { animation-delay: 0.12s; }
.hero-stagger > *:nth-child(3) { animation-delay: 0.19s; }
.hero-stagger > *:nth-child(4) { animation-delay: 0.26s; }

.card-stagger > * {
  animation: cardSlideUp var(--duration-slow) var(--ease-apple) both;
  pointer-events: auto;
}
.card-stagger > *:nth-child(1) { animation-delay: 0.08s; }
.card-stagger > *:nth-child(2) { animation-delay: 0.16s; }
.card-stagger > *:nth-child(3) { animation-delay: 0.24s; }

@keyframes pageEnter {
  from { transform: translateY(20px); }
  to { transform: translateY(0); }
}

@keyframes heroFadeUp {
  from { transform: translateY(12px); }
  to { transform: translateY(0); }
}

@keyframes cardSlideUp {
  from { transform: translateY(16px) scale(0.99); }
  to { transform: translateY(0) scale(1); }
}

/* ── 页面切换动效（苹果风格 blur + 位移）── */
#stage-success[hidden],
#stage-form[hidden],
.view-hidden {
  display: none !important;
}

.motion-stage-enter {
  animation: appleStageIn var(--duration-slow) var(--ease-apple) both;
}

.motion-stage-exit {
  animation: appleStageOut 0.42s var(--ease-apple-out) both;
  pointer-events: none;
}

@keyframes appleStageIn {
  from {
    opacity: 0.5;
    transform: translateY(22px) scale(0.96);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes appleStageOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-14px) scale(0.97);
    filter: blur(6px);
  }
}

/* 成功页内部元素依次弹出 */
.motion-pop {
  animation: motionPop 0.5s var(--ease-spring) both;
}

@keyframes motionPop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 弹窗 sheet */
.motion-sheet-enter {
  animation: sheetIn 0.52s var(--ease-spring) both;
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.btn-press.is-pressed,
.apple-button.is-pressed,
.filter-tab.is-pressed,
.benefit-card.is-pressed {
  transform: scale(0.97) !important;
}

/* ── Benefit cards：左侧单选圆点始终可见 ── */
.benefit-card {
  align-items: flex-start;
  border: 2px solid #e2e8f0;
  background-color: #f8fafc;
  transition:
    border-color var(--duration-fast) var(--ease-apple),
    background-color var(--duration-fast) var(--ease-apple),
    box-shadow var(--duration-fast) var(--ease-apple);
}

.benefit-card:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.benefit-card:has(input[type="radio"]:checked),
.benefit-card.is-selected {
  border-color: #3b82f6 !important;
  background-color: #eff6ff !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.benefit-card:has(input[type="radio"]:checked) .benefit-label,
.benefit-card.is-selected .benefit-label {
  color: #1d4ed8 !important;
}

/* 单选圆点：未选空心，选中蓝底白勾 */
.benefit-radio {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid #94a3b8;
  background: #fff;
  box-sizing: border-box;
  position: relative;
  transition:
    border-color var(--duration-fast) var(--ease-apple),
    background-color var(--duration-fast) var(--ease-apple);
}

.benefit-card:has(input[type="radio"]:checked) .benefit-radio,
.benefit-card.is-selected .benefit-radio {
  border-color: #0071e3;
  background-color: #0071e3;
}

.benefit-card:has(input[type="radio"]:checked) .benefit-radio::after,
.benefit-card.is-selected .benefit-radio::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 9px;
  margin-top: -1px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* ── Error alert ── */
.alert-motion {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    max-height var(--duration-normal) var(--ease-apple),
    opacity var(--duration-normal) var(--ease-apple),
    transform var(--duration-normal) var(--ease-apple),
    margin var(--duration-normal) var(--ease-apple);
  margin-top: 0 !important;
}

.alert-motion.is-visible {
  max-height: 120px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 0;
}

/* ── Success 图标弹跳（由 JS replayPop 触发子元素）── */
.success-icon-wrap.motion-pop {
  animation: successIconIn 0.65s var(--ease-spring) both;
}

@keyframes successIconIn {
  from { transform: scale(0.5); }
  65% { transform: scale(1.08); }
  to { transform: scale(1); }
}

/* ── Contact pill button ── */
.btn-pill {
  transition:
    transform var(--duration-fast) var(--ease-spring),
    background var(--duration-fast) var(--ease-apple),
    box-shadow var(--duration-fast) var(--ease-apple);
}

.btn-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

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

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--duration-normal) var(--ease-apple),
    background var(--duration-normal) var(--ease-apple),
    backdrop-filter var(--duration-normal) var(--ease-apple),
    visibility 0s linear var(--duration-normal);
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    opacity var(--duration-normal) var(--ease-apple),
    background var(--duration-normal) var(--ease-apple),
    backdrop-filter var(--duration-normal) var(--ease-apple),
    visibility 0s;
}

.modal-sheet {
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  transform: translateY(24px) scale(0.92);
  opacity: 0;
  transition:
    transform var(--duration-slow) var(--ease-spring),
    opacity var(--duration-normal) var(--ease-apple);
}

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

.modal-overlay.is-closing {
  opacity: 0;
  pointer-events: none;
  background: rgba(15, 23, 42, 0);
  backdrop-filter: blur(0);
}

.modal-overlay.is-closing .modal-sheet {
  transform: translateY(16px) scale(0.94);
  opacity: 0;
  transition-duration: 0.32s;
  transition-timing-function: var(--ease-apple-out);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.modal-actions button {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.9375rem;
  border: none;
  cursor: pointer;
}

.modal-btn-cancel {
  background: #f1f5f9;
  color: #334155;
}

.modal-btn-confirm {
  background: #0071e3;
  color: white;
}

.modal-btn-danger {
  background: #dc2626;
  color: white;
}

/* ── Toast ── */
.toast-stack {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-item {
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #0f172a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: toastIn 0.45s var(--ease-spring) forwards;
}

.toast-item.is-leaving {
  animation: toastOut 0.32s var(--ease-apple-out) forwards;
}

.toast-item.toast-success { color: #15803d; }
.toast-item.toast-error { color: #b91c1c; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── Spinner ── */
.spin {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden-view {
  display: none !important;
}
