/* ============================================================================
   Cascading product-type filter control (shared/_product_type_cascade).
   Trigger button + modal of "open" listboxes. Scoped entirely under .pt-cascade
   so it is portable to every product-type surface during rollout. Uses the
   warm-minimal design tokens (no hard-coded palette). No inline styles.
   ========================================================================== */

/* ── Field wrapper (generic filter bars) ─────────────────────────────────────
   Used by shared/_product_type_filters so the control occupies a filter cell the
   same way the old per-level multi-selects did. .filters-form is a wrapping flexbox
   whose cells size to content, so a DEFINITE width (not min-width) is what keeps the
   cell from growing with a long selection and reflowing the bar. The mobile
   breakpoint's `.filter-group { min-width: 100% }` still takes over on small screens.
   On Seasonality Studio the control is wrapped by _filter_card (grid) instead. */
.pt-cascade-field { flex: 0 0 220px; }

/* ── Trigger button ──────────────────────────────────────────────────────── */
.pt-cascade {
  display: block;
  width: 100%;
  min-width: 0;
}

.pt-cascade__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  /* Never let the button size to its label: a long selection must ellipsize
     inside a fixed-width trigger, not widen the filter cell and reflow the whole
     filter bar + table on every pick. */
  overflow: hidden;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease;
}
.pt-cascade__trigger:hover { border-color: var(--border-hover); }
.pt-cascade__trigger:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.pt-cascade__trigger.is-active {
  border-color: var(--blue);
  background: var(--blue-tint);
}

.pt-cascade__summary {
  /* flex:1 + min-width:0 is what actually lets the text ellipsize instead of
     pushing the trigger wider (the flexbox min-content default is the bug). */
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.pt-cascade__trigger.is-active .pt-cascade__summary { color: var(--blue); }
.pt-cascade__caret { color: var(--light); font-size: 10px; flex: none; }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.pt-cascade__overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 27, 22, 0.42);
}
.pt-cascade__overlay[hidden] { display: none; }

.pt-cascade__dialog {
  display: flex;
  flex-direction: column;
  width: min(920px, 100%);
  max-height: min(640px, 90vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(30, 27, 22, 0.22);
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.pt-cascade__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.pt-cascade__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.pt-cascade__close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
}
.pt-cascade__close:hover { background: var(--bg); color: var(--ink); }

/* ── Breadcrumb of the current selection ─────────────────────────────────── */
.pt-cascade__breadcrumb {
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-light);
  min-height: 37px;
  display: flex;
  align-items: center;
}

/* ── Columns of open listboxes ───────────────────────────────────────────── */
.pt-cascade__columns {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  overflow: auto;
  flex: 1 1 auto;
}
.pt-cascade__col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 0;
  min-width: 150px;
}
.pt-cascade__col-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Rendered "open" (size=N) so the buyer scans values without clicking to open. */
.pt-cascade__list {
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  padding: 4px;
}
.pt-cascade__list:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
.pt-cascade__list:disabled { background: var(--bg); color: var(--light); cursor: not-allowed; }
.pt-cascade__list option {
  padding: 5px 8px;
  border-radius: 5px;
}
.pt-cascade__list option:checked {
  background: var(--blue) linear-gradient(0deg, var(--blue), var(--blue));
  color: #fff;
  font-weight: 600;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.pt-cascade__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-alt);
}
.pt-cascade__footer-right { display: flex; gap: 8px; }

.pt-cascade .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.pt-cascade .btn-secondary { background: var(--surface); color: #555; border-color: var(--border-hover); }
.pt-cascade .btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.pt-cascade .btn-outline { background: var(--surface); color: var(--muted); border-color: var(--border); }
.pt-cascade .btn-outline:hover { background: var(--bg); color: #555; }

/* ── Narrow screens: stack columns, let the dialog scroll ─────────────────── */
@media (max-width: 720px) {
  .pt-cascade__columns { flex-direction: column; }
  .pt-cascade__col { min-width: 0; }
  .pt-cascade__list { min-height: 160px; }
}
