/*
 * Responsive fixes for the production im7vt template.
 * Loaded from footer.php after component and cookie-consent styles.
 */

@media screen and (max-width: 959px) {
  /* The compact header is already active in this range, so the desktop
     120 px content offset leaves an unnecessary empty band below it. */
  .cart_bg > .container {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-top: 40px !important;
    padding-right: 20px !important;
    padding-left: 20px !important;
  }

  .cart_bg > .container > h1 {
    margin: 0 0 24px !important;
    padding: 0 !important;
    line-height: 1.08 !important;
  }

  .cart-new {
    flex-direction: column !important;
    gap: 32px !important;
  }

  .list-cart {
    width: 100% !important;
    min-width: 0 !important;
  }

  .basket-checkout-container {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  #bx-soa-order {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 24px !important;
  }

  #bx-soa-order > *,
  .bx-soa-delivery-pay-wrapper > * {
    min-width: 0;
  }
}

/* Cookie notice scales down with the viewport instead of keeping its
   desktop 532 px footprint on tablets. */
@media screen and (max-width: 959px) {
  .rk-cookie {
    right: 20px !important;
    bottom: 20px !important;
  }

  .rk-cookie__compact {
    width: min(440px, calc(100vw - 40px)) !important;
    padding: 16px 18px !important;
    border-radius: 18px !important;
  }

  .rk-cookie__compact-text h2 {
    font-size: 18px !important;
    line-height: 1.2 !important;
  }

  .rk-cookie__compact-text p {
    margin-top: 5px !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  .rk-cookie__compact-actions {
    gap: 12px !important;
    margin-top: 14px !important;
  }

  .rk-cookie__button,
  .rk-cookie__settings-link {
    min-height: 34px !important;
    font-size: 12px !important;
  }

  .rk-cookie__button {
    padding: 7px 16px !important;
  }

  .rk-cookie__button svg,
  .rk-cookie__settings-link svg {
    width: 17px !important;
    height: 17px !important;
  }
}

@media screen and (max-width: 767px) {
  .bx-soa-delivery-pay-wrapper,
  .col-sm-12.bx-soa-customer {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Checkout: use the same 20 px page gutter throughout the mobile/tablet
     range. The component's own rule only starts below 480 px. */
  .cart_bg > .container {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 32px 20px 60px !important;
  }

  .cart_bg > .container > h1 {
    margin: 0 0 24px !important;
    padding: 0 !important;
    font-size: clamp(30px, 5.55vw, 40px) !important;
    line-height: 1.08 !important;
  }

  #bx-soa-order {
    width: 100% !important;
    margin: 0 !important;
  }

  #bx-soa-order > .bx-soa {
    box-sizing: border-box !important;
    width: 100% !important;
  }

  /* Keep "Стоимость:" and its value together instead of reserving 30% for
     the label at 481–766 px. */
  #bx-soa-delivery ul.bx-soa-pp-list li {
    justify-content: flex-start !important;
  }

  #bx-soa-delivery .bx-soa-pp-list-termin {
    flex: 0 0 auto !important;
    width: auto !important;
  }

  #bx-soa-delivery .bx-soa-pp-list-description {
    flex: 0 0 auto !important;
    width: auto !important;
  }

  /* Both checkout actions have one shared footprint on phones and small
     tablets. */
  #bx-soa-orderSave .chek_new {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-top: 32px !important;
  }

  #bx-soa-orderSave .chek_new > a {
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 52px !important;
    margin: 0 !important;
    padding: 8px 12px !important;
    border-width: 2px !important;
    border-radius: 999px !important;
    font-family: Montserrat, Arial, sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    text-align: center !important;
    white-space: normal !important;
  }
}

@media screen and (max-width: 640px) {
  .rk-cookie {
    right: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
  }

  .rk-cookie__compact {
    width: 100% !important;
    padding: 14px !important;
    border-radius: 16px !important;
  }

  .rk-cookie__compact-text h2 {
    font-size: 16px !important;
  }

  .rk-cookie__compact-text p {
    font-size: 12px !important;
  }

  .rk-cookie__compact-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    gap: 8px !important;
    margin-top: 12px !important;
  }

  .rk-cookie .rk-cookie__compact-actions button {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 38px !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
    line-height: 1.15 !important;
    white-space: normal !important;
  }
}

/* Preserve two compact product/category columns on common phones, but stop
   forcing them into unusably narrow cards below 360 px. */
@media screen and (max-width: 359px) {
  .product-grid,
  .im-sections-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .product-grid {
    gap: 24px !important;
  }

  .im-section-card {
    aspect-ratio: 16 / 9 !important;
  }

  /* The final amount is one semantic fragment and must not split after the
     first digit. */
  .cart-offer-progress__title strong:last-child {
    white-space: nowrap !important;
  }

  .basket-coupon-block-field .form-group {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .basket-coupon-block-field input.form-control {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    padding-right: 12px !important;
    padding-left: 14px !important;
  }

  .basket-coupon-block-field .basket-coupon-block-coupon-btn {
    box-sizing: border-box !important;
    position: static !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 8px 12px !important;
    transform: none !important;
  }
}

@media screen and (max-width: 639px) {
  .im-section-card__title {
    font-size: 14px !important;
    line-height: 1.25 !important;
  }
}

/* Product names must remain readable in narrow two-column cards. */
#allrecords .product-card .tn-elem[data-elem-id="1692104725947"] .tn-atom {
  height: auto !important;
  min-height: 40px;
  max-height: none !important;
  overflow: visible !important;
  line-height: 1.15 !important;
}

@media screen and (max-width: 479px) {
  .cart_bg > .container > h1 {
    font-size: 27px !important;
  }

  #bx-soa-order > .bx-soa {
    padding: 24px 20px !important;
  }

  /* Reserve a real text lane for the required-field hint. */
  #bx-soa-order .soa-property-container.im-required input:not([type="checkbox"]):not([type="radio"]),
  #bx-soa-order .soa-property-container.im-required textarea {
    box-sizing: border-box !important;
    width: 100% !important;
    padding-right: 112px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #bx-soa-order .bx-soa-location-input-container.im-required .bx-ui-sls-fake,
  #bx-soa-order .bx-soa-location-input-container.im-required .bx-ui-sls-route {
    box-sizing: border-box !important;
    padding-right: 108px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #bx-soa-order .soa-property-container.im-required::after,
  #bx-soa-order .bx-soa-location-input-container.im-required::after {
    right: 12px !important;
    max-width: 92px !important;
    overflow: hidden !important;
    font-size: 9px !important;
    text-overflow: ellipsis !important;
  }

  #bx-soa-orderSave .chek_new {
    gap: 8px !important;
  }

  #bx-soa-orderSave .chek_new > a {
    min-height: 56px !important;
    padding: 7px 6px !important;
    font-size: clamp(11px, 3.35vw, 13px) !important;
  }

  #allrecords .product-card .tn-elem[data-elem-id="1692104725947"] .tn-atom {
    font-size: 15px !important;
  }

  #allrecords .product-card a.js-related-add,
  #allrecords .product-card a.js-related-detail,
  #allrecords .product-card .related-qty.quantity-control {
    min-height: 44px !important;
    height: 44px !important;
    max-height: 44px !important;
  }
}

@media screen and (max-width: 359px) {
  .cart_bg > .container > h1 {
    font-size: 25px !important;
  }
}
