/*
 * Maman & Moi: Sleep Sacks category page (kit elements 8, 10, 11 and the card grid).
 * Phone first. Breakpoints: 600 px and 1024 px, min-width only. Only --mm- tokens. Classes start with .cat-.
 * Loaded after tokens.css, base.css, shell.css and widgets.css.
 * Note: base.css sets `ul[class] { padding: 0 }` (specificity 0,1,1), so lists that need padding are written ul.cat-x.
 */

/* ---------- Breadcrumbs and head (elements 8, 10) ---------- */
.cat-crumbs { padding-top: var(--mm-s1); }
.cat-crumbs .crumbs a { min-width: var(--mm-tap); justify-content: center; }   /* "Home" is only 38 px wide on its own */
.cat-head { display: grid; gap: var(--mm-s3); padding-top: var(--mm-s1); }
.cat-head-txt { display: flex; flex-direction: column; gap: var(--mm-s3); }
.cat-intro { max-width: 68ch; }
.cat-head-photo { display: none; }

@media (min-width: 1024px) {
  .cat-head { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--mm-gutter); align-items: end; padding-top: var(--mm-s3); }
  .cat-head-txt { grid-column: 1 / span 8; }
  .cat-head-photo { display: flex; grid-column: 9 / span 4; }
}

/* ---------- Sub-group chips: one scrolling row on a phone, 16 px of padding at both ends ---------- */
.cat-chips-nav { margin-top: var(--mm-s4); }
ul.cat-chips {
  display: flex; align-items: center; gap: var(--mm-s2); list-style: none;
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  margin-inline: calc(-1 * var(--mm-margin)); padding: 2px 0 2px var(--mm-margin);
}
ul.cat-chips::-webkit-scrollbar { display: none; }
ul.cat-chips::after { content: ""; flex: 0 0 calc(var(--mm-margin) - var(--mm-s2)); }   /* end padding that scroll boxes keep */
.cat-chips > li { flex: none; }
.cat-togl { display: inline-flex; align-items: center; gap: var(--mm-s2); min-height: var(--mm-tap); padding: 0 var(--mm-s3); font: 700 .9375rem/1.25rem var(--mm-font-text); white-space: nowrap; }

@media (min-width: 1024px) {
  ul.cat-chips { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding: 0; }
  ul.cat-chips::after { display: none; }
  .cat-chips > li:last-child { margin-left: var(--mm-s2); }
}

/* ---------- Shop block: filter bar, applied chips, grid ---------- */
.cat-shop { margin-top: var(--mm-s4); }
.no-js .cat-bar { display: none; }   /* the bar needs scripts here; WooCommerce prints real links in the theme */

/* Phone: one row, Filter and Sort side by side, the count under it */
.cat-bar { background: var(--mm-white); border-block: 1px solid var(--mm-line); }
.cat-bar-in { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--mm-s1) var(--mm-s2); padding-block: var(--mm-s2); align-items: center; }
.cat-fbtn { grid-column: 1; grid-row: 1; width: 100%; }
.cat-sort { grid-column: 2; grid-row: 1; position: relative; display: flex; align-items: center; }
.cat-count { grid-column: 1 / -1; grid-row: 2; font: 600 .875rem/1.25rem var(--mm-font-text); font-variant-numeric: tabular-nums; }
.cat-groups { display: none; }

/* Count badge (on Filter and on each group button) */
.cat-n { display: inline-block; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--mm-navy); color: var(--mm-white); font: 700 .75rem/1.25rem var(--mm-font-text); text-align: center; font-variant-numeric: tabular-nums; }

/* Sort: a native select. On a phone the label sits inside it ("Sort: Featured"). */
.cat-sort label { position: absolute; left: 14px; z-index: 1; pointer-events: none; font: 600 1rem/1.375rem var(--mm-font-text); }
.cat-sort label::after { content: ":"; }
.cat-sort .sel { min-height: var(--mm-tap); font-weight: 600; padding-left: 62px; }

/* Group buttons (computer): TOG, Size, Print, Price */
.cat-gb {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--mm-tap); padding: 0 10px 0 16px;
  border: 1.5px solid var(--mm-line-strong); border-radius: var(--mm-r-sm); background: var(--mm-white);
  font: 600 .9375rem/1.25rem var(--mm-font-text); color: var(--mm-navy);
}
.cat-gb:hover { border-color: var(--mm-navy); }
.cat-gb[aria-expanded="true"] { border-color: var(--mm-navy); background: var(--mm-mint-50); box-shadow: 0 0 0 .5px var(--mm-navy); }
.cat-gb .ic { transition: transform var(--mm-t-quick) var(--mm-ease-soft); }
.cat-gb[aria-expanded="true"] .ic { transform: rotate(180deg); }

/* Popovers (computer): small, one shadow, each choice applies at once */
.cat-pop {
  position: absolute; top: calc(100% - var(--mm-s1)); left: 0; z-index: 2; width: 300px; max-width: 100%;
  max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: var(--mm-s4);
  padding: var(--mm-s5); background: var(--mm-white); border-radius: var(--mm-r-md);
  box-shadow: var(--mm-shadow), 0 0 0 1px var(--mm-line);
}
.cat-pop-print { width: 560px; }
.cat-pop .lbl { margin-bottom: var(--mm-s3); display: block; }
.cat-opts { display: flex; flex-direction: column; }
.cat-opts .opt { justify-content: flex-start; }
.cat-opts .cb:disabled { border-color: var(--mm-glyph-off); cursor: not-allowed; }
.cat-opts .cb:disabled + span { color: var(--mm-disabled-fg); }
.cat-opts .opt:has(.cb:disabled) { cursor: not-allowed; }
.cat-why { color: var(--mm-grey-700); font-size: .8125rem; }
.cat-pop-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--mm-s4); border-top: 1px solid var(--mm-line); padding-top: var(--mm-s2); }
.cat-note { margin-top: var(--mm-s2); }

/* Print swatches (popover and sheet): a placeholder pattern until her swatch photos are cropped */
.cat-prints { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--mm-s2) 0; }
.cat-pop-print .cat-prints { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--mm-s3) var(--mm-s1); }
.cat-prints[data-collapsed="true"] .is-extra { display: none; }
.cat-swt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding-bottom: var(--mm-s1); cursor: pointer; text-align: center; font: 500 .8125rem/1rem var(--mm-font-text); text-wrap: balance; }
.cat-swc { position: relative; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; }
.cat-swc .sw { width: 36px; height: 36px; }
.cat-ring { position: absolute; inset: 0; width: 48px; height: 48px; display: none; overflow: visible; }
.cat-swt input:checked ~ .cat-swc .cat-ring { display: block; }
.cat-swt input:checked ~ .cat-swn { font-weight: 700; }
.cat-swt input:focus-visible ~ .cat-swc { outline: 2px solid var(--mm-navy); outline-offset: 2px; }
.cat-swn { overflow-wrap: anywhere; }

/* Applied filters: mint-100 chips with a 44 px remove button (REVIEW.md), then Clear all */
ul.cat-applied {
  display: flex; align-items: center; gap: var(--mm-s2); list-style: none;
  overflow-x: auto; scrollbar-width: none;
  margin: var(--mm-s2) calc(-1 * var(--mm-margin)) 0; padding: 0 0 0 var(--mm-margin);
}
ul.cat-applied::-webkit-scrollbar { display: none; }
ul.cat-applied::after { content: ""; flex: 0 0 calc(var(--mm-margin) - var(--mm-s2)); }
.cat-applied > li { flex: none; }
.cat-ap { display: inline-flex; align-items: center; min-height: var(--mm-tap); padding-left: 14px; border-radius: var(--mm-r-sm); background: var(--mm-mint-100); font: 600 .9375rem/1.25rem var(--mm-font-text); white-space: nowrap; }
.cat-ap .icb:hover { background: var(--mm-mint-200); }
.cat-ap .ic { width: 18px; height: 18px; }

/* Grid and states */
.cat-grid { margin-top: var(--mm-s4); }
.cat-item { min-width: 0; }
.cat-empty { margin-top: var(--mm-s4); }
.cat-empty .btn-txt { vertical-align: baseline; }
.cat-foot { margin-top: var(--mm-s6); text-align: center; font-variant-numeric: tabular-nums; }

@media (min-width: 1024px) {
  .cat-shop { margin-top: var(--mm-s5); }
  /* Sticks under the COMPACT header (64 px on a computer; shell.css names it --sh-c). The header box stays 88 px tall
     but only its bar is drawn, and it is compact by the time this bar can stick (after 120 px of scroll). z-index 20 is under the header's 50. */
  .cat-bar { position: sticky; top: var(--sh-c, 64px); z-index: 20; }
  .cat-bar-in { display: flex; gap: var(--mm-s2); padding-block: var(--mm-s3); }
  .cat-fbtn { display: none; }
  .cat-groups { display: flex; align-items: center; gap: var(--mm-s2); margin-right: auto; }
  .cat-groups .lbl { margin-right: var(--mm-s1); }
  .cat-count { grid-column: auto; font-size: .9375rem; margin-right: var(--mm-s2); }
  .cat-sort label { position: static; margin-right: var(--mm-s3); pointer-events: auto; font-size: .875rem; font-weight: 600; }
  .cat-sort label::after { content: none; }
  .cat-sort .sel { width: auto; padding-left: 14px; }
  ul.cat-applied { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding: 0; }
  ul.cat-applied::after { display: none; }
  .cat-grid { margin-top: var(--mm-s5); }
}

/* ---------- Phone filter sheet (role=dialog, opened with MM.dialog.open) ---------- */
@media (min-width: 600px) {
  #cat-sheet { width: min(100%, 560px); margin-inline: auto; }   /* tablets: centred, not stretched */
}
#cat-sheet .sheet-body { display: flex; flex-direction: column; gap: var(--mm-s5); }
#cat-sheet .sheet-foot { padding-bottom: calc(var(--mm-s3) + env(safe-area-inset-bottom, 0px)); }
.cat-fs .lbl { margin-bottom: 10px; display: block; }
.cat-chipgrid { display: grid; gap: var(--mm-s2); }
.cat-cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cat-cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cat-chipgrid .chip { flex-direction: column; gap: 0; min-height: 52px; padding: 6px 4px; }
.cat-chipgrid .chip small { font-size: .75rem; line-height: 1rem; font-weight: 500; }
.cat-chipgrid .chip[aria-pressed="true"] small { font-weight: 600; }
.chip[disabled] { background: var(--mm-disabled-bg); border-color: transparent; color: var(--mm-disabled-fg); cursor: not-allowed; }
.cat-price { display: flex; flex-wrap: wrap; gap: var(--mm-s2); }
.cat-allprints { margin-top: var(--mm-s1); }
.cat-go { flex: 1; }
.cat-go[aria-disabled="true"] { background: var(--mm-disabled-bg); color: var(--mm-disabled-fg); cursor: not-allowed; }

/* ---------- Text block and questions (element 10) ---------- */
.cat-text { display: grid; gap: var(--mm-s6); }
.cat-copy-in { position: relative; }
.cat-more { margin-top: var(--mm-s1); }
.cat-more .ic { transition: transform var(--mm-t-quick) var(--mm-ease-soft); }
.cat-more[aria-expanded="true"] .ic { transform: rotate(180deg); }
.no-js .cat-more { display: none; }
/* About 6 lines on a phone, with a fade. The text is never removed: it is clipped, not display: none. */
html:not(.no-js) .cat-copy[data-open="false"] .cat-copy-in { max-height: calc(6 * 1.5em); overflow: hidden; }
html:not(.no-js) .cat-copy[data-open="false"] .cat-copy-in::after { content: ""; position: absolute; inset: auto 0 0 0; height: 56px; pointer-events: none; background: linear-gradient(to top, var(--mm-white), transparent); }
.cat-qa h3 { margin-bottom: var(--mm-s3); }
.cat-qa .acc-body p + p { margin-top: var(--mm-s2); }

@media (min-width: 1024px) {
  .cat-text { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--mm-gutter); }
  .cat-copy { grid-column: 1 / span 6; }
  .cat-qa { grid-column: 8 / span 5; padding-top: var(--mm-s1); }
  /* Plenty of room on a computer: the whole text shows and Read more goes away */
  html:not(.no-js) .cat-copy[data-open="false"] .cat-copy-in { max-height: none; overflow: visible; }
  html:not(.no-js) .cat-copy[data-open="false"] .cat-copy-in::after { display: none; }
  .cat-more { display: none; }
}

/* ---------- Related guides ---------- */
ul.cat-guide-list { display: grid; gap: var(--mm-s3); }
.cat-guide {
  display: flex; flex-direction: column; gap: var(--mm-s2); height: 100%; padding: var(--mm-s5);
  border: 1.5px solid var(--mm-line); border-radius: var(--mm-r-md); color: var(--mm-navy); text-decoration: none;
}
.cat-guide:hover { border-color: var(--mm-navy); color: var(--mm-navy); text-decoration: none; }
.cat-guide h3 { text-wrap: balance; }
.cat-guide-m { display: flex; align-items: center; justify-content: space-between; gap: var(--mm-s3); margin-top: auto; padding-top: var(--mm-s2); font-size: var(--mm-fs-small); }
.cat-guide-go { display: inline-flex; align-items: center; gap: var(--mm-s1); min-height: var(--mm-tap); font-weight: 700; }
.cat-guide:hover .cat-guide-go { text-decoration: underline dashed 2px; text-underline-offset: 4px; }

@media (min-width: 1024px) {
  ul.cat-guide-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--mm-gutter); }
}

/* ---------- Reduced motion: the chevrons turn instantly ---------- */
@media (prefers-reduced-motion: reduce) {
  .cat-gb .ic, .cat-more .ic { transition: none; }
}

/* Four sleep sacks: two rows of two on a tablet, never three and one */
@media (min-width: 600px) and (max-width: 1023.98px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
