/**
 * /cards faceted search layout. Wider page container so 5 cards fit per row.
 */

/* /cards needs room for 5 tiles + filters: slim gutters instead of the
   theme's 12.5% desktop gutter, capped at a comfortable max width. */
.debtsunset-layout .debtsunset-main .debtsunset-container:has(.ds-search) {
  --ds-gutter: clamp(1rem, 3vw, 3rem);
  max-width: 1640px;
}

.ds-search__lede {
  max-width: 75ch;
  margin: 0 0 1.25rem;
  color: var(--ds-ink-muted, #6B5647);
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Toolbar: keyword box + sort + button in one row. */
.debtsunset-layout .ds-search__toolbar form.ds-search__form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 1rem;
  background: var(--ds-surface, #FDF8F3);
  border-radius: var(--ds-radius-container, 16px);
}

.debtsunset-layout .ds-search__form .form-item { margin: 0; }
.debtsunset-layout .ds-search__form .form-item-keys { flex: 1 1 22rem; }
.debtsunset-layout .ds-search__form .form-item-keys input { width: 100%; }
.debtsunset-layout .ds-search__form .form-item-sort-by { flex: 0 1 14rem; }
.debtsunset-layout .ds-search__form .form-item-sort-by label { font-size: 0.8rem; font-weight: 700; }
.debtsunset-layout .ds-search__form .form-actions { margin: 0; }
.debtsunset-layout .ds-search__form .form-actions input { margin: 0; }

/* Two columns: facets + results. */
.ds-search__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 860px) {
  .ds-search__body { grid-template-columns: 250px minmax(0, 1fr); gap: 1.75rem; }
  .ds-search__facets { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
}

/* Filters panel (<details>). */
.debtsunset-layout .ds-filters {
  margin: 0;
  background: var(--ds-surface, #FDF8F3);
  border: 1px solid color-mix(in srgb, var(--ds-ink, #0A1A33) 10%, transparent);
  border-radius: var(--ds-radius-container, 16px);
}

.debtsunset-layout .ds-filters > summary.ds-filters__toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}
.ds-filters__toggle::-webkit-details-marker { display: none; }

@media (min-width: 860px) {
  .debtsunset-layout .ds-filters > summary.ds-filters__toggle { pointer-events: none; }
}

.ds-filters__count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  color: var(--ds-btn-primary-ink, #fff);
  background: var(--ds-link, #B8402B);
  border-radius: 999px;
  font-size: 0.8rem;
}

.ds-filters__panel { padding: 0 1.1rem 1rem; }

.ds-facet { padding: 0.9rem 0; border-top: 1px solid color-mix(in srgb, var(--ds-ink, #0A1A33) 10%, transparent); }
.debtsunset-layout .ds-facet__title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ds-ink-muted, #6B5647);
}

/* Facets checkbox widget: tidy list, no bullets, no underlines. */
.debtsunset-layout .ds-facet ul { margin: 0; padding: 0; list-style: none; }
.debtsunset-layout .ds-facet li { margin: 0; padding: 0.15rem 0; list-style: none; }
.debtsunset-layout .ds-facet a { display: inline-flex; gap: 0.35rem; color: var(--ds-ink, #0A1A33); text-decoration: none; font-size: 0.93rem; }
.debtsunset-layout .ds-facet a:hover { color: var(--ds-link, #B8402B); }
.debtsunset-layout .ds-facet .facet-item__count { color: var(--ds-ink-muted, #6B5647); font-size: 0.85rem; }
.debtsunset-layout .ds-facet .facet-item input[type="checkbox"] { margin: 0.2rem 0.45rem 0 0; }
.debtsunset-layout .ds-facet .facet-item label { display: inline; font-weight: 500; font-size: 0.93rem; cursor: pointer; }
.debtsunset-layout .ds-facet .facets-soft-limit-link { display: inline-block; margin-top: 0.4rem; font-size: 0.85rem; font-weight: 700; color: var(--ds-link, #B8402B); text-decoration: none; }

/* Result meta row + layout toggle. */
.ds-search__meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin: 0 0 0.75rem; }
.ds-search__count { margin: 0; font-weight: 700; }

.ds-viewtoggle { display: inline-flex; padding: 3px; background: var(--ds-surface, #FDF8F3); border: 1px solid color-mix(in srgb, var(--ds-ink, #0A1A33) 12%, transparent); border-radius: 999px; }
.debtsunset-layout .ds-viewtoggle a.ds-viewtoggle__btn {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.85rem;
  color: var(--ds-ink, #0A1A33); border-radius: 999px; font-size: 0.875rem; font-weight: 700; text-decoration: none;
}
.debtsunset-layout .ds-viewtoggle a.ds-viewtoggle__btn.is-active { color: var(--ds-btn-primary-ink, #fff); background: var(--ds-link, #B8402B); }

/* Active filter chips (facets_summary). */
.debtsunset-layout .ds-search__active ul { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.debtsunset-layout .ds-search__active li { margin: 0; list-style: none; }
.debtsunset-layout .ds-search__active ul li a {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.75rem;
  color: var(--ds-ink-on-soft, #0A1A33); background: var(--ds-soft, #F3C9A6); border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
}
.debtsunset-layout .ds-search__active ul li a::after { content: "×"; font-size: 1.05rem; line-height: 1; }
.debtsunset-layout .ds-search__active ul li.facet-summary-item--clear a { color: var(--ds-link, #B8402B); background: none; text-decoration: none; }
.debtsunset-layout .ds-search__active ul li.facet-summary-item--clear a::after { content: ""; }

/* 5 per row on wide screens; compact tiles. */
.debtsunset-layout .ds-grid5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
@media (max-width: 499px) { .debtsunset-layout .ds-grid5 { grid-template-columns: 1fr; } }
@media (min-width: 1100px) { .debtsunset-layout .ds-grid5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1300px) { .debtsunset-layout .ds-grid5 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1480px) { .debtsunset-layout .ds-grid5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.ds-grid5 .ds-cardtile__art { padding: 0.85rem 0.9rem 0.25rem; }
.ds-grid5 .ds-cardtile__body { padding: 0.6rem 0.9rem 0.9rem; gap: 0.35rem; }
.debtsunset-layout .ds-grid5 .ds-cardtile__name { font-size: 1rem; }
.ds-grid5 .ds-cardtile__pitch {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 0.85rem;
}
.ds-grid5 .ds-cardtile__facts { font-size: 0.78rem; gap: 0.25rem 0.6rem; }
.ds-grid5 .ds-star { width: 15px; height: 15px; }

/* Table layout. */
.ds-cardtable__wrap { overflow-x: auto; background: var(--ds-surface, #FDF8F3); border-radius: 14px; border: 1px solid color-mix(in srgb, var(--ds-ink, #0A1A33) 10%, transparent); }
.debtsunset-layout table.ds-cardtable { width: 100%; min-width: 720px; margin: 0; border-collapse: collapse; font-size: 0.9rem; }
.debtsunset-layout .ds-cardtable thead th { position: sticky; top: 0; padding: 0.7rem 0.8rem; text-align: left; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; }
.debtsunset-layout .ds-cardtable tbody th, .debtsunset-layout .ds-cardtable td { padding: 0.55rem 0.8rem; vertical-align: middle; border-top: 1px solid color-mix(in srgb, var(--ds-ink, #0A1A33) 8%, transparent); font-weight: 500; }
.debtsunset-layout .ds-cardtable a.ds-cardtable__card { display: flex; align-items: center; gap: 0.7rem; color: var(--ds-ink, #0A1A33); text-decoration: none; }
.debtsunset-layout .ds-cardtable a.ds-cardtable__card:hover .ds-cardtable__name { color: var(--ds-link, #B8402B); }
.debtsunset-layout .ds-cardtable__card img { flex: none; width: 64px; height: 40px; aspect-ratio: 856 / 540; object-fit: contain; border-radius: 0; box-shadow: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.ds-cardtable__name { display: block; font-weight: 700; }
.ds-cardtable__issuer { display: block; color: var(--ds-ink-muted, #6B5647); font-size: 0.8rem; }
.ds-cardtable__rating { color: var(--ds-ink, #0A1A33); font-weight: 700; white-space: nowrap; }
.ds-cardtable__rating::first-letter { color: var(--ds-marigold, #FBB03B); }
.ds-cardtable tr.is-closed img { filter: grayscale(.7); opacity: .7; }

.ds-search__empty { padding: 2rem; text-align: center; background: var(--ds-surface, #FDF8F3); border-radius: var(--ds-radius-container, 16px); }

/* facets_summary prefixes each chip with a "(-)" status text; the × replaces it. */
.debtsunset-layout .ds-search__active .facet-item__status { display: none; }

/* Checkbox + label side by side even for long labels. */
.debtsunset-layout .ds-facet li.facet-item { display: flex; align-items: flex-start; gap: 0.45rem; }
.debtsunset-layout .ds-facet li.facet-item input[type="checkbox"] { flex: none; margin: 0.2rem 0 0; }
.debtsunset-layout .ds-facet li.facet-item label { flex: 1 1 auto; min-width: 0; line-height: 1.35; }

/* Table: keep APR ranges, fees and months on one line. */
.debtsunset-layout .ds-cardtable td { white-space: nowrap; }
.debtsunset-layout .ds-cardtable td:last-child { white-space: normal; min-width: 9rem; }

.debtsunset-layout .ds-search__form .form-actions { flex: 0 0 auto; }
.debtsunset-layout .ds-search__form .form-actions input { width: auto; padding-inline: 1.75rem; }

/* /cards/issuers */
.debtsunset-layout ul.ds-issuers { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.debtsunset-layout ul.ds-issuers li { margin: 0; list-style: none; }
.debtsunset-layout ul.ds-issuers a.ds-issuer { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.9rem 1.1rem; color: var(--ds-ink, #0A1A33); background: var(--ds-surface, #FDF8F3); border: 1px solid color-mix(in srgb, var(--ds-ink, #0A1A33) 10%, transparent); border-radius: 12px; text-decoration: none; }
.debtsunset-layout ul.ds-issuers a.ds-issuer:hover { border-color: var(--ds-link, #B8402B); }
.ds-issuer__name { font-weight: 700; }
.ds-issuer__n { color: var(--ds-ink-muted, #6B5647); font-size: 0.875rem; white-space: nowrap; }

/* Grid items default to min-width:auto, which let the wide table stretch the page on phones; the wrap scrolls instead. */
.ds-search__results { min-width: 0; }
