/* ==========================================================================
   Vendex — "market" homepage (inc/home-market.php, template-parts/home-market.php)
   Phone first. ≥768px: 3-column feed. ≥1024px: category hero + category cards.
   Cards stay large on phones: 2-column feed (~165–185px wide), 156px row cards.
   ========================================================================== */

body.vx-home-market { background: #EEF0F3; }
/* html and body both carry overflow-x:hidden, which makes <body> its own
   (never-scrolling) scroll container, so position:sticky inside it can't
   stick. clip still stops sideways scroll without creating a container. */
body.vx-home-market { overflow-x: clip; overflow-y: visible; }

.hm {
    --hm-ink: #0F1729;
    --hm-muted: #5B6472;
    --hm-line: #E3E6EB;
    --hm-navy: #00184a;
    --hm-price: var(--vx-primary-ink, #CD4000);
    color: var(--hm-ink);
    font-family: "DM Sans", "IBM Plex Sans Arabic", "Cairo", sans-serif;
    padding-bottom: 24px;
}
.hm h2 { margin: 0; color: var(--hm-ink); }
.hm a { text-decoration: none; }

/* Header on this page only: the search gets its own full-width row on phones
   (Amazon / AliExpress). Everywhere else the header keeps one row. */
@media (max-width: 768px) {
    body.vx-home-market .hp-header-main { flex-wrap: wrap; row-gap: 10px; }
    body.vx-home-market .hp-header-logo { margin-inline-end: auto; }
    /* .hp-header-main in the selector: ltr-overrides.css sets order:2 at the same weight */
    body.vx-home-market .hp-header-main .hp-header-search { order: 5; flex: 1 0 100%; max-width: none; }
}

/* ── Category tabs (phones): sticky, filter the feed in place ── */
.hm-tabs {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding: 0 8px;
    background: #fff;
    border-bottom: 1px solid var(--hm-line);
    scrollbar-width: none;
}
.hm-tabs::-webkit-scrollbar { display: none; }
.hm-tab {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 0 12px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--hm-muted);
    white-space: nowrap;
    cursor: pointer;
    box-shadow: inset 0 0 0 transparent;
}
.hm-tab.is-active { color: var(--hm-ink); box-shadow: inset 0 -3px 0 var(--hm-navy); }

.hm-trust {
    display: flex;
    flex-wrap: wrap;               /* French runs longer: wrap, never clip */
    justify-content: space-between;
    gap: 4px 12px;
    padding: 10px 14px;
    background: #E6F4EA;
    color: #14532D;
    font-size: 12px;
    font-weight: 700;
}
.hm-trust span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

.hm-wrap { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }

/* ── Blocks and section heads ── */
.hm-block { background: #fff; padding: 14px 0 16px; }
.hm-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0 14px 12px;
}
.hm-head h2 { font-size: 18px; font-weight: 700; }
.hm-head a { flex: 0 0 auto; white-space: nowrap; }
body.vx-ltr .hm-head a svg { transform: scaleX(-1); }
.hm-head a { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 700; color: var(--hm-navy); }

/* ── Product card ── */
.hm-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    color: var(--hm-ink);
    transition: box-shadow .2s;
}
.hm-card:hover { box-shadow: 0 6px 18px -8px rgba(15, 23, 41, .28); }
.hm-card-media { position: relative; display: block; background: #F3F5F8; }
.hm-card-media img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.hm-disc {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #DC2626;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}
body.vx-ltr .hm-disc { right: auto; left: 8px; }
.hm-card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 12px; }
.hm-card-name {
    font-size: 14px;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-align: start;
}
.hm-card-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 17px; font-weight: 800; color: var(--hm-price); }
.hm-card-price ins { text-decoration: none; }
.hm-card-price del { font-size: 12px; font-weight: 400; color: var(--hm-muted); }

/* ── Horizontal rows (recently viewed, offers, trending) ── */
.hm-track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 156px;
    gap: 10px;
    overflow-x: auto;
    padding: 0 14px;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 14px;
    scrollbar-width: none;
}
.hm-track::-webkit-scrollbar { display: none; }
.hm-track .hm-card { scroll-snap-align: start; border: 1px solid var(--hm-line); }
.hm-track .hm-card-name { font-size: 13px; }
.hm-track .hm-card-price { font-size: 16px; }

/* ── Category photo grid (phones) ── */
.hm-cat-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(2, auto);
    grid-auto-columns: 84px;
    gap: 14px 10px;
    overflow-x: auto;
    padding: 0 14px;
    scrollbar-width: none;
}
.hm-cat-grid::-webkit-scrollbar { display: none; }
.hm-cat { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--hm-ink); }
.hm-cat img { width: 76px; height: 76px; object-fit: cover; border-radius: 20px; border: 1px solid var(--hm-line); background: #F3F5F8; }
.hm-cat span { font-size: 12px; font-weight: 700; line-height: 1.25; text-align: center; }

/* ── Feed ── */
.hm-feed { padding: 14px 10px 0; }
.hm-feed-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 12px; }
.hm-feed-head h2 { font-size: 20px; font-weight: 700; }
.hm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hm-grid.is-loading { opacity: .5; transition: opacity .2s; }
.hm-feed-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0 8px; }
.hm-loading { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hm-muted); }
.hm-loading[hidden] { display: none; }
.hm-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #C9CED6; border-top-color: var(--hm-navy); animation: hm-spin .8s linear infinite; }
@keyframes hm-spin { to { transform: rotate(360deg); } }
.hm-load-more {
    min-height: 46px;
    padding: 0 28px;
    border: 1px solid #C9CED6;
    border-radius: 10px;
    background: #fff;
    color: var(--hm-ink);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.hm-load-more[hidden] { display: none; }
.hm-empty { margin: 0; font-size: 14px; color: var(--hm-muted); }

/* Category chips (desktop feed filter) */
.hm-chips { display: none; flex-wrap: wrap; gap: 8px; }
.hm-chip {
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid #D5DAE1;
    border-radius: 999px;
    background: #fff;
    color: var(--hm-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.hm-chip.is-active { background: var(--hm-navy); border-color: var(--hm-navy); color: #fff; }

/* Desktop-only blocks */
.hm-hero, .hm-quads { display: none; }

/* A category tab picked on a phone: the feed is the page. */
@media (max-width: 1023px) {
    .hm.is-filtered .hm-only-all { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .hm-spinner { animation-duration: 2.4s; }
}

/* ── Tablet ── */
@media (min-width: 768px) {
    .hm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
    .hm-track { grid-auto-columns: 190px; }
    .hm-feed { padding: 18px 16px 0; }
}

/* ── Desktop ── */
@media (min-width: 1024px) {
    .hm-tabs, .hm-trust, .hm-cats { display: none; }
    .hm-wrap { max-width: 1320px; margin: 0 auto; padding: 20px 24px 0; gap: 20px; }
    .hm-block, .hm-quad, .hm-hero > * { border-radius: 14px; }
    .hm-block { padding: 18px 0 20px; }
    .hm-head { padding: 0 20px 14px; }
    .hm-track { padding: 0 20px; scroll-padding-inline: 20px; }
    .hm-chips { display: flex; }
    .hm-feed { padding: 0; }
    .hm-feed-head { padding: 0 0 14px; }
    .hm-feed-head h2 { font-size: 22px; }
    .hm-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }

    /* Category hero: list | panel | side */
    .hm-hero { display: grid; grid-template-columns: 240px minmax(0, 1fr) 280px; gap: 16px; align-items: stretch; }
    .hm-hero-cats { background: #fff; padding: 8px; display: flex; flex-direction: column; }
    .hm-hero-cat {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 44px;
        padding: 6px 10px;
        border: 0;
        border-radius: 10px;
        background: none;
        font: inherit;
        text-align: start;
        cursor: pointer;
        color: var(--hm-ink);
        font-size: 14px;
        font-weight: 700;
    }
    .hm-hero-cat img { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; object-fit: cover; border: 1px solid var(--hm-line); }
    .hm-hero-cat span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .hm-hero-cat svg { color: var(--hm-muted); flex: 0 0 auto; }
    body.vx-ltr .hm-hero-cat svg { transform: scaleX(-1); }
    .hm-hero-cat:hover, .hm-hero-cat:focus-visible { background: #F3F5F8; }
    .hm-hero-cat.is-active { background: #E8EDF7; color: var(--hm-navy); }
    .hm-hero-all { margin-top: auto; padding: 10px; font-size: 14px; font-weight: 700; color: var(--hm-navy); }

    .hm-panel { background: #fff; padding: 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
    .hm-panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
    .hm-panel-count { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--hm-muted); }
    .hm-panel-title { font-size: 32px; line-height: 1.15; font-weight: 800; }
    .hm-panel-cta {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-height: 44px;
        padding: 0 18px;
        border-radius: 10px;
        background: var(--hm-navy);
        color: #fff;
        font-size: 14px;
        font-weight: 700;
    }
    .hm-panel-cta:hover { color: #fff; background: #002a7a; }
    body.vx-ltr .hm-panel-cta svg { transform: scaleX(-1); }
    .hm-panel-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-content: start; transition: opacity .15s; }
    .hm-panel-grid.is-loading { opacity: .45; }
    .hm-panel-grid .hm-card { border: 1px solid var(--hm-line); }
    .hm-panel-grid .hm-card-body { padding: 8px 10px 10px; gap: 4px; }
    .hm-panel-grid .hm-card-name { font-size: 13px; }
    .hm-panel-grid .hm-card-price { font-size: 15px; }
    .hm-panel-grid .hp-free-ship-tag { display: none; }

    .hm-side { display: flex; flex-direction: column; gap: 16px; }
    .hm-side-card { background: #fff; border-radius: 14px; padding: 20px; margin: 0; }
    .hm-side-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
    .hm-side-card p { margin: 0 0 14px; font-size: 14px; line-height: 1.6; color: var(--hm-muted); }
    .hm-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 46px;
        border-radius: 10px;
        background: var(--vx-primary, #FF6B00);
        color: #fff;
        font-size: 16px;
        font-weight: 700;
    }
    .hm-btn:hover { color: #fff; filter: brightness(1.05); }
    .hm-promises { list-style: none; display: flex; flex-direction: column; gap: 14px; }
    .hm-promises li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--hm-muted); }
    .hm-promises svg { flex: 0 0 22px; }
    .hm-promises strong { display: block; font-size: 14px; color: var(--hm-ink); }

    /* Four category cards */
    .hm-quads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
    .hm-quad { background: #fff; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
    .hm-quad h2 { font-size: 18px; font-weight: 700; }
    .hm-quad-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .hm-quad-grid .hm-card { border-radius: 10px; }
    .hm-quad-grid .hm-card-media { border-radius: 10px; overflow: hidden; }
    .hm-quad-grid .hm-card-body { padding: 6px 0 0; }
    .hm-quad-grid .hm-card-name, .hm-quad-grid .hp-free-ship-tag { display: none; }
    .hm-quad-grid .hm-card-price { font-size: 14px; }
    .hm-quad-grid .hm-card-price del { display: none; }
    .hm-more { font-size: 14px; font-weight: 700; color: var(--hm-navy); }
}

/* ==========================================================================
   Email popup — same rules as css/homepage.css (not loaded on this layout)
   ========================================================================== */
   ============================================================ */
.vx-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: vxPopupFadeIn 0.3s ease;
}
@keyframes vxPopupFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.vx-popup-box {
    background: linear-gradient(180deg, #fffdf9 0%, #fff5ea 100%);
    border: 1px solid rgba(255, 140, 0, 0.16);
    border-radius: 28px;
    padding: 38px 30px 30px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.22), 0 8px 20px rgba(255, 107, 0, 0.08);
    animation: vxPopupSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes vxPopupSlideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.vx-popup-close {
    position: absolute;
    top: 12px;
    left: 14px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--vx-text-muted, #666666);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}
.vx-popup-close:hover { color: #333; background: #f5f5f5; }
.vx-popup-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 12px;
}
.vx-popup-title {
    font-size: 22px;
    font-weight: 800;
    color: #00184a;
    margin: 0 0 8px;
}
.vx-popup-sub {
    font-size: 14px;
    color: #666;
    margin: 0 0 20px;
    line-height: 1.5;
}
.vx-popup-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}
.vx-popup-input {
    width: 100%;
    min-height: 56px;
    padding: 0 18px;
    border: 1.5px solid rgba(0, 24, 74, 0.12);
    border-radius: 18px;
    font-size: 15px;
    font-family: "IBM Plex Sans Arabic", "Cairo", sans-serif;
    text-align: left;
    box-sizing: border-box;
    color: #1f2c45;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.vx-popup-input:focus {
    border-color: rgba(255, 107, 0, 0.42);
    box-shadow: 0 0 0 4px rgba(255, 107, 0, 0.12);
}
.vx-popup-input::placeholder { color: #988c83; }
.vx-popup-submit.button {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: normal;
    text-align: center;
    vertical-align: middle;
    width: 100%;
    height: auto;
    min-height: 56px;
    padding: 16px 28px !important;
    background: linear-gradient(135deg, #FF8C00, #FF6B00) !important;
    color: #fff !important;
    border: none;
    border-radius: 12px !important;
    font-size: 17px !important;
    font-weight: 700;
    font-family: "IBM Plex Sans Arabic", "Cairo", sans-serif;
    cursor: pointer;
    text-transform: none;
    text-decoration: none !important;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 4px 16px rgba(255,107,0,0.35) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}
.vx-popup-submit.button:hover,
.vx-popup-submit.button:focus,
.vx-popup-submit.button:visited {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #FF8C00, #FF6B00) !important;
    box-shadow: 0 6px 22px rgba(255,107,0,0.45) !important;
    color: #fff !important;
    text-decoration: none !important;
}
.vx-popup-submit.button:active { transform: translateY(0); }
.vx-popup-submit.button:disabled { opacity: 0.6; cursor: default; }

/* Success state */
.vx-popup-tick {
    width: 56px;
    height: 56px;
    background: #16a34a;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 12px;
}
.vx-popup-success-msg {
    font-size: 16px;
    font-weight: 700;
    color: #16a34a;
    margin: 0 0 16px;
}
.vx-popup-code-wrap {
    background: #fffbe0;
    border: 2px dashed #FFB800;
    border-radius: 14px;
    padding: 16px;
}
.vx-popup-label {
    font-size: 12px;
    color: #888;
    display: block;
    margin-bottom: 6px;
}
.vx-popup-code {
    font-size: 28px;
    font-weight: 900;
    color: #00184a;
    letter-spacing: 3px;
    font-family: monospace;
}
.vx-popup-code-hint {
    font-size: 12px;
    color: #888;
    margin: 6px 0 0;
}

@media (max-width: 480px) {
    .vx-popup-box {
        padding: 30px 18px 22px;
        border-radius: 24px;
    }
    .vx-popup-title { font-size: 18px; }
    .vx-popup-input { border-radius: 16px; }
    .vx-popup-submit.button { border-radius: 12px !important; }
}
