/* 
 * 纯CSS实现的模态框和交互功能
 * modal-css-only.css
 * 用于替代部分JavaScript功能
 */

/* ===== 1. 返回顶部按钮的纯CSS实现 ===== */
/* 使用:target伪类实现返回顶部按钮的显示/隐藏 */
#backToTop {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 当页面滚动到一定位置时显示按钮 */
/* 注意：纯CSS无法检测滚动位置，这里使用替代方案 */
/* 方案1：使用锚点链接，但需要用户点击 */
/* 方案2：保留少量JavaScript，但可以简化 */

/* 简化方案：始终显示返回顶部按钮，但位置固定 */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(45deg, #D4AF37, #8B0000);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    /* 确保作为锚点链接也能正确显示 */
    text-align: center;
    line-height: 50px;
}

#backToTop:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

#backToTop:active {
    transform: scale(0.95);
}

/* ===== 2. 模态框的纯CSS实现 ===== */
/* 使用:target伪类控制模态框的显示/隐藏 */
.image-overlay-full {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 当模态框被target时显示 */
.image-overlay-full:target {
    opacity: 1;
    visibility: visible;
}

/* 模态框内容样式 */
.image-overlay-full > img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* 购买和联系模态框的特殊样式 */
#buy-modal > div,
#contact-modal > div {
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
}

/* 点击模态框背景关闭的效果 */
.image-overlay-full {
    cursor: pointer;
}

.image-overlay-full > * {
    cursor: default;
}

/* 关闭按钮样式（可选） */
.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 2001;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== 3. 平滑滚动效果 ===== */
/* 为所有锚点链接添加平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* ===== 4. 响应式调整 ===== */
@media (max-width: 768px) {
    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .close-modal {
        top: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    #backToTop {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .image-overlay-full > img {
        max-width: 95%;
        max-height: 95%;
    }
}