/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* 瀑布流容器 */
.masonry-container {
    position: relative;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    column-count: 4; /* 默认4列 */
    column-gap: 20px;
}

/* 响应式调整 - 大屏桌面 */
@media (min-width: 1200px) {
    .masonry-container {
        padding: 25px;
        column-count: 5; /* 大屏5列 */
        column-gap: 25px;
    }
}

/* 桌面 */
@media (min-width: 1024px) and (max-width: 1199px) {
    .masonry-container {
        padding: 20px;
        column-count: 4; /* 桌面4列 */
        column-gap: 20px;
    }
}

/* 平板 */
@media (min-width: 769px) and (max-width: 1023px) {
    .masonry-container {
        padding: 15px;
        column-count: 3; /* 平板3列 */
        column-gap: 15px;
    }
}

/* 图片项样式 */
.masonry-item {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    will-change: transform;
    break-inside: avoid; /* 防止图片被分割到两列 */
    margin-bottom: 20px; /* 列间距 */
    display: inline-block;
    width: 100%;
}

/* 手机端图片项样式调整 */
@media (max-width: 767px) {
    .masonry-item {
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

.masonry-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
}

/* 加载动画已移除 */

.masonry-item .item-info {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0 0 8px 8px;
}

.masonry-item .item-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
    text-align: center;
}

.masonry-item .item-description {
    display: none; /* 在瀑布流列表中隐藏描述 */
}

/* 弹窗样式 */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.popup-overlay.active {
    display: flex;
    opacity: 1;
}

.popup-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 90%;
    max-height: 800px;
    margin: auto;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.1s ease;
}

.popup-overlay.active .popup-container {
    transform: scale(1);
}

/* 关闭按钮 */
.popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background-color 0.3s ease;
}

.popup-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* 导航按钮 */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: 16px;
}

.next-btn {
    right: 16px;
}

/* 弹窗内容 */
.popup-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 图片容器 */
.popup-image-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    min-height: 300px;
}

.popup-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.1s ease;
}

/* 图片加载动画已移除 */

/* 图片切换优化 - 无延时 */
.popup-image {
    transition: none !important;
}

/* 灯箱切换优化 */
.popup-overlay.switching .popup-image {
    opacity: 1;
}

/* 图片信息 */
.popup-info {
    padding: 24px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.popup-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

.popup-description {
    font-size: 16px;
    color: #666;
    line-height: 1.6;
}

/* 灯箱描述中的链接样式 */
.popup-description a {
    color: #dc3545;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.popup-description a:hover {
    color: #c82333;
    text-decoration: underline;
}

.popup-description a:visited {
    color: #dc3545;
}

/* 底部操作区域 */
.popup-footer {
    padding: 20px 24px;
    border-top: 1px solid #e9ecef;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.popup-footer-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 反应按钮区域 */
.footer-reactions {
    display: flex;
    gap: 8px;
}

.reaction-type {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    text-decoration: none;
    transition: transform 0.2s ease, background-color 0.2s ease;
    position: relative;
}

.reaction-type:hover {
    transform: scale(1.1);
}

.reaction-type.active {
    transform: scale(1.2);
    animation: reactionBounce 0.3s ease;
}

.reaction-type.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.reaction-type.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #ccc;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes reactionBounce {
    0%, 100% { transform: scale(1.2); }
    50% { transform: scale(1.4); }
}

.reaction-like {
    background: #e3f2fd;
    color: #1976d2;
}

.reaction-like::before {
    content: "👍";
    font-size: 16px;
    margin-right: 4px;
}

.reaction-love {
    background: #fce4ec;
    color: #c2185b;
}

.reaction-love::before {
    content: "❤️";
    font-size: 16px;
    margin-right: 4px;
}

.reaction-haha {
    background: #fff3e0;
    color: #f57c00;
}

.reaction-haha::before {
    content: "😂";
    font-size: 16px;
    margin-right: 4px;
}

.reaction-wow {
    background: #f3e5f5;
    color: #7b1fa2;
}

.reaction-wow::before {
    content: "😮";
    font-size: 16px;
    margin-right: 4px;
}

.reaction-sad {
    background: #e8f5e8;
    color: #388e3c;
}

.reaction-sad::before {
    content: "😢";
    font-size: 16px;
    margin-right: 4px;
}

.reaction-angry {
    background: #ffebee;
    color: #d32f2f;
}

.reaction-angry::before {
    content: "😠";
    font-size: 16px;
    margin-right: 4px;
}

.reaction-count {
    font-size: 12px;
    font-weight: 600;
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: white;
    border-radius: 10px;
    padding: 2px 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 18px;
    text-align: center;
}

/* 点赞按钮 */
.button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid #e9ecef;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.button:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
}

.button-likes {
    color: #666;
}

.button-likes.active {
    color: #e91e63;
    border-color: #e91e63;
    background: #fce4ec;
}

.count {
    font-size: 14px;
    font-weight: 600;
    color: #666;
}


/* 响应式设计 */
@media (max-width: 768px) {
    .popup-container {
        width: 95%;
        /* 使用calc确保为关闭按钮预留空间，同时保持footer完整显示 */
        height: calc(95% - 50px);
        max-height: calc(800px - 50px);
        /* 确保关闭按钮不被遮挡 */
        padding-top: 50px;
        box-sizing: border-box;
    }
    
    /* 手机端关闭按钮优化 */
    .popup-close {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        z-index: 1001;
        background: rgba(0, 0, 0, 0.8);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .popup-close::before,
    .popup-close::after {
        width: 20px;
        height: 2px;
    }
    
    .popup-info {
        padding: 16px;
    }
    
    .popup-title {
        font-size: 18px;
    }
    
    .popup-description {
        font-size: 14px;
    }
    
    .popup-footer {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
        /* 确保footer始终可见，不会被压缩 */
        flex-shrink: 0;
        min-height: 80px;
    }
    
    .popup-footer-item {
        justify-content: center;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
    }
    
    .prev-btn {
        left: 8px;
    }
    
    .next-btn {
        right: 8px;
    }
}

/* 中等屏幕手机 (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .masonry-container {
        padding: 10px;
        column-gap: 8px;
        column-count: 3 !important; /* 中等屏幕3列 */
    }
}

/* 小屏手机 (480px及以下) */
@media (max-width: 480px) {
    .masonry-container {
        padding: 8px;
        column-gap: 6px;
        column-count: 3 !important; /* 手机端3列布局 */
    }
    
    /* 小屏手机灯箱优化 */
    .popup-container {
        width: 98%;
        /* 使用calc确保为关闭按钮预留空间，同时保持footer完整显示 */
        height: calc(98% - 60px);
        max-height: calc(800px - 60px);
        padding-top: 60px;
    }
    
    .popup-close {
        top: 8px;
        right: 8px;
        width: 48px;
        height: 48px;
        background: rgba(0, 0, 0, 0.9);
    }
    
    .popup-close::before,
    .popup-close::after {
        width: 24px;
        height: 3px;
    }
    
    .masonry-item {
        margin-bottom: 6px; /* 手机端较小的间距 */
    }
    
    .masonry-item .item-info {
        padding: 8px 12px;
    }
    
    .masonry-item .item-title {
        font-size: 14px;
        margin: 0 0 6px 0;
    }
    
    .masonry-item .item-description {
        display: none; /* 在瀑布流列表中隐藏描述 */
    }
    
    .footer-reactions {
        gap: 4px;
    }
    
    .reaction-type {
        width: 32px;
        height: 32px;
    }
    
    .reaction-count {
        font-size: 10px;
        padding: 1px 4px;
        min-width: 16px;
    }
    
    /* 小屏手机footer保护 */
    .popup-footer {
        flex-shrink: 0;
        min-height: 90px;
        padding: 12px;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .masonry-item {
        border: 2px solid #000;
    }
    
    .popup-container {
        border: 2px solid #000;
    }
    
    .button {
        border-width: 2px;
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 焦点样式 */
button:focus,
a:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* 加载状态样式已移除 */