/* ============================================================
 * unified-cards.css  —  SINGLE SOURCE OF TRUTH for grid layout
 * ============================================================
 *
 * Owns:
 *   .amk-grid  +  .amk-cols-1..6
 *   .amk-section.amk-full  (full-width breakout)
 *   .amk-card  (base card)
 *   .amk-cats  (category grid variant)
 *   .amk-sold-badge
 *
 * Anti-duplication rules:
 *   - americanmarket.css      MUST NOT define .amk-grid.amk-cols-*
 *   - amk-grid-fix.css        SHOULD BE DELETED entirely
 *   - functions.php inline    MUST NOT print .amk-cols-5 or .amk-cols-6
 *
 * If a future file or block re-defines these selectors, the
 * cascade war restarts and 6-cols won't render at desktop
 * widths. Keep this file the authoritative one.
 *
 * Loads via wp_enqueue_style in functions.php — make sure no
 * other file uses `!important` on the same selectors after it.
 * ============================================================ */


/* ============================================================
 * 1. BASE GRID
 * ============================================================ */
.amk-grid {
    display: grid;
    gap: 18px;
    margin: 12px 0 24px;
    width: 100%;
    box-sizing: border-box;
    align-items: stretch;
    grid-auto-rows: 1fr;
}


/* ============================================================
 * 2. COLUMN COUNT MODIFIERS — desktop
 *    Same syntax for .amk-grid and .amk-cats.
 * ============================================================ */
.amk-grid.amk-cols-1,
.amk-cats.amk-cols-1 { grid-template-columns: 1fr; }

.amk-grid.amk-cols-2,
.amk-cats.amk-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.amk-grid.amk-cols-3,
.amk-cats.amk-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.amk-grid.amk-cols-4,
.amk-cats.amk-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.amk-grid.amk-cols-5,
.amk-cats.amk-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.amk-grid.amk-cols-6,
.amk-cats.amk-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }


/* ============================================================
 * 3. RESPONSIVE STEP-DOWN — generous so 6 cols survives normal
 *    desktop widths INCLUDING 90% browser zoom on 1920px.
 *
 *    Effective viewport at common zoom levels (1920px screen):
 *      100% zoom → 1920px  → 6 cols
 *       90% zoom → 1728px  → 6 cols  ✅ (was collapsing to 5)
 *       80% zoom → 1536px  → 6 cols
 *       75% zoom → 1440px  → 6 cols
 *
 *    Step-down happens at 1100 → 900 → 720 → 540 → 420.
 * ============================================================ */

@media (max-width: 1100px) {
    .amk-grid.amk-cols-6 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .amk-grid.amk-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .amk-grid.amk-cols-6,
    .amk-grid.amk-cols-5 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .amk-grid.amk-cols-6,
    .amk-grid.amk-cols-5,
    .amk-grid.amk-cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
    .amk-grid.amk-cols-6,
    .amk-grid.amk-cols-5,
    .amk-grid.amk-cols-4,
    .amk-grid.amk-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
    .amk-grid.amk-cols-6,
    .amk-grid.amk-cols-5,
    .amk-grid.amk-cols-4,
    .amk-grid.amk-cols-3,
    .amk-grid.amk-cols-2 { grid-template-columns: 1fr; }
}

/* Categories grid step-down (same breakpoints) */
@media (max-width: 1100px) {
    .amk-cats.amk-cols-6 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .amk-cats.amk-cols-6,
    .amk-cats.amk-cols-5 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .amk-cats.amk-cols-6,
    .amk-cats.amk-cols-5,
    .amk-cats.amk-cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
    .amk-cats.amk-cols-6,
    .amk-cats.amk-cols-5,
    .amk-cats.amk-cols-4,
    .amk-cats.amk-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
    .amk-cats { grid-template-columns: 1fr; }
}


/* ============================================================
 * 4. FULL-WIDTH BREAKOUT — for sections that need to escape
 *    the theme's content-width wrapper (which is typically
 *    ~1200px) so the grid has room to render 6 columns.
 *
 *    Usage:  <section class="amk-section amk-full">
 *
 *    Trick: 100vw + negative margin = element starts at left
 *    viewport edge regardless of parent width.
 * ============================================================ */
.amk-section.amk-full {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
}

/* The grid inside a .amk-full section fills the section width */
.amk-section.amk-full .amk-grid {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Stop horizontal scroll on body caused by 100vw being slightly
   wider than 100% when a vertical scrollbar is present. */
html, body {
    overflow-x: hidden;
}

/* Loosen common content-wrapper classes when they contain a
   full-width section, so nothing clips the breakout. */
.entry-content:has(.amk-full),
.site-content:has(.amk-full),
.content-area:has(.amk-full),
main:has(.amk-full),
article:has(.amk-full),
.wp-block-post-content:has(.amk-full) {
    overflow: visible;
    max-width: none;
}


/* ============================================================
 * 5. CARD BASE
 * ============================================================ */
.amk-card {
    position: relative;
    display: block;
    background: rgba(20, 30, 50, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    min-width: 0;
    box-sizing: border-box;
}

.amk-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
}

.amk-card__inner {
    display: block;
    width: 100%;
    height: 100%;
}


/* ============================================================
 * 6. CARD MEDIA / IMAGE AREA
 * ============================================================ */
.amk-card__img,
.amk-card__media {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background-color: #0e1726;
    background-size: cover;
    background-position: center;
}

.amk-card__img--empty,
.amk-card__media.is-empty {
    background-image: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.06),
        rgba(255, 255, 255, 0.02)
    );
}

.amk-card-media-link {
    display: block;
    text-decoration: none;
}


/* ============================================================
 * 7. CARD CONTENT / OVERLAY
 * ============================================================ */
.amk-card__overlay,
.amk-card__content {
    padding: 12px 14px 14px;
    color: #fff;
}

.amk-card__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 4px;
}

.amk-card__title a {
    color: #fff;
    text-decoration: none;
}

.amk-card__price {
    font-size: 16px;
    font-weight: 700;
    color: #ff5c5c;
    margin-bottom: 4px;
}

.amk-card__meta {
    font-size: 13px;
    opacity: 0.8;
    line-height: 1.4;
}


/* ============================================================
 * 8. CATEGORY GRID — base
 * ============================================================ */
.amk-cats {
    display: grid;
    gap: 14px;
    margin: 12px 0 24px;
}


/* ============================================================
 * 9. SOLD BADGE
 * ============================================================ */
.amk-sold-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.9), rgba(180, 0, 0, 0.9));
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}


/* ============================================================
 * 10. SECTION HELPERS
 * ============================================================ */
.amk-section {
    margin: 24px 0 32px;
}

.amk-section__title {
    font-size: 22px;
    font-weight: 700;
    margin: 8px 0 14px;
    color: #fff;
}

.amk-empty {
    padding: 18px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
}