/* =============================================================
   AdultGuest Marketplace – grid.css
   Module 03: Full grid layout, listing cards, toolbar,
   pagination, filters, list-view mode, animations, empty state.
   ============================================================= */

/* ─────────────────────────────────────────────
   ARCHIVE PAGE HEADER
   ───────────────────────────────────────────── */
.archive-page-header {
    background: linear-gradient(160deg, var(--bg-secondary) 0%, #110a1f 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 52px 0 36px;
    position: relative;
    overflow: hidden;
}

/* decorative orb — purely visual, no layout impact */
.archive-page-header::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139,61,255,.1) 0%, transparent 70%);
    pointer-events: none;
}

/* The .container inside .archive-page-header inherits the global
   .container rule — max-width: var(--page-width), same gutters as
   the content container below. No overrides needed. */

.archive-header-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.archive-title {
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    margin: 10px 0 6px;
}

.archive-subtitle {
    color: var(--text-muted);
    font-size: .88rem;
    margin: 0;
}

/* ─── Archive search form ─── */
.archive-search-form { flex-shrink: 0; }

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    overflow: hidden;
    transition: border-color .25s;
    /* fluid: grows/shrinks with available space, never overflows header row */
    width: clamp(220px, 28vw, 360px);
}

.search-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255,45,117,.12);
}

.search-input-wrap .search-icon {
    flex-shrink: 0;
    margin: 0 10px;
    color: var(--text-muted);
}

.search-input-wrap input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 8px;
    font-size: .88rem;
    color: var(--text-primary);
    box-shadow: none;
    outline: none;
    min-width: 0;
}

.search-input-wrap .search-clear {
    padding: 0 10px;
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1;
    cursor: pointer;
    transition: color .2s;
    text-decoration: none;
}

.search-input-wrap .search-clear:hover { color: var(--accent); }

.search-input-wrap .btn {
    border-radius: 0;
    padding: 10px 16px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   MAIN CONTENT WRAPPER
   Inline style removed from the template.
   Vertical rhythm lives here, not inline.
   ───────────────────────────────────────────── */
.archive-content {
    padding-top:    48px;
    padding-bottom: 80px;
}

/* ─────────────────────────────────────────────
   CATEGORY FILTER TABS (scrollable on mobile)
   ─────────────────────────────────────────────
   width: 100% is CRITICAL.
   Without it, overflow-x:auto creates a shrink-
   wrap block-formatting context that can be 1–2px
   narrower than its siblings, breaking left-edge
   alignment with the toolbar and grid below.
   ───────────────────────────────────────────── */
.cat-filter-scrollable {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 28px;
    padding-bottom: 4px;
}

.cat-filter-scrollable::-webkit-scrollbar { display: none; }

.category-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: max-content;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.filter-btn:hover {
    background: rgba(255,45,117,.1);
    border-color: rgba(255,45,117,.35);
    color: var(--accent);
}

.filter-btn.active {
    background: rgba(255,45,117,.14);
    border-color: rgba(255,45,117,.5);
    color: var(--accent);
    font-weight: 600;
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    background: rgba(255,255,255,.07);
    border-radius: 10px;
    font-size: .7rem;
    font-weight: 600;
}

.filter-btn.active .filter-count {
    background: rgba(255,45,117,.2);
}

/* ─────────────────────────────────────────────
   TOOLBAR
   ───────────────────────────────────────────── */
.listings-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-left { }

.results-count {
    font-size: .82rem;
    color: var(--text-muted);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .82rem;
    color: var(--text-muted);
}

.toolbar-select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-btn);
    padding: 7px 30px 7px 12px;
    font-size: .82rem;
    font-family: var(--font-body);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a89cc0'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color .2s;
}

.toolbar-select:focus,
.toolbar-select:hover {
    border-color: var(--accent);
}

/* Grid / List toggle */
.view-toggle {
    display: flex;
    gap: 4px;
}

.view-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.view-btn:hover,
.view-btn.active {
    background: rgba(255,45,117,.1);
    border-color: rgba(255,45,117,.4);
    color: var(--accent);
}

/* ─────────────────────────────────────────────
   ACTIVE FILTERS BAR
   ───────────────────────────────────────────── */
.active-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: rgba(255,45,117,.06);
    border: 1px solid rgba(255,45,117,.15);
    border-radius: var(--radius-btn);
}

.active-filters-label {
    font-size: .78rem;
    color: var(--text-muted);
    margin-right: 4px;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255,45,117,.12);
    border: 1px solid rgba(255,45,117,.3);
    border-radius: 20px;
    font-size: .78rem;
    color: var(--accent);
    font-weight: 500;
}

.remove-filter {
    color: var(--accent);
    font-size: .7rem;
    text-decoration: none;
    opacity: .7;
    transition: opacity .2s;
}

.remove-filter:hover { opacity: 1; color: var(--accent); }

.clear-all-filters {
    font-size: .78rem;
    color: var(--text-muted);
    text-decoration: underline;
    margin-left: auto;
    transition: color .2s;
}

.clear-all-filters:hover { color: var(--accent); }

/* ─────────────────────────────────────────────
   LISTINGS GRID – GRID VIEW
   ───────────────────────────────────────────── */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    position: relative;
}

/* ─────────────────────────────────────────────
   LISTING CARD — grid item
   Every card is a flex column with a fixed-size
   image at top and a stretching body below.
   min-width: 0 prevents the card from overflowing
   its grid cell (flex children ignore grid track
   width without this).
   ───────────────────────────────────────────── */
.listing-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    overflow: hidden;
    transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;           /* CRITICAL: prevents overflow of grid cell */
    width: 100%;            /* fills the grid column track */
    height: 100%;           /* makes all cards in a row equal height */
}

/* CSS-only reveal — no JS required, no invisible-card risk */
@keyframes agm-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.agm-card-reveal {
    animation: agm-fade-up .35s ease both;
}

.listings-grid .agm-card-reveal:nth-child(2) { animation-delay: .05s; }
.listings-grid .agm-card-reveal:nth-child(3) { animation-delay: .10s; }
.listings-grid .agm-card-reveal:nth-child(4) { animation-delay: .15s; }
.listings-grid .agm-card-reveal:nth-child(5) { animation-delay: .05s; }
.listings-grid .agm-card-reveal:nth-child(6) { animation-delay: .10s; }
.listings-grid .agm-card-reveal:nth-child(7) { animation-delay: .15s; }
.listings-grid .agm-card-reveal:nth-child(8) { animation-delay: .20s; }

@media (prefers-reduced-motion: reduce) {
    .agm-card-reveal { animation: none; }
}

/* hover / glow states */
.listing-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-card);
    background: linear-gradient(135deg, rgba(255,45,117,.04), rgba(139,61,255,.04));
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}

.listing-card:hover {
    border-color: rgba(255,45,117,.45);
    box-shadow: 0 12px 48px rgba(255,45,117,.2), 0 4px 16px rgba(0,0,0,.5);
    transform: translateY(-4px);
}

.listing-card:hover::before { opacity: 1; }

.listing-card.featured {
    border-color: rgba(139,61,255,.4);
    box-shadow: 0 0 0 1px rgba(139,61,255,.2), var(--shadow-card);
}

.listing-card.featured:hover {
    border-color: rgba(139,61,255,.7);
    box-shadow: 0 12px 48px rgba(139,61,255,.25), 0 4px 16px rgba(0,0,0,.5);
}

/* ─────────────────────────────────────────────
   CARD IMAGE — fixed container, object-fit:contain
   ─────────────────────────────────────────────
   height: 200px is the ONLY sizing constraint.
   width: 100% fills the card. flex-shrink: 0
   prevents the image area from collapsing in
   flex-column layout.
   ───────────────────────────────────────────── */
.card-image {
    position: relative;
    width: 100%;
    height: 200px;
    flex-shrink: 0;         /* never compress the image in grid view */
    overflow: hidden;
    background: var(--bg-secondary);
    background-image: radial-gradient(ellipse at 50% 50%,
        rgba(139,61,255,.06) 0%,
        transparent 70%);
}

.card-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;        /* full image always visible — no crop, no stretch */
    object-position: center center;
    transition: opacity .3s ease;
}

.listing-card:hover .card-image img { opacity: .88; }

/* gradient overlay at bottom (shows through transparent areas) */
.card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(11,11,11,.5) 100%);
    pointer-events: none;
}

/* Badges sit above the overlay */
.card-image .featured-badge,
.card-image .category-badge {
    position: absolute;
    top: 10px;
    z-index: 2;
}
.card-image .featured-badge  { left: 10px; }
.card-image .category-badge  { right: 10px; }

/* placeholder: no thumbnail uploaded */
.card-image--placeholder {
    background-image:
        radial-gradient(ellipse at 50% 50%,
            rgba(139,61,255,.1) 0%, transparent 65%),
        repeating-linear-gradient(
            45deg,
            transparent,          transparent 12px,
            rgba(255,255,255,.015) 12px, rgba(255,255,255,.015) 13px
        );
}

.card-image--placeholder img {
    opacity: .3;
    filter: grayscale(60%);
}

/* ─────────────────────────────────────────────
   CARD BODY
   ───────────────────────────────────────────── */
.card-body {
    padding: 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;           /* prevents text from overflowing card */
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-title a {
    color: inherit;
    text-decoration: none;
    transition: color .2s;
}

.card-title a:hover { color: var(--accent); }

.card-desc {
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    line-height: 1.6;
}

/* Meta stats (DA / Traffic) */
.card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.meta-item {
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    text-align: center;
    transition: border-color .2s;
}

.listing-card:hover .meta-item { border-color: rgba(255,45,117,.15); }

.meta-label {
    font-size: .65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    display: block;
    margin-bottom: 2px;
}

.meta-value {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

/* Price row */
.card-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.price-label {
    font-size: .74rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.price-value {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--highlight));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Card action buttons */
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.card-actions .btn {
    flex: 1;
    padding: 9px 10px;
    font-size: .78rem;
    justify-content: center;
}

/* ─────────────────────────────────────────────
   LIST VIEW MODE
   ─────────────────────────────────────────────
   When .list-view is on the grid, each card
   becomes a horizontal row:
     [ image 240px ] [ title · stats · price · actions → ]
   All list-view overrides use ≥ 3-part selectors
   to guarantee higher specificity than base rules.
   ───────────────────────────────────────────── */
.listings-grid.list-view {
    grid-template-columns: 1fr;
    gap: 14px;
}

/* Card: switch to horizontal row */
.listings-grid.list-view .listing-card {
    flex-direction: row;
    align-items: stretch;
    height: auto;           /* natural height in list mode */
}

/* Image: fixed width, full card height */
.listings-grid.list-view .listing-card .card-image {
    width: 240px;           /* fixed left column */
    height: auto;           /* stretch to card height */
    min-height: 140px;      /* minimum so short cards still look good */
    flex-shrink: 0;
    flex-grow: 0;
    aspect-ratio: unset;
    border-radius: var(--radius-card) 0 0 var(--radius-card);
    overflow: hidden;
}

/* Body: takes remaining horizontal space, becomes a flex row itself */
.listings-grid.list-view .listing-card .card-body {
    flex: 1;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding: 16px 20px;
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Title block */
.listings-grid.list-view .listing-card .card-title {
    font-size: 1rem;
    flex: 1 1 160px;
    min-width: 120px;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    margin-bottom: 0;
}

/* Hide excerpt in list view (too long) */
.listings-grid.list-view .listing-card .card-desc {
    display: none;
}

/* Stats: compact horizontal boxes, no flex grow */
.listings-grid.list-view .listing-card .card-meta {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.listings-grid.list-view .listing-card .card-meta .meta-item {
    min-width: 64px;
    padding: 6px 10px;
}

/* Price: stacked label + value, no borders */
.listings-grid.list-view .listing-card .card-price {
    border: none;
    padding: 0;
    margin-bottom: 0;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 2px;
}

/* Action buttons: stacked column, fixed width */
.listings-grid.list-view .listing-card .card-actions {
    flex-direction: column;
    flex-shrink: 0;
    width: 130px;
    margin-top: 0;
    gap: 6px;
}

.listings-grid.list-view .listing-card .card-actions .btn {
    width: 100%;
    font-size: .76rem;
    padding: 8px 10px;
}


/* ─────────────────────────────────────────────
   PAGINATION
   ───────────────────────────────────────────── */
.agm-pagination {
    display: flex;
    justify-content: center;
    margin-top: 56px;
}

.agm-pagination .page-numbers {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.agm-pagination .page-numbers li { margin: 0; }

.agm-pagination .page-numbers a,
.agm-pagination .page-numbers span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.agm-pagination .page-numbers a:hover {
    border-color: rgba(255,45,117,.4);
    color: var(--accent);
    background: rgba(255,45,117,.08);
}

.agm-pagination .page-numbers .current {
    background: linear-gradient(135deg, var(--accent), #c0155a);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 16px rgba(255,45,117,.35);
}

.agm-pagination .page-numbers .dots {
    border: none;
    background: transparent;
    color: var(--text-muted);
}

/* ─────────────────────────────────────────────
   EMPTY STATE
   ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 100px 24px;
    max-width: 480px;
    margin: 0 auto;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.empty-state h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* ─────────────────────────────────────────────
   LOADING SKELETON (AJAX refresh)
   ───────────────────────────────────────────── */
@keyframes agm-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.listing-card-skeleton {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.skeleton-block {
    background: linear-gradient(90deg, #1a1a2e 25%, #221633 50%, #1a1a2e 75%);
    background-size: 400px 100%;
    animation: agm-shimmer 1.4s infinite;
    border-radius: 4px;
}

.skeleton-image  { aspect-ratio: 16/9; width: 100%; border-radius: 0; }
.skeleton-line   { height: 12px; margin: 8px 18px; }
.skeleton-line-sm { height: 10px; margin: 6px 18px; width: 60%; }
.skeleton-btn   { height: 36px; margin: 12px 18px 18px; border-radius: 8px; }

/* ─────────────────────────────────────────────
   RESPONSIVE BREAKPOINTS
   ───────────────────────────────────────────── */

/* ─────────────────────────────────────────────
   RESPONSIVE BREAKPOINTS
   ─────────────────────────────────────────────
   Breakpoints are set relative to --page-width (1280px).
   Container gutters shrink at each step (see style.css).
   Avoid duplicating max-width values here — the container
   is already handled; only grid columns change below.
   ───────────────────────────────────────────── */

/* ≥ 1361px: 4 cols (container at max-width 1280px + gutters) */
/* 1024px–1360px: 3 cols */
@media (max-width: 1360px) {
    .listings-grid:not(.list-view) {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 720px–1023px: 2 cols + collapse list-view image */
@media (max-width: 1023px) {
    .listings-grid:not(.list-view) {
        grid-template-columns: repeat(2, 1fr);
    }

    .listings-grid.list-view .card-image {
        width: 160px;
        height: 120px;
    }

    .listings-grid.list-view .card-body {
        gap: 14px;
    }

    .archive-header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Search form goes full width when header stacks */
    .search-input-wrap {
        width: 100%;
    }
    .archive-search-form { width: 100%; }
}

/* < 640px: single column, stack everything */
@media (max-width: 639px) {
    .listings-grid:not(.list-view) {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .listings-grid.list-view {
        grid-template-columns: 1fr;
    }

    .listings-grid.list-view .listing-card {
        flex-direction: column;
    }

    .listings-grid.list-view .card-image {
        width: 100%;
        height: 200px;
        aspect-ratio: unset;
    }

    .listings-grid.list-view .card-body {
        flex-direction: column;
        align-items: stretch;
    }

    .listings-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .agm-pagination .page-numbers a,
    .agm-pagination .page-numbers span {
        min-width: 34px;
        height: 34px;
        font-size: .8rem;
    }
}
