@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    /* 全局颜色变量 */
    --background: 0 0% 100%;
    --foreground: 20 14.3% 4.1%;
    --card: 0 0% 100%;
    --card-foreground: 20 14.3% 4.1%;
    --popover: 0 0% 100%;
    --popover-foreground: 20 14.3% 4.1%;
    --primary: 24 9.8% 10%;
    --primary-foreground: 60 9.1% 97.8%;
    --secondary: 60 4.8% 95.9%;
    --secondary-foreground: 24 9.8% 10%;
    --muted: 60 4.8% 95.9%;
    --muted-foreground: 25 5.3% 44.7%;
    --accent: 60 4.8% 95.9%;
    --accent-foreground: 24 9.8% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 60 9.1% 97.8%;
    --border: 20 5.9% 90%;
    --input: 20 5.9% 90%;
    --ring: 20 14.3% 4.1%;
    --radius: 1rem;

    /* 图表颜色 */
    --chart-1: 220 70% 50%;
    --chart-2: 340 75% 55%;
    --chart-3: 30 80% 55%;
    --chart-4: 280 65% 60%;
    --chart-5: 160 60% 45%;
    --chart-6: 180 50% 50%;
    --chart-7: 216 50% 50%;
    --chart-8: 252 50% 50%;
    --chart-9: 288 50% 50%;
    --chart-10: 324 50% 50%;
    
    /* 背景图片 */
    --background-image: url('https://t.mwm.moe/ys/');
  }

  /* 黑暗模式变量 */
  .dark {
    --background: 20 14.3% 4.1%;
    --foreground: 60 9.1% 97.8%;
    --card: 20 14.3% 4.1%;
    --card-foreground: 60 9.1% 97.8%;
    --popover: 20 14.3% 4.1%;
    --popover-foreground: 60 9.1% 97.8%;
    --primary: 60 9.1% 97.8%;
    --primary-foreground: 24 9.8% 10%;
    --secondary: 12 6.5% 15.1%;
    --secondary-foreground: 60 9.1% 97.8%;
    --muted: 12 6.5% 15.1%;
    --muted-foreground: 24 5.4% 63.9%;
    --accent: 12 6.5% 15.1%;
    --accent-foreground: 60 9.1% 97.8%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 60 9.1% 97.8%;
    --border: 12 6.5% 15.1%;
    --input: 12 6.5% 15.1%;
    --ring: 24 5.7% 82.9%;
    --chart-1: 220 70% 50%;
    --chart-2: 340 75% 55%;
    --chart-3: 30 80% 55%;
    --chart-4: 280 65% 60%;
    --chart-5: 160 60% 45%;
    --chart-6: 180 50% 50%;
    --chart-7: 216 50% 50%;
    --chart-8: 252 50% 50%;
    --chart-9: 288 50% 50%;
    --chart-10: 324 50% 50%;
  }

  /* 全局样式 */
  * {
    @apply border-border;
  }

  html {
    @apply scroll-smooth;
  }

  body {
    @apply bg-background text-foreground;
    background-image: var(--background-image);
    background-size: cover;
    background-position: center;
    font-synthesis-weight: none;
    text-rendering: optimizeLegibility;
  }
}

@layer utilities {
  /* 数字步骤样式 */
  .step {
    counter-increment: step;
  }

  .step:before {
    @apply absolute inline-flex h-9 w-9 items-center justify-center rounded-full border-4 border-background bg-muted text-center -indent-px font-mono text-base font-medium;
    @apply ml-[-50px] mt-[-4px];
    content: counter(step);
  }
}

@media (max-width: 640px) {
  /* 移动端容器样式 */
  .container {
    @apply px-4;
  }
}

/* 选中文本样式 */
::selection {
  @apply bg-stone-300 dark:bg-stone-800;
}

/* Hamster 加载动画 */
.hamster-loading-wrapper {
  --size: 12px;
  height: var(--size);
  width: var(--size);
  inset: 0;
  z-index: 10;
}

.hamster-loading-wrapper[data-visible="false"] {
  transform-origin: center;
  animation: hamster-fade-out 0.2s ease forwards;
}

.hamster-spinner {
  position: relative;
  top: 50%;
  left: 50%;
  height: var(--size);
  width: var(--size);
}

.hamster-loading-bar {
  --gray11: hsl(0, 0%, 43.5%);
  animation: hamster-spin 0.8s linear infinite;
  background: var(--gray11);
  border-radius: 6px;
  height: 13%;
  left: -10%;
  position: absolute;
  top: -3.9%;
  width: 30%;
}

.hamster-loading-bar:nth-child(n) {
  animation-delay: calc((n - 1) * -0.1s);
  transform: rotate(calc((n - 1) * 45deg)) translate(120%);
}

/* 动画 */
@keyframes hamster-fade-in {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes hamster-fade-out {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes hamster-spin {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0.15;
  }
}

/* 隐藏滚动条 */
.scrollbar-hidden {
  @apply scrollbar-none;
}

@layer utilities {
  .scrollbar-none {
    scrollbar-width: none; /* Firefox */
  }

  .scrollbar-none::-webkit-scrollbar {
    display: none; /* Chrome, Safari 和 Opera */
  }
}
