/*
  Adaptive layout layer for MagNet Home.
  Loaded after the base styles: keeps the desktop look while removing
  horizontal overflow and reflowing every interaction for touch screens.
*/
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

.wrap,
.hero-grid,
.order-section,
.order-card,
.form-main,
.order-summary,
.info-strip article,
.benefits article,
.email-verification,
.email-code-panel,
.cdek-modal__dialog,
.cdek-modal__content {
  min-width: 0;
}

.hero-trust,
.cdek-pvz-display,
#cdek-pvz-status,
#email-verification-status,
#promo-status,
.error,
.review-item,
.legal-footer,
.faq-item p {
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .wrap {
    padding-inline: clamp(20px, 3vw, 30px);
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .hero-copy,
  .hero-purchase {
    max-width: min(100%, 500px);
  }

  .main-nav {
    gap: clamp(12px, 2vw, 22px);
  }

  .main-nav a,
  .main-nav button {
    font-size: 12px;
  }
}

/* The header changes before its contents can collide at tablet widths. */
@media (max-width: 1020px) {
  .nav-row {
    min-height: 68px;
    gap: 10px;
  }

  .brand-wordmark strong {
    font-size: 20px;
  }

  .support {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    margin-left: auto;
    padding: 8px;
    border-radius: 50%;
  }

  .support span {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

  .menu-toggle .icon {
    width: 24px;
    height: 24px;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: 68px;
    right: 0;
    left: 0;
    z-index: 10;
    gap: 0;
    margin: 0;
    padding: 12px max(20px, calc((100vw - 1200px) / 2 + 20px));
    border-bottom: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 10px 24px rgb(23 40 44 / 10%);
    flex-direction: column;
    align-items: stretch;
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav a,
  .main-nav button {
    min-height: 44px;
    padding: 11px 0;
    font-size: 15px;
    line-height: 22px;
  }

  .hero-grid {
    display: flex;
    min-height: 0;
    padding-top: 28px;
    padding-bottom: 28px;
    flex-direction: column;
  }

  .hero-copy,
  .hero-purchase {
    width: 100%;
    max-width: 620px;
  }

  .hero-visual {
    position: relative;
    right: auto;
    left: auto;
    order: 2;
    width: calc(100% + 2 * clamp(20px, 3vw, 30px));
    height: clamp(280px, 52vw, 390px);
    margin: 14px calc(-1 * clamp(20px, 3vw, 30px)) 4px;
    background-image: var(--hero-image);
    background-position: center bottom;
    background-size: cover;
  }

  .hero-purchase {
    order: 3;
    padding-top: 14px;
  }

  .benefits {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .benefits article,
  .info-strip article {
    min-width: 0;
  }

  .order-section {
    grid-template-columns: 1fr;
  }

  .order-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .order-steps li {
    min-width: 0;
    gap: 8px;
  }

  #order-form {
    grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 650px) {
  .wrap {
    padding-inline: 20px;
  }

  .hero-grid {
    padding-top: 24px;
    padding-bottom: 26px;
  }

  .hero h1 {
    font-size: clamp(32px, 9vw, 40px);
    letter-spacing: -1.25px;
  }

  .hero-lead {
    max-width: 540px;
    font-size: 16px;
  }

  .hero-visual {
    width: calc(100% + 40px);
    height: clamp(260px, 74vw, 340px);
    margin-right: -20px;
    margin-left: -20px;
    background-size: auto 110%;
  }

  .price {
    font-size: clamp(34px, 10vw, 40px);
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .button {
    min-width: min(100%, 160px);
    flex: 1 1 160px;
    min-height: 46px;
    padding-inline: 14px;
    white-space: normal;
    text-align: center;
  }

  .services {
    width: 100%;
    max-width: 420px;
    margin-inline: auto;
    gap: clamp(5px, 2vw, 10px);
  }

  .services .service-icon,
  .services .service-mark {
    width: 34px;
    height: 34px;
  }

  .services .service-label {
    overflow: hidden;
    font-size: clamp(9px, 2.8vw, 11px);
    text-overflow: ellipsis;
  }

  .hero-trust p {
    font-size: 13px;
  }

  .payment-methods {
    gap: 6px;
  }

  .payment-mark {
    min-height: 30px;
    padding-inline: 8px;
  }

  .benefits {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 24px 0 14px;
  }

  .benefits article,
  .benefits article:first-child,
  .benefits article + article {
    padding: 0;
    border: 0;
  }

  .benefits article {
    gap: 16px;
  }

  .benefits h2 {
    font-size: 16px;
  }

  .benefits p,
  .info-strip p {
    font-size: 13px;
  }

  .benefits br {
    display: none;
  }

  .info-strip {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 18px;
  }

  .info-strip article,
  .info-strip article + article,
  .info-strip article:last-child {
    grid-column: auto;
    margin: 0;
    padding: 0 !important;
    border: 0;
  }

  .order-section {
    gap: 18px;
    margin-inline: -8px;
    padding: 16px 12px;
  }

  .order-sidebar {
    padding-inline: 4px;
  }

  .order-sidebar h2 {
    font-size: 25px;
  }

  .order-sidebar h2 br {
    display: block;
  }

  .order-steps {
    gap: 6px;
    margin-top: 18px;
  }

  .order-steps li {
    align-items: flex-start;
    gap: 6px;
  }

  .order-steps li > span {
    width: 25px;
    height: 25px;
    font-size: 13px;
  }

  .order-steps b {
    font-size: 11px;
    line-height: 25px;
  }

  .order-steps small {
    display: none;
  }

  .order-card {
    padding: 17px 13px;
  }

  #order-form,
  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .field-wide {
    grid-column: auto;
  }

  .form-grid label,
  .cdek-pvz-field > label,
  .email-field > label {
    font-size: 13px;
  }

  input:not([type="checkbox"]),
  textarea,
  select {
    min-height: 46px;
    padding: 11px 12px;
    font-size: 16px;
  }

  textarea {
    min-height: 80px;
  }

  .cdek-pvz-button,
  .email-verification .button.compact,
  .order-summary .button {
    min-height: 46px;
  }

  .email-verification {
    padding: 12px;
  }

  .email-verification-actions,
  .email-code-panel {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    align-items: stretch;
  }

  .email-code-panel input {
    min-height: 46px;
  }

  .consent {
    gap: 10px;
    font-size: 11px;
  }

  .consent input {
    width: 20px;
    height: 20px;
  }

  .order-summary {
    padding: 17px;
  }

  .order-summary > p,
  .order-summary .small {
    font-size: 12px;
  }

  .order-summary .button {
    font-size: 14px;
  }

  .faq-section {
    margin: 44px 0;
  }

  .faq-item summary {
    min-height: 58px;
    padding: 16px;
    font-size: 15px;
  }

  .faq-item p {
    padding: 14px 16px 17px;
    font-size: 14px;
  }

  .reviews-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .reviews-heading .button,
  #more-reviews {
    min-height: 44px;
  }

  .review-item {
    padding: 17px;
  }

  .review-photos img {
    width: min(120px, calc(50vw - 38px));
    height: auto;
    aspect-ratio: 6 / 5;
  }

  .legal-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 26px 0;
  }

  .legal-footer .brand {
    flex-basis: auto;
  }

  .cdek-modal__close {
    width: 44px;
    height: 44px;
  }

  .cdek-search {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .cdek-search .button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .wrap {
    padding-inline: 16px;
  }

  .brand-wordmark {
    gap: 5px;
  }

  .brand-wordmark strong {
    font-size: 18px;
  }

  .brand-wordmark small {
    font-size: 8px;
  }

  .nav-row {
    gap: 5px;
  }

  .support,
  .menu-toggle {
    width: 42px;
    min-width: 42px;
  }

  .hero-visual {
    width: calc(100% + 32px);
    height: min(76vw, 310px);
    margin-right: -16px;
    margin-left: -16px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .button {
    width: 100%;
    flex-basis: auto;
  }

  .services {
    gap: 3px;
  }

  .services .service-icon,
  .services .service-mark {
    width: 31px;
    height: 31px;
  }

  .services .service-label {
    font-size: 9px;
  }

  .payment-methods {
    display: grid;
    grid-template-columns: repeat(2, max-content);
  }

  .order-section {
    margin-inline: -4px;
    padding: 14px 9px;
  }

  .order-steps {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .order-steps li {
    align-items: center;
  }

  .order-steps small {
    display: block;
  }

  .order-summary,
  .order-card {
    border-radius: 7px;
  }

  .cdek-modal__header h2 {
    font-size: 16px;
  }
}

@media (max-width: 340px) {
  .brand-wordmark strong {
    font-size: 16px;
  }

  .brand-wordmark small {
    display: none;
  }

  .hero h1 {
    font-size: 31px;
  }

  .hero-lead {
    font-size: 15px;
  }

  .services .service-label {
    font-size: 8px;
  }

  .faq-item summary {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* Final mobile touch and readability pass. */
@media (max-width: 650px) {
  input:not([type="checkbox"]), textarea, select { min-height: 48px; font-size: 16px; }
  .cdek-pvz-button, .order-summary .button, .hero-actions .button { min-height: 48px; }
  .hardware-card p { font-size: 15px; line-height: 1.55; }
  .review-item { font-size: 15px; line-height: 1.55; }
}
@media (max-width: 360px) {
  .tariff-picker, .hardware-value { border-radius: 9px; }
  .tariff-heading h3 { font-size: 19px; }
  .hardware-heading h2 { font-size: 26px; }
}
