/**
 * @file
 * Catalog pages: the filters on the left and the grid of product cards.
 */

.sm-catalog__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* The filters column, a page without filterable fields has none. */
@media (min-width: 1024px) {
  .sm-catalog__layout--filters {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}

/* Filters */

.sm-catalog__filters-toggle > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
}

@media (min-width: 1024px) {
  .sm-catalog__filters {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }

  /* The filters are always open on wide screens. */
  .sm-catalog__filters-toggle > summary {
    display: none;
  }
}

.sm-catalog__filters form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sm-catalog__filters fieldset {
  margin: 0;
  padding: 0 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--color-border, #e5e5e5);
  min-width: 0;
}

.sm-catalog__filters legend {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  padding: 0;
}

/* Long lists of options scroll inside their filter. */
.sm-catalog__filters .bef-checkboxes {
  max-height: 14rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.sm-catalog__filters .form-type-checkbox,
.sm-catalog__filters .form-item.form-type-checkbox {
  margin: 0.15rem 0;
}

.sm-catalog__filters .form-actions {
  margin: 0;
}

/* Cards */

/*
 * The cards have the same standard width on every listing: the catalog
 * pages with or without filters, the search page and the favorites. A wider
 * listing gets more cards in a row, not bigger cards; the phones get two.
 * The rows of a view are inside the wrapper of the infinite scroll pager.
 */
:root {
  --sm-card-width: 216px;
}

.sm-catalog__grid > .views-infinite-scroll-content-wrapper,
.sm-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 768px) {
  .sm-catalog__grid > .views-infinite-scroll-content-wrapper,
  .sm-card-grid {
    grid-template-columns: repeat(auto-fill, var(--sm-card-width));
  }
}

/* The clearfix pseudo elements would take grid cells. */
.sm-catalog__grid > .views-infinite-scroll-content-wrapper::before,
.sm-catalog__grid > .views-infinite-scroll-content-wrapper::after {
  display: none;
}

.sm-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sm-card__link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.sm-card__media {
  position: relative;
}

.sm-card__image {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--light-primary, #f5f5f5);
}

.sm-card__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.sm-card__link:hover .sm-card__image img {
  transform: scale(1.03);
}

/* Below the image: the SKU, the price under it */
.sm-card__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin-top: 0.5rem;
}

.sm-card__sku {
  max-width: 100%;
  color: var(--color-primary, #b0347f);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.sm-card__sku:hover,
.sm-card__sku:focus-visible {
  text-decoration: underline;
}


/* The size of the tile or the grid over the bottom-left of the image */
.sm-card__size {
  position: absolute;
  left: 0.4rem;
  bottom: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  pointer-events: none;
}

.sm-card__price {
  white-space: nowrap;
  font-weight: 600;
  line-height: 1.3;
}

/* The price of the unit with the price of the square meter below it */
.sm-card__price-sqm {
  font-weight: 400;
  font-size: 0.9em;
  opacity: 0.75;
}

/* Load more */

.sm-catalog .pager {
  margin-top: 1.5rem;
  text-align: center;
}

/* Search page */

.sm-catalog__search {
  margin-bottom: 1.5rem;
}

.sm-catalog__search form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.sm-catalog__search .form-item {
  flex: 1 1 16rem;
  margin: 0;
}

.sm-catalog__search input[type=text] {
  width: 100%;
}

.sm-catalog__search .form-actions {
  margin: 0;
}

/* The favorites star over the card image */

.sm-card__favorite {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
}

.sm-fav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  color: var(--text-color, #333);
  font-size: 1.1rem;
  text-decoration: none;
  transition: transform 0.15s, color 0.15s;
}

.sm-fav__link:hover,
.sm-fav__link:focus-visible {
  transform: scale(1.1);
  color: var(--color-primary, #b0347f);
}

.sm-fav--on .sm-fav__link {
  color: var(--color-primary, #b0347f);
}

/* The toggle in progress */
.sm-fav .ajax-progress {
  display: none;
}

.sm-fav__link.is-disabled,
.sm-fav a[disabled] {
  opacity: 0.5;
}

/* The cart page */

.sm-cart__sku {
  color: var(--color-primary, #b0347f);
  font-weight: 700;
}

.sm-cart__thumbnail {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
}

.sm-cart__price,
.sm-cart__price-sqm {
  display: block;
  white-space: nowrap;
}

.sm-cart__price-sqm {
  font-size: 0.85em;
  opacity: 0.75;
}

.sm-cart__area {
  white-space: nowrap;
}

.sm-cart__minimum {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-primary, #b0347f);
  background: var(--light-primary, #f6f6f6);
  font-weight: 600;
}

/* The floating "Применить" next to the cursor after a change of a filter, see js/catalog.js */
/* over the position: relative of .button, see buttons.css */
button.button.sm-catalog__apply-floating {
  position: absolute;
  z-index: 500;
  margin: 0;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

button.button.sm-catalog__apply-floating[hidden] {
  display: none;
}

/* "Применить" and "Сбросить" side by side at the bottom of the filters */
.sm-catalog__filters .form-actions {
  display: flex;
  gap: 0.5rem;
}

.sm-catalog__filters .form-actions .button {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding-right: 0.5em;
  padding-left: 0.5em;
}
