/*
 * "Explore Topics" card and homepage topic carousel — shared by the Adult and
 * Youth category pages ({adult,youth}/loadTopic.js) and the homepage Adult and
 * Youth carousels (index.html). Card data: {adult,youth}/exploreTopicCards.js.
 * Rendering and the carousel: shared/topicCards.js.
 */

.Topic-topic-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    min-height: 140px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-end;
}

.Topic-topic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.1) 60%, rgba(0, 0, 0, 0) 100%);
    transition: background 0.3s ease;
}

.Topic-topic-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(178, 152, 220, 0.25);
}

.Topic-topic-card:hover::before {
    background: linear-gradient(to top, rgba(84, 64, 122, 0.85) 0%, rgba(178, 152, 220, 0.3) 60%, rgba(178, 152, 220, 0.1) 100%);
}

.Topic-topic-label {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: 600;
    color: white;
    text-align: left;
    line-height: 1.3;
    font-family: 'Poppins', -apple-system, sans-serif;
    padding: 12px 14px;
    width: 100%;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@media (max-width: 600px) {
    .Topic-topic-card {
        min-height: 120px;
    }

    .Topic-topic-label {
        font-size: 12px;
        padding: 10px 12px;
    }
}

/* Dark mode (category pages only; the homepage is light-only) */
body.dark-mode .Topic-topic-card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark-mode .Topic-topic-card:hover {
    box-shadow: 0 8px 20px rgba(178, 152, 220, 0.35);
}

/* Homepage topic carousels: one horizontally scrollable row of the cards above.
   --topics-carousel-accent tints the arrows to match each homepage section. */
.topics-carousel {
    --topics-carousel-accent: #6A5490;
    --topics-carousel-accent-rgb: 106, 84, 144;
    position: relative;
    align-self: stretch;
    width: 100%;
    max-width: 1000px;
    min-width: 0;
    margin: 0 auto 2rem;
}

.topics-carousel-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    /* Room for the card hover lift and shadow inside the scroll clip */
    padding: 6px 2px 14px;
    scroll-padding-inline: 2px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.topics-carousel-track::-webkit-scrollbar {
    display: none;
}

/* Four cards per view on desktop, matching the category page's four-column grid */
.topics-carousel-track > .Topic-topic-card {
    flex: 0 0 calc((100% - 48px) / 4);
    scroll-snap-align: start;
}

.topics-carousel-nav {
    position: absolute;
    top: calc(50% - 4px);
    transform: translateY(-50%);
    z-index: 2;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(var(--topics-carousel-accent-rgb), 0.15);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--topics-carousel-accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

.topics-carousel-nav:hover {
    box-shadow: 0 4px 12px rgba(var(--topics-carousel-accent-rgb), 0.25);
}

.topics-carousel-nav:focus-visible {
    outline: 2px solid var(--topics-carousel-accent);
    outline-offset: 2px;
}

/* Youth section: green arrows, matching its title and Explore Topics button */
.youth-chat-card .topics-carousel {
    --topics-carousel-accent: #2C5F4F;
    --topics-carousel-accent-rgb: 44, 95, 79;
}

.topics-carousel-nav--prev { left: -18px; }
.topics-carousel-nav--next { right: -18px; }

@media (max-width: 1100px) {
    .topics-carousel-nav--prev { left: 4px; }
    .topics-carousel-nav--next { right: 4px; }
}

@media (max-width: 900px) {
    .topics-carousel-track > .Topic-topic-card {
        flex-basis: calc((100% - 32px) / 3);
    }
}

/* Touch-sized screens: swipe only, with the next card peeking in */
@media (max-width: 768px) {
    .topics-carousel-nav {
        display: none;
    }

    .topics-carousel-track > .Topic-topic-card {
        flex-basis: calc((100% - 32px) / 2.4);
    }
}

@media (max-width: 600px) {
    .topics-carousel-track {
        gap: 12px;
    }

    .topics-carousel-track > .Topic-topic-card {
        flex-basis: calc((100% - 24px) / 2.3);
    }
}

@media (prefers-reduced-motion: reduce) {
    .topics-carousel-track {
        scroll-behavior: auto;
    }
}
