/*
 * Product pages BK-1, BK-2 and BK-3 (WP-10; page-product.php; boards BK3 at 1440 and BK3-mobile at 390, canvas
 * version 60). Loaded only on these pages (functions.php: page type 'product', body class k-type-product).
 * Breadcrumbs, buttons, the phone link, the stored-text styles (.page-text) and the catalogue are components
 * (css/components.css); this file draws the main block, the description band and its two cards.
 *
 * Widths: ≥1200 as drawn (360 | characteristics | 288); 768–1199 two columns (picture and contacts | characteristics);
 * <768 one column in the phone board's order (picture, characteristics, price, «Арендовать», contacts); <390 each
 * characteristic's label above its value.
 */

/* ---------- Main block: H1, picture | characteristics, price, «Арендовать» | phone, WhatsApp, delivery ---------- */

.k-type-product .k-product__main {
  background: var(--k-white);
  padding: 0 0 72px;
}

.k-type-product .k-product__title {
  margin: 20px 0 0;
  overflow-wrap: break-word;
  /* 768–1199 has no board: «…БК-3 в аренду» never leaves «в» at a line end. Phones keep BK3-mobile's breaks. */
  text-wrap: balance;
}

.k-type-product .k-product__grid {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 288px;
  gap: 32px;
  align-items: start;
}

.k-type-product .k-product__figure {
  margin: 0;
  padding: 20px;
  background: var(--k-white);
  border: 1px solid var(--k-hairline);
  border-radius: var(--k-radius-card);
}

.k-type-product .k-product__img {
  display: block;
  width: 100%;
  height: 320px;
  object-fit: contain;
}

.k-type-product .k-product__info {
  grid-column: 2;
  min-width: 0;
}

.k-type-product .k-product__specs {
  margin: 0;
  border-top: 1px solid var(--k-hairline);
  font-size: 16px;
  line-height: 22px;
}

.k-type-product .k-product__spec {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--k-hairline);
}

.k-type-product .k-product__spec dt {
  color: var(--k-muted);
}

.k-type-product .k-product__spec dd {
  margin: 0;
  color: var(--k-ink);
  overflow-wrap: break-word;
}

.k-type-product .k-product__price {
  margin: 28px 0 0;
  font-size: 28px;
  line-height: 34px;
  font-weight: 700;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--k-ink);
}

.k-type-product .k-product__vat {
  font-size: 17px;
  line-height: 22px;
  font-weight: 400;
  white-space: nowrap;
  color: var(--k-muted);
}

.k-type-product .k-product__cta {
  margin-top: 20px;
  padding: 0 28px;
}

.k-type-product .k-product__contact {
  grid-column: 3;
  padding: 24px;
  border-radius: var(--k-radius-panel);
  background: var(--k-panel);
}

.k-type-product .k-product__phone {
  min-height: 0;
  height: 48px;
}

.k-type-product .k-product__whatsapp {
  display: flex;
  width: fit-content;
  margin-top: 12px;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  font-size: 16px;
}

.k-type-product .k-product__whatsapp svg {
  flex: none;
  color: var(--k-blue);
}

.k-type-product .k-product__delivery {
  margin: 20px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--k-hairline);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--k-ink);
}

.k-type-product .k-product__delivery .k-ui-icon {
  flex: none;
  margin-top: 1px;
  color: var(--k-blue);
}

/* ---------- «Описание товара»: the stored text; «Преимущества» and «Сфера применения» as two cards ---------- */

.k-type-product .k-product__about {
  background: var(--k-band);
  padding: 72px 0;
}

.k-type-product .k-product__about-title {
  margin: 0;
}

.k-type-product .k-product__text {
  margin-top: 20px;
}

.k-type-product .k-product__text > * {
  max-width: 840px;
}

/* The two paragraphs of the opening text are stored as one, split by a <br> in its own span (BK-1, BK-3): that span
   becomes the gap between two paragraphs. */
.k-type-product .k-product__text > p:first-child > span:has(> br:only-child) {
  display: block;
  height: 16px;
  overflow: hidden;
}

/* BK-1: «Преимущества» is followed by a bold <br> and a span <br> (an empty line); they become the same gap as the
   one under «Сфера применения» (the paragraph margin). */
.k-type-product .k-product__text > p > b:has(> br:only-child) {
  display: block;
  height: 16px;
  overflow: hidden;
}

.k-type-product .k-product__text > p > b:has(> br:only-child) + span:has(> br:only-child) {
  display: none;
}

/* The description's lists carry role="list" (page-product.php: list-style none drops their semantics in Safari), and
   the .page-text list rules skip lists with a role; these restate those rules, so nothing moves. */
.k-type-product .k-product__text ul[role="list"] {
  margin: 0 0 16px;
  padding-left: 24px;
}

.k-type-product .k-product__text ul[role="list"] > li {
  margin: 0 0 8px;
}

.k-type-product .k-product__text ul[role="list"] > li:last-child {
  margin-bottom: 0;
}

.k-type-product .k-product__text ul[role="list"] > li::marker {
  color: var(--k-blue);
}

/* Old editor leftovers: empty paragraphs inside list items. */
.k-type-product .k-product__text li p:empty {
  display: none;
}

/* BK-1: one list item holding every line, the later ones after a typed «•»; the first line gets the same «•». */
.k-type-product .k-product__text ul:has(> li:only-child) {
  padding-left: 0;
  list-style: none;
}

.k-type-product .k-product__text ul:has(> li:only-child) > li::before {
  content: "•";
}

/* The cards: the text ends with «title paragraph, list, title paragraph, list» (BK-2, BK-3). The title and the list of
   each card sit in two grid rows shared by both columns, so the cards are equally tall; dense placement puts the
   second title back into the first card row. Without :has() the text stays plain. */
.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row dense;
  column-gap: 24px;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > * {
  grid-column: 1 / -1;
}

/* Grid items keep their margins: the last opening paragraph ends flush, the cards' 40 px start above them. */
.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :nth-last-child(5) {
  margin-bottom: 0;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(p:nth-last-child(4), ul:nth-last-child(3), p:nth-last-child(2), ul:last-child) {
  max-width: none;
  margin: 0;
  background: var(--k-white);
  border: 1px solid var(--k-hairline);
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(p:nth-last-child(4), p:nth-last-child(2)) {
  margin-top: 40px;
  padding: 32px 32px 0;
  border-bottom: 0;
  border-radius: var(--k-radius-card) var(--k-radius-card) 0 0;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) {
  padding: 16px 32px 32px;
  border-top: 0;
  border-radius: 0 0 var(--k-radius-card) var(--k-radius-card);
  list-style: none;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(p:nth-last-child(4), ul:nth-last-child(3)) {
  grid-column: 1;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(p:nth-last-child(2), ul:last-child) {
  grid-column: 2;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) > li {
  position: relative;
  margin: 0;
  padding-left: 32px;
  font-size: 16px;
  line-height: 1.5;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) > li + li {
  margin-top: 12px;
}

.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 20px;
  height: 20px;
  background: var(--k-blue);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* «Сфера применения»: a chevron instead of the tick. */
.k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > ul:last-child > li::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E");
}

/* ---------- 768–1199: two columns, picture and contacts on the left ---------- */

@media (max-width: 1199px) {
  .k-type-product .k-product__grid {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px 32px;
  }

  .k-type-product .k-product__figure {
    grid-column: 1;
    grid-row: 1;
  }

  .k-type-product .k-product__info {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .k-type-product .k-product__contact {
    grid-column: 1;
    grid-row: 2;
  }
}

@media (max-width: 1023px) {
  .k-type-product .k-product__main {
    padding-bottom: 56px;
  }

  .k-type-product .k-product__grid {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 24px;
  }

  .k-type-product .k-product__img {
    height: 260px;
  }

  .k-type-product .k-product__spec {
    grid-template-columns: minmax(0, 190px) minmax(0, 1fr);
    gap: 12px;
  }

  .k-type-product .k-product__about {
    padding: 56px 0;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(p:nth-last-child(4), p:nth-last-child(2)) {
    padding: 24px 24px 0;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) {
    padding: 16px 24px 24px;
  }
}

/* ---------- Phones (BK3-mobile): one column ---------- */

@media (max-width: 767px) {
  .k-type-product .k-product__main {
    padding-bottom: 32px;
  }

  .k-type-product .k-product__title {
    margin-top: 14px;
    text-wrap: wrap;
  }

  .k-type-product .k-product__grid {
    margin-top: 20px;
    display: block;
  }

  .k-type-product .k-product__figure {
    padding: 16px;
  }

  .k-type-product .k-product__img {
    height: 240px;
  }

  .k-type-product .k-product__specs {
    margin-top: 20px;
    font-size: 15px;
    line-height: 21px;
  }

  /* 150 px labels as drawn at 390; below the board width the label sits above its value (see the end of the file). */
  .k-type-product .k-product__spec {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
  }

  .k-type-product .k-product__price {
    margin-top: 24px;
    font-size: 26px;
    line-height: 32px;
  }

  .k-type-product .k-product__vat {
    font-size: 16px;
  }

  .k-type-product .k-product__cta {
    display: flex;
    width: 100%;
    margin-top: 16px;
  }

  .k-type-product .k-product__contact {
    margin-top: 24px;
    padding: 16px;
  }

  .k-type-product .k-product__phone {
    gap: 10px;
  }

  .k-type-product .k-product__whatsapp {
    margin-top: 8px;
  }

  .k-type-product .k-product__delivery {
    margin-top: 16px;
    padding-top: 16px;
    gap: 12px;
    font-size: 16px;
    line-height: 24px;
  }

  .k-type-product .k-product__about {
    padding: 24px 0 28px;
  }

  .k-type-product .k-product__text {
    margin-top: 12px;
  }

  .k-type-product .k-product__text > p {
    margin-bottom: 12px;
  }

  .k-type-product .k-product__text > p:first-child > span:has(> br:only-child),
  .k-type-product .k-product__text > p > b:has(> br:only-child) {
    height: 12px;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) {
    display: block;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(p:nth-last-child(4), p:nth-last-child(2)) {
    padding: 16px 16px 0;
    font-size: 22px;
    line-height: 28px;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > p:nth-last-child(4) {
    margin-top: 16px;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > p:nth-last-child(2) {
    margin-top: 12px;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) {
    padding: 12px 16px 16px;
  }

  .k-type-product .k-product__text:has(> p + ul + p + ul:last-child) > :is(ul:nth-last-child(3), ul:last-child) > li {
    line-height: 24px;
  }
}

/* ---------- Narrower than the phone board (<390): each label above its value ---------- */

/* Below 390 the value column would fall under the longest values (≈ 1,5 м³/мин (≈ 1500 л/мин), 185 px) and the
   browser would break them after «/». */
@media (max-width: 389px) {
  .k-type-product .k-product__spec {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
}

/* ---------- Below 375 px: the three-level trail wraps ---------- */

/* «Аренда компрессора с бетоноломами» takes a line of its own; with the 20 px line its 44 px tap area would cover the
   lower half of «Главная» on the line above (a tap there opened /betonolomy/). Taller lines and smaller tap areas keep
   every link's area to itself (28 px, no overlap); 375 px and wider are unchanged. */
@media (max-width: 374px) {
  .k-type-product .k-crumbs__nav p {
    line-height: 32px;
  }

  .k-type-product .k-crumbs__nav a {
    padding: 6px 0;
    margin: -6px 0;
    white-space: nowrap;
  }
}
