/* Mobile UX fixes — pk-profilplus.ru (max-width: 600px / 768px) */

@media screen and (max-width: 600px) {
  /* P0: iOS zoom prevention — inputs >= 16px */
  input.input,
  textarea.input,
  select.input,
  .input,
  input[type="text"],
  input[type="tel"],
  input[type="email"],
  input[type="number"],
  input[type="search"],
  textarea,
  select,
  .hero2__panel-form .input,
  .fence-selector input,
  .fence-selector textarea,
  .fence-selector select {
    font-size: 16px !important;
  }

  /* Header: keep phone text hidden (adaptiv), only icon; no flex-breaking tap rules */
  .header .tel-header .tel-mob,
  .header a.tel.tel-mob {
    display: none !important;
  }

  .header .tel-header {
    padding-right: 0;
    flex-shrink: 0;
  }

  .header .social {
    flex-shrink: 0;
    gap: 0.35rem;
  }

  .header .social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
  }

  .header .social img {
    width: 28px;
    height: 28px;
    pointer-events: none;
  }

  /* Promo banners: long titles overflowed / clipped under sticky CTA */
  .promo-item {
    aspect-ratio: auto;
    min-height: 240px;
    padding: 1.15rem 1rem 5.5rem;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .promo-title {
    font-size: clamp(1.05rem, 5.2vw, 1.35rem);
    line-height: 1.15;
    margin-bottom: 0.5rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
  }

  .promo-title strong {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .promo-subtitle {
    font-size: 0.92rem;
    line-height: 1.35;
    max-width: 100%;
  }

  /* P0: sticky add-to-cart bar on product pages */
  .product-sticky-buy {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 13;
    grid-template-columns: 1fr auto;
    gap: 0.65em;
    align-items: center;
    padding: 0.65em 1rem;
    padding-bottom: calc(0.65em + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #e3e3e3;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(8px);
  }

  .product-sticky-buy.is-visible {
    display: grid;
  }

  .product-sticky-buy__price {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    color: #1a1a1a;
  }

  .product-sticky-buy__price .mvtforms2-price,
  .product-sticky-buy__price .msoptionsprice-cost {
    font-size: 1.15rem;
  }

  .product-sticky-buy__btn {
    min-height: 44px;
    padding: 0.65em 1.1em;
    white-space: nowrap;
    border: 0;
    cursor: pointer;
  }

  body.has-product-sticky-buy {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  }

  /* P1: hero — keep primary + catalog; demote «Задать вопрос» to text */
  .hero2__actions {
    flex-wrap: wrap;
  }

  .hero2__actions a.hero2__secondary[href="#callback"],
  .hero2__actions a.bric:nth-child(3) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: #fff !important;
    text-decoration: underline;
    padding: 0.35rem 0 !important;
    min-height: auto !important;
    width: 100%;
    justify-content: flex-start;
    font-size: 0.9rem;
  }

  /* P1: denser KSP on hero if grid */
  .hero2__ksp,
  .hero2__stats {
    font-size: 0.85em;
  }

  /* P1: quiz radios readable */
  .fence-selector label,
  .fence-selector__option,
  .fence-selector [class*="radio"] {
    font-size: 14px !important;
  }

  /* P2: clamp product card titles */
  .card .card-name,
  .card .card-name a,
  .card_txt .card-name a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: 2.6em;
    line-height: 1.3;
  }

  /* Product card: sentence-case title, stronger specs, compact back */
  .product-info .product-name,
  h1.product-name {
    text-transform: none;
    font-size: 1.2rem;
    line-height: 1.3;
    letter-spacing: 0;
  }

  .product-info .char_row {
    line-height: 1.55;
    font-size: 0.92rem;
    color: #222;
  }

  .product-info .char_row .char_name {
    color: #444;
    font-weight: 600;
  }

  .product-info .char_row .char_param {
    color: #111;
    font-weight: 700;
  }

  .button.button-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: auto;
    min-height: 36px;
    padding: 0.35rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    background: transparent;
    color: #2f6b1a;
    border: 1px solid #c5d9b8;
    box-shadow: none;
  }

  .button.button-back:before {
    width: 0.75em;
    height: 0.75em;
  }

  /* Compact buy formula: qty × height in one row, total below */
  .ms2_form > .flex-b.flex-column {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      "qty x h"
      "cost cost cost";
    align-items: end;
    column-gap: 0.5rem;
    row-gap: 0.75rem;
    margin-top: 1.25rem !important;
  }

  .ms2_form > .flex-b.flex-column > :nth-child(1),
  .ms2_form > .flex-b.flex-column > :nth-child(3) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    font-size: 0.85rem;
    line-height: 1.2;
    text-align: left;
  }

  .ms2_form > .flex-b.flex-column > :nth-child(1) {
    grid-area: qty;
  }

  /* «×» — высота как у степпера, по центру кнопок */
  .ms2_form > .flex-b.flex-column > :nth-child(2) {
    grid-area: x;
    align-self: end;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: calc(2.4rem + 1rem); /* кнопки 2.4rem + padding степпера */
    padding: 0;
    margin: 0;
    font-size: 1.05rem;
    line-height: 1;
  }

  .ms2_form > .flex-b.flex-column > :nth-child(3) {
    grid-area: h;
  }

  .ms2_form > .flex-b.flex-column > :nth-child(4) {
    display: none; /* "=" moved visually into total block */
  }

  .ms2_form > .flex-b.flex-column > :nth-child(5) {
    grid-area: cost;
    text-align: center;
    padding-top: 0.15rem;
  }

  .ms2_form .main-quantity {
    width: 100% !important;
    max-width: none;
    box-sizing: border-box;
    margin: 0;
  }

  .ms2_form .main-quantity a {
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
  }

  .ms2_form .main-quantity .counter {
    width: auto;
    max-width: 2.75rem;
    height: auto;
    font-size: 1rem;
  }

  .ms2_form .dlina {
    font-size: 1.75rem;
    opacity: 1;
    margin-top: 0.15rem;
  }

  .ms2_form > .mt-5:last-child {
    margin-top: 1rem !important;
  }
}

/* Product title: readable sentence case on all viewports */
h1.product-name,
.product-info .product-name {
  text-transform: none;
}

.product-info .char_row .char_name {
  color: #444;
}

.product-info .char_row .char_param {
  color: #111;
}

@media screen and (min-width: 601px) {
  .product-sticky-buy {
    display: none !important;
  }

  body.has-product-sticky-buy {
    padding-bottom: 0 !important;
  }
}

/* P1: tablet catalog — avoid cramped multi-column */
@media screen and (max-width: 768px) and (min-width: 601px) {
  .grid-3,
  .grid-4,
  .grid-5 {
    grid-template-columns: 1fr 1fr;
  }
}

@media screen and (max-width: 1024px) and (min-width: 769px) {
  .grid-4,
  .grid-5 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
