/*
 * Marketplace Landing Page — [liveag_marketplace]
 *
 * Styles for the catalog listing at /marketplace/.
 * Loaded via <link> tag inside the shortcode's ob_start() buffer —
 * only on pages that render [liveag_marketplace].
 *
 * Layout: two views toggled by JS —
 *   List  (.liveag-mp-view-list)  — clean list rows, divider-only separation.
 *   Tiles (.liveag-mp-view-tiles) — responsive card grid, thumbnail at top.
 *
 * @since POC
 * @ver   20260617d
 * @package LiveAg_Catalog
 */

/* =========================================================
   CONTAINER
   ========================================================= */

.liveag-marketplace {
    font-family: 'Poppins', sans-serif;
    color: #2b2b2b;
    padding: 0 0 56px;
    box-sizing: border-box;
}

/* =========================================================
   TOOLBAR — view toggle + sort toggle row
   ========================================================= */

.liveag-mp-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

/* ---- View toggle ---- */

.liveag-mp-view-toggle {
    display: flex;
    gap: 4px;
}

.liveag-mp-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #999;
    background: none;
    border: 1px solid #e0dbd3;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.liveag-mp-view-btn:hover {
    color: #4a7436;
    border-color: #9BBF7C;
    background-color: #f9f7f3;
}

/* Active state: aria-pressed="true" via CSS attribute selector */
.liveag-mp-view-btn[aria-pressed="true"] {
    color: #4a7436;
    border-color: #4a7436;
    background-color: #f5f0e8;
    font-weight: 600;
}

/* CSS-drawn list-lines icon (three horizontal bars) */
.liveag-mp-view-icon--list {
    display: inline-block;
    width: 13px;
    height: 10px;
    position: relative;
    flex-shrink: 0;
}

.liveag-mp-view-icon--list::before,
.liveag-mp-view-icon--list::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1.5px;
    background-color: currentColor;
    border-radius: 1px;
}

.liveag-mp-view-icon--list::before {
    top: 0;
    box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
}

.liveag-mp-view-icon--list::after {
    display: none;
}

/*
 * CSS-drawn grid icon (2x2 squares via box-shadow).
 * Earlier inline-grid approach only provided 2 pseudo-element cells.
 * Box-shadow on a single ::before simulates all 4 squares.
 */
.liveag-mp-view-icon--tiles {
    display: inline-block;
    width: 11px;
    height: 11px;
    position: relative;
    flex-shrink: 0;
}

.liveag-mp-view-icon--tiles::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4.5px;
    height: 4.5px;
    background-color: currentColor;
    border-radius: 1px;
    box-shadow:
        6.5px 0 0 currentColor,
        0     6.5px 0 currentColor,
        6.5px 6.5px 0 currentColor;
}

.liveag-mp-view-icon--tiles::after {
    display: none;
}

/* ---- Sort toggle ---- */

.liveag-mp-sort-toggle {
    display: flex;
    gap: 4px;
}

.liveag-mp-sort-btn {
    display: inline-flex;
    align-items: center;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #999;
    background: none;
    border: 1px solid #e0dbd3;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.liveag-mp-sort-btn:hover {
    color: #4a7436;
    border-color: #9BBF7C;
    background-color: #f9f7f3;
}

/* Active state: aria-pressed="true" via CSS attribute selector */
.liveag-mp-sort-btn[aria-pressed="true"] {
    color: #4a7436;
    border-color: #4a7436;
    background-color: #f5f0e8;
    font-weight: 600;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */

.liveag-mp-empty {
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    color: #888;
    text-align: center;
    padding: 56px 0;
    margin: 0;
}

/* =========================================================
   SECTION (single merged Catalogs block)
   ========================================================= */

.liveag-mp-section {
    margin-bottom: 56px;
}

.liveag-mp-section:last-child {
    margin-bottom: 0;
}

/*
 * Section heading — understated label style.
 * Small caps, tracked, green, with a thin rule extending right.
 * Using flex so the rule fills available width alongside the text.
 */
.liveag-mp-section-heading {
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #4a7436;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 12px 0;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

/* Thin rule extending from the section label to the right edge */
.liveag-mp-section-heading::after {
    content: '';
    display: block;
    height: 1px;
    background-color: #d4cdc3;
    flex: 1 1 auto;
    min-width: 20px;
}

/* =========================================================
   LIST CONTAINER
   Top border closes the list — each row adds a bottom border.
   In tiles view this becomes a CSS grid.
   ========================================================= */

.liveag-mp-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e8e3da;
}

/* =========================================================
   LIST ROW (anchor element — entire row is clickable)
   Base rules (mobile-first) appear here, before any @media.
   ========================================================= */

.liveag-mp-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #668866;
    text-decoration: none;
    color: inherit;
    padding: 4px 4px;
    box-sizing: border-box;
    transition: background-color 0.15s ease;
}

.liveag-mp-row:hover,
.liveag-mp-row:focus {
    background-color: #ffffff;
    outline: none;
    text-decoration: none;
    color: inherit;
}

.liveag-mp-row:focus-visible {
    outline: 2px solid #4a7436;
    outline-offset: -2px;
}

/* =========================================================
   THUMBNAIL
   Base: 44px square — useful in list view, hidden via CSS.
   In tiles view: full-width at top of card (overridden below).
   ========================================================= */

.liveag-mp-row-thumb {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    overflow: hidden;
    background-color: #f5f0e8;
    position: relative;
}

.liveag-mp-row-thumb-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* =========================================================
   ROW BODY
   ========================================================= */

.liveag-mp-row-body {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Header row: title + badge inline */
.liveag-mp-row-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.liveag-mp-row-title {
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #2b2b2b;
    margin: 0;
    padding: 0;
    line-height: 1.3;
    flex: 1 1 auto;
    min-width: 0;
}

.liveag-mp-row-date {
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #2b2b2b;
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.liveag-mp-row-desc {
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #2b2b2b;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    /* No line-clamp: full description shown in both List and Tiles views. */
    display: block;
    overflow: visible;
}

/* =========================================================
   STATUS BADGE — dot + label, no filled background
   A small colored circle followed by the status text.
   Much lighter than a filled pill; blends into the row.
   ========================================================= */

.liveag-mp-badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 5px;
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    line-height: 1;
}

/* Colored dot — rendered via ::before pseudo-element */
.liveag-mp-badge::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.liveag-mp-badge--active {
    color: #c00;
}
.liveag-mp-badge--active::before {
    background-color: #c00;
}

.liveag-mp-badge--upcoming {
    color: #41a100;
}
.liveag-mp-badge--upcoming::before {
    background-color: #41a100;
}

.liveag-mp-badge--past {
    color: #704400;
}
.liveag-mp-badge--past::before {
    background-color: #704400;
}

/* =========================================================
   LIST VIEW — scoped overrides under .liveag-mp-view-list
   Hide thumbnail column; collapse <br> to space; tighten vertical density.
   ========================================================= */

.liveag-mp-view-list .liveag-mp-row-thumb {
    display: none;
}

/* PHP emits " <br>" between title parts; hide the <br> in list view.
 * The leading space remains, keeping the two parts on one line with a space separator. */
.liveag-mp-view-list .liveag-mp-row-title br {
    display: none;
}

/* Tighten internal vertical spacing so more catalogs fit on screen. */
.liveag-mp-view-list .liveag-mp-row-body {
    gap: 0;
}

.liveag-mp-view-list .liveag-mp-row-title {
    line-height: 1.15;
}

.liveag-mp-view-list .liveag-mp-row-date {
    line-height: 1.2;
}

/*
 * Description in list view: full text, tighter line-height for density.
 * No line-clamp — full description wraps and shows completely.
 */
.liveag-mp-view-list .liveag-mp-row-desc {
    line-height: 1.3;
}

/* =========================================================
   TILES VIEW — card grid layout
   The .liveag-mp-list becomes a CSS Grid.
   Each .liveag-mp-row becomes a vertical card.
   ========================================================= */

/*
 * CSS Grid replaces the old flex-wrap layout.
 * auto-fit collapses empty trailing tracks so justify-content: center
 * actually centers the populated columns as a block within the container.
 * With auto-fill, empty ghost tracks fill the full row width and center
 * has nothing to act on — tiles appear left-aligned on wide viewports.
 * auto-fit + fixed 270px max: items still fill left-to-right; a lone
 * leftover tucks under column 1 (consistent with the left-to-right flow).
 * min(100%, 270px) lets the single column shrink on phones narrower than 270px.
 */
.liveag-mp-view-tiles .liveag-mp-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 270px));
    justify-content: center;
    gap: 20px;
    border-top: none;
}

/*
 * Card: vertical flex, white bg, rounded, 1px #555 border, drop shadow.
 * height: 100% fills the full CSS Grid row track so all cards in a row
 * are the same height regardless of description length (equal-height tiles).
 * The grid container already stretches items by default (align-items: stretch);
 * height: 100% reinforces this for the anchor element specifically.
 */
.liveag-mp-view-tiles .liveag-mp-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border: 1px solid #555555;
    border-radius: 9px;
    background-color: #fffefd;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    overflow: hidden;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    /* Grid track governs width; no flex: 0 1 270px needed here. */
    width: auto;
    height: 100%;
}

.liveag-mp-view-tiles .liveag-mp-row:hover,
.liveag-mp-view-tiles .liveag-mp-row:focus {
    background-color: #fffefd;
    border: 1px solid #555555;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(74, 116, 54, 0.2);
    transform: translateY(-1px);
}

/*
 * Thumbnail at top of tile — full width, portrait 27/35 aspect ratio.
 * position: relative enables the ::after overlay pseudo-element.
 * border-bottom provides the divider between image and body text;
 * updated to #77aa77 (#7a7) for a softer green tone.
 */
.liveag-mp-view-tiles .liveag-mp-row-thumb {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 27 / 35;
    border-radius: 0;
    flex-shrink: unset;
    border-bottom: 1px solid #77aa77;
    position: relative;
}

/*
 * Transparent overlay suppresses Edge/Chrome image-hover toolbar
 * (Visual Search icon, copy-image, etc.) WITHOUT removing the <img>
 * so alt text and SEO are preserved.
 * The ::after sits inside the <a> card link so clicks still activate
 * the anchor naturally — no pointer-events manipulation needed.
 * z-index:1 places it above the <img> (z-index: auto / 0).
 * inset:0 covers exactly the thumb div, nothing outside the image.
 */
.liveag-mp-view-tiles .liveag-mp-row-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

.liveag-mp-view-tiles .liveag-mp-row-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/*
 * Content area padding inside tile.
 * flex: 1 1 auto makes the body grow to fill the card's remaining height
 * after the fixed-aspect-ratio thumbnail, so short-description cards
 * in the same row match the height of their tallest neighbour.
 */
.liveag-mp-view-tiles .liveag-mp-row-body {
    flex: 1 1 auto;
    min-width: unset;
    padding: 16px;
    gap: 4px;
}

/* Title one step smaller in tile cards (card width tighter at 270px) */
.liveag-mp-view-tiles .liveag-mp-row-title {
    font-size: 15px;
}

/* Date slightly more prominent in tiles */
.liveag-mp-view-tiles .liveag-mp-row-date {
    font-size: 13px;
}

/* Description in tiles: full text shown, no clamp. Slightly larger font than list base. */
.liveag-mp-view-tiles .liveag-mp-row-desc {
    font-size: 13px;
    color: #444444;
}

/* =========================================================
   RESPONSIVE — TABLET (768px and up)
   ========================================================= */

@media (min-width: 768px) {
    .liveag-marketplace {
        padding: 0 0 64px;
    }

    /* --- LIST view tablet adjustments --- */
    .liveag-mp-view-list .liveag-mp-row {
        gap: 18px;
        padding: 5px 6px;
    }

    .liveag-mp-view-list .liveag-mp-row-body {
        gap: 0;
    }

    .liveag-mp-view-list .liveag-mp-row-title {
        font-size: 16px;
    }

    .liveag-mp-view-list .liveag-mp-row-date {
        font-size: 13px;
    }

    .liveag-mp-view-list .liveag-mp-row-desc {
        font-size: 13px;
    }

    /* --- TILES view tablet: grid governs columns; only body padding overridden --- */
    .liveag-mp-view-tiles .liveag-mp-row-body {
        padding: 18px;
    }
}

/* =========================================================
   RESPONSIVE — DESKTOP (1024px and up)
   ========================================================= */

@media (min-width: 1024px) {
    .liveag-marketplace {
        padding: 0 0 72px;
    }

    .liveag-mp-section {
        margin-bottom: 64px;
    }

    /* --- LIST view desktop adjustments --- */
    .liveag-mp-view-list .liveag-mp-row {
        gap: 20px;
        padding: 5px 8px;
    }

    .liveag-mp-view-list .liveag-mp-row-body {
        gap: 0;
    }

    .liveag-mp-view-list .liveag-mp-row-title {
        font-size: 17px;
    }

    /* --- TILES view desktop: grid governs columns; body padding + title overridden --- */
    .liveag-mp-view-tiles .liveag-mp-row-body {
        padding: 20px;
    }

    .liveag-mp-view-tiles .liveag-mp-row-title {
        font-size: 16px;
    }
}
