/*
 * STRUCTURE AUDIT — catalog listing families (do not reuse):
 * - A119 / shoppers-hub-3 cd-*: chapter bands (lead tile + sibling list per category).
 * - A119 spine / A120 prior tc-*: sticky side index + accordion ledger link rows.
 * - A97 abacus: bead-rod tally tabs + grouped ledger rows.
 * - A97 tiles / many clones: hero + uniform category card grid.
 * - A115 spindle / filmstrip: hanging tabs + horizontal strips.
 * - A113 docket: margin TOC + policy-style sections.
 * - Appily-onehundredtwenty shop sh-*: sticky command bar + mosaic product cells (not catalog).
 * - Common banned: heading + repeat(auto-fill) product card grid.
 *
 * THIS FILE — SPEC_INDEX_TABLE:
 * - Sticky ct-index rail (desktop) / horizontal chip jump bar (mobile).
 * - Per-group <table.ct-spec> with thead + tbody rows (thumb, name, SKU, price, action) — not cards, not bands, not mosaic.
 * - Search + sort via ct-probe form (existing GET logic); aria-sort reflects active sort.
 */

.page-catalog {
  overflow-x: clip;
}

.ct-catalog {
  padding-bottom: var(--at-space-6);
}

.ct-mast {
  padding: var(--at-space-5) 0 var(--at-space-3);
}

.ct-body {
  padding: 0 0 var(--at-space-4);
}

.ct-mast__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: var(--at-space-3) 0 0;
  padding: 0;
}

.ct-body__shell {
  display: flex;
  flex-direction: column;
  gap: var(--at-space-5);
  min-width: 0;
}

@media (min-width: 1024px) {
  .ct-body__shell {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--at-space-6);
  }
}

/* —— Group index —— */
body.a120-body.page-catalog .ct-index {
  flex: 0 0 auto;
  min-width: 0;
  align-self: flex-start;
}

@media (max-width: 1023px) {
  body.a120-body.page-catalog .ct-index {
    margin-inline: calc(-1 * var(--at-gutter));
    padding: var(--at-space-2) var(--at-gutter) var(--at-space-3);
    background: color-mix(in srgb, var(--at-canvas) 90%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--at-line);
    box-shadow: 0 0.35rem 1rem color-mix(in srgb, var(--at-ink) 6%, transparent);
  }
}

@media (min-width: 1024px) {
  body.a120-body.page-catalog .ct-index {
    width: 11.5rem;
    flex-shrink: 0;
    top: calc(var(--at-nav-h) + var(--at-space-3));
    max-height: calc(100vh - var(--at-nav-h) - var(--at-space-5));
    padding: var(--at-space-2);
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius-lg);
    background: color-mix(in srgb, var(--at-surface) 94%, var(--at-canvas-deep) 6%);
    box-shadow: var(--at-shadow-sm);
  }
}

.ct-index__label {
  margin: 0 0 var(--at-space-2);
  font-family: var(--at-font-ui);
  font-size: var(--at-text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--at-ink-soft);
}

@media (max-width: 1023px) {
  .ct-index__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

.ct-index__track {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

@media (min-width: 1024px) {
  .ct-index__track {
    flex-direction: column;
    overflow: visible;
    max-height: calc(100vh - var(--at-nav-h) - 6rem);
    overflow-y: auto;
    padding-bottom: 0;
  }
}

.ct-index__link {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.35rem 0.5rem;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--at-radius-md);
  border: 1px solid var(--at-line);
  background: var(--at-surface);
  text-decoration: none;
  color: var(--at-ink);
  font-family: var(--at-font-ui);
  font-size: var(--at-text-xs);
  font-weight: 600;
  transition: border-color var(--at-dur) var(--at-ease), background var(--at-dur) var(--at-ease);
}

.ct-index__link:hover {
  border-color: color-mix(in srgb, var(--at-moss) 45%, var(--at-line));
  background: var(--at-dew);
}

.ct-index__link:focus-visible {
  outline: 2px solid var(--at-moss);
  outline-offset: 2px;
}

@media (min-width: 1024px) {
  .ct-index__link {
    grid-template-columns: 1.75rem 1fr auto;
  }
}

.ct-index__link.is-active {
  border-color: var(--at-moss);
  background: var(--at-dew);
}

.ct-index__num {
  font-family: var(--at-font-display);
  color: var(--at-moss);
}

.ct-index__name {
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.ct-index__count {
  color: var(--at-ink-soft);
  font-size: 0.7rem;
}

/* —— Main column —— */
.ct-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--at-space-5);
}

.ct-probe {
  display: grid;
  gap: var(--at-space-3);
  align-items: end;
  padding: var(--at-space-4);
  background: color-mix(in srgb, var(--at-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (min-width: 768px) {
  .ct-probe {
    grid-template-columns: minmax(0, 1.4fr) minmax(8rem, 10rem) auto auto;
  }
}

@media (max-width: 767px) {
  .ct-probe__go,
  .ct-probe__clear {
    width: 100%;
  }
}

.ct-probe__field {
  display: grid;
  gap: 0.25rem;
  font-family: var(--at-font-ui);
  font-size: var(--at-text-xs);
  font-weight: 600;
  color: var(--at-ink-soft);
}

.ct-probe__go,
.ct-probe__clear {
  min-height: 2.75rem;
}

.ct-groups {
  display: flex;
  flex-direction: column;
  gap: var(--at-space-3);
}

.ct-group {
  scroll-margin-top: calc(var(--at-nav-h) + 5.75rem);
  border: 1px solid var(--at-line);
  border-radius: var(--at-radius-lg);
  background: color-mix(in srgb, var(--at-surface) 94%, var(--at-canvas-deep) 6%);
  box-shadow: var(--at-shadow-sm);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .ct-group {
    scroll-margin-top: calc(var(--at-nav-h) + var(--at-space-4));
  }
}

.ct-group__body {
  padding: 0 var(--at-space-3) var(--at-space-3);
}

.ct-group__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--at-space-2) var(--at-space-3);
  padding: var(--at-space-3) var(--at-space-3);
  margin: 0;
  list-style: none;
  cursor: pointer;
  background: var(--at-canvas-deep);
  border-bottom: 1px solid transparent;
  transition: background var(--at-dur) var(--at-ease);
}

.ct-group__head:hover {
  background: color-mix(in srgb, var(--at-canvas-deep) 82%, var(--at-dew) 18%);
}

.ct-group__head:focus-visible {
  outline: 2px solid var(--at-moss);
  outline-offset: -2px;
}

.ct-group[open] > .ct-group__head {
  border-bottom-color: var(--at-line);
}

.ct-group__head::marker,
.ct-group__head::-webkit-details-marker {
  display: none;
}

.ct-group__head-copy {
  flex: 1 1 10rem;
  min-width: 0;
}

.ct-group__tools {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--at-space-2);
}

.ct-group__aisle {
  flex-shrink: 0;
  min-height: 2.5rem;
}

.ct-group__chev {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--at-moss);
  border-bottom: 2px solid var(--at-moss);
  transform: rotate(45deg);
  transition: transform var(--at-dur) var(--at-ease);
  flex-shrink: 0;
}

.ct-group[open] > .ct-group__head .ct-group__chev {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}

@media (max-width: 479px) {
  .ct-group__head {
    flex-direction: column;
    align-items: stretch;
  }

  .ct-group__tools {
    justify-content: space-between;
    width: 100%;
  }
}

.ct-group__head .ds-title {
  font-size: var(--at-text-lg);
  margin: 0;
}

.ct-group__none {
  margin: 0;
  font-family: var(--at-font-ui);
  color: var(--at-ink-soft);
}

.ct-group .ct-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--at-line);
  border-radius: var(--at-radius-md);
  background: var(--at-surface);
}

.ct-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--at-line);
  border-radius: var(--at-radius-lg);
  background: var(--at-surface);
  box-shadow: var(--at-shadow-sm);
}

.ct-spec {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--at-font-ui);
  font-size: var(--at-text-sm);
}

.ct-spec caption {
  caption-side: top;
}

.ct-spec thead th {
  text-align: left;
  padding: var(--at-space-3);
  font-size: var(--at-text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--at-ink-soft);
  border-bottom: 1px solid var(--at-line);
  background: var(--at-canvas-deep);
}

.ct-spec tbody tr {
  border-bottom: 1px solid var(--at-line);
}

.ct-spec tbody tr:last-child {
  border-bottom: none;
}

.ct-spec td,
.ct-spec th[scope="row"] {
  padding: var(--at-space-3);
  vertical-align: middle;
}

.ct-spec__pack a {
  display: block;
  width: 4rem;
  height: 4rem;
  border-radius: var(--at-radius-md);
  overflow: hidden;
}

.ct-spec__pack img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ct-spec__ph {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--at-dew);
}

.ct-spec__name a {
  text-decoration: none;
  color: var(--at-ink);
  font-family: var(--at-font-display);
  font-weight: 400;
  overflow-wrap: anywhere;
}

.ct-spec__name a:hover {
  color: var(--at-moss);
}

.ct-spec__price {
  font-weight: 700;
  color: var(--at-terra);
  white-space: nowrap;
}

.ct-spec__act .ds-btn {
  min-height: 2.75rem;
  white-space: nowrap;
}

.ct-group__foot {
  margin-top: var(--at-space-3);
  padding-top: var(--at-space-2);
  border-top: 1px dashed var(--at-line);
}

.ct-group__foot .ds-btn {
  width: 100%;
  justify-content: center;
}

@media (min-width: 480px) {
  .ct-group__foot .ds-btn {
    width: auto;
  }
}

.ct-empty {
  text-align: center;
  padding: var(--at-space-6);
}

.ct-outro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--at-space-3);
}

.ct-outro__line {
  margin: 0;
  font-family: var(--at-font-ui);
  font-size: var(--at-text-sm);
  color: var(--at-ink-soft);
  max-width: 36ch;
}

/* —— Mobile: stacked spec rows —— */
@media (max-width: 767px) {
  .ct-table-wrap {
    overflow-x: visible;
  }

  .ct-spec thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .ct-spec,
  .ct-spec tbody,
  .ct-spec tr,
  .ct-spec td,
  .ct-spec th {
    display: block;
    width: 100%;
  }

  .ct-spec tbody tr {
    padding: var(--at-space-2);
    margin-bottom: var(--at-space-2);
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius-md);
    background: var(--at-surface);
  }

  .ct-spec td,
  .ct-spec th[scope="row"] {
    padding: 0.35rem 0;
    border: none;
  }

  .ct-spec td::before,
  .ct-spec th[scope="row"]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--at-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--at-moss-light);
    margin-bottom: 0.15rem;
  }

  .ct-spec__pack::before,
  .ct-spec th[scope="row"]::before {
    content: none;
  }

  .ct-spec__pack {
    margin-bottom: var(--at-space-2);
  }

  .ct-spec__act .ds-btn {
    width: 100%;
  }
}
