/* ==========================================================================
   category.css — category / tag listing page overrides
   Loaded AFTER styles/index.css, header.css and home.css (see category.ejs).
   home.css already switches body.sp-home from the old full-viewport swiper
   deck to normal document flow and supplies the shared `.sp-main` content
   width/padding -- category.ejs reuses both by carrying `class="sp-home
   sp-category"` on <body>. Everything specific to this page is additionally
   scoped under body.sp-category so it can't leak onto the homepage or any
   other view sharing home.css.

   Also loaded by all_items.ejs (see all_items.css, loaded right after this
   file): the "filters sidebar + sort toolbar + infinite-scroll product
   grid" shell below is identical structure for both a single category/tag
   listing and the all-items listing, so it lives here once and all_items.css
   only adds the bits that differ (a second filter facet for categories,
   clear visual separation between the two facets, and a couple of offcanvas
   corrections). If you're changing card/grid/filter layout, change it here
   -- all_items.css should only ever need facet-specific additions.
   ========================================================================== */

body.sp-category .sp-main {
  padding-top: 0.5rem;
}

/* ---------- Page title / count ---------- */
.sp-category-hero {
  padding: 1.5rem 0 1.25rem;
  border-bottom: 2px solid var(--sp-ink);
  margin-bottom: 24px;
}

.sp-category-hero__title {
  margin: 0 0 4px;
  font-size: clamp(24px, 3.5vw, 34px);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--sp-ink);
}

.sp-category-hero__count {
  margin: 0;
  font-size: 14px;
  color: var(--sp-muted);
  font-weight: 500;
}

@media (max-width: 560px) {
  .sp-category-hero {
    padding: 1rem 0 1rem;
    margin-bottom: 16px;
  }
}

/* ==========================================================================
   Card container/media base rules, copied verbatim from
   items_grid_shell.ejs's own <style> block. grid_item_card.ejs's <style>
   only covers the card's *internal* details (body, name, price, badges);
   the container/media rules normally come along for the ride because every
   other grid includes items_grid_shell.ejs. Both the category/tag page and
   the all-items page use their own wrapping/infinite-scroll grid instead
   (see .sp-cat-grid below), so these are reproduced here once, in a
   dedicated override file rather than a partial's inline <style>, so a
   single place stays canonical for every infinite-scroll grid on the site.
   ========================================================================== */
.sp-items-grid-shell-card {
  background: var(--sp-bg);
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.sp-items-grid-shell-card:hover {
  border-color: var(--sp-line);
  box-shadow: 0 10px 24px var(--sp-shadow);
}

.sp-items-grid-shell-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--sp-bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sp-items-grid-shell-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.sp-items-grid-shell-card:hover .sp-items-grid-shell-card__media img {
  transform: scale(1.04);
}

.sp-items-grid-shell-card__badges {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 2;
}

.sp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1.4;
  color: #fff;
  white-space: nowrap;
}

.sp-badge--hot {
  background: var(--sp-orange);
}

.sp-badge--discount {
  background: var(--sp-red);
}

.sp-badge--express {
  background: var(--sp-ink);
}

.sp-badge--standard {
  background: var(--sp-green);
}

.sp-badge svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

/* ==========================================================================
   Shared "filters + toolbar + infinite-scroll grid" shell, used by both
   category_items_grid.ejs and all_items_grid.ejs.
   ========================================================================== */
.sp-cat-items {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: start;
  padding: 8px 0 56px;
}

@media (max-width: 900px) {
  .sp-cat-items {
    grid-template-columns: 1fr;
  }
}

/* ---- Filters sidebar (desktop) ---- */
.sp-cat-filters {
  position: sticky;
  top: 16px;
  background: var(--sp-bg);
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  padding: 16px;
}

@media (max-width: 900px) {
  .sp-cat-filters {
    position: static;
    display: none;
  }
}

.sp-cat-filters__title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 12px;
  color: var(--sp-ink);
}

/* Second+ facet block within the same filters panel (all-items page) --
   a top rule + spacing gives clear separation between e.g. "Categories"
   and "Tags" without needing two separate panels. */
.sp-cat-filters__group + .sp-cat-filters__group {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--sp-line);
}

.sp-cat-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  color: var(--sp-ink);
}

.sp-cat-filter-option input {
  accent-color: var(--sp-red);
  width: 16px;
  height: 16px;
}

.sp-cat-filter-option label {
  cursor: pointer;
  flex: 1;
}

/* ---- Mobile filters trigger + offcanvas ----
   Bootstrap's `text-bg-dark` (used by the old itemFiltersOffcanvas) reads
   as a jarring dark panel against this page's light, card-style design --
   overridden below to match .sp-cat-filters instead: same white background,
   ink text, and red-accented checkboxes, so the mobile filter drawer looks
   like an extension of the page rather than a bolted-on Bootstrap default. */
.sp-cat-offcanvas {
  background: var(--sp-bg);
  color: var(--sp-ink);
}

.sp-cat-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--sp-line);
}

.sp-cat-offcanvas .offcanvas-title {
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sp-cat-offcanvas .btn-close {
  filter: none; /* keep Bootstrap's dark-icon default; text-bg-dark inverted it */
}

/* ---- Toolbar (mobile filters trigger + sort) ---- */
.sp-cat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sp-cat-toolbar__filters-btn {
  display: none;
}

@media (max-width: 900px) {
  .sp-cat-toolbar__filters-btn {
    display: inline-flex;
  }
}

.sp-cat-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sp-ink);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sp-cat-sort:hover {
  background: var(--sp-red);
}

/* ---- Staggered / wrapping product grid ----
   Unlike sp-items-grid-shell-grid's fixed column count, this wraps
   naturally so cards appended in batches during infinite scroll settle
   into place without a reflow jump, matching the reference layout's
   simple wrapping product-grid. */
.sp-cat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.sp-cat-grid .sp-items-grid-shell-card {
  flex: 1 1 220px;
  max-width: calc(20% - 16px);
}

@media (max-width: 1100px) {
  .sp-cat-grid .sp-items-grid-shell-card {
    max-width: calc(25% - 15px);
  }
}

@media (max-width: 820px) {
  .sp-cat-grid .sp-items-grid-shell-card {
    max-width: calc(33.333% - 14px);
  }
}

@media (max-width: 560px) {
  .sp-cat-grid {
    gap: 12px;
  }
  .sp-cat-grid .sp-items-grid-shell-card {
    max-width: calc(50% - 6px);
  }
}

/* ---- Infinite scroll sentinel / status row ---- */
.sp-cat-scroll-status {
  grid-column: 1 / -1;
  text-align: center;
  padding: 28px 0;
  color: var(--sp-muted);
  font-size: 14px;
}

.sp-cat-scroll-status .spinner-border {
  width: 1.75rem;
  height: 1.75rem;
}

.sp-cat-empty {
  padding: 48px 0;
  text-align: center;
  color: var(--sp-muted);
}
