/**
 * ai-components.css
 * 全局基线样式：snippet 组件 + Typography CSS class + Design Tokens fallback
 *
 * 加载顺序：Design Tokens (:root) → 本文件 → 全局动态 CSS → section CSS
 * 所有值引用 var(--xxx)，不硬编码。
 */

/* ═══════════════════════════════════════════════════════════════════
   Snippet 组件基线
   ═══════════════════════════════════════════════════════════════════ */

/* ── ai-btn ─────────────────────────────────────────────────────── */

.ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  font-family: var(--body-font);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transition-base);
}

.ai-btn--sm { height: 36px; padding: 0 var(--spacing-md); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.ai-btn--md { height: 44px; padding: 0 var(--spacing-lg); font-size: var(--text-md); border-radius: var(--radius-md); }
.ai-btn--lg { height: 52px; padding: 0 32px; font-size: var(--text-lg); border-radius: var(--radius-md); }

.ai-btn--default { background: var(--brand-color); color: #fff; }
.ai-btn--default:hover { opacity: 0.9; }
.ai-btn--outline { background: transparent; border: 1.5px solid var(--brand-color); color: var(--brand-color); }
.ai-btn--outline:hover { background: var(--brand-color); color: #fff; }
.ai-btn--ghost { background: transparent; color: var(--brand-color); padding-left: 0; padding-right: 0; }
.ai-btn--ghost:hover { opacity: 0.7; }
.ai-btn:disabled,
.ai-btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── ai-grid ────────────────────────────────────────────────────── */

.ai-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
}
.ai-grid--sm { gap: var(--spacing-sm); }
.ai-grid--md { gap: var(--spacing-md); }
.ai-grid--lg { gap: var(--spacing-lg); }

@media (max-width: 749px) {
  .ai-grid { grid-template-columns: repeat(var(--columns-mobile, 1), 1fr); }
}
@media (min-width: 750px) and (max-width: 1023px) {
  .ai-grid { grid-template-columns: repeat(min(var(--columns, 3), 2), 1fr); }
}

/* ── ai-icon ────────────────────────────────────────────────────── */

.ai-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: currentColor; }
.ai-icon--sm { width: 16px; height: 16px; }
.ai-icon--md { width: 20px; height: 20px; }
.ai-icon--lg { width: 24px; height: 24px; }
.ai-icon svg { width: 100%; height: 100%; }

/* ── ai-image ───────────────────────────────────────────────────── */

.ai-image { position: relative; overflow: hidden; width: 100%; }
.ai-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ai-image--16\:9 { aspect-ratio: 16/9; }
.ai-image--4\:3 { aspect-ratio: 4/3; }
.ai-image--3\:2 { aspect-ratio: 3/2; }
.ai-image--1\:1 { aspect-ratio: 1/1; }
.ai-image--3\:4 { aspect-ratio: 3/4; }
.ai-image--auto { aspect-ratio: auto; }

/* ── ai-container (section-mark) ────────────────────────────────── */

.section-mark { background-color: var(--bg-color); color: var(--text-color); }

.padding-top-none { padding-top: 0; }
.padding-top-sm { padding-top: var(--spacing-sm); }
.padding-top-md { padding-top: var(--spacing-lg); }
.padding-top-lg { padding-top: var(--spacing-xl); }
.padding-top-xl { padding-top: var(--spacing-2xl); }

.padding-bottom-none { padding-bottom: 0; }
.padding-bottom-sm { padding-bottom: var(--spacing-sm); }
.padding-bottom-md { padding-bottom: var(--spacing-lg); }
.padding-bottom-lg { padding-bottom: var(--spacing-xl); }
.padding-bottom-xl { padding-bottom: var(--spacing-2xl); }

.full-screen { width: 100vw; margin-left: calc(-50vw + 50%); }

/* ═══════════════════════════════════════════════════════════════════
   Typography CSS Classes
   ═══════════════════════════════════════════════════════════════════ */

/* ── Headings (.ai-h1 ~ .ai-h4) ────────────────────────────────── */

.ai-h1, .ai-h2, .ai-h3, .ai-h4 {
  font-family: var(--heading-font);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-color);
  margin: 0;
}
.ai-h1 { font-size: var(--heading-xl); }
.ai-h2 { font-size: var(--heading-lg); }
.ai-h3 { font-size: var(--heading-md); }
.ai-h4 { font-size: var(--heading-sm); }

/* ── Body text (.ai-p) ──────────────────────────────────────────── */

.ai-p {
  font-family: var(--body-font);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text-color);
  margin: 0;
}

/* ── Small text (.ai-small) ─────────────────────────────────────── */

.ai-small {
  font-family: var(--body-font);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-color);
  opacity: 0.8;
}

/* ── Blockquote (.ai-blockquote) ────────────────────────────────── */

.ai-blockquote {
  font-family: var(--heading-font);
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.6;
  color: var(--text-color);
  margin: 0;
  padding-left: var(--spacing-lg);
  border-left: 3px solid var(--brand-color);
}

/* ═══════════════════════════════════════════════════════════════════
   Utility Components (CSS-only)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Badge (.ai-badge) ──────────────────────────────────────────── */

.ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px var(--spacing-sm);
  font-family: var(--body-font);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.ai-badge--default { background: var(--brand-color); color: #fff; }
.ai-badge--sale { background: var(--striking-color); color: #fff; }
.ai-badge--new { background: var(--accent-color); color: #fff; }
.ai-badge--hot { background: var(--striking-color); color: #fff; }
.ai-badge--outline { background: transparent; border: 1px solid var(--brand-color); color: var(--brand-color); }

/* ── Separator (.ai-separator) ──────────────────────────────────── */

.ai-separator {
  border: none;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.1));
  margin: var(--spacing-lg) 0;
}

/* ── Section Header (.ai-section-header) ────────────────────────── */

.ai-section-header {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
}
.ai-section-header--left { align-items: flex-start; text-align: left; }
.ai-section-header--center { align-items: center; text-align: center; }
.ai-section-header--right { align-items: flex-end; text-align: right; }
.ai-section-header__sub {
  font-family: var(--body-font);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--secondary-color);
}
.ai-section-header__desc {
  max-width: 600px;
  opacity: 0.8;
}

/* ── Card (.ai-card) ────────────────────────────────────────────── */

.ai-card {
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-base);
  text-decoration: none;
  color: inherit;
}
.ai-card--flat { background: transparent; }
.ai-card--elevated { background: var(--bg-color); box-shadow: var(--shadow-md); }
.ai-card--elevated:hover { box-shadow: var(--shadow-lg); }
.ai-card--outlined { background: var(--bg-color); border: 1px solid rgba(0,0,0,0.1); }

/* ═══════════════════════════════════════════════════════════════════
   Shared Animations
   ═══════════════════════════════════════════════════════════════════ */

/* ── Entrance (one-shot, fill: both) ───────────────────────────── */

@keyframes ai-fade-in      { from { opacity: 0 } to { opacity: 1 } }
@keyframes ai-fade-in-up   { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ai-fade-in-down { from { opacity: 0; transform: translateY(-20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ai-fade-in-left { from { opacity: 0; transform: translateX(-20px) } to { opacity: 1; transform: translateX(0) } }
@keyframes ai-fade-in-right{ from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: translateX(0) } }
@keyframes ai-scale-in     { from { opacity: 0; transform: scale(0.95) } to { opacity: 1; transform: scale(1) } }
@keyframes ai-slide-up     { from { transform: translateY(100%) } to { transform: translateY(0) } }
@keyframes ai-bounce-in    { 0% { opacity: 0; transform: scale(0.3) } 50% { opacity: 1; transform: scale(1.05) } 70% { transform: scale(0.95) } 100% { transform: scale(1) } }
@keyframes ai-rotate-in    { from { opacity: 0; transform: rotate(-90deg) } to { opacity: 1; transform: rotate(0) } }
@keyframes ai-flip-in      { from { opacity: 0; transform: perspective(400px) rotateY(-90deg) } to { opacity: 1; transform: perspective(400px) rotateY(0) } }
@keyframes ai-blur-in      { from { opacity: 0; filter: blur(12px) } to { opacity: 1; filter: blur(0) } }
@keyframes ai-typewriter    { from { width: 0 } to { width: 100% } }

.ai-animate-fade-in       { animation: ai-fade-in var(--transition-base) both }
.ai-animate-fade-in-up    { animation: ai-fade-in-up var(--transition-base) both }
.ai-animate-fade-in-down  { animation: ai-fade-in-down var(--transition-base) both }
.ai-animate-fade-in-left  { animation: ai-fade-in-left var(--transition-base) both }
.ai-animate-fade-in-right { animation: ai-fade-in-right var(--transition-base) both }
.ai-animate-scale-in      { animation: ai-scale-in var(--transition-base) both }
.ai-animate-slide-up      { animation: ai-slide-up var(--transition-base) both }
.ai-animate-bounce-in     { animation: ai-bounce-in 0.6s cubic-bezier(0.34,1.56,0.64,1) both }
.ai-animate-rotate-in     { animation: ai-rotate-in var(--transition-base) both }
.ai-animate-flip-in       { animation: ai-flip-in 0.5s ease both }
.ai-animate-blur-in       { animation: ai-blur-in 0.6s ease both }
.ai-animate-typewriter     { overflow: hidden; white-space: nowrap; border-right: 2px solid var(--text-color); animation: ai-typewriter 2s steps(30) both }

/* ── Looping (infinite) ────────────────────────────────────────── */

@keyframes ai-pulse        { 0%, 100% { opacity: 1 } 50% { opacity: 0.6 } }
@keyframes ai-float        { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
@keyframes ai-shimmer      { from { background-position: -200% 0 } to { background-position: 200% 0 } }
@keyframes ai-scan-line    { from { transform: translateY(-100%) } to { transform: translateY(100%) } }
@keyframes ai-glitch       { 0%, 100% { transform: translate(0) } 20% { transform: translate(-2px, 1px) } 40% { transform: translate(2px, -1px) } 60% { transform: translate(-1px, -2px) } 80% { transform: translate(1px, 2px) } }
@keyframes ai-shake        { 0%, 100% { transform: translateX(0) } 25% { transform: translateX(-4px) } 75% { transform: translateX(4px) } }
@keyframes ai-spin         { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }
@keyframes ai-ping         { 0% { transform: scale(1); opacity: 1 } 75%, 100% { transform: scale(2); opacity: 0 } }
@keyframes ai-bounce       { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-25%) } }
@keyframes ai-wiggle       { 0%, 100% { transform: rotate(0) } 25% { transform: rotate(-6deg) } 75% { transform: rotate(6deg) } }

.ai-animate-pulse          { animation: ai-pulse 2s ease-in-out infinite }
.ai-animate-float          { animation: ai-float 3s ease-in-out infinite }
.ai-animate-shimmer        { animation: ai-shimmer 2s linear infinite; background-size: 200% 100% }
.ai-animate-scan-line      { animation: ai-scan-line 3s linear infinite }
.ai-animate-glitch         { animation: ai-glitch 4s infinite }
.ai-animate-shake          { animation: ai-shake 0.4s ease }
.ai-animate-spin           { animation: ai-spin 1s linear infinite }
.ai-animate-ping           { animation: ai-ping 1.5s cubic-bezier(0,0,0.2,1) infinite }
.ai-animate-bounce         { animation: ai-bounce 1s ease-in-out infinite }
.ai-animate-wiggle         { animation: ai-wiggle 0.5s ease }

/* ── Exit (one-shot, fill: both) ──────────────────────────────── */

@keyframes ai-fade-out     { from { opacity: 1 } to { opacity: 0 } }

.ai-animate-fade-out       { animation: ai-fade-out var(--transition-base) both }

/* ── Stagger delays for list items ─────────────────────────────── */

.ai-delay-1 { animation-delay: 0.1s }
.ai-delay-2 { animation-delay: 0.2s }
.ai-delay-3 { animation-delay: 0.3s }
.ai-delay-4 { animation-delay: 0.4s }
.ai-delay-5 { animation-delay: 0.5s }
.ai-delay-6 { animation-delay: 0.6s }
.ai-delay-7 { animation-delay: 0.7s }
.ai-delay-8 { animation-delay: 0.8s }

@media (prefers-reduced-motion: reduce) {
  [class*="ai-animate-"] { animation: none !important; }
}
