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

body {
    font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
    background-color: #f5efe0; /* 改为纸张同色系的浅色背景 */
    min-height: 100vh;
    padding: 20px;
    color: #333;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 应用容器 */
.app-container {
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: calc(100vh - 40px); /* 考虑padding的高度 */
    justify-content: center;
}

/* 纸张容器 */
.paper-container {
    width: 100%;
    perspective: 1000px;
    margin: auto 0; /* 垂直方向自动边距，实现垂直居中 */
}

/* 纸张样式 */
.paper {
    background-color: #f8f3e3; /* 米黄色，模拟旧纸张 */
    padding: 30px;
    border-radius: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 5px rgba(0, 0, 0, 0.1);
    position: relative;
    /* transform: rotate(-1deg); */
    /* transition: transform 0.3s ease; */
}

.paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('paper.png');
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

/* .paper:hover {
    transform: rotate(0deg);
} */

/* 页眉样式 */
header {
    margin-bottom: 30px;
    position: relative;
    z-index: 1;
}

h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 2rem;
    color: #8b4513;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
}

/* 电影列表样式 */
.list-container {
    position: relative;
    z-index: 1;
    margin-bottom: 20px;
}

/* 电影列表 - 流式布局 */
.movie-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    align-items: flex-start;
}

/* 加载中和错误样式 */
.loading, .error {
    width: 100%;
    padding: 20px;
    text-align: center;
    font-family: 'Noto Serif SC', serif;
    border-radius: 5px;
    margin: 20px 0;
}

.loading {
    background-color: rgba(255, 255, 255, 0.7);
    color: #8b4513;
    animation: pulse 1.5s infinite;
}

.error {
    background-color: rgba(255, 200, 200, 0.7);
    color: #d32f2f;
    border: 1px dashed #d32f2f;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.movie-item {
    position: relative;
    background-color: transparent;
    margin-bottom: 10px;
    transition: transform 0.2s ease;
    cursor: pointer;
    list-style-type: none;
    /* 移除固定宽度，改为自适应宽度 */
    display: inline-block;
    margin-right: 10px;
}

.movie-item:hover {
    transform: scale(1.05);
    z-index: 2;
}

.movie-inner {
    position: relative;
    padding: 8px 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    /* 添加不同的旋转角度使布局更自然 */
    transform: rotate(calc(var(--rotation, 0deg) * 0.5));
    z-index: 1;
}

/* 为每个电影项添加随机旋转 */
.movie-item:nth-child(odd) .movie-inner {
    --rotation: 1deg;
}

.movie-item:nth-child(even) .movie-inner {
    --rotation: -1deg;
}

.movie-item:nth-child(3n) .movie-inner {
    --rotation: 0.5deg;
}

.movie-item:nth-child(4n) .movie-inner {
    --rotation: -0.5deg;
}

.movie-item:hover .movie-inner {
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.movie-rank {
    display: none; /* 隐藏排名标记 */
}

.movie-title {
    display: inline-block;
    font-family: 'Long Cang', cursive;
    font-size: 1.1rem;
    position: relative;
    color: #333;
    white-space: nowrap;
}

.movie-rating {
    display: block;
    font-size: 0.85rem;
    color: #8b4513;
    margin-top: 3px;
    font-family: 'Noto Serif SC', serif;
}

/* 标记为已观看的电影样式 */
.movie-item.watched .movie-inner {
    background-color: rgba(255, 255, 255, 0.7);
    position: relative;
    transform: rotate(calc(var(--rotation, 0deg) * 0.7)); /* 增加旋转角度 */
}

.movie-item.watched .movie-title {
    color: #333;
    position: relative;
    z-index: 1;
    font-weight: 500; /* 增加文本加粗 */
}

.movie-item.watched .movie-inner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 236, 61, 0.35); /* 修改为黄色背景 */
    border-radius: 3px;
    z-index: 0;
    opacity: 0.7;
    /* 添加黄色背景的斑点效果 */
    background-image: 
        linear-gradient(45deg, rgba(255, 236, 61, 0.15) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 236, 61, 0.15) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 236, 61, 0.15) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 236, 61, 0.15) 75%);
    background-size: 4px 4px;
    background-position: 0 0, 0 2px, 2px -2px, -2px 0px;
    /* 添加黄色背景的剪裁效果 */
    clip-path: polygon(
        0% 3%, 2% 0%, 98% 1%, 100% 4%, 99% 96%, 97% 100%, 3% 99%, 0% 95%
    );
    box-shadow: 0 0 5px rgba(255, 236, 61, 0.2);
    /* 添加黄色背景的动画效果 */
    animation: marker-effect 0.5s ease-out forwards;
    transform-origin: center;
    /* 添加折角效果 */
    border-top: 2px solid rgba(255, 236, 61, 0.5);
    border-bottom: 2px solid rgba(255, 236, 61, 0.5);
}

.movie-item.watched .movie-inner::before {
    content: '\2713'; /* 选中标记 */
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: rgba(255, 236, 61, 0.9);
    color: #333;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transform: rotate(5deg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* 添加选中标记的效果 */
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
    animation: check-mark 0.3s ease-in-out forwards;
}

@keyframes check-mark {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.2) rotate(5deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(5deg);
        opacity: 1;
    }
}

.movie-item.watched:hover .movie-inner::after {
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

/* 控制区域容器 */
.controls-container {
    margin-top: 20px;
    background-color: #f8f3e3; /* 同纸张颜色 */
    padding: 15px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    /* transform: rotate(1deg); */
    /* transition: transform 0.3s ease; */
}

/* .controls-container:hover {
    transform: rotate(0deg);
} */

/* 统计信息样式 */
.stats {
    font-size: 1rem;
    color: #666;
    font-family: 'Noto Serif SC', serif;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.data-timestamp {
    font-size: 0.85rem;
    color: #8b4513;
    opacity: 0.8;
}

/* 按钮容器 */
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 按钮样式 */
.app-button {
    background-color: rgba(139, 69, 19, 0.1); /* 棕色 */
    color: #8b4513; /* 棕色 */
    border: 1px solid rgba(139, 69, 19, 0.3);
    padding: 8px 15px;
    font-family: 'ZCOOL XiaoWei', serif;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.app-button:hover {
    background-color: rgba(139, 69, 19, 0.2);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 图片预览 */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.image-preview.hidden {
    display: none;
}

.preview-container {
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-content {
    overflow: auto;
    margin-bottom: 20px;
    max-width: 100%;
    max-height: 70vh;
}

.preview-content img {
    max-width: 100%;
    display: block;
}

.preview-actions {
    display: flex;
    gap: 10px;
}

/* 移动设备适配 */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        overflow: auto; /* 允许滚动 */
        -ms-overflow-style: none;  /* 隐藏IE和Edge滚动条 */
        scrollbar-width: none;  /* 隐藏Firefox滚动条 */
    }
    
    /* 隐藏Webkit浏览器滚动条 */
    body::-webkit-scrollbar {
        display: none;
    }

    .app-container {
        padding: 0;
        width: 150%; /* 扩大容器宽度以适应内容 */
        max-width: none;
    }

    .paper-container {
        margin: 0;
        overflow: visible; /* 允许内容溢出 */
        border-radius: 8px;
        /* 为底部控制区域留出空间 */
        margin-bottom: 130px;
    }

    .paper {
        min-height: 100%;
        padding: 15px;
        border-radius: 8px;
        transform: none; /* 移除旋转效果 */
    }

    .movie-list {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding: 5px;
        justify-content: flex-start;
    }

    .movie-item {
        margin: 0;
        width: auto; /* 移除固定宽度 */
        flex-grow: 0;
        flex-shrink: 0;
    }

    .movie-inner {
        padding: 5px;
        white-space: nowrap; /* 阻止文字换行 */
        overflow: visible; /* 允许内容溢出 */
    }

    .movie-title {
        font-size: 0.9rem;
        white-space: nowrap;
        display: inline-block;
        max-width: none; /* 移除最大宽度限制 */
    }

    .movie-info {
        font-size: 0.75rem;
    }

    /* 固定控制区域在底部 */
    .controls-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(245, 239, 224, 0.95);
        padding: 10px;
        margin: 0;
        z-index: 100;
        border-top: 1px solid rgba(139, 69, 19, 0.1);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05); /* 添加阴影效果 */
    }

    /* 优化按钮布局 */
    .actions {
        display: flex;
        gap: 8px;
        margin-top: 10px;
    }

    .app-button {
        flex: 1;
        padding: 8px;
        font-size: 0.85rem;
    }
    
    /* 优化图片预览 */
    .image-preview {
        z-index: 200; /* 确保图片预览在控制区域上方 */
        background-color: rgba(0, 0, 0, 0.8);
    }
    
    .preview-container {
        max-width: 95%;
        max-height: 80vh;
        margin: 10px auto;
        padding-bottom: 70px; /* 为底部控制区域留出空间 */
    }
    
    .preview-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(245, 239, 224, 0.95);
        padding: 10px;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid rgba(139, 69, 19, 0.1);
    }
}

/* 响应式设计 */
@media (max-width: 600px) {
    .paper {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .controls-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stats {
        text-align: center;
        margin-bottom: 10px;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .app-button {
        width: 100%;
    }
}

@keyframes marker-effect {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    50% {
        opacity: 0.9;
    }
    100% {
        opacity: 0.7;
        transform: scale(1);
    }
}
