/* BSDyno catalog-overhaul components (task-50): search facets, typeahead, brands, compare.
   Loaded after styles.css; uses the same palette tokens. Mobile-first safe: no fixed widths
   that can push the document wider than the viewport. */

/* ------------------------------- programs band ------------------------------- */
.programs-band { padding: 22px 0 8px; border-top: 1px solid var(--line); margin-top: 26px; }
.programs-band .chip-group { margin-top: 8px; }
@media (max-width: 640px) { .programs-band { padding-top: 16px; } }

/* --------------------------------- typeahead -------------------------------- */
.typeahead-wrap { position: relative; }
.typeahead-list {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 42px rgba(11, 18, 32, .16); overflow: hidden; display: none;
  max-height: min(420px, 60vh); overflow-y: auto; text-align: left;
}
.typeahead-list.open { display: block; }
.typeahead-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  border: 0; background: #fff; padding: 10px 13px; cursor: pointer;
  border-bottom: 1px solid #f0f2f8; font: inherit; color: var(--ink);
}
.typeahead-item:last-child { border-bottom: 0; }
.typeahead-item:hover, .typeahead-item[aria-selected="true"] { background: #f3f4ff; }
.typeahead-item .ta-main { min-width: 0; display: block; }
.typeahead-item .ta-title {
  display: block; font-size: 13px; font-weight: 600; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.typeahead-item .ta-meta { display: block; font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.typeahead-item .ta-price { margin-left: auto; flex: 0 0 auto; font-size: 12.5px; font-weight: 700; color: var(--ink); }
.typeahead-note {
  padding: 8px 13px; font-size: 11.5px; color: var(--muted-2); background: #f8f9fd;
  border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px;
}
.typeahead-note a { color: var(--blue); font-weight: 700; }
.typeahead-empty { padding: 14px; font-size: 13px; color: var(--muted); }

/* ------------------------------ search layout ------------------------------- */
.search-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 26px; align-items: start; }
@media (max-width: 900px) { .search-layout { grid-template-columns: minmax(0, 1fr); } }
.facet-rail {
  border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 6px 16px 16px;
  position: sticky; top: 14px;
}
@media (max-width: 900px) { .facet-rail { position: static; } }
.facet-rail h2 { font-size: 11.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.facet-group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.facet-group:last-child { border-bottom: 0; }
.facet-group h3 { font-size: 11.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.facet-options { display: flex; flex-wrap: wrap; gap: 6px; }
.facet-chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer; line-height: 1.3;
}
.facet-chip .count { color: var(--muted-2); font-weight: 500; margin-left: 4px; }
.facet-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.facet-chip[aria-pressed="true"] .count { color: #cfd4e6; }
.facet-reset { margin-top: 14px; }
.facet-rail .facet-all { width: 100%; }
.search-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 6px 0 14px; }
.search-head .muted { font-size: 13px; }
.search-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search-toolbar select {
  border: 1.5px solid var(--line); border-radius: 9px; background: #fff; padding: 8px 10px;
  font: 600 12.5px Montserrat, system-ui, sans-serif; color: var(--ink);
}
.result-note { font-size: 12px; color: var(--muted-2); margin: 0 0 12px; }
.search-card .sc-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.search-card .sc-brand { font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--blue); }
.search-card .sc-title { font-size: 14px; line-height: 1.35; margin: 4px 0 6px; }
.search-card .sc-title a { color: var(--ink); }
.search-card .sc-title a:hover { color: var(--blue); }
.search-card .sc-meta { font-size: 11.5px; color: var(--muted-2); }
.search-card .sc-price { font-size: 16px; font-weight: 800; margin: 8px 0 4px; }
.search-card .sc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.search-card .sc-actions .btn { padding: 8px 12px; font-size: 12px; }
.compare-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--muted); cursor: pointer; user-select: none;
}
.compare-toggle input { accent-color: var(--blue); width: 15px; height: 15px; }

/* --------------------------------- brands ---------------------------------- */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.brand-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 18px; }
.brand-card h3 { margin: 0 0 6px; font-size: 16px; }
.brand-card h3 a { color: var(--ink); }
.brand-card h3 a:hover { color: var(--blue); }
.brand-card .muted { font-size: 12px; line-height: 1.5; margin: 0 0 8px; }
.brand-card .link { font-size: 12.5px; font-weight: 700; }

/* --------------------------------- compare --------------------------------- */
.compare-picker { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 16px; margin: 0 0 18px; }
.compare-picker label { display: block; font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.compare-picker .cmp-input-row { display: flex; gap: 8px; flex-wrap: wrap; }
.compare-picker input {
  flex: 1 1 260px; min-width: 0; padding: 11px 13px; border: 1.5px solid var(--line);
  border-radius: 9px; font: 400 14px Montserrat, system-ui, sans-serif;
}
.compare-picker .cmp-results { margin-top: 8px; display: grid; gap: 4px; }
.compare-picker .cmp-result {
  display: flex; gap: 10px; align-items: baseline; justify-content: space-between;
  width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.compare-picker .cmp-result:hover { border-color: var(--blue); background: #f6f7ff; }
.compare-picker .cmp-result .cmp-r-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-picker .cmp-result .cmp-r-meta { color: var(--muted-2); font-size: 11.5px; flex: 0 0 auto; }
.compare-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.compare-chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 999px; background: #f7f8fe; padding: 6px 8px 6px 12px; font-size: 12.5px; font-weight: 600;
  max-width: 100%;
}
.compare-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.compare-chip button { border: 0; background: #e8eaf4; border-radius: 999px; width: 20px; height: 20px; cursor: pointer; font-weight: 700; color: var(--muted); }
.compare-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.compare-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.compare-table th, .compare-table td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
.compare-table thead th { background: #f7f8fe; font-size: 12.5px; }
.compare-table thead th:first-child { width: 150px; }
.compare-table tbody th { font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); width: 150px; }
.compare-table .cmp-prod { font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.compare-table .cmp-prod a { color: var(--ink); }
.compare-table .cmp-sub { font-size: 11.5px; color: var(--muted-2); font-weight: 500; margin-top: 3px; }
.compare-table .cmp-price { font-size: 15px; font-weight: 800; }
.compare-table .cmp-actions { display: flex; flex-direction: column; gap: 6px; }
.compare-table .cmp-actions .btn { padding: 8px 11px; font-size: 12px; }
.cmp-remove { border: 0; background: none; color: var(--muted-2); font-size: 11.5px; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; margin-top: 4px; }
.cmp-remove:hover { color: var(--magenta); }
@media (max-width: 640px) {
  .compare-table { min-width: 560px; }
  .compare-table thead th:first-child, .compare-table tbody th { width: 110px; }
}

/* --------------------------- floating compare pill -------------------------- */
.compare-pill {
  position: fixed; left: 16px; bottom: 16px; z-index: 70;
  display: none; align-items: center; gap: 8px;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 16px;
  font-size: 13px; font-weight: 700; text-decoration: none;
  box-shadow: 0 12px 30px rgba(11, 18, 32, .28);
}
.compare-pill.show { display: inline-flex; }
.compare-pill:hover { background: var(--blue); color: #fff; }
@media (max-width: 640px) { .compare-pill { left: 12px; bottom: 12px; padding: 9px 14px; font-size: 12px; } }

/* ---------------------------- long text safety ------------------------------ */
.brand-card h3, .search-card .sc-title, .offer-card h3, .compare-table .cmp-prod { overflow-wrap: anywhere; }

/* wide data tables scroll inside their own box on small screens */
@media (max-width: 640px) { .spec-table { display: block; overflow-x: auto; } }

