/* card.css — 分享卡片 Modal 样式（Phase 3） */

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
  /* iOS 安全区 */
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
}

.share-modal--open {
  display: flex;
}

/* Modal 打开时禁止 body 滚动 */
body.modal-open {
  overflow: hidden;
}

.share-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

.share-modal__panel {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.share-modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.share-modal__title {
  font-size: var(--text-lg);
  margin: 0;
}

.share-modal__close {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--space-2);
  transition: color 0.15s ease;
}

.share-modal__close:hover {
  color: var(--color-text-primary);
}

/* ---------- 加载态 ---------- */
.share-modal__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) 0;
  color: var(--color-text-secondary);
  text-align: center;
}

.share-modal__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- 成品预览 ---------- */
.share-modal__preview {
  /* 容器宽度自适应，图片居中，高度交给 img 限制 */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  margin-bottom: var(--space-3);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

/*
 * 海报是 9:16 竖长图（原尺寸 1080×1920），宽度优先会导致高度超出屏幕，
 * 用户看不到底部二维码。改成高度优先：max-height 限制6成视口高，
 * 宽度自动按 9:16 算。这样不论桌面手机都能一眼看全。
 */
.share-modal__preview img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.share-modal__hint {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: var(--space-3);
  line-height: 1.6;
}

.share-modal__actions {
  display: flex;
  gap: var(--space-3);
}

.share-modal__actions .btn {
  flex: 1;
}

/* ---------- 错误态 ---------- */
.share-modal__error {
  text-align: center;
  padding: var(--space-5) 0;
  color: var(--color-text-secondary);
}

.share-modal__error p {
  margin-bottom: var(--space-3);
}

/* ---------- 动效 ---------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
  .share-modal__panel {
    padding: var(--space-3);
  }
}

/* ---------- 屏幕切换动效（Phase 3 体验打磨） ---------- */
.screen--active {
  animation: screenFadeIn 0.3s ease;
}

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

/* 结果页 hero 区入场动效（稍微延后，突出戏剧感） */
#screen-result.screen--active .result-hero {
  animation: resultHeroIn 0.5s ease 0.1s both;
}

@keyframes resultHeroIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 15 维度卡片错落入场 */
#screen-result.screen--active .dim-item {
  animation: dimItemIn 0.4s ease both;
}

#screen-result.screen--active .dim-item:nth-child(1) { animation-delay: 0.15s; }
#screen-result.screen--active .dim-item:nth-child(2) { animation-delay: 0.18s; }
#screen-result.screen--active .dim-item:nth-child(3) { animation-delay: 0.21s; }
#screen-result.screen--active .dim-item:nth-child(4) { animation-delay: 0.24s; }
#screen-result.screen--active .dim-item:nth-child(5) { animation-delay: 0.27s; }
#screen-result.screen--active .dim-item:nth-child(6) { animation-delay: 0.30s; }
#screen-result.screen--active .dim-item:nth-child(7) { animation-delay: 0.33s; }
#screen-result.screen--active .dim-item:nth-child(8) { animation-delay: 0.36s; }
#screen-result.screen--active .dim-item:nth-child(9) { animation-delay: 0.39s; }
#screen-result.screen--active .dim-item:nth-child(10) { animation-delay: 0.42s; }
#screen-result.screen--active .dim-item:nth-child(11) { animation-delay: 0.45s; }
#screen-result.screen--active .dim-item:nth-child(12) { animation-delay: 0.48s; }
#screen-result.screen--active .dim-item:nth-child(13) { animation-delay: 0.51s; }
#screen-result.screen--active .dim-item:nth-child(14) { animation-delay: 0.54s; }
#screen-result.screen--active .dim-item:nth-child(15) { animation-delay: 0.57s; }

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

/* 尊重用户减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .screen--active,
  #screen-result.screen--active .result-hero,
  #screen-result.screen--active .dim-item,
  .share-modal__backdrop,
  .share-modal__panel {
    animation: none !important;
  }
}
