/* =========================================================
   Catalogue and sections (PLP) — Optitechno

   Loads next to pdp.css and relies on it: the tokens, buttons, badges,
   container and breadcrumbs live there, and the listing templates carry both
   classes on <main> ("pdp plp") so the design system applies unchanged.
   Only the layout of a listing is new, and it is namespaced "plp-".
   ========================================================= */

/* ---------- Head ---------- */
.plp-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  max-width: 820px;
}
.plp-head__title {
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.08;
  letter-spacing: -.03em;
}
.plp-head__lead,
.plp-head__lead p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--pdp-text-2);
  text-wrap: pretty;
}
.plp-head__lead p + p { margin-top: 10px; }

/* ---------- Layout ---------- */
.plp-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-top: 32px;
  padding-bottom: 32px;
}
/* on the root the listing follows the tiles, so it needs the same step
   between blocks that the tiles got from the head */
.plp-all { margin-top: 40px; }
.plp-all .plp-layout { margin-top: 16px; }
.plp-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- Sections ----------
   Sticky because a listing is 12 cards tall and the sections are how you
   leave it. This is a column beside the content, not a second bar stacked
   under the fixed header. */
.plp-aside {
  position: sticky;
  top: calc(var(--pdp-header-h) + 24px);
  max-height: calc(100vh - var(--pdp-header-h) - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.plp-cats {
  display: block;
  padding: 18px 14px;
  background: var(--pdp-surface);
  border: 1px solid var(--pdp-line);
  border-radius: var(--pdp-r-xl);
}
.plp-cats__title {
  display: block;
  padding: 0 10px 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--pdp-muted);
  /* a heading on the desktop, a control only once it can fold */
  list-style: none;
  cursor: default;
}
.plp-cats__title::-webkit-details-marker { display: none; }
.plp .plp-cats__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--pdp-text);
  transition: background-color .2s, color .2s;
}
.plp .plp-cats__link:hover { background: var(--pdp-chip); color: var(--pdp-ink); }
.plp .plp-cats__link--current {
  background: var(--pdp-primary-tint);
  color: var(--pdp-ink);
  font-weight: 500;
}
.plp-cats__count { flex: none; font-size: 12px; color: var(--pdp-muted-2); }
.plp .plp-cats__link--current .plp-cats__count { color: var(--pdp-primary); }
.plp-cats__sub {
  margin: 2px 0 6px 10px;
  padding-left: 10px;
  border-left: 1px solid var(--pdp-line);
}
.plp .plp-cats__link--child { font-size: 13px; color: var(--pdp-muted); }

/* ---------- Blocks of the page ----------
   The theme spaces every <section> on the site:
   "section:not(:first-child) {padding: 90px 0 95px}". That is 185px of empty
   room inside each block here, and it is what made the root look like it had
   been pulled apart. Same cure as on the product page — say it with the .plp
   prefix, which outweighs one element plus one class. */
.plp .plp-sections,
.plp .plp-all { padding-top: 0; padding-bottom: 0; }
.plp .plp-about { padding: 28px; }

/* ---------- Sections as tiles (catalogue root) ----------
   The root has no side column, so the listing gets the full width. */
.plp-layout--full { grid-template-columns: minmax(0, 1fr); }

.plp-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 40px;
}
.plp-sections__title { font-size: 20px; line-height: 1.3; letter-spacing: -.01em; }
.plp-sections__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.plp .plp-section-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
  height: 100%;
  padding: 16px 18px;
  background: var(--pdp-surface);
  color: var(--pdp-ink);
  border: 1px solid var(--pdp-line);
  border-radius: var(--pdp-r-lg);
  transition: border-color .2s, box-shadow .2s, color .2s;
}
.plp .plp-section-card:hover {
  color: var(--pdp-ink);
  border-color: #B9C6E4;
  box-shadow: 0 8px 24px rgba(11, 21, 48, .06);
}
.plp-section-card__name { font-size: 15px; font-weight: 500; line-height: 1.35; }
.plp-section-card__count { grid-column: 1; font-size: 12px; color: var(--pdp-muted); }
.plp-section-card__arrow {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--pdp-chip);
  color: var(--pdp-primary);
  font-weight: 500;
  transition: background-color .2s, color .2s;
}
.plp .plp-section-card:hover .plp-section-card__arrow { background: var(--pdp-primary); color: #fff; }

/* ---------- Toolbar ---------- */
.plp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
}
.plp-toolbar__heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.plp-toolbar__title { font-size: 20px; line-height: 1.3; letter-spacing: -.01em; }
.plp-toolbar__count { font-size: 14px; color: var(--pdp-muted); }
.plp-toolbar__count--beside::before { content: "· "; }
.plp-toolbar__count strong { color: var(--pdp-ink); font-weight: 500; }
.plp-sort { display: flex; align-items: center; gap: 10px; }
.plp-sort__label { font-size: 13px; color: var(--pdp-muted); }
.plp-sort__select {
  height: 40px;
  padding: 0 34px 0 12px;
  background: var(--pdp-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2356607A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") right 12px center / 14px no-repeat;
  border: 1px solid var(--pdp-border);
  border-radius: var(--pdp-r-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--pdp-ink);
  cursor: pointer;
  appearance: none;
}
.plp-sort__select:focus-visible { outline: 2px solid var(--pdp-primary); outline-offset: 2px; }

/* ---------- Grid ---------- */
.plp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.plp-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--pdp-surface);
  border: 1px solid var(--pdp-line);
  border-radius: var(--pdp-r-xl);
  transition: border-color .2s, box-shadow .2s;
}
.plp-card:hover { border-color: #B9C6E4; box-shadow: 0 8px 24px rgba(11, 21, 48, .06); }
/* Square, and the photo fills it edge to edge. 96% of the catalogue's photos
   are square (278 of 290 sampled), so "cover" crops nothing at all on
   almost every card; the 4% that are slightly wider lose a sliver of their
   sides, which beats the white margin a fitted image left on every card. */
.plp-card__media {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--pdp-surface);
  border-bottom: 1px solid var(--pdp-line-soft);
}
.plp .plp-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.plp-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 12px;
}
.plp-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.plp-card__sku { color: var(--pdp-muted); }
.plp-card__title { font-size: 16px; font-weight: 500; line-height: 1.35; letter-spacing: -.01em; }
.plp .plp-card__link { color: var(--pdp-ink); }
.plp .plp-card__link:hover { color: var(--pdp-primary); }
.plp-card__price { margin-top: auto; font-size: 13px; color: var(--pdp-muted); }
.plp-card__price .price-on-request { font: inherit; color: inherit; }
.plp-card__add { margin: 0 18px 18px; }

.plp-empty {
  padding: 32px;
  background: var(--pdp-surface);
  border: 1px solid var(--pdp-line);
  border-radius: var(--pdp-r-xl);
  font-size: 15px;
  line-height: 1.6;
  color: var(--pdp-text-2);
}

/* ---------- Pagination ---------- */
.plp-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.plp-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  background: var(--pdp-surface);
  border: 1px solid var(--pdp-line);
  border-radius: var(--pdp-r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--pdp-ink);
  transition: border-color .2s, background-color .2s, color .2s;
}
.plp .plp-pagination a.page-numbers:hover { border-color: var(--pdp-ink); color: var(--pdp-ink); }
.plp-pagination .page-numbers.current {
  background: var(--pdp-primary);
  border-color: var(--pdp-primary);
  color: #fff;
}
.plp-pagination .page-numbers.dots { background: none; border-color: transparent; color: var(--pdp-muted); }

/* ---------- Text block under the catalogue ---------- */
.plp-about { margin-top: 40px; margin-bottom: 40px; gap: 12px; }
.plp-about :where(p, ul, ol) { font-size: 15px; line-height: 1.7; color: var(--pdp-text-2); }
.plp-about :where(h2, h3) { font-size: 20px; line-height: 1.3; text-transform: none; }
.plp-about ul, .plp-about ol { padding-left: 20px; }
.plp-about ul { list-style: disc; }
.plp-about ol { list-style: decimal; }
.plp-about li::marker { content: unset; }
.plp-about a { text-decoration: underline; }
.plp-about .table-scroll { margin: 0; }

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1199px) {
  .plp-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 24px; }
  .plp-layout--full { grid-template-columns: minmax(0, 1fr); }
  .plp-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 899px) {
  /* the sections stop being a column and sit above the listing; they stay a
     full list rather than a scrolling strip, so a child section is still
     reachable from a phone */
  .plp-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .plp-aside { position: static; max-height: none; overflow: visible; }
  .plp-cats__list { columns: 2; column-gap: 16px; }
  .plp-cats__item { break-inside: avoid; }

  /* folded by the script on load; here it only looks like a control */
  .plp-cats__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 10px;
    cursor: pointer;
  }
  .plp-cats[open] .plp-cats__title { padding-bottom: 12px; }
  .plp-cats__title::after {
    content: "";
    width: 10px; height: 10px;
    border-right: 2px solid var(--pdp-muted);
    border-bottom: 2px solid var(--pdp-muted);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .2s;
  }
  .plp-cats[open] .plp-cats__title::after { transform: rotate(-135deg) translate(-2px, -2px); }
  .plp-head { margin-top: 16px; }
}

@media (max-width: 599px) {
  .plp-cats__list { columns: 1; }
  /* seventeen tiles in one column is 1 190px before the first product;
     two compact columns without the arrow is half that */
  .plp-sections__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .plp-section-card { padding: 10px 12px; border-radius: var(--pdp-r-sm); }
  .plp-section-card__arrow { display: none; }
  .plp-section-card__name { font-size: 13px; line-height: 1.3; }
  .plp-section-card__count { font-size: 11px; }
  .plp-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .plp-card__body { padding: 12px 14px 10px; }
  .plp-card__title { font-size: 15px; }
  .plp-card__add { margin: 0 14px 14px; }
  .plp-toolbar { gap: 10px; }
  .plp-sort { width: 100%; }
  .plp-sort__select { flex: 1 1 auto; }
}

/* =========================================================
   Витрина на главной
   Тот же набор карточек, но это не листинг: двенадцать товаров ложатся
   в четыре колонки по три ряда, а не в пять «как получится».
   ========================================================= */
.main--bestsellers__list.plp-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

@media (min-width: 1200px) {
  .main--bestsellers__list.plp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 599px) {
  .main--bestsellers__list.plp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
