/* Shop listing page */
@import url("./catalog-card.css");

/* ---------- header ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--ink-500); }
.crumbs li { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs li + li::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--ink-300); border-top: 1.5px solid var(--ink-300); transform: rotate(45deg); margin-right: 2px; }
.crumbs a { padding-block: 12px; margin-block: -12px; color: var(--ink-600); }
.crumbs a:hover { color: var(--ink-900); text-decoration: underline; text-underline-offset: 3px; }
.crumbs [aria-current] { color: var(--ink-800); font-weight: 550; }

.shop-head { padding-top: 26px; }
.shop-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px 32px; margin-top: 14px; }
.shop-title { font-size: clamp(30px, 3.5vw, 46px); letter-spacing: -0.032em; font-weight: 850; }
.shop-sub { margin-top: 10px; max-width: 62ch; font-size: 15.5px; line-height: 1.55; color: var(--ink-600); }

.shop-search { position: relative; flex: none; width: min(380px, 100%); }
.shop-search svg { position: absolute; left: 14px; top: 50%; width: 19px; height: 19px; transform: translateY(-50%); color: var(--ink-500); pointer-events: none; }
.shop-search .input { height: 48px; padding: 0 44px 0 44px; border-radius: 10px; background: var(--bg-soft); border-color: var(--bg-soft); }
.shop-search .input:hover { border-color: var(--line-strong); }
.shop-search .input:focus { background: #fff; }
.shop-search .input::placeholder { color: var(--ink-500); }
.shop-search .input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--ink-500);
}
.search-clear:hover { background: #fff; color: var(--ink-900); }
.search-clear svg { position: static; transform: none; width: 18px; height: 18px; color: currentColor; }
.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; font-size: 12px; font-weight: 600; color: var(--ink-500); pointer-events: none; }
.shop-search:focus-within .search-kbd, .shop-search.has-value .search-kbd { display: none; }
/* The "/" shortcut hint means nothing on a touch-only tablet or phone. */
@media (hover: none) and (pointer: coarse) { .shop-search .search-kbd { display: none; } }

.cat-nav { margin-top: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tab { gap: 7px; height: 38px; padding: 0 12px 0 13px; }
.cat-tab .n { font-size: 12.5px; font-weight: 600; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.cat-tab.is-active .n { color: rgba(255, 255, 255, 0.72); }
.cat-tab.is-zero:not(.is-active) { color: var(--ink-500); border-color: var(--line); }
.cat-select { display: none; }
.cat-tabs.is-loading .chip { width: 120px; border: 0; }

/* ---------- body ---------- */
.shop-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 26px; padding-bottom: clamp(64px, 9vw, 120px); }
.results { min-width: 0; }

/* ---------- filters ---------- */
.filters-head, .filters-foot { display: none; }
.filters-title { font-family: var(--font-sans); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.fgroup { border-bottom: 1px solid var(--line); }
.fgroup:first-child { border-top: 1px solid var(--line); }
.fgroup > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 2px; list-style: none; cursor: pointer; user-select: none;
  font-size: 14.5px; font-weight: 700; color: var(--ink-900);
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary .sel { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--brand-600); }
.fgroup > summary svg { width: 16px; height: 16px; flex: none; color: var(--ink-500); transition: transform 0.2s var(--ease); }
.fgroup[open] > summary svg { transform: rotate(180deg); }
.fgroup > summary:focus-visible { box-shadow: var(--ring); border-radius: var(--radius-xs); }
.fbody { padding: 0 0 16px; }
.fopts { display: grid; gap: 1px; }
.fopt {
  display: flex; align-items: center; gap: 11px; min-height: 36px; padding: 4px 8px; margin: 0 -8px;
  border-radius: var(--radius-xs); cursor: pointer; font-size: 14.5px; color: var(--ink-800);
  transition: background-color 0.12s var(--ease);
}
.fopt:hover { background: var(--bg-soft); }
.fopt .n { margin-left: auto; padding-left: 8px; font-size: 12.5px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.fopt.is-zero { color: var(--ink-500); cursor: default; }
.fopt.is-zero:hover { background: none; }
.fopt input:disabled { opacity: 0.45; }
.fdot { width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--paint, #ddd); box-shadow: inset 0 0 0 1px rgba(11, 18, 32, 0.18); }
.fdot.is-pattern { background: conic-gradient(from 30deg, #5d6b4d, #a08a6a, #2b2f2a, #7d7a68, #5d6b4d); }

.price-custom { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-top: 12px; }
.price-custom .field { gap: 4px; }
.price-custom .label { font-size: 12.5px; font-weight: 600; color: var(--ink-600); }
.price-custom .input { height: 40px; padding: 0 10px; font-size: 14.5px; }
.price-custom .to { padding-bottom: 10px; font-size: 13px; color: var(--ink-500); }
.price-custom .btn { height: 40px; }
.price-note { margin-top: 10px; font-size: 12.5px; color: var(--ink-500); }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 14.5px; font-weight: 550; line-height: 1.4; color: var(--ink-800); }
.switch input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; position: relative; flex: none;
  width: 40px; height: 24px; margin: 0; border-radius: var(--radius-pill); background: var(--line-strong);
  cursor: pointer; transition: background-color 0.2s var(--ease);
}
.switch input[type="checkbox"]::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(11, 18, 32, 0.25); transition: transform 0.2s var(--ease);
}
.switch input[type="checkbox"]:checked { background: var(--brand-600); }
.switch input[type="checkbox"]:checked::before { transform: translateX(16px); }
.switch input[type="checkbox"]:focus-visible { box-shadow: var(--ring); }
.switch small { display: block; margin-top: 3px; font-size: 13px; font-weight: 400; color: var(--ink-500); }

@media (min-width: 1024px) {
  .shop-body { grid-template-columns: 244px minmax(0, 1fr); gap: 44px; }
  .filters {
    position: sticky; top: calc(var(--header-h) + 22px); align-self: start;
    max-height: calc(100vh - var(--header-h) - 44px); overflow-y: auto; overscroll-behavior: contain;
    margin-top: -4px; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .filters .fgroup:first-child { border-top: 0; }
  .filters .fgroup:first-child > summary { padding-top: 12px; }
  .toolbar .filter-btn { display: none; }
}
@media (min-width: 1200px) {
  .results .pgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 20px; }
}

/* Full-screen sheet below the desktop breakpoint */
@media (max-width: 1023.98px) {
  .filters {
    position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column;
    height: 100vh; height: 100dvh; background: #fff;
    transform: translateY(102%); visibility: hidden;
    transition: transform 0.32s var(--ease), visibility 0s linear 0.32s;
  }
  .filters.is-open { transform: none; visibility: visible; transition: transform 0.32s var(--ease), visibility 0s; }
  .filters-head {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: 62px; padding: 0 10px 0 20px; border-bottom: 1px solid var(--line); background: #fff;
  }
  .filters-close { width: 44px; height: 44px; }
  .filters-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 6px 20px 28px; }
  .filters-scroll .fgroup:first-child { border-top: 0; }
  /* "Clear all" at its natural width, "Show 100 styles" fills the rest; both stay on one line down to 280px. */
  .filters-foot {
    flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: #fff;
    box-shadow: 0 -8px 24px rgba(11, 18, 32, 0.06);
  }
  .filters-foot .btn { height: 50px; white-space: nowrap; }
  .filters-foot [data-filters-clear] { padding: 0 18px; }
  .sheet-backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(7, 11, 20, 0.4); opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s; }
  .sheet-backdrop.is-open { opacity: 1; visibility: visible; }
  .fopt { min-height: 44px; font-size: 15.5px; }
}
@media (max-width: 339.98px) {
  .filters-foot .btn, .filters-foot [data-filters-clear] { padding: 0 12px; }
}
@media (min-width: 1024px) { .sheet-backdrop { display: none; } }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 18px; }
.result-count { font-size: 14.5px; color: var(--ink-600); }
.result-count strong { color: var(--ink-900); font-weight: 700; }
.sort { display: flex; align-items: center; gap: 10px; flex: none; }
.sort-label { font-size: 14px; color: var(--ink-600); white-space: nowrap; }
.sort-field { position: relative; min-width: 0; }
.sort .select { width: auto; min-width: 200px; height: 42px; font-size: 14.5px; font-weight: 550; }
/* Phones draw the select's text with this short label (the native option text is too long for half a toolbar). */
.sort-value { display: none; }
.filter-btn { position: relative; }
.filter-btn svg { width: 18px; height: 18px; }
.filter-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--brand-600); color: #fff; font-size: 11.5px; font-weight: 700; }
.filter-badge[hidden] { display: none !important; }
.count-row { display: none; }

@media (max-width: 1023.98px) {
  .toolbar {
    position: sticky; top: var(--header-h); z-index: 30;
    margin: 0 calc(var(--gutter) * -1) 14px; padding: 10px var(--gutter);
    background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .toolbar .result-count { display: none; }
  .count-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
  .count-row .result-count { display: block; }
}

/* ---------- active filters ---------- */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -2px 0 22px; }
.afchip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 32px; padding: 0 8px 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--bg-soft);
  font-size: 13.5px; font-weight: 550; color: var(--ink-800); transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.afchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.afchip:hover { border-color: var(--ink-500); background: #fff; }
.afchip svg { width: 14px; height: 14px; flex: none; color: var(--ink-500); }
.afchip .fdot { width: 12px; height: 12px; }
.afclear { height: 32px; padding: 0 6px; border: 0; background: none; font-size: 13.5px; font-weight: 650; color: var(--brand-600); text-decoration: underline; text-underline-offset: 3px; }
.afclear:hover { color: var(--brand-700); }

/* ---------- grid states ---------- */
.results .pgrid { transition: opacity 0.18s var(--ease); }
.results .pgrid.is-updating { opacity: 0.35; }
.empty {
  display: grid; justify-items: center; gap: 10px; padding: clamp(40px, 7vw, 72px) 20px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--bg-soft);
}
.empty svg { width: 56px; height: 56px; color: var(--ink-400); margin-bottom: 6px; }
.empty h2 { font-size: 22px; letter-spacing: -0.02em; }
.empty p { max-width: 46ch; color: var(--ink-600); font-size: 15px; }
.empty .row { justify-content: center; margin-top: 10px; }
.empty-cats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }

.shop-error { padding: 48px 20px; text-align: center; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .shop-head-row { flex-direction: column; align-items: stretch; }
  .shop-search { width: 100%; }
}
@media (max-width: 639.98px) {
  .shop-head { padding-top: 18px; }
  .shop-head-row { margin-top: 10px; gap: 14px; }
  .shop-sub { display: none; }
  .shop-search .search-kbd { display: none; }
  .cat-nav { margin-top: 12px; padding-bottom: 16px; border-bottom: 0; }
  .cat-tabs { display: none; }
  .cat-select { display: grid; gap: 6px; }
  /* The closed select shows "Hoodies & Sweatshirts (23)", or just the name when that would be cut off (the count is
     also in the line under the toolbar); the open picker keeps the counts. */
  .cat-select-field { position: relative; }
  .cat-select .select { height: 48px; font-weight: 600; color: transparent; }
  .cat-select .select option { color: var(--ink-900); }
  .cat-select .select-value {
    position: absolute; inset: 0 40px 0 15px; display: flex; align-items: center; overflow: hidden; white-space: nowrap;
    pointer-events: none; font-size: 16px; font-weight: 600; color: var(--ink-900);
  }
  /* The heading right below names the category, so the trail stops at Shop instead of wrapping. */
  .crumbs li:nth-child(3):last-child { display: none; }
  .shop-body { padding-top: 4px; }
  .toolbar { gap: 10px; }
  /* Filters keeps its natural width (it grows a count badge); sort takes the rest of the row. */
  .toolbar .filter-btn { flex: none; height: 44px; padding: 0 14px; gap: 7px; white-space: nowrap; }
  .toolbar .sort { flex: 1 1 0; min-width: 0; }
  .sort-field { flex: 1 1 auto; }
  /* Visually hidden, still the select's accessible name. */
  .sort-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  /* 16px stops iOS zooming the page on focus; the visible text is .sort-value, so the select's own text is transparent. */
  .sort .select { min-width: 0; width: 100%; height: 44px; font-size: 16px; color: transparent; }
  .sort .select option { color: var(--ink-900); }
  .sort-value {
    position: absolute; inset: 0 38px 0 14px; display: flex; align-items: center; overflow: hidden; white-space: nowrap;
    pointer-events: none; font-size: 15px; font-weight: 600; color: var(--ink-900);
  }
  .sort-value-short { display: none; }
  .sort-value.is-tight .sort-value-long { display: none; }
  .sort-value.is-tight .sort-value-short { display: inline; }
  /* Empty state: the two actions stack as one equal-width column instead of two ragged centred buttons. */
  .empty .row { flex-direction: column; align-items: stretch; width: min(100%, 260px); }
  /* No clear button until there is text, so the placeholder can use that room. */
  .shop-search .input { padding-left: 42px; }
  .shop-search:not(.has-value) .input { padding-right: 12px; }
}
/* The filter sheet is used on touch screens: 16px fields stop iOS zooming in on focus. */
@media (max-width: 1023.98px) {
  .price-custom .input { font-size: 16px; }
}
