/* home-layouts.css — Feed / Grid / Rail product-first homepage layouts.
 *
 * Every rule is scoped under #home-v2 (the layouts' container), so nothing can
 * leak into Classic (#home-classic) — the one exception is .sfl-preview-pill,
 * which is appended to <body> and only exists in preview mode. Built on the
 * existing tokens (shopsmart-tokens.css / ss-foundation.css); no new palette.
 */

/* 16px top: the first row (Grid/Feed category icons) sat 2px under the
   header. (2026-11-04) */
#home-v2 { max-width: 1280px; margin: 0 auto; padding: 16px 16px 48px; }
#home-v2 * { min-width: 0; } /* let fl/grid children shrink — no horizontal page scroll */

#home-v2 .sfl-h { font-size: 18px; font-weight: 700; margin: 16px 0 10px; color: var(--text-1, #0D2B55); }

/* Horizontal scrollers: scroll inside their own box, scrollbar hidden. */
#home-v2 .sfl-cats,
#home-v2 .sfl-tabs,
#home-v2 .sfl-shops-rail,
#home-v2 .sfr-side,
#home-v2 .sfr-shops-rail { overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none; }
#home-v2 .sfl-cats::-webkit-scrollbar,
#home-v2 .sfl-tabs::-webkit-scrollbar,
#home-v2 .sfl-shops-rail::-webkit-scrollbar,
#home-v2 .sfr-side::-webkit-scrollbar,
#home-v2 .sfr-shops-rail::-webkit-scrollbar { display: none; }

/* ── Tabs (Feed + Grid) — 44px tap targets, keyboard-driven ──────────────── */
#home-v2 .sfl-tabs { display: flex; gap: 8px; padding: 10px 0; }
#home-v2 .sfl-tab {
  flex: 0 0 auto; min-height: 44px; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--line-2, #d0d5dd); background: var(--surface-card, #fff);
  color: var(--text-1, #0D2B55); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
#home-v2 .sfl-tab[aria-selected="true"] { background: var(--accent, #1B9BDB); color: #fff; border-color: var(--accent, #1B9BDB); }
#home-v2 .sfl-tab:focus-visible { outline: 2px solid var(--accent, #1B9BDB); outline-offset: 2px; }

/* ── Category icons row ──────────────────────────────────────────────────── */
#home-v2 .sfl-cats { display: flex; gap: 10px; padding: 2px 0 8px; }
#home-v2 .sfl-cat {
  flex: 0 0 auto; width: 58px; min-height: 44px; display: flex; flex-direction: column;
  align-items: center; gap: 5px; text-decoration: none; color: var(--text-2, #475467);
}
#home-v2 .sfl-cat-img, #home-v2 .sfl-cat-glyph {
  width: 46px; height: 46px; border-radius: 50%; object-fit: cover; display: grid;
  place-items: center; background: var(--surface-sunken, #f2f4f7); font-size: 22px;
}
#home-v2 .sfl-cat-name { font-size: 10.5px; text-align: center; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Flash strip ─────────────────────────────────────────────────────────── */
#home-v2 .sfl-flash { margin: 6px 0 14px; }
#home-v2 .sfl-flash-head { display: flex; align-items: center; margin-bottom: 8px; }
#home-v2 .sfl-flash-ttl { font-weight: 700; color: var(--text-1, #0D2B55); }
#home-v2 .sfl-flash-rail { position: relative; }
/* The ‹ › arrows live in this row (navHost). ss-card.js gives a hosted nav an
   inline 12px right margin; here it ends flush with the cards. */
#home-v2 .sfl-flash-head .ss-rail-nav { margin-right: 0 !important; }

/* ── Load more / end / empty ─────────────────────────────────────────────── */
#home-v2 .sfl-loadmore {
  display: block; margin: 18px auto; min-height: 44px; padding: 0 26px; border-radius: 999px;
  border: 1px solid var(--line-2, #d0d5dd); background: var(--surface-card, #fff);
  color: var(--text-1, #0D2B55); font-weight: 600; cursor: pointer;
}
#home-v2 .sfl-loadmore:focus-visible { outline: 2px solid var(--accent, #1B9BDB); outline-offset: 2px; }
#home-v2 .sfl-end, #home-v2 .sfl-empty { text-align: center; padding: 22px 0 8px; color: var(--text-3, #667085); }
#home-v2 .sfl-end a, #home-v2 .sfl-empty a { color: var(--accent, #1B9BDB); font-weight: 600; }
#home-v2 .sfl-sentinel { height: 1px; }

/* ── Bottom block (stats + shops) ────────────────────────────────────────── */
#home-v2 .sfl-bottom { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line-2, #d0d5dd); }
#home-v2 .sfl-stats { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline; background: var(--surface-card, #fff); border: 1px solid var(--line-2, #d0d5dd); border-radius: 10px; padding: 9px 14px; }
#home-v2 .sfl-stat { display: inline-flex; align-items: baseline; gap: 5px; }
#home-v2 .sfl-stat-n { font-size: 15px; font-weight: 800; color: var(--text-1, #0D2B55); font-variant-numeric: tabular-nums; }
#home-v2 .sfl-stat-l { font-size: 12px; color: var(--text-3, #667085); }
#home-v2 .sfl-shops-block { margin-top: 18px; }
#home-v2 .sfl-shops-rail { display: flex; gap: 14px; padding: 10px 0; }
#home-v2 .sfl-shop { flex: 0 0 auto; display: flex; flex-direction: row; align-items: center; gap: 8px; text-decoration: none; color: var(--text-1, #0D2B55); background: var(--surface-card, #fff); border: 1px solid var(--line-2, #d0d5dd); border-radius: 999px; padding: 5px 13px 5px 5px; }
#home-v2 .sfl-shop-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--surface-sunken, #f2f4f7); font-weight: 700; font-size: 12px; color: var(--text-2, #475467); }
#home-v2 .sfl-shop-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }

/* ── Layout A: Feed — masonry via CSS columns ────────────────────────────── */
#home-v2 .sfl-feed-masonry { column-count: 2; column-gap: 12px; }
@media (min-width: 600px) { #home-v2 .sfl-feed-masonry { column-count: auto; column-width: 196px; } }
#home-v2 .sfl-feed-masonry > .ss-pcard { display: inline-block; width: 100%; margin: 0 0 14px; break-inside: avoid; -webkit-column-break-inside: avoid; }

/* ── Layout B: Grid ──────────────────────────────────────────────────────── */
#home-v2 .sfg-cats { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 8px; }
#home-v2 .sfg-cats::-webkit-scrollbar { display: none; }
#home-v2 .sfg-cat { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 58px; min-height: 44px; text-decoration: none; color: var(--text-2, #475467); font-size: 10.5px; text-align: center; line-height: 1.2; }
#home-v2 .sfg-cat img, #home-v2 .sfg-cat span[aria-hidden] { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-size: 22px; background: var(--surface-sunken, #f2f4f7); }
#home-v2 .sfg-cat > span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Center the category icons when they fit; when the row overflows, the auto
   margins collapse to 0, so it still starts at the left and scrolls (plain
   justify-content:center would cut off the first icons). (2026-11-04) */
#home-v2 .sfg-cats > :first-child, #home-v2 .sfl-cats > :first-child { margin-left: auto; }
#home-v2 .sfg-cats > :last-child, #home-v2 .sfl-cats > :last-child { margin-right: auto; }
/* Single category nav = the ICON strip (preferred over the text megabar).
   Hide the header's redundant department bar ON THE HOMEPAGE only (this
   stylesheet loads only here), and turn the icon strips into single-row
   scrollers; home-layouts.js adds ‹ › arrows for mouse users. (2026-10-24) */
.megabar.ssh-depts { display: none; }
/* Classic's category section (.cats-grid is a 10-col grid → 2 rows) becomes a
   single scrollable row of compact icons, matching Feed/Grid. */
#home-classic .cats-grid { display: flex; grid-template-columns: none; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 8px; min-height: 0; }
#home-classic .cats-grid::-webkit-scrollbar { display: none; }
#home-classic .cats-grid > * { flex: 0 0 auto; width: 76px; }
#home-classic .cat-ico { width: 44px; height: 44px; font-size: 20px; }
#home-classic .cat-name { font-size: 11px; }
#home-v2 .sfg-tabbar { background: var(--surface-page, var(--surface-card, #fff)); padding: 8px 0; }
@media (min-width: 768px) { #home-v2 .sfg-tabbar { position: sticky; top: 0; z-index: 5; } } /* one sticky bar; phones stay unsticky */
#home-v2 .sfg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 600px) { #home-v2 .sfg-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; } }

/* ── Layout C: Rail ──────────────────────────────────────────────────────── */
#home-v2 .sfr-ticker { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 1px solid var(--line-2, #d0d5dd); border-radius: 10px; padding: 9px 14px; margin: 10px 0 14px; background: var(--surface-sunken, #f2f4f7); color: var(--text-2, #475467); font-size: 13px; }
#home-v2 .sfr-body { display: block; }
#home-v2 .sfr-side { display: flex; gap: 8px; padding: 4px 0 12px; }
#home-v2 .sfr-chip { flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2, #d0d5dd); background: var(--surface-card, #fff); color: var(--text-1, #0D2B55); text-decoration: none; font-size: 13px; white-space: nowrap; }
#home-v2 .sfr-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
#home-v2 .sfr-cell { position: relative; display: flex; flex-direction: column; }
#home-v2 .sfr-cell > .ss-pcard { flex: 1 1 auto; }
#home-v2 .sfr-qadd { margin-top: 8px; min-height: 44px; border-radius: 10px; border: 1px solid var(--accent, #1B9BDB); background: var(--accent, #1B9BDB); color: #fff; font-weight: 700; cursor: pointer; }
#home-v2 .sfr-qadd:focus-visible { outline: 2px solid var(--text-1, #0D2B55); outline-offset: 2px; }
#home-v2 .sfr-shops { grid-column: 1 / -1; margin: 6px 0; }
#home-v2 .sfr-shops-rail { display: flex; gap: 14px; }
@media (min-width: 1024px) {
  #home-v2 .sfr-body { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
  #home-v2 .sfr-side { position: sticky; top: 12px; flex-direction: column; overflow: visible; padding: 0; }
  #home-v2 .sfr-chip { width: 100%; }
}

/* ── Preview pill (appended to body in ?home_layout= preview) ─────────────── */
.sfl-preview-pill {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--ss-bottomnav-h, 56px) + 16px);
  z-index: 95; background: var(--accent, #1B9BDB); color: #fff; padding: 8px 16px;
  border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
@media (min-width: 900px) { .sfl-preview-pill { bottom: 20px; } }

/* ── Compact card treatment (approved mockup, 2026-10-24) ─────────────────
   Scoped to #home-v2 so Classic and every other page that loads ss-card are
   untouched; ss-card.js is not modified. Shrinks the product tiles, shows a
   compact rating/shop meta line on phones (an exception to ss-foundation's
   768px hide, for these layouts only), and slims the flash-deal rail. */
#home-v2 .ss-pcard { border-radius: 12px; }
#home-v2 .ss-pcard-media { aspect-ratio: 1 / 1; }
#home-v2 .ss-pcard-body { padding: 9px 11px 11px; }
#home-v2 .ss-pcard-name { font-size: 13px; line-height: 1.3; }
#home-v2 .ss-pcard-price { font-size: 15px; }
#home-v2 .ss-pcard-deal { font-size: 11px; }
#home-v2 .ss-pcard-save { transform: scale(0.82); }
/* Stars + sold, then the seller's city: one line each (they keep a fixed
   height, so a wrapped second row would be cut off). */
#home-v2 .ss-pcard-meta,
#home-v2 .ss-pcard-loc { font-size: 10.5px; }
/* No dead space in the card body (2026-11-05). ss-foundation reserves a
   two-line name and an empty was-price / stars / city line on every card.
   Here the name takes only the lines it needs, and price + facts sit at the
   bottom, so a row still lines up on its prices and its sold/city lines.
   An empty line is dropped unless another card in the same rail or grid
   fills it; then it stays reserved so that row keeps lining up. */
#home-v2 .ss-pcard-body { flex: 1 1 auto; }
#home-v2 .ss-pcard-name { height: auto; margin-bottom: 4px; }
#home-v2 .ss-pcard-price { margin-top: auto; }
#home-v2 :is(.sfl-flash-rail, .sfg-grid):not(:has(.ss-pcard-deal:not(:empty))) .ss-pcard-deal,
#home-v2 :is(.sfl-flash-rail, .sfg-grid):not(:has(.ss-pcard-meta:not(:empty))) .ss-pcard-meta,
#home-v2 :is(.sfl-flash-rail, .sfg-grid):not(:has(.ss-pcard-loc:not(:empty))) .ss-pcard-loc { display: none; }
/* Slimmer flash-deal rail tiles (ss-rail reads --ss-rail-item). */
#home-v2 .sfl-flash-rail .ss-rail { --ss-rail-item: 124px; }
/* Denser Rail cards where there's room (sidebar claims width at 1024). */
@media (min-width: 900px)  { #home-v2 .sfr-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { #home-v2 .sfr-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { #home-v2 .sfr-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── Classic (the live homepage) compact treatment — scoped to #home-classic
   so ONLY the homepage changes (product/category/search pages and ss-card.js
   are untouched). Compacts the product tiles and slims the two promo panes.
   The big hero sale image is left intact on purpose — its artwork can't be
   cropped safely without a visual check. Reversible by removing this block.
   (2026-10-24) */
#home-classic .ss-pcard { border-radius: 12px; }
#home-classic .ss-pcard-media { aspect-ratio: 1 / 1; }
#home-classic .ss-pcard-body { padding: 7px 9px 9px; }
#home-classic .ss-pcard-name { font-size: 12.5px; line-height: 1.25; }
#home-classic .ss-pcard-price { font-size: 14px; }
#home-classic .ss-pcard-deal { font-size: 11px; }
#home-classic .ss-pcard-save { transform: scale(0.82); }
/* Stars + sold, then the seller's city: one line each (they keep a fixed
   height, so a wrapped second row would be cut off). */
#home-classic .ss-pcard-meta,
#home-classic .ss-pcard-loc { font-size: 10.5px; }
#home-classic .promo-card { padding: 14px 16px; }
#home-classic .promo-card h3 { font-size: 18px; line-height: 1.15; }
#home-classic .promo-card p { font-size: 12px; }
/* Hero: cap the sale banner's height so the block reads smaller. Center-crop
   keeps the middle of the artwork (where the headline usually sits). Adjust the
   cap (or remove this rule) if it clips the banner text. */
#home-classic .hero-banner img { max-height: 230px; object-fit: cover; object-position: center; }
/* "Banners completely removed" experiment: hides the whole hero block (sale
   image + stats overlay + the two promo panes), so the homepage opens on
   Shop by category. Remove this one rule to bring the hero back. If the stats
   strip should stay, re-add it as a slim bar (follow-up). (2026-10-24) */
#home-classic .hero-grid { display: none; }
/* "Remove all banners" in Feed/Grid/Rail too: these layouts have no hero/promo
   panes, so the banner-type elements are the Rail promo ticker and the slim
   stats strip — hide both. Shops stay (content, not a banner); flash stays
   (products). Remove these rules to bring them back. (2026-10-24) */
#home-v2 .sfr-ticker { display: none; }
#home-v2 .sfl-stats { display: none; }

/* ‹ › scroll arrows for the category strips, added by home-layouts.js. Shown
   only on hover-capable, fine-pointer devices (desktop mouse) and only when the
   strip overflows; touch devices just swipe. (2026-10-24) */
.sfl-hscroll { position: relative; }
.sfl-hs-btn { display: none; }
@media (hover: hover) and (pointer: fine) {
  .sfl-hscroll.sfl-hs-on .sfl-hs-btn {
    display: grid; place-items: center; position: absolute; top: 44%; transform: translateY(-50%);
    z-index: 4; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-2, #d0d5dd);
    background: var(--surface-card, #fff); color: var(--text-1, #0D2B55); cursor: pointer;
    box-shadow: 0 2px 10px rgba(13, 43, 85, .16); font-size: 20px; line-height: 1; padding: 0;
  }
  .sfl-hscroll .sfl-hs-prev { left: -2px; }
  .sfl-hscroll .sfl-hs-next { right: -2px; }
  .sfl-hscroll .sfl-hs-btn:disabled { opacity: 0; pointer-events: none; }
}

/* Feed pagination (Prev / Page N / Next) — one bounded page in the DOM. */
#home-v2 .sfl-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 4px; }
#home-v2 .sfl-pager-btn { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2, #d0d5dd); background: var(--surface-card, #fff); color: var(--text-1, #0D2B55); font-weight: 600; font-size: 13.5px; cursor: pointer; }
#home-v2 .sfl-pager-btn:disabled { opacity: .45; pointer-events: none; }
#home-v2 .sfl-pager-btn:focus-visible { outline: 2px solid var(--accent, #1B9BDB); outline-offset: 2px; }
#home-v2 .sfl-pager-info { font-size: 13px; color: var(--text-3, #667085); font-variant-numeric: tabular-nums; }
