/* 首页特定样式 */

/* 粒子背景 */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

/* 宠物卡片滚动区域 - 确保隐藏溢出 */
section.py-16.bg-white.overflow-hidden {
    overflow: hidden !important;
    position: relative;
}

section.py-16.bg-white.overflow-hidden > .relative {
    overflow: hidden !important;
    width: 100%;
    position: relative;
}

/* 无限滚动容器 - 横向flex布局 */
.infinite-scroll {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    width: 200%;
    animation: scroll-left 30s linear infinite;
    will-change: transform;
    position: relative;
}

.infinite-scroll:hover {
    animation-play-state: paused;
}

/* 滚动动画 - 从右往左，确保无缝循环 */
@keyframes scroll-left {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* 卡片容器 - 确保横向排列，即使内容少也能填满50% */
.infinite-scroll > .flex {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-start;
    flex-shrink: 0;
    width: 50%;
    min-width: 50%;
    max-width: 50%;
    gap: 1.5rem;
    justify-content: flex-start;
    position: relative;
}

/* 确保w-full类不会覆盖50%宽度 */
.infinite-scroll > .flex.w-full {
    width: 50%;
    min-width: 50%;
    max-width: 50%;
    flex-shrink: 0;
}

/* 确保space-x-6类正确应用间距 */
.infinite-scroll > .flex.space-x-6 {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-start;
}

/* 宠物卡片样式 - 确保横向排列且不换行，默认可见 */
.pet-card {
    display: block !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    width: 16rem !important;
    min-width: 16rem !important;
    max-width: 16rem !important;
    margin-right: 0 !important;
    opacity: 1 !important; /* 确保默认可见 */
    visibility: visible !important; /* 确保默认可见 */
}

/* page-transition 类 - 确保默认可见 */
.page-transition {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* 确保在flex容器内的卡片正确排列 */
.flex.space-x-6 .pet-card,
.infinite-scroll .flex .pet-card {
    display: block !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 覆盖Tailwind的flex类，确保横向排列 */
.infinite-scroll.flex {
    display: flex !important;
    flex-direction: row !important;
}

.infinite-scroll .flex {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
}

/* 确保所有卡片容器都是横向的 */
.infinite-scroll .flex.space-x-6 {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
}

/* 修复可能的垂直排列问题 */
.infinite-scroll,
.infinite-scroll > *,
.infinite-scroll .flex {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
}

/* 确保按钮默认可见并正确显示 */
.pet-card button,
.infinite-scroll button,
.pet-card .bg-warm-orange {
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
    background-color: #FF6B35 !important; /* warm-orange 颜色 */
    color: white !important;
}

.pet-card button:hover,
.infinite-scroll button:hover {
    background-color: #E55A2B !important; /* hover 时的颜色，类似 orange-600 */
    opacity: 1 !important;
}

/* 确保按钮内的文字可见 */
.pet-card button,
.infinite-scroll button {
    color: white !important;
    text-decoration: none !important;
}

/* 横向排列的轮播样式 - 从右往左 */
#petCarousel {
    max-width: 100% !important;
    margin: 0 auto !important;
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
}

#petCarousel .splide__track {
    overflow: hidden !important;
    width: 100% !important;
}

/* 确保列表横向排列 */
#petCarousel .splide__list {
    display: flex !important;
    flex-direction: row !important; /* 横向排列 */
    gap: 20px;
}

#petCarousel .splide__slide {
    width: calc(25% - 20px) !important;
    max-width: 100% !important;
    height: 305px !important; /* li高度305px */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    flex-shrink: 0 !important;
}

#petCarousel .splide__slide > div {
    width: 100% !important;
    max-width: 600px !important; /* 限制卡片最大宽度 */
    height: 100% !important;
    margin: 0 auto !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
}

#petCarousel .splide__slide > div:hover {
    transform: scale(1.02) !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

#petCarousel .splide__slide img {
    width: 100% !important;
    height: 192px !important; /* 图片高度192px */
    object-fit: cover !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* 从右往左滑入动画 */
@keyframes slideInFromRight {
    0% {
        transform: translateX(100%) !important;
        opacity: 0 !important;
    }
    100% {
        transform: translateX(0) !important;
        opacity: 1 !important;
    }
}

#petCarousel .splide__slide.is-active > div {
    animation: slideInFromRight 0.8s ease-out !important;
}

/* 轮播箭头样式调整 - 水平方向左右箭头 */
#petCarousel .splide__arrows {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    pointer-events: none !important;
    z-index: 10 !important;
    left: 0 !important;
}

#petCarousel .splide__arrow {
    pointer-events: all !important;
    background: rgba(127, 176, 105, 0.8) !important;
    border: none !important;
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
}

#petCarousel .splide__arrow:hover {
    background: rgba(127, 176, 105, 1) !important;
    transform: scale(1.1) !important;
}

#petCarousel .splide__arrow--prev {
    left: 20px !important;
}

#petCarousel .splide__arrow--next {
    right: 20px !important;
}

/* 首页响应式 */
@media (max-width: 1024px) {
    .infinite-scroll {
        width: 200%;
        animation-duration: 34s;
    }

    .infinite-scroll > .flex {
        gap: 1rem;
        width: 60%;
        min-width: 60%;
        max-width: 60%;
    }

    #petCarousel .splide__slide {
        width: calc(40% - 16px);
    }
}

@media (max-width: 768px) {
    .infinite-scroll {
        width: 160%;
        animation-duration: 32s;
    }

    .infinite-scroll > .flex,
    .infinite-scroll > .flex.w-full {
        width: 70%;
        min-width: 70%;
        max-width: 70%;
    }

    .pet-card {
        width: 13rem !important;
        min-width: 13rem !important;
        max-width: 13rem !important;
    }

    #petCarousel .splide__slide {
        width: calc(60% - 12px);
    }

    #petCarousel .splide__arrow {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 640px) {
    .infinite-scroll {
        width: 135%;
        animation-duration: 30s;
    }

    .infinite-scroll > .flex,
    .infinite-scroll > .flex.w-full {
        width: 85%;
        min-width: 85%;
        max-width: 85%;
    }

    .pet-card {
        width: 11.5rem !important;
        min-width: 11.5rem !important;
        max-width: 11.5rem !important;
    }

    #petCarousel .splide__slide {
        width: 90%;
        min-height: 260px;
        height: auto;
    }

    #petCarousel .splide__arrows {
        top: auto;
        bottom: 12px;
    }
}

@media (max-width: 480px) {
    .infinite-scroll {
        width: 115%;
        animation-duration: 28s;
    }

    .infinite-scroll > .flex,
    .infinite-scroll > .flex.w-full {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }

    .pet-card {
        width: 10.25rem !important;
        min-width: 10.25rem !important;
        max-width: 10.25rem !important;
    }

    #petCarousel .splide__slide {
        width: 100%;
        min-height: 230px;
        height: auto;
    }

    #petCarousel .splide__arrow {
        width: 36px;
        height: 36px;
    }
}

/* 模态框样式 */
#modal-container {
    display: none;
    z-index: 10000 !important;
}

/* 助养计划模态框样式 */
#sponsorship-modal:not(.hidden) {
    display: flex !important;
}

#sponsorship-modal.hidden {
    display: none !important;
}

#modal-container:not(.hidden) {
    display: flex !important;
    animation: fadeIn 0.3s ease-in-out;
    z-index: 10000 !important;
}

#modal-container.hidden {
    display: none !important;
}

#modal-container > div {
    z-index: 10000 !important;
}

#modal-container .page-transition {
    animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 模态框中的轮播样式 */
#modal-pet-carousel {
    width: 100%;
    height: 256px;
    position: relative;
}

#modal-pet-carousel .splide__track {
    height: 100%;
}

#modal-pet-carousel .splide__list {
    height: 100%;
}

#modal-pet-carousel .splide__slide {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /*!* 覆盖 Splide 自动生成的背景样式，将 cover 改为 contain *!*/
    /*background-size: contain !important;*/
    /*background-position: center center !important;*/
    /*background-repeat: no-repeat !important;*/
}

#modal-pet-carousel .splide__slide img,
#modal-pet-carousel .splide__slide video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#modal-pet-carousel .splide__arrows {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
    padding: 0 10px;
}

#modal-pet-carousel .splide__arrow {
    pointer-events: all;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
    color: white;
}

#modal-pet-carousel .splide__arrow:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

#modal-pet-carousel .splide__arrow--prev {
    left: 10px;
}

#modal-pet-carousel .splide__arrow--next {
    right: 10px;
}

#modal-pet-carousel .splide__pagination {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
}

#modal-pet-carousel .splide__pagination__page {
    background: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

#modal-pet-carousel .splide__pagination__page.is-active {
    background: rgba(255, 255, 255, 1);
}

