/* One space between consecutive sections. Keep card and form padding inside each section. */
#main-content {
  --home-section-gap: clamp(3rem, 6.25vw, 5rem);
}

#main-content > :is(.seo-section-nav, .pricing-tariffs-section, .case-showcase-layout,
    .seo-guide, .advantages, .seo-directions, .promo, .competitive-niches-section,
    .business-improvement-section, .test-drive-section, .team-section-wrapper,
    .portfolio-section-wrapper) {
  margin-block: var(--home-section-gap) 0;
  padding-block: 0;
}

#main-content > .test-drive-section {
  /* The shared tablet layout sets the section padding with !important. */
  padding-block: 0 !important;
}

#main-content > .case-showcase-layout > .seo-case-studies-showcase {
  margin-block: 0;
}

#main-content > .home-work-plan .seo-guide-topics:last-child {
  margin-block-end: 0;
}

#main-content > .contact-engagement-form {
  margin-block: var(--home-section-gap) 0;
  overflow: hidden;
}

#main-content > .contact-engagement-form .inquiry-service > span {
  color: #fff;
}

@media (max-width: 720px) {
  #main-content > .contact-engagement-form > .background-image {
    top: 0;
    height: 100%;
  }
}

@media (max-width: 1120px) {
  /* The steps carousel already reserves 1rem below the cards. */
  #main-content > .business-improvement-section + .seo-guide {
    margin-block-start: calc(var(--home-section-gap) - 1rem);
  }
}

@media (min-width: 1029px) {
  /* The grid needs row spacing only between rows. */
  #main-content .team-members-row:last-child {
    margin-bottom: 0 !important;
  }
}

@media (min-width: 1616px) {
  #main-content .niches-list {
    min-height: 0;
  }

  #main-content .business-improvement-section .process-header-wrapper {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  /* At 480px the shared phone and tablet carousel rules both match. */
  #main-content .portfolio-grid-container {
    margin-inline: -1.5rem -1.2rem;
    padding-inline: 1.5rem;
  }
}

@media (min-width: 761px) {
  #main-content .home-search-intro {
    align-items: start;
  }

  #main-content .home-search-heading {
    margin-block: 0;
  }
}

@media (min-width: 761px) and (max-width: 1028px) {
  #main-content .home-search-intro {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1029px) {
  /* Use the same tracks for the introductory text and the card row below it. */
  #main-content > .hero {
    --home-service-rail: 572px;
    --home-hero-gutter: 11px;
  }

  #main-content .home-search-intro,
  #main-content .services-preview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--home-service-rail);
    column-gap: var(--home-hero-gutter);
  }

  #main-content .home-search-offer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem;
    max-width: none;
  }

  #main-content .home-search-offer > p:first-child {
    grid-column: 1 / -1;
  }

  #main-content .home-search-offer .home-search-prices,
  #main-content .home-offer-actions {
    margin: 0;
  }

  #main-content .home-offer-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    text-align: center;
  }

  #main-content .home-offer-actions > a:last-child {
    padding-block: .45rem;
  }
}

@media (min-width: 1029px) and (max-width: 1616px) {
  #main-content > .hero {
    --home-service-rail: 464px;
    --home-hero-gutter: 8px;
  }
}

/* The six service topics and the three guides share the same column edges. */
#seo-prodvizhenie .seo-guide-topics {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 700px) and (max-width: 959.98px) {
  #seo-prodvizhenie .seo-guide-topics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #seo-prodvizhenie .seo-guide-topics > article:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 960px) {
  #seo-prodvizhenie .seo-guide-topics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 981px) {
  #seo-prodvizhenie .seo-guide-topics + h2 {
    margin-block-start: var(--home-section-gap);
  }

  #zakazat-seo .promo-button {
    width: fit-content;
    max-width: 100%;
    min-height: 44px;
    height: auto;
    gap: .75rem;
    padding: .6rem 1rem;
  }
}

@media (min-width: 1120px) {
  .business-improvement-section .business-improvement-frame {
    --step-column-gap: clamp(1.5rem, 3vw, 3.5rem);
    display: grid;
    gap: clamp(1.75rem, 3vw, 3rem);
    min-width: 0;
    height: auto;
  }

  .business-improvement-section .process-header-wrapper {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    align-items: start;
    gap: var(--step-column-gap);
  }

  .business-improvement-section :is(.process-header-wrapper, .steps-container-grid) {
    position: static;
    inset: auto;
    width: 100%;
    height: auto;
  }

  .business-improvement-section :is(.main-title-h1, .header-text-container, .description-text-large,
      .step-heading-wrapper, .step-title-h5, .step-content-wrapper, .step-description-text) {
    width: auto;
    height: auto;
    min-width: 0;
  }

  .business-improvement-section .description-text-large {
    font-size: clamp(1.125rem, 1.35vw, 1.5rem);
    line-height: 1.35;
  }

  .business-improvement-section .steps-container-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    margin: 0;
    padding: 0;
    overflow: visible;
    gap: 1rem var(--step-column-gap);
  }

  .business-improvement-section .step-card-item {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: inherit;
    width: auto;
    min-width: 0;
  }

  .business-improvement-section .step-heading-wrapper {
    gap: 1rem;
    align-self: stretch;
  }

  .business-improvement-section .number-badge-circle {
    flex: none;
  }

  .business-improvement-section .step-title-h5 {
    line-height: 1.2;
  }

  .business-improvement-section .step-content-wrapper {
    display: contents;
  }

  .business-improvement-section .steps-container-grid::before {
    content: none;
  }

  .business-improvement-section .divider-line {
    display: none;
  }

  .business-improvement-section .ellipse-indicator-container {
    position: relative;
    align-self: center;
    width: 100%;
    height: 1rem;
    padding: 0;
    margin: 0;
  }

  .business-improvement-section .ellipse-indicator-container::before {
    content: "";
    position: absolute;
    inset-inline: .5rem calc(-1 * var(--step-column-gap) - .5rem);
    height: 2px;
    background: #dcdcdc;
  }

  .business-improvement-section .step-card-item:last-child .ellipse-indicator-container::before {
    inset-inline-end: 0;
  }

  .business-improvement-section .ellipse-dot {
    position: relative;
    width: 1rem;
    height: 1rem;
  }

  .business-improvement-section .step-description-text {
    line-height: 1.45;
  }
}

@media (min-width: 1029px) {
  #zakazat-seo .promo-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 21.25rem);
    align-items: center;
    gap: clamp(1.5rem, 3vw, 3rem);
  }

  #zakazat-seo .promo-info-card {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
  }
}

@media (min-width: 721px) {
  #main-content .contact-engagement-form:has(noscript p) {
    height: auto;
  }

  #main-content .contact-engagement-form:has(noscript p) .form-container-wrapper {
    display: grid;
    gap: 2rem;
    padding-block: clamp(3rem, 6vw, 6rem);
  }

  #main-content .contact-engagement-form:has(noscript p) :is(.form-header-section, .form-fields-section) {
    position: relative;
    top: 0;
  }

  #contactEngagementForm noscript :is(p, a) {
    color: #fff;
  }
}

@media (min-width: 1616px) {
  #main-content :is(.niches-main-title, .business-improvement-section .main-title-h1, .team-main-heading) {
    line-height: 1.18;
  }
}

@media (min-width: 1029px), (scripting: none) {
  .team-section-wrapper .team-members-row {
    position: relative;
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 1028px) and (scripting: none) {
  #main-content .team-members-row {
    display: grid !important;
  }

  #main-content .team-members-row + .team-members-row {
    margin-block-start: 1rem;
  }

  #main-content .team-slider-controls {
    display: none;
  }
}
