/* 02-catalog.css — the catalogue (/): header, tabs and filters, theme tree, card grid.
   Part of the former single site.css. These files are ORDER-DEPENDENT: they are linked in
   numeric order in _Layout.cshtml and later rules still override earlier ones exactly as they
   did in the one big file. Do not reorder the <link> tags. */

/* Task 085: an exchange's market list. The hero, the sync form and three KPI cards stood over the first card (y 588
   at 1 440 × 900); now one header line, one line of tabs and filters, then the cards. */
.catalog-page-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.catalog-page-main {
  min-width: 0;
}

.catalog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 12px;
}

.catalog-head h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

/* «Набори | Мініфігурки» (task 178): what the catalogue lists, beside its title — above the sets' four tabs, which
   filter the sets only. */
.catalog-kind {
  align-self: center;
}

.catalog-head__meta {
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

/* Tabs left, filters right, on one line where they fit. Held under the header while the cards scroll (task 134):
   its top is the header's bottom (--app-header); z-index under the header's 10, so the search's panel (task 130) opens
   over it. */
.catalog-bar {
  position: sticky;
  top: var(--app-header);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 8px;
  padding: 8px 0;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

/* «Показати ще (N)» under the grid once catalog-lazyload.js has loaded its 3 pages by scrolling (task 134). */
.catalog-more {
  display: flex;
  margin: var(--space-4) auto;
}

.catalog-more[hidden] {
  display: none;
}

.catalog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.catalog-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-md);
  padding: 0 12px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.catalog-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.catalog-tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.catalog-tab__count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.catalog-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 420px;
  justify-content: flex-end;
}

.catalog-filter .form-control,
.catalog-filter .form-select,
.catalog-filter .btn {
  min-height: var(--control-md);
  font-size: 0.9rem;
}

.catalog-filter .page-search {
  flex: 1 1 180px;
  max-width: 280px;
}

/* Wide enough for its longest word: «Вигідні спочатку» was cut to «Вигідні спочат» (task 085). */
.catalog-filter__year {
  flex: 0 0 auto;
  width: auto;
  min-width: 112px;
}

.catalog-filter__sort {
  flex: 0 0 auto;
  width: auto;
  min-width: 168px;
}

.catalog-result-bar {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0 2px 10px;
}

.catalog-result-bar__note {
  color: var(--muted);
}

/* The theme tree. On a wide screen it is a sticky column and its <details> fold never closes — the same
   ::details-content trick as the nav menu (01-base.css); at ≤ 1 024 px it is «Теми», folded, so the first screen of a
   phone shows cards (task 085: the open tree pushed the first card to y 1 750 at 390). */
.catalog-tree-fold__toggle {
  display: none;
}

.catalog-tree-fold::details-content {
  content-visibility: visible;
}

@supports not selector(::details-content) {
  .catalog-tree-fold__toggle {
    display: list-item;
    cursor: pointer;
    font-weight: 600;
  }
}

.catalog-tree {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.catalog-tree__switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.catalog-tree__switch-option {
  min-width: 0;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
}

.catalog-tree__switch-option.is-active {
  color: var(--surface-1);
  background: var(--text);
  border-color: var(--text);
}

.catalog-tree__body {
  padding: 8px;
  overflow-y: auto;
}

.catalog-tree__empty {
  padding: 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.catalog-tree__all,
.catalog-tree-node__link,
.catalog-tree-node__child {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  color: var(--text);
}

.catalog-tree__all {
  min-height: 36px;
  padding: 0 10px;
  margin-bottom: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
}

.catalog-tree__all span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A long theme takes a second line instead of being cut («LEGO Ideas and CUUSOO», «BrickLink Designer Program»);
   the full name is the link's title too. The column keeps its width. */
.catalog-tree-node__link span,
.catalog-tree-node__child span {
  min-width: 0;
  padding: 6px 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.catalog-tree__all strong,
.catalog-tree-node__link strong,
.catalog-tree-node__child strong {
  min-width: 28px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.catalog-tree-node {
  border-radius: 8px;
}

.catalog-tree-node summary {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  min-height: 36px;
  list-style: none;
}

.catalog-tree-node summary::-webkit-details-marker {
  display: none;
}

.catalog-tree-node__chevron {
  width: 8px;
  height: 8px;
  justify-self: center;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.catalog-tree-node[open] .catalog-tree-node__chevron {
  transform: rotate(45deg);
}

.catalog-tree-node__link {
  min-height: 34px;
  padding: 0 8px;
  font-weight: 700;
}

.catalog-tree-node__children {
  display: grid;
  gap: 2px;
  margin: 0 0 5px 22px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.catalog-tree-node__child {
  min-height: 32px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.catalog-tree__all:hover,
.catalog-tree-node__link:hover,
.catalog-tree-node__child:hover {
  background: var(--surface-3);
}

.catalog-tree__all.is-active,
.catalog-tree-node__link.is-active,
.catalog-tree-node__child.is-active {
  color: var(--accent-contrast);
  background: var(--accent);
}

.catalog-tree__all.is-active strong,
.catalog-tree-node__link.is-active strong,
.catalog-tree-node__child.is-active strong {
  color: var(--accent-text);
  border-color: rgba(255, 255, 255, 0.7);
}

@media (max-width: 1024px) {
  .catalog-page-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .catalog-tree-fold:not([open])::details-content {
    content-visibility: hidden;
  }

  .catalog-tree-fold__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }

  .catalog-tree-fold__toggle::-webkit-details-marker {
    display: none;
  }

  .catalog-tree-fold__toggle::after {
    content: "▾";
    color: var(--muted);
  }

  .catalog-tree-fold[open] > .catalog-tree-fold__toggle::after {
    content: "▴";
  }

  .catalog-tree {
    position: static;
    max-height: none;
    margin-top: 6px;
  }

  .catalog-tree__body {
    max-height: 360px;
  }

  .catalog-filter {
    justify-content: flex-start;
  }

  .catalog-filter .page-search {
    max-width: none;
  }
}

/* The card grid. A card is SIX rows of the grid's own tracks (subgrid): photo, name, chips, the price, MSRP and
   floor, where the price is — so a row of cards starts each section at one height. A new line on the card needs a row here
   and in _SetCards.cshtml. Without subgrid a card is a plain column and simply does not align. */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  column-gap: 14px;
  row-gap: 0;
  margin-bottom: 24px;
}

.catalog-grid > .empty-state {
  grid-column: 1 / -1;
}

.set-card {
  position: relative;
  display: grid;
  grid-row: span 6;
  grid-template-rows: subgrid;
  row-gap: 6px;
  min-width: 0;
  margin-bottom: 14px;
  padding-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color var(--duration-1) var(--ease), box-shadow var(--duration-1) var(--ease);
}

/* The whole card is the set's link (task 192): its title's ::after covers it, so the card answers the pointer. */
.set-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}

.set-card:has(.set-card-title:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .set-card {
    transition: none;
  }
}

.set-card--good {
  border-color: color-mix(in srgb, var(--up) 35%, var(--surface-1));
}

.set-card > :not(.set-card-media, .ui-wish) {
  min-width: 0;
  padding: 0 12px;
}

.set-card-media {
  display: block;
  position: relative;
  height: 150px;
  margin-bottom: 4px;
  background: var(--photo-bg);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.set-card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: var(--photo-inset);
  object-fit: contain;
  object-position: center;
}

/* The card's one percent (task 085): it was the ribbon and «▼ 60% від референтної» under the prices. Top left since
   task 192, the phone card's badge in its colours; ♡ holds the right corner. */
.set-card-ribbon {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--up);
  color: var(--bg);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: var(--radius-1);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* "Куплено" badge on catalog cards for sets already in the collection */
.chip-owned {
  background: var(--up);
  border-color: var(--up);
  color: var(--surface-1);
}

/* The name takes two lines, not one cut with «…» (task 085); the number, theme and parts under it. */
.set-card-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.set-card-title::after {
  content: "";
  position: absolute;
  inset: 0;
}

.set-card-title:hover,
.set-card:hover .set-card-title {
  color: var(--text);
  text-decoration: underline;
}

.set-card-title:focus-visible {
  outline: none;
}

/* What explains itself on hover stays above the stretched link: the chips' titles (the signal, the score's parts) and
   BrickLink's. Only the chips themselves: the row's empty width still opens the set. */
.set-card-tags,
.set-card-quote__ref {
  position: relative;
  z-index: 1;
}

.set-card-tags {
  pointer-events: none;
}

.set-card-tags .tag {
  pointer-events: auto;
  /* The phone card's 0.75rem (16-phone.css, .ui-m-card__tags .tag): the global .tag's 0.72rem is 10.8 px, under
     impeccable's 11 px floor (task 192). Both go if .tag itself reaches 11 px. */
  font-size: 0.75rem;
}

.set-card-sub {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* «Зараз 103.50» large in the deal's colour, the BrickLink reference beside it — struck when the offer is under it. */
.set-card-quote {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  font-variant-numeric: tabular-nums;
}

.set-card-quote small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.set-card-quote__now {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.set-card-quote__now.is-good {
  color: var(--up);
}

.set-card-quote__ref {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  cursor: help;
}

.set-card-quote__ref.is-struck .set-card-quote__ref-value {
  text-decoration: line-through;
}

/* MSRP and the floor, one small line (task 082's words; two pills before task 085). The figure is coloured. */
.set-card-msrp {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.set-card-msrp__item {
  white-space: nowrap;
}

.set-card-msrp strong {
  font-weight: 700;
}

.set-card-msrp .set-card-metric--good {
  color: var(--up);
}

.set-card-msrp .set-card-metric--bad {
  color: var(--down);
}

.set-card-msrp .set-card-metric--warn {
  color: var(--warn);
}

/* Over MSRP on a set retired over two years ago is the market, not a bad price (task 086). */
.set-card-msrp .set-card-metric--neutral {
  color: var(--muted);
}

/* Where the price is: the provider at the card's foot (its «Купити →» and «Не цікаво» went to the set page, task 192). */
.set-card > .set-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
}

/* The best offer's source: <provider-mark> wide, cut to the card's width by its own name. */
.set-card-provider {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}


.detail-back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--ink);
  font-weight: 600;
}

/* The phone (task 105). ≤ 900 px: the tabs are one row that scrolls on its own; the search fills the line with «Теми»
   and «Фільтри (N)» beside it, each opening a bottom sheet (Index.cshtml, .ui-filters — the year and the sort in one,
   the tree in the other, open in its sheet). ≤ 480 px: two compact cards a row (one at ≤ 360), the offer's buttons
   the provider under the prices. The fold «Теми» of 901 – 1 024 px is not shown here. */
@media (max-width: 900px) {
  .catalog-bar {
    display: grid;
    gap: var(--space-2);
  }

  .catalog-tabs {
    flex-wrap: nowrap;
    max-width: none;
    margin: 0 -12px;
    scroll-padding-inline: 12px;
    padding: 0 12px;
  }

  .catalog-filter {
    flex-wrap: nowrap;
    gap: var(--space-2);
  }

  .catalog-filter .page-search {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .catalog-filter .ui-filters .form-select,
  .catalog-filter .ui-filters .btn {
    width: 100%;
    min-width: 0;
  }

  .catalog-tree-sheet .catalog-tree-fold > .catalog-tree-fold__toggle {
    display: none;
  }

  .catalog-tree-sheet .catalog-tree-fold::details-content {
    content-visibility: visible;
  }

  .catalog-tree-sheet .catalog-tree {
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .catalog-tree-sheet .catalog-tree__body {
    max-height: none;
  }
}

@supports not selector(::details-content) {
  .catalog-tree-sheet .catalog-tree-fold > .catalog-tree-fold__toggle {
    display: flex;
  }
}

@media (max-width: 480px) {
  .catalog-head h1 {
    font-size: var(--text-xl);
  }

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-2);
  }

  .set-card {
    row-gap: 4px;
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-radius: var(--radius-3);
  }

  .set-card > :not(.set-card-media, .ui-wish) {
    padding: 0 var(--space-2);
  }

  .set-card-media {
    height: 112px;
  }

  .set-card-ribbon {
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    font-size: 0.75rem;
  }

  /* A title is a link: 24 px at least (WCAG 2.5.8), one or two lines. */
  .set-card-title {
    min-height: 24px;
    padding-top: 3px;
    font-size: 0.9rem;
  }

  .set-card-sub {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .set-card-quote {
    gap: 0 var(--space-2);
  }

  .set-card-quote__now {
    font-size: 1.05rem;
  }

  .set-card-quote__ref {
    font-size: 0.78rem;
  }

  .set-card > .set-card-foot {
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 var(--space-2);
  }

  .set-card-provider {
    flex-basis: 100%;
  }
}

@media (max-width: 360px) {
  .catalog-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .set-card-media {
    height: 150px;
  }
}

/* ── A list written for a search (task 198, Pages/Lists/_SetList): «LEGO wycofane w 2026», «Promocje LEGO» ──
   The catalogue's own cards and grid; above them the title, one line of figures and, for the years, a segmented
   switch; a month's heading over its cards. No sidebar, no filters: the address is the filter. */
.sl-head {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.sl-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.sl-back:hover {
  color: var(--text);
}

.sl-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.15;
  text-wrap: balance;
}

.sl-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-4);
}

.sl-summary {
  margin: 0;
  text-wrap: pretty;
  color: var(--text-muted);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

/* A figure and its words stay on one line («jeszcze w sprzedaży: 71» never leaves «71» alone at 360 px). */
.sl-summary > span {
  white-space: nowrap;
}

.sl-summary > span:first-child {
  color: var(--text);
  font-weight: 600;
}

.sl-months {
  margin-bottom: var(--space-5);
}

.sl-group {
  margin: var(--space-6) 0 var(--space-3);
  scroll-margin-top: calc(var(--app-header) + var(--space-4));
  font-size: var(--text-lg);
  line-height: 1.25;
}

.sl-group--first {
  margin-top: 0;
}

.sl-group__count {
  margin-left: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* «Pokaż więcej» lands on the first new card (list-more.js): clear of the sticky header. */
.sl-list .set-card,
.sl-list .ui-m-card {
  scroll-margin-top: calc(var(--app-header) + var(--space-4));
}

.sl-more {
  display: flex;
  justify-content: center;
  margin: var(--space-5) 0 0;
}

.sl-empty {
  margin: var(--space-6) 0;
  color: var(--text-muted);
}

/* The phone's (16-phone.css' .ui-m-* parts): the title is the head's, the line and the years under it. */
.sl-page--phone .sl-bar {
  display: grid;
  justify-content: stretch;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}

.sl-page--phone .sl-summary {
  font-size: var(--text-sm);
}

/* Three steps a phone reads apart (impeccable detect, task 198: 15 / 13.1 / 12.2 px was a flat 1.15 : 1). */
.sl-page--phone .sl-group {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-lg);
}

.sl-page--phone .sl-group--first {
  margin-top: 0;
}

.sl-page--phone .ui-m-head__title {
  font-size: var(--text-xl);
  white-space: normal;
  text-wrap: balance;
}

/* Under the forecast on the set page (task 198): one quiet line, never a banner. */
.sp-disclaimer,
.sd-disclaimer {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}
