﻿:root {
    /* 默认样式变量，防止未配置时错乱 */
    --carousel-img-height: 200px;
    --carousel-gap: 16px;
    --carousel-slide-width: 300px;
}

.carousel-component {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin: 20px 0;
}

.carousel-container {
    width: 100%;
    overflow: hidden;
}

.carousel-track {
    display: flex;
    gap: var(--carousel-gap);
    transform: translateX(0);
    transition: transform 0.5s ease;
    will-change: transform;
}

.carousel-slide {
    flex: 0 0 var(--carousel-slide-width);
    height: var(--carousel-img-height);
    position: relative;
    overflow: hidden; /* 确保悬浮层不超出图片范围 */
}

    .carousel-slide a {
        display: block;
        width: 100%;
        height: 100%;
        text-decoration: none;
        position: relative; /* 作为悬浮层的父容器 */
    }

    .carousel-slide img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
        cursor: pointer;
        transition: transform 0.3s ease; /* 图片轻微缩放效果 */
    }

/* 悬浮层样式 - 查看相关产品 */
.carousel-hover-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* 半透明黑色背景 */
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease;
    pointer-events: none; /* 不影响点击事件 */
    z-index: 10;
}

/* 鼠标悬浮时显示悬浮层 */
.carousel-slide:hover .carousel-hover-layer {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7); /* 加深背景 */
}

/* 鼠标悬浮时图片轻微缩放 */
.carousel-slide:hover img {
    transform: scale(1.05);
}

.carousel-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    box-sizing: border-box;
    border-radius: 0 0 8px 8px;
    z-index: 5; /* 确保标题在悬浮层下方 */
}

/* 模态框样式 */
.carousel-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.carousel-modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

.carousel-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

    .carousel-modal-close:hover {
        color: #ccc;
    }

.carousel-modal-caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 18px;
    text-align: center;
    max-width: 80%;
}

/* 响应式调整 */
@media (max-width: 768px) {
    :root {
        --carousel-slide-width: calc(100% - 32px);
    }

    .carousel-hover-layer {
        font-size: 16px; /* 移动端缩小字体 */
    }
}
