/**
 * 全局样式基础文件
 * 职责：定义全局 CSS 变量、样式重置、通用动画
 * 所有页面共用，禁止放页面专属样式
 */

/* ========== 1. 全局 CSS 变量 ========== */
:root {
  /* 主题色 - 红色系 */
  --color-red: #DC2626;
  --color-red-deep: #B91C1C;
  --color-red-dark: #991B1B;
  --color-red-light: #EF4444;
  --color-red-bright: #F87171;
  --color-red-pale: #FEE2E2;
  --color-red-mist: #FEF2F2;
  --color-red-tint: #FFF1F1;

  /* 辅助色 */
  --color-gold: #F59E0B;
  --color-gold-pale: #FEF3C7;
  --color-green: #10B981;
  --color-green-pale: #D1FAE5;
  --color-blue: #3B82F6;
  --color-blue-pale: #DBEAFE;
  --color-purple: #8B5CF6;
  --color-purple-pale: #F3E8FF;

  /* 短变量别名（兼容已有页面样式） */
  --red: var(--color-red);
  --red-deep: var(--color-red-deep);
  --red-dark: var(--color-red-dark);
  --red-light: var(--color-red-light);
  --red-bright: var(--color-red-bright);
  --red-pale: var(--color-red-pale);
  --red-mist: var(--color-red-mist);
  --red-tint: var(--color-red-tint);
  --gold: var(--color-gold);
  --gold-pale: var(--color-gold-pale);
  --green: var(--color-green);
  --green-pale: var(--color-green-pale);
  --blue: var(--color-blue);
  --blue-pale: var(--color-blue-pale);
  --purple: var(--color-purple);
  --purple-pale: var(--color-purple-pale);
  --surface: var(--color-surface);
  --surface-tint: var(--color-surface-tint);

  /* 边框短变量 */
  --border: var(--color-border);
  --border-light: var(--color-border-light);

  /* 文本短变量 */
  --text: var(--color-text);
  --text-2: var(--color-text-2);
  --text-3: var(--color-text-3);
  --text-4: var(--color-text-4);

  /* 额外辅助色 */
  --cyan: #06B6D4;
  --cyan-pale: #ECFEFF;
  --cat-accent: var(--color-red);

  /* 背景与表面 */
  --color-bg: #FFF5F5;
  --color-surface: #FFFFFF;
  --color-surface-tint: #FEFAFA;

  /* 文本颜色 */
  --color-text: #1C0A0A;
  --color-text-2: #6B4848;
  --color-text-3: #9B7878;
  --color-text-4: #C9AEAE;
  --color-text-inverse: #FFFFFF;

  /* 边框颜色 */
  --color-border: #F0D5D5;
  --color-border-light: #F8E8E8;

  /* 阴影层级 */
  --shadow-sm: 0 1px 3px rgba(185, 28, 28, 0.06);
  --shadow-md: 0 4px 16px rgba(185, 28, 28, 0.08);
  --shadow-lg: 0 8px 30px rgba(185, 28, 28, 0.12);
  --shadow-xl: 0 24px 60px rgba(60, 8, 8, 0.34);

  /* 圆角规范 */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* 间距规范 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-12: 48px;

  /* 字体大小 */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 26px;

  /* 字体粗细 */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* 过渡时间 */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  --transition-xslow: 0.5s ease;

  /* 层级规范 */
  --z-base: 1;
  --z-sticky: 10;
  --z-overlay: 100;
  --z-modal: 1000;
  --z-tooltip: 9999;
}


/* ========== 2. 样式重置 ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

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

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

ul,
ol {
  list-style: none;
}


/* ========== 3. 通用动画 ========== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

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

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

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

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

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

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

@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-36px, -24px) scale(1.06); }
}

@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-28px, 26px) scale(0.94); }
}

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


/* ========== 4. 通用工具类 ========== */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

.invisible {
  visibility: hidden;
  pointer-events: none;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-grow { flex-grow: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 > *:not(:last-child){margin-right: var(--space-1);}
.gap-2 > *:not(:last-child){margin-right: var(--space-2);}
.gap-3 > *:not(:last-child){margin-right: var(--space-3);}
.gap-4 > *:not(:last-child){margin-right: var(--space-4);}


/* ========== 5. 无障碍支持 ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--color-red);
  outline-offset: 2px;
}

:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}


/* ========== 6. 响应式断点 ========== */
/* 手机 */
@media (max-width: 480px) {
  html { font-size: 14px; }
}

/* 平板 */
@media (min-width: 481px) and (max-width: 768px) {
  html { font-size: 15px; }
}

/* 桌面 */
@media (min-width: 769px) {
  html { font-size: 16px; }
}
