/* 07-wishlist.css — wishlist page, deal strips, provider snapshot cards.
   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. */
/* ── Wishlist page ─────────────────────────────────────── */
/* Task 162 rebuilt it on the design system (tokens of 00-tokens.css, .ui-* of 01-components.css): one list, a row a set,
   no cards, no table switch, no sidebar. The page's own rules are only the row's layout, the buyer's two colours of the
   distance to the target and the «⋯» panel. Red is never the page's: the distance reads green under the target, amber
   within 10 % over it (WishlistRow.CloseWithin), neutral beyond. */
.wishlist-page {
  font-variant-numeric: tabular-nums;
}

/* The buyer's colours of the distance to the target; the phone's row re-states them over 16-phone.css's muted line
   (18-wishlist-mobile.css). */
.wl-under,
.wl-gain {
  color: var(--up);
}

.wl-near {
  color: var(--warn);
}

.wl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.wl-head h1 {
  margin: 0;
  font-size: var(--text-xl);
}

/* «Набори | Мініфігурки» (task 179) beside the title; the summary keeps the right edge. */
.wl-kind {
  align-self: center;
  margin-right: auto;
}

.wl-head__total {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-md);
}

.wl-head__total strong {
  color: var(--up);
  font-size: var(--text-xl);
}

/* The search, then the filters and the sort (task 186): one row from 901 px (the sheet is display: contents there). */
.wl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.wl-search {
  flex: 0 1 16rem;
  min-width: 12rem;
}

.wl-toolbar .wl-bar {
  flex: 1 1 32rem;
  margin-bottom: 0;
}

.wl-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

/* The count reads on the pressed tab's fill too (text-faint there was 3.2 : 1 in the dark theme). */
.wl-bar .ui-tab__count {
  color: var(--text-muted);
}

.wl-tab--empty,
.wl-tab--empty:hover {
  color: var(--text-faint);
  cursor: default;
}

/* The list: a .ui-table on a card, no overflow box — the «⋯» panel opens over the rows, and an overflow: auto parent
   would clip it. position: relative is the containing block of the head's .visually-hidden «Дії». */
.wl-list {
  position: relative;
  border-radius: var(--radius-3);
  background: var(--surface-1);
  box-shadow: var(--shadow-1);
}

.wl-table td {
  white-space: normal;
}

.wl-cell-set {
  width: 100%;
}

.wl-set {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 24px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.wl-set:hover .wl-set__name {
  text-decoration: underline;
}

.wl-set__img {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-2);
  background: var(--photo-bg);
  overflow: hidden;
}

.wl-set__img img {
  width: 100%;
  height: 100%;
  padding: var(--photo-inset);
  object-fit: contain;
}

.wl-set__name {
  display: -webkit-box;
  min-width: 0;
  overflow-wrap: anywhere;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.wl-set__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 2px 0 0 calc(48px + var(--space-3));
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* A chip under the name at --text-xs: .tag's own 10.8 px is under the 11 px floor (impeccable detect, task 162). */
.wl-set__meta .tag {
  font-size: var(--text-xs);
}

/* «Вказати» where a target is missing: a 24 px target at least (WCAG 2.5.8). */
.wl-set-target {
  display: inline-block;
  line-height: 24px;
}

.wl-cell-price b {
  display: block;
  font-size: var(--text-lg);
  white-space: nowrap;
}

.wl-cell-price small,
.wl-cell-target small {
  display: block;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.wl-cell-price,
.wl-cell-target,
.wl-cell-gap {
  white-space: nowrap;
}

.wl-gap {
  font-weight: 600;
}

/* An order's three cells over the wish's four (tasks 166, 175): what it cost, BrickLink's price of its copies, the
   difference — each figure over its words, as the price over its shop. */
.wl-order {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap; /* .wl-table td's normal outranks a cell class: «замовлено 23 лист.» broke in two */
}

.wl-order b {
  font-size: var(--text-lg);
}

/* «немає цін вживаних» is read, not a placeholder: --text-faint is 4.1:1 (impeccable detect, task 175). */
.wl-order .wl-none {
  color: var(--text-muted);
}

@media (min-width: 901px) {
  /* Every row an order: the head says «BrickLink» and «Різниця» over the columns. */
  .wl-table--orders .wl-order__head-label {
    display: none;
  }

  /* A wished figure's words the table's head already says («BrickLink», «ціль», «до цілі», tasks 179, 181); the card
     under 901 px has no head and keeps them. */
  .wl-table--figures .wl-fig__head-label {
    display: none;
  }
}

/* «немає цін» on one line: .wl-table td's normal (0,1,1) outranks the cell's nowrap, and the price column broke it in two. */
.wl-table .wl-fig-price .wl-none {
  color: var(--text-muted);
  white-space: nowrap;
}

.wl-table--figures .wl-cell-gap small {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.wl-order small {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.wl-none {
  color: var(--text-faint);
}

.wl-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* The row's «⋯»: its details and the rest of the actions, a .ui-menu (a <details>, so no script; one open at a time by
   its name). The panel is wider than a menu: it carries a key–value list and the trend. */
.wl-more > summary {
  cursor: pointer;
}

.wl-more__panel {
  width: min(360px, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-3);
  gap: var(--space-1);
}

.wl-facts {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.wl-facts dd {
  font-weight: 500;
}

.wl-facts .set-tags {
  justify-content: flex-end;
}

.wl-stale {
  color: var(--warn);
}

.wl-facts__note {
  margin: 0 0 var(--space-2);
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* The trend reads from the buyer's side: cheaper is good news, dearer a caution (04-collection.css draws the block). */
.wishlist-page .price-trend {
  --trend-up: var(--warn);
  --trend-down: var(--up);
  margin-bottom: var(--space-2);
}

/* Under 901 px (a tablet, or a phone that chose the desktop page): a row is a card of three lines — the set, the
   figures, the actions — never a table that scrolls sideways. */
@media (max-width: 900px) {
  .wl-head {
    flex-wrap: wrap;
  }

  .wl-search {
    flex: 1 1 auto;
  }

  .wl-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .wl-table thead {
    display: none;
  }

  .wl-table,
  .wl-table tbody {
    display: block;
  }

  .wl-table tr {
    display: grid;
    grid-template-columns: repeat(4, auto) 1fr;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3);
    box-shadow: inset 0 -1px 0 var(--border);
  }

  .wl-table tbody td,
  .wl-table tbody td.ui-num {
    display: block;
    padding: 0;
    box-shadow: none;
    text-align: left;
  }

  .wl-cell-set,
  .wl-cell-actions {
    grid-column: 1 / -1;
  }

  .wl-cell-order[colspan] {
    grid-column: span 2;
  }

  .wl-order {
    align-items: flex-start;
  }

  .wl-actions {
    justify-content: flex-start;
  }

  .wl-actions .ui-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .wl-more__panel {
    left: 0;
    right: auto;
  }
}

/* The catalogue's next pages: 3 by scrolling, then «Показати ще (N)» (catalog-lazyload.js, task 134) */
.catalog-lazy-sentinel {
    height: 1px;
    width: 100%;
}

.catalog-lazy-status {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.25rem 0;
    color: var(--text-muted, #6b7280);
    font-size: 0.9rem;
}

/* Provider source snapshots — redesigned cards */
.snapshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.9rem;
}
.snapshot-card {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.snapshot-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.snapshot-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.snapshot-card__provider {
    display: flex;
    align-items: center;
    min-width: 0;
    font-weight: 700;
    color: var(--text);
}

.snapshot-card__time {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}
.snapshot-card__headline {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.3;
}
.snapshot-card__bar {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--good) 0%, var(--accent-2) 55%, #e04b4b 100%);
    margin: 0.15rem 0 0.35rem;
}
.snapshot-card__bar-marker {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--text);
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.35);
}
.snapshot-card__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    text-align: center;
    padding-top: 0.2rem;
    border-top: 1px solid var(--border);
}
.snapshot-stat {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    padding-top: 0.45rem;
    min-width: 0;
}
.snapshot-stat__label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.snapshot-stat__value {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}
.snapshot-stat--primary .snapshot-stat__value {
    color: var(--accent-text);
    font-size: 0.98rem;
}

/* Market analytics — verdict banner + KPI tiles (status-coded) */
.verdict {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.verdict__icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  background: rgba(17, 24, 39, 0.05);
  color: var(--muted);
}
.verdict__label { font-size: 1.3rem; font-weight: 800; line-height: 1.15; }
.verdict__note { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }

.verdict--good { background: var(--good-bg); border-color: color-mix(in srgb, var(--up) 35%, var(--surface-1)); }
.verdict--good .verdict__label, .verdict--good .verdict__icon { color: var(--good); }
.verdict--good .verdict__icon { background: rgba(19, 138, 75, 0.14); }
.verdict--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, var(--surface-1)); }
.verdict--warn .verdict__label, .verdict--warn .verdict__icon { color: #b5730a; }
.verdict--warn .verdict__icon { background: rgba(245, 159, 10, 0.16); }
.verdict--bad { background: var(--down-bg); border-color: color-mix(in srgb, var(--down) 35%, var(--surface-1)); }
.verdict--bad .verdict__label, .verdict--bad .verdict__icon { color: var(--down); }
.verdict--bad .verdict__icon { background: rgba(192, 57, 43, 0.12); }

.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 0 4px;
}
.kpi {
  flex: 1 1 0;
  min-width: 96px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 11px 12px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  overflow-wrap: anywhere;
}
/* No translate lift here: the scroll container (overflow-x) clips vertical overflow,
   which would shear the top of a lifted card. Use a contained shadow instead. */
.kpi:hover { box-shadow: 0 1px 5px rgba(17, 24, 39, 0.16); border-color: var(--muted); }
.kpi__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.kpi__value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
}
.kpi__note { font-size: 0.79rem; color: var(--muted); margin-top: 4px; line-height: 1.3; }
.kpi__arrow { font-size: 0.9rem; }
.kpi__arrow--good { color: var(--good); }
.kpi__arrow--bad { color: var(--down); }
.kpi__arrow--neutral { color: var(--muted); }

.kpi--good { background: var(--good-bg); border-color: color-mix(in srgb, var(--up) 35%, var(--surface-1)); }
.kpi--good .kpi__value { color: var(--good); }
.kpi--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, var(--surface-1)); }
.kpi--warn .kpi__value { color: #b5730a; }
.kpi--bad { background: var(--down-bg); border-color: color-mix(in srgb, var(--down) 35%, var(--surface-1)); }
.kpi--bad .kpi__value { color: var(--down); }

.kpi--forecast {
  min-width: 172px;
}

/* The range wraps at its dash and nowhere else (ForecastRange.PriceEnds, task 070): at 1440 px the card is
   172 px and "PLN 4 215 – 5 144" was 245 px on one unbreakable line, cut off by the next card. */
.kpi__value--forecast {
  align-items: baseline;
  font-size: 1.15rem;
  line-height: 1.2;
}

.kpi__forecast-price {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.3em;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.kpi__forecast-price > span {
  white-space: nowrap;
}

.kpi--forecast .kpi__forecast-percent {
  margin-top: 6px;
}

.kpi__forecast-percent {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  padding: 4px 7px;
  white-space: nowrap;
}

/* Liquidity tile — red→green gradient by score, with a 10-segment meter */
.kpi--liquidity {
  background: hsl(var(--liq-hue), 70%, 96%);
  border-color: hsl(var(--liq-hue), 55%, 80%);
}
.kpi--liquidity .kpi__value { color: hsl(var(--liq-hue), 60%, 34%); }
.kpi__unit { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-left: 3px; }
.liq-meter { display: flex; gap: 3px; margin-top: 7px; }
.liq-pip { flex: 1; height: 6px; border-radius: 2px; background: var(--border); }
.liq-pip.is-on { background: hsl(var(--pip-hue), 68%, 45%); }

/* Brickset reviews */
.bs-rating { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.bs-rating__score { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.bs-stars { color: #f5a623; font-size: 1.15rem; letter-spacing: 1px; }
.bs-stars--sm { font-size: 0.95rem; }
.bs-rating__meta { color: var(--muted); font-size: 0.9rem; }
.bs-reviews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}
.bs-review {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 14px 16px;
}
.bs-review__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.bs-review__title { font-weight: 700; }
.bs-review__meta { font-size: 0.77rem; color: var(--muted); margin-bottom: 8px; }
.bs-review__body {
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bs-review__aspects { display: flex; flex-wrap: wrap; gap: 5px 12px; font-size: 0.75rem; color: var(--muted); }
.bs-review__aspects b { color: var(--text); font-weight: 700; }

/* The phone (task 105): the toolbar is the «Фільтри» sheet's body — no frame of its own, a group a block. */
@media (max-width: 900px) {
  .wishlist-filters-toggle {
    justify-self: start;
    width: 100%;
  }

  .ui-filters .wishlist-toolbar {
    display: grid;
    gap: var(--space-4);
    padding: 0;
    border: 0;
    background: none;
  }

  .ui-filters .wishlist-toolbar__group {
    gap: var(--space-2);
  }

  .ui-filters .wishlist-toolbar__label {
    flex-basis: 100%;
  }
}
