/* ============================================
   XZL Core CSS — Variables + Base + Animations
   Merged for performance: eliminates 3 HTTP requests
   ============================================ */

/* ============================================
   SECTION 1: Design Tokens
   ============================================ */
:root {
  /* ---- Brand Colors ---- */
  --color-primary:        #1A5632;
  --color-primary-hover:  #22874A;
  --color-primary-light:  #2EA062;
  --color-accent:         #D4A853;
  --color-accent-hover:   #C49A45;

  /* ---- Backgrounds ---- */
  --bg-primary:     #FFFFFF;
  --bg-secondary:   #F5F7F5;
  --bg-tertiary:    #E8EDE8;
  --bg-dark:        #0F1F15;
  --bg-glass:       rgba(255, 255, 255, 0.72);

  /* ---- Text ---- */
  --text-primary:     #1A1A2E;
  --text-secondary:   #4A5568;
  --text-tertiary:    #A0AEC0;
  --text-on-dark:     #FFFFFF;
  --text-on-primary:  #FFFFFF;

  /* ---- Functional ---- */
  --color-success: #38A169;
  --color-warning: #ECC94B;
  --color-error:   #E53E3E;
  --color-info:    #3182CE;

  /* ---- Gradients ---- */
  --gradient-primary:   linear-gradient(135deg, #1A5632 0%, #22874A 50%, #2EA062 100%);
  --gradient-hero:      linear-gradient(160deg, #0F1F15 0%, #1A5632 40%, #22874A 100%);
  --gradient-card:      linear-gradient(180deg, rgba(26,86,50,0.04) 0%, rgba(26,86,50,0) 100%);
  --gradient-glass:     linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.6) 100%);
  --gradient-accent:    linear-gradient(135deg, #D4A853 0%, #E8C97A 100%);

  /* ---- Shadows ---- */
  --shadow-xs:   0 1px 2px rgba(15, 31, 21, 0.05);
  --shadow-sm:   0 2px 8px rgba(15, 31, 21, 0.06);
  --shadow-md:   0 4px 16px rgba(15, 31, 21, 0.08);
  --shadow-lg:   0 8px 32px rgba(15, 31, 21, 0.10);
  --shadow-xl:   0 16px 48px rgba(15, 31, 21, 0.12);
  --shadow-glow: 0 0 40px rgba(46, 160, 98, 0.15);

  /* ---- Border Radius ---- */
  --radius-sm:   0.375rem;
  --radius-md:   0.625rem;
  --radius-lg:   1rem;
  --radius-xl:   1.5rem;
  --radius-2xl:  2rem;
  --radius-full: 9999px;

  /* ---- Spacing Scale ---- */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* ---- Typography (系统字体优先，本地加载无延迟) ---- */
  --font-display: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --font-body:    'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, -apple-system, sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;
  --text-5xl:  3rem;
  --text-6xl:  3.75rem;
  --text-7xl:  4.5rem;

  --leading-tight:   1.2;
  --leading-snug:    1.375;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;

  --tracking-tighter: -0.03em;
  --tracking-tight:   -0.015em;
  --tracking-normal:  0;
  --tracking-wide:    0.025em;

  /* ---- Transitions ---- */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:     cubic-bezier(0.7, 0, 0.84, 0);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --duration-fast:   150ms;
  --duration-normal: 300ms;
  --duration-slow:   500ms;
  --duration-slower: 800ms;

  /* ---- Layout ---- */
  --max-width:    1400px;
  --nav-height:   72px;
  --section-py:   clamp(4rem, 8vw, 7rem);

  /* ---- Z-Index Scale ---- */
  --z-base:      1;
  --z-sticky:    100;
  --z-nav:       1000;
  --z-overlay:   2000;
  --z-modal:     3000;
  --z-toast:     4000;
}

/* ---- Dark Mode ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary:     #0F1F15;
    --bg-secondary:   #162B1E;
    --bg-tertiary:    #1E3A28;
    --text-primary:   #F5F7F5;
    --text-secondary: #A0AEC0;
    --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg:      0 8px 32px rgba(0, 0, 0, 0.3);
  }
}

/* ============================================
   SECTION 2: Base Reset & Typography
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed; /* optimizeLegibility 会触发 layout 代价较大 */
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
  min-height: 100dvh;
}

img, video, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button { cursor: pointer; }
ul, ol { list-style: none; }

/* ---- Focus Styles ---- */
:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

h1 { font-size: clamp(2.25rem, 5vw, 4.5rem); letter-spacing: var(--tracking-tighter); }
h2 { font-size: clamp(1.75rem, 3.5vw, 3rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.875rem); }
h4 { font-size: var(--text-xl); }

p {
  max-width: 65ch;
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* ---- Layout Utilities ---- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section { padding: var(--section-py) 0; }
.section--dark { background-color: var(--bg-dark); color: var(--text-on-dark); }
.section--dark h2, .section--dark h3 { color: var(--text-on-dark); }
.section--dark p { color: rgba(255, 255, 255, 0.7); }
.section--alt { background-color: var(--bg-secondary); }

/* ---- Section Header ---- */
.section-header {
  text-align: center;
  max-width: 680px;
  margin: 0 auto var(--space-16);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary-light);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-4);
}

.section-label::before {
  content: '';
  width: 24px;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
}

.section-title { margin-bottom: var(--space-4); }

.section-desc {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 60ch;
  margin: 0 auto;
}

/* ---- Glass Effect ---- */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.glass-dark {
  background: rgba(15, 31, 21, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---- Button System ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-8);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-full);
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-out);
}

.btn:hover::after { transform: translateX(0); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-md), 0 4px 20px rgba(26, 86, 50, 0.25);
}

.btn-primary:hover {
  box-shadow: var(--shadow-lg), 0 8px 30px rgba(26, 86, 50, 0.35);
  transform: translateY(-1px);
}

.btn-outline {
  border: 1.5px solid var(--color-primary);
  color: var(--color-primary);
  background: transparent;
}

.btn-outline:hover {
  background: var(--color-primary);
  color: var(--text-on-primary);
}

.btn-outline-white {
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: var(--text-on-dark);
  background: transparent;
}

.btn-outline-white:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-ghost {
  color: var(--color-primary);
  padding: var(--space-2) var(--space-4);
}

.btn-ghost:hover { background: rgba(26, 86, 50, 0.06); }
.btn-lg { padding: var(--space-4) var(--space-10); font-size: var(--text-lg); }
.btn-sm { padding: var(--space-2) var(--space-5); font-size: var(--text-sm); }

/* ---- Card System ---- */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(26, 86, 50, 0.08);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(26, 86, 50, 0.15);
  transform: translateY(-4px);
}

.card-body { padding: var(--space-6); }

/* ---- Badge / Tag ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: rgba(26, 86, 50, 0.08);
  color: var(--color-primary);
}

.badge-accent {
  background: rgba(212, 168, 83, 0.12);
  color: #A07D2F;
}

/* ---- Grid Helpers ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-8); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-8); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-8); }

@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---- Scroll Animations ---- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
.reveal-left.is-visible { opacity: 1; transform: translateX(0); }

.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
.reveal-right.is-visible { opacity: 1; transform: translateX(0); }

.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
.reveal-scale.is-visible { opacity: 1; transform: scale(1); }

.stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
.stagger.is-visible > * { opacity: 1; transform: translateY(0); }

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal, .reveal-left, .reveal-right, .reveal-scale, .stagger > * {
    opacity: 1;
    transform: none;
  }
}

/* ---- Page content offset ---- */
.page-content { padding-top: var(--nav-height); }

/* ---- Divider ---- */
.divider {
  width: 60px;
  height: 3px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
}

/* ---- Text Utilities ---- */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-accent { color: var(--color-accent); }

/* ---- Icon Container ---- */
.icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  flex-shrink: 0;
}
.icon-box--sm { width: 40px; height: 40px; border-radius: var(--radius-md); }
.icon-box--outline {
  background: transparent;
  border: 1.5px solid rgba(26, 86, 50, 0.15);
  color: var(--color-primary);
}

/* ============================================
   SECTION 3: Animations & Keyframes
   ============================================ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes float-slow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes gradient-rotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

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

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes scaleInBounce {
  0%   { opacity: 0; transform: scale(0.3); }
  50%  { transform: scale(1.05); }
  70%  { transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideInFromBottom {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes slideInFromRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 40s linear infinite;
}
.marquee-track:hover { animation-play-state: paused; }

@keyframes border-glow {
  0%, 100% { border-color: rgba(46, 160, 98, 0.2); }
  50% { border-color: rgba(46, 160, 98, 0.5); }
}
.border-glow { animation: border-glow 2s ease-in-out infinite; }

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.typewriter-cursor::after {
  content: '|';
  animation: blink-cursor 1s step-end infinite;
  color: var(--color-primary-light);
}

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

/* Motion Utility Classes */
.animate-float      { animation: float 4s ease-in-out infinite; }
.animate-float-slow { animation: float-slow 6s ease-in-out infinite; }
.animate-shimmer    { animation: shimmer 3s ease-in-out infinite; }
.animate-spin       { animation: spin 1s linear infinite; }
.animate-border-glow { animation: border-glow 2s ease-in-out infinite; }

.animate-pulse-ring { position: relative; }
.animate-pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--color-primary-light);
  animation: pulse-ring 2s ease-out infinite;
}

/* Hover Tilt */
.hover-tilt { transition: transform var(--duration-normal) var(--ease-out); }
.hover-tilt:hover { transform: perspective(600px) rotateX(2deg) rotateY(-2deg) translateY(-4px); }

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 37%, var(--bg-tertiary) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-md);
}
.skeleton-text { height: 1em; margin-bottom: 0.5em; }
.skeleton-text:last-child { width: 70%; }
.skeleton-circle { border-radius: var(--radius-full); }
.skeleton-card { height: 200px; border-radius: var(--radius-lg); }

/* Toast Animation */
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-20px) scale(0.95); }
}
.toast-enter { animation: toast-in var(--duration-normal) var(--ease-out) forwards; }
.toast-exit  { animation: toast-out var(--duration-normal) var(--ease-in) forwards; }

/* Modal */
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Tab */
@keyframes tab-underline {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Number Counter */
@keyframes number-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
