2025-05-22 20:42:10 +08:00

284 lines
5.5 KiB
CSS

@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 221.2 83.2% 53.3%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 221.2 83.2% 53.3%;
--radius: 0.75rem;
/* 新增自定义颜色 */
--success: 142.1 76.2% 36.3%;
--success-foreground: 355.7 100% 97.3%;
--warning: 38 92% 50%;
--warning-foreground: 48 96% 89%;
--info: 221.2 83.2% 53.3%;
--info-foreground: 210 40% 98%;
/* 书籍封面阴影 */
--book-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 217.2 91.2% 59.8%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 224.3 76.3% 48%;
/* 新增自定义颜色 - 暗色模式 */
--success: 142.1 70.6% 45.3%;
--success-foreground: 144.9 80.4% 10%;
--warning: 48 96% 89%;
--warning-foreground: 38 92% 50%;
--info: 217.2 91.2% 59.8%;
--info-foreground: 222.2 47.4% 11.2%;
/* 书籍封面阴影 - 暗色模式 */
--book-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.25), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
/* 平滑滚动 */
html {
scroll-behavior: smooth;
}
}
/* 自定义容器样式,确保内容居中 */
.container {
width: 100%;
margin-left: auto;
margin-right: auto;
padding-left: 1rem;
padding-right: 1rem;
max-width: 1400px; /* 设置最大宽度 */
}
@media (min-width: 640px) {
.container {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
}
@media (min-width: 1024px) {
.container {
padding-left: 2rem;
padding-right: 2rem;
}
}
/* 书籍卡片样式 */
.book-card {
@apply transition-all duration-300 hover:shadow-xl;
}
.book-card .book-cover {
@apply relative overflow-hidden rounded-t-lg;
box-shadow: var(--book-shadow);
}
.book-card .book-cover img {
@apply object-cover w-full h-full transition-transform duration-500;
}
.book-card:hover .book-cover img {
@apply scale-110;
}
.book-card .book-info {
@apply p-4 transition-colors duration-300;
}
.book-card:hover .book-info {
@apply bg-accent/50;
}
/* 页面过渡动画 */
.page-transition-enter {
opacity: 0;
transform: translateY(10px);
}
.page-transition-enter-active {
opacity: 1;
transform: translateY(0);
transition: opacity 300ms, transform 300ms;
}
.page-transition-exit {
opacity: 1;
transform: translateY(0);
}
.page-transition-exit-active {
opacity: 0;
transform: translateY(-10px);
transition: opacity 300ms, transform 300ms;
}
/* 自定义滚动条 */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
@apply bg-muted/50 rounded-full;
}
::-webkit-scrollbar-thumb {
@apply bg-muted-foreground/30 rounded-full transition-colors;
}
::-webkit-scrollbar-thumb:hover {
@apply bg-muted-foreground/50;
}
/* 加载动画 */
.loading-shimmer {
@apply relative overflow-hidden bg-muted/50;
}
.loading-shimmer::after {
@apply absolute inset-0;
content: "";
animation: shimmer 2s infinite;
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.2) 50%,
rgba(255, 255, 255, 0) 100%
);
}
@keyframes shimmer {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(100%);
}
}
/* 图书详情页样式 */
.book-detail-image {
@apply rounded-lg overflow-hidden;
box-shadow: var(--book-shadow);
}
/* 按钮悬停效果 */
.btn-hover-effect {
@apply relative overflow-hidden;
}
.btn-hover-effect::after {
@apply absolute inset-0 bg-white/20 opacity-0 transition-opacity;
content: "";
}
.btn-hover-effect:hover::after {
@apply opacity-100;
}
/* 搜索框聚焦效果 */
.search-focus-ring {
@apply transition-shadow duration-300;
}
.search-focus-ring:focus-within {
@apply shadow-md shadow-primary/20;
}
/* 购物车徽章动画 */
@keyframes pulse-badge {
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
}
.cart-badge {
animation: pulse-badge 2s ease-in-out infinite;
}
/* 价格标签样式 */
.price-tag {
@apply relative inline-block px-3 py-1 bg-primary/10 text-primary font-bold rounded-md;
}
.price-tag::before {
@apply absolute -left-2 top-1/2 w-3 h-3 bg-background rounded-full transform -translate-y-1/2;
content: "";
}
.price-tag::after {
@apply absolute -right-2 top-1/2 w-3 h-3 bg-background rounded-full transform -translate-y-1/2;
content: "";
}