/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

/* 自定义工具类 */
.glass-effect {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.card-shadow {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.skill-icon {
    transition: all 0.3s ease;
}

.skill-icon:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* 背景Canvas样式 */
#background-canvas,
#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* 主题切换按钮样式 */
#theme-toggle,
#themeToggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #165DFF;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(22, 93, 255, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
}

#theme-toggle:hover,
#themeToggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(22, 93, 255, 0.5);
}

/* 暗黑模式样式 */
body.dark {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark .glass-effect {
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid rgba(70, 70, 70, 0.3);
}

body.dark h1, body.dark h2, body.dark h3, body.dark h4, body.dark h5, body.dark h6 {
    color: #e0e0e0;
}

body.dark p, body.dark span, body.dark li {
    color: #b0b0b0;
}

body.dark .bg-gray-200 {
    background-color: #333;
}

body.dark .text-gray-600 {
    color: #b0b0b0;
}

body.dark .text-gray-800 {
    color: #e0e0e0;
}

body.dark .text-gray-500 {
    color: #808080;
}

body.dark .card-shadow {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.dark .skill-icon:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Tailwind CSS 工具类扩展 */
body.dark .dark\:glass-effect {
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(70, 70, 70, 0.3);
}

body.dark .dark\:card-shadow {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.dark .dark\:skill-icon:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* 瀑布流布局 - 真正的瀑布流效果 */
.masonry-grid {
    columns: 3;
    column-gap: 1.5rem;
    /* 确保网格在各种设备上可见 */
    display: block;
}

/* 确保每个项目不会被分割到不同列 */
.masonry-item {
    break-inside: avoid;
    -webkit-break-inside: avoid; /* Safari支持 */
    margin-bottom: 1.5rem;
    width: 100%;
    /* 确保在移动设备上可见 */
    display: block;
    position: relative;
}

/* 响应式调整 */
@media (max-width: 1023px) {
    .masonry-grid {
        columns: 2;
    }
}

@media (max-width: 767px) {
    .masonry-grid {
        columns: 1;
        /* 为手机端添加更明确的样式 */
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .masonry-item {
        /* 确保在手机端完全显示 */
        width: 100%;
        break-inside: avoid;
        -webkit-break-inside: avoid;
        margin-bottom: 0; /* 移除margin，使用flex gap */
    }
}

/* 作品卡片样式 */
.work-item {
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.work-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.work-item .relative {
    position: relative;
    display: block;
    overflow: hidden;
    width: 100%;
}

/* 只为包含图片的work-item添加cursor: pointer */
.work-item:not(:has(video)) .relative {
    cursor: pointer;
}

.work-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s ease;
}

.work-item:hover img {
    transform: scale(1.05);
}

.work-item .relative .bg-secondary\/80 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.work-item:hover .relative .bg-secondary\/80 {
    opacity: 1;
}

.work-item .work-content {
    padding: 16px;
}

.work-item h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.work-item p {
    font-size: 0.9rem;
    color: #666;
}

/* 源文件下载链接样式 */
.work-item .p-4 a[download] {
    margin-top: 1rem; /* 增加顶部间距，让链接与上一行文字有更明显的分隔 */
    display: inline-flex;
    align-items: center;
    padding-top: 0.5rem; /* 额外增加顶部内边距 */
}

.work-item:hover .relative .bg-secondary\/80 {
    opacity: 1;
}

/* 返回按钮样式 */
.back-button {
    position: fixed;
    top: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #165DFF;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(22, 93, 255, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    /* 确保所有子元素（包括箭头）都显示为白色 */
}

/* 确保返回按钮内的所有元素（包括箭头、SVG等）都显示为白色 */
.back-button * {
    color: white !important;
    fill: white !important;
    stroke: white !important;
}

.back-button:hover {
    transform: translateX(-5px) scale(1.1);
    box-shadow: 0 6px 20px rgba(22, 93, 255, 0.5);
}

body.dark .back-button {
    background-color: #333;
    border: 2px solid #666;
    /* 确保暗色模式下箭头仍然是白色 */
}

/* 确保暗色模式下返回按钮内的所有元素也显示为白色 */
body.dark .back-button * {
    color: white !important;
    fill: white !important;
    stroke: white !important;
}

/* 暗黑模式下的作品卡片 */
body.dark .work-item p {
    color: #b0b0b0;
}

/* 响应式调整 */
@media (max-width: 768px) {
    #theme-toggle,
    #themeToggle {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
    }
    
    .back-button {
        width: 45px;
        height: 45px;
        top: 20px;
        left: 20px;
    }
    
    .container {
        padding: 1rem;
    }
}