
/* Instagram-like Explore Page Styles */
:root {
    --explore-bg: var(--surface-page);
    --explore-border: var(--line-strong);
    --explore-text: var(--ink);
    --explore-text-muted: var(--ink-muted);
    --explore-accent: #777777;
    --explore-accent-light: var(--brand-fill);
}

.explore-page {
    background: var(--explore-bg);
    min-height: 100vh;
}

.explore-container {
    background: var(--explore-bg);
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Stories-style Horizontal Chat Bar */
.stories-bar {
    background: var(--explore-bg);
    padding: 12px 0;
}

.stories-list {
    display: flex;
    gap: 16px;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.stories-list::-webkit-scrollbar {
    display: none;
}

.stories-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 8px;
    color: var(--explore-text-muted);
}

/* Story Avatar Style */
.chat-thumb-container {
    flex: 0 0 auto;
    text-align: center;
}

.chat-thumb-card {
    width: 66px !important;
    height: 66px !important;
    border-radius: 50% !important;
    border: 2px solid transparent !important;
    background: linear-gradient(var(--explore-bg), var(--explore-bg)) padding-box,
                linear-gradient(45deg, #a85c0c, #9f3814, #8a1628, #999999, #a5a5a5) border-box;
    padding: 3px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-thumb-card:hover {
    transform: scale(1.05);
}

.chat-thumb-card img {
    border-radius: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--explore-bg);
    z-index: 100;
    top: 56px;
}

@media (max-width: 991px) {
    .filter-bar {
        top: 50px;
    }
}

/* Tags Scroll */
.tags-scroll {
    display: flex;
    flex: 1;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 0;
}

.tags-scroll::-webkit-scrollbar {
    display: none;
}

.tags-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--explore-text-muted);
    font-size: 12px;
}

/* Query Tag Pills */
.query-tag {
    flex-shrink: 0;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    background: var(--explore-border);
    color: var(--explore-text);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.query-tag:hover {
    background: var(--fill-mid-soft);
}

.query-tag.active {
    background: var(--explore-text) !important;
    color: var(--explore-bg) !important;
}

/* Filter Icons */
.filter-icons {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.filter-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--explore-border);
    color: var(--explore-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.filter-icon-btn:hover,
.filter-icon-btn.active {
    background: var(--explore-text);
    color: var(--explore-bg);
}

.filter-dropdown {
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.filter-dropdown .dropdown-item {
    color: var(--explore-text);
    padding: 10px 16px;
    font-size: 14px;
}

.filter-dropdown .dropdown-item:hover {
    background: var(--fill-mid-soft);
}

.filter-dropdown .dropdown-divider {
    border-color: var(--line);
}

/* Explore Grid Gallery */
.explore-gallery {
    padding: 8px;
}

.explore-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 4px;
}

@media (min-width: 576px) {
    .explore-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .explore-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1200px) {
    .explore-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1600px) {
    .explore-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Gallery Card - Instagram Style */
.gallery-card {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface-sunken);
}

.gallery-card .card {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    height: 100%;
}

.gallery-card .gallery-image-wrapper {
    aspect-ratio: 1 !important;
    border-radius: 0 !important;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.gallery-card:hover img {
    transform: scale(1.02);
}

/* Hover Overlay */
.gallery-card .card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--glass);
    transition: background 0.2s ease;
    pointer-events: none;
}

.gallery-card:hover .card::after {
    background: var(--veil);
}

/* Card Overlay Content - Hidden by default, shown on hover */
.gallery-card .position-absolute.bottom-0 {
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.gallery-card:hover .position-absolute.bottom-0 {
    opacity: 1;
}

/* Hide bottom gradient by default */
.gallery-card .position-absolute[style*="gradient"] {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-card:hover .position-absolute[style*="gradient"] {
    opacity: 1;
}

/* Top badges always visible */
.gallery-card .position-absolute.top-0 {
    z-index: 10;
}

/* Multi-image indicator */
.gallery-card .multi-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--ink);
    font-size: 18px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.16));
    z-index: 5;
}

/* Video indicator */
.gallery-card .video-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--ink);
    font-size: 48px;
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.16));
    z-index: 5;
}

/* NSFW Blur - Only apply when gallery has blur-nsfw class */
.blur-nsfw .nsfw-content img {
    filter: blur(20px);
}

.blur-nsfw .nsfw-content:hover img {
    filter: blur(10px);
}

/* When user opts to show NSFW, no blur */
.nsfw-content img {
    transition: filter 0.3s ease;
}

/* Load More Area */
.load-more-area {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--explore-text-muted);
}

/* Spinner */
.spinner-border {
    color: var(--explore-text);
    border-color: var(--explore-text);
    border-right-color: transparent;
}

.text-purple {
    color: var(--explore-accent) !important;
}

/* Badge Styles */
.gallery-card .badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 4px;
}

/* Hidden elements for compatibility */
#selected-gender-text {
    display: none;
}

/* Override Bootstrap Grid for Gallery */
.explore-grid .gallery-card.col-6,
.explore-grid .gallery-card.col-sm-6,
.explore-grid .gallery-card.col-lg-3,
.explore-grid .gallery-card.col-xl-2 {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Responsive text */
@media (max-width: 576px) {
    .gallery-card h6 {
        font-size: 0.75rem !important;
    }
    
    .gallery-card .badge {
        font-size: 8px;
    }
    
    .filter-bar {
        padding: 8px 10px;
    }
    
    .query-tag {
        padding: 5px 12px;
        font-size: 12px;
    }
    
    .filter-icon-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* Safe area for mobile */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .explore-gallery {
        padding-bottom: calc(env(safe-area-inset-bottom) + 60px);
    }
}

/* Touch feedback */
@media (hover: none) {
    .gallery-card:active {
        opacity: 0.7;
    }
    
    .query-tag:active {
        transform: scale(0.95);
    }
}

/* Gallery hover effects - preserve for compatibility */
.gallery-hover {
    transition: transform 0.3s ease;
}

.gallery-img {
    transition: opacity 0.3s ease;
}
/* ─── Banner Carousel ─────────────────────────────────────────────── */
.banner-carousel {
    position: relative;
    overflow: hidden;
    background: var(--explore-bg);
}

.banner-carousel-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

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

.banner-slide {
    flex: 0 0 100%;
    scroll-snap-align: start;
    display: block;
    position: relative;
    cursor: pointer;
}

.banner-slide img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 150px;
    filter: brightness(1.25) contrast(1.1);
}

@media (min-width: 768px) {
    .banner-slide img {
        max-height: 80vh;
        object-fit: cover;
        filter: brightness(1.2) contrast(1.1);
    }
}

/* Carousel Dots */
.banner-carousel-dots {
    position: absolute;
    bottom: 9px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    z-index: 2;
}

.banner-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--explore-text-muted);
    transition: all 0.3s ease;
    cursor: pointer;
}

.banner-dot.active {
    background: var(--explore-accent);
    width: 18px;
    border-radius: 3px;
}

/* ─── Character Cards Grid (GirlfriendGPT-style) ───────────────── */
.char-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
}

@media (min-width: 768px) {
    .char-cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 16px;
    }
}

@media (min-width: 1200px) {
    .char-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Character Card */
.char-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface-sunken);
    aspect-ratio: 3 / 4;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.char-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.char-card-image {
    position: absolute;
    inset: 0;
}

.char-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    transition: transform 0.3s ease;
}

.char-card:hover .char-card-image img {
    transform: scale(1.05);
}

/* Card overlay.
   The bottom of a tile is a DARK band, not a white fade. The old gradient
   ended in rgba(255,255,255,.85), which on the ChatLamix skin put near-white
   ink (--ink) on a near-white wash — the name was unreadable on half the
   grid. The scrim tokens are dark in every skin, which is what "text on a
   photo" needs; the light-family ink for that band is --on-media-*. */
.char-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    /* Only the top dim here — enough to hold the price/lock badge. The bottom
       band is painted by .char-card-info so it can carry its own blur. */
    background: linear-gradient(
        to bottom,
        var(--scrim-soft) 0%,
        transparent 26%
    );
}

/* NSFW / SFW Tag */
.char-card-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
}

.char-card-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    pointer-events: auto;
}

.char-card-tag.nsfw {
    background: var(--fill-mid);
    color: var(--ink) !important;
}

/* `.char-card-icon` (private-album / new-images pips) and `.char-card-emoji-badge`
   lived here. buildCharCard() no longer emits either: a bare emoji floating over
   someone's photo read as cheap, and its shape/colour was whatever the phone's
   emoji font decided. The lock + price chip below is the only tile badge. */

.char-card-tag.sfw {
    background: #22c55e;
    color: var(--ink);
}

.char-card-tag.creator-exclusive {
    background: rgba(175, 127, 3, 0.95);
    color: var(--ink-inverse);
    text-decoration: none;
    gap: 4px;
}

.char-card-tag.creator-exclusive:hover {
    color: var(--ink-inverse);
    text-decoration: none;
}

/* Card info — the dark footer band.
   Frosted dark glass over the bottom of the photo: name, one-line intro,
   stats. ::before feathers the photo into the band so the top edge isn't a
   hard cut (the blur can't do the fade itself — backdrop-filter applies to
   the whole box, so a transparent-topped gradient would still blur square). */
.char-card-info {
    position: relative;
    padding: 10px 12px 11px;
    background: var(--scrim-strong);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
    backdrop-filter: blur(14px) saturate(130%);
    border-top: 1px solid var(--veil-glass);
}

.char-card-info::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 64px;
    background: linear-gradient(to top, var(--scrim) 0%, transparent 100%);
    pointer-events: none;
}

.char-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--on-media-ink);
    margin: 0 0 3px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Short intro — the character's own one-liner (short_intro). Two lines max,
   and the box keeps its height when the line wraps short so the stats row
   sits on the same baseline across the row of cards. */
.char-card-desc {
    font-size: 11.5px;
    color: var(--on-media-ink-soft);
    margin: 0 0 7px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Stats row */
.char-card-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-card-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--on-media-ink-soft);
    font-weight: 600;
}

/* The stat glyphs are the card's one spot of brand colour — violet on the
   ChatLamix skin, a bright neutral on the monochrome one. Both icons share
   --on-media-accent; they used to be two different greys for no reason. */
.char-card-stat i {
    font-size: 12px;
    color: var(--on-media-accent);
}

/* Premium price badge — a character sold on a subscription must not look free
   in the grid. Rendered by buildCharCard() in public/js/gallery-display-utils.js.
   (The old .coins-stat lived here; pointsSpent is platform revenue, not the
   creator's earnings, so it no longer appears on the card.) */
/* Subscription price tag.
   Reads as a price, not a reward: neutral dark glass so the number carries the
   message, with the lock in brand violet as the only colour. The old loud
   purple gradient + gem looked like a game badge sitting on someone's photo. */
.char-card-premium-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 8px;
    background: var(--veil-strong);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: var(--ink);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
    white-space: nowrap;
    pointer-events: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
}

.char-card-premium-badge i {
    font-size: 0.9em;
    color: var(--ink-soft);
}

/* "/mo" is secondary to the number it qualifies */
.char-card-premium-badge em {
    font-style: normal;
    font-weight: 500;
    opacity: 0.72;
}

@media (max-width: 480px) {
    .char-card-premium-badge {
        font-size: 10px;
        padding: 2px 7px;
    }
}

/* NSFW blur for char-cards */
.blur-nsfw .char-card.nsfw-content .char-card-image img {
    filter: blur(20px);
}

.blur-nsfw .char-card.nsfw-content:hover .char-card-image img {
    filter: blur(10px);
}

/* Loading items inside char-cards-grid */
.char-cards-grid .loading-grid {
    display: contents;
}

.char-cards-grid .loading-item,
.explore-grid .loading-item {
    aspect-ratio: 3 / 4;
    border-radius: 16px;
    background: linear-gradient(110deg, #e5e5e5 8%, #d9d9d9 18%, #e5e5e5 33%);
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
}

.explore-grid .loading-grid {
    display: contents;
}

@keyframes shimmer {
    to { background-position-x: -200%; }
}

/* Mobile adjustments */
@media (max-width: 576px) {
    .char-cards-grid {
        gap: 8px;
        padding: 8px;
    }

    .char-card-name {
        font-size: 13px;
    }

    /* Two columns on a phone leaves ~165px of card: one line of intro is all
       that fits before it reads as a wall of grey text under the name. */
    .char-card-desc {
        font-size: 10.5px;
        margin-bottom: 5px;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }

    .char-card-info {
        padding: 8px 10px 9px;
    }

    .char-card-info::before {
        height: 44px;
    }

    .char-card-tag {
        font-size: 10px;
        padding: 2px 8px;
    }

    .char-card-stats {
        gap: 8px;
    }

    .char-card-stat {
        font-size: 11px;
    }
}

/* ─── Create AI Companion CTA Banner ───────────────────────────── */
.create-companion-cta {
    background: var(--veil-strong);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 56px 24px 64px;
    margin-top: 40px;
    text-align: center;
}

.create-companion-cta-inner {
    max-width: 580px;
    margin: 0 auto;
}

.create-companion-cta-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    line-height: 1;
}

.create-companion-cta-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--ink) !important;
    line-height: 1.3;
    margin-bottom: 14px;
    letter-spacing: -0.02em;
}

.create-companion-cta-sub {
    font-size: 1rem;
    color: var(--ink-muted) !important;
    margin-bottom: 28px;
    line-height: 1.6;
}

.create-companion-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--fill-mid);
    color: var(--ink);
    padding: 15px 36px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.create-companion-cta-btn:hover {
    background: var(--fill-mid);
    color: var(--ink);
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.06);
    text-decoration: none;
}

.create-companion-cta-btn:active {
    transform: translateY(0);
}

@media (max-width: 576px) {
    .create-companion-cta {
        padding: 44px 20px 56px;
    }

    .create-companion-cta-title {
        font-size: 1.4rem;
    }

    .create-companion-cta-btn {
        padding: 14px 28px;
        font-size: 0.95rem;
    }
}

/* Admin NSFW toggle button on char-cards */
.char-card-admin-nsfw-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: none;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(4px);
}

.char-card-admin-nsfw-toggle:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.char-card-admin-nsfw-toggle.is-nsfw {
    background: rgba(144, 25, 36, 0.85);
    color: var(--status-ink);
}

.char-card-admin-nsfw-toggle.is-sfw {
    background: rgba(40, 167, 69, 0.85);
    color: var(--ink);
}

.char-card-admin-nsfw-toggle i {
    font-size: 12px;
}
