@use '../abstracts' as *;

$font-footer-disclaimer: 'Roboto Condensed', sans-serif;

// Подвал сайта (Figma: Dr Smile footer, узлы 124:1955 … 124:3141)
.site-footer {
  background: $color-dark-blue;
  color: $color-white;
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 80px 0;
  border-radius: $radius-md $radius-md 0 0;

  @include between($bp-md, $until-991) {
    gap: 17px;
  }

  // Макет 576: компактный внешний контур подвала
  @include viewport-mobile {
    padding: 30px 0;
    gap: 30px;
  }

  @include sm {
    padding: 80px 0;
  }

  @media (max-width: #{$bp-xs}) {
    padding: 60px 0;
    border-radius: unset;
  }
}

.site-footer__main {
  padding: 0;
}

.site-footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 282px) minmax(0, 1fr);
  gap: 30px;
  align-items: start;

  @include between($bp-lg, $until-1919) {
    grid-template-columns: minmax(0, 255px) minmax(0, 1fr);
  }

  @include between($bp-md2, $until-1439) {
    grid-template-columns: minmax(0, 205px) minmax(0, 1fr);
  }

  @include md2 {
    grid-template-columns: minmax(0, 255px) minmax(0, 1fr);
  }

  // 768–991: Figma footer 124:2840 — колонка на всю ширину (лого + блок контактов, затем нав 4 колонки)
  @include between($bp-md, $until-991) {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }

  @include md {
    grid-template-columns: 1fr 1fr;
    gap: 30px;
  }

  @include sm {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

.site-footer__info {
  display: flex;
  flex-direction: column;
  gap: 30px;

  // 768–991: лого по центру; 329+30+329 (Frame 115). Контакты — по высоте блока справа (span строк), без «дыры» слева под кнопкой
  @include between($bp-md, $until-991) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 30px;
    row-gap: 30px;
    align-items: start;

    .site-footer__logo {
      grid-column: 1 / -1;
      justify-self: center;
      margin-inline: 0;
    }

    .site-footer__logo img {
      width: 321px;
      max-width: 321px;
    }

    .site-footer__contact-wrap {
      grid-column: 1;
      grid-row: 2 / span 3;
      align-self: start;
      align-items: stretch;
    }

    .site-footer__rating {
      grid-column: 2;
      grid-row: 2;
      align-self: start;
      margin-inline: 0;
    }

    .site-footer__social {
      grid-column: 2;
      grid-row: 3;
      align-self: start;
      justify-content: flex-start;
      flex-wrap: nowrap;
      gap: 15px;
    }

    .site-footer__license {
      grid-column: 2;
      grid-row: 4;
      align-self: start;
      max-width: 100%;
      text-align: left;
      /* Frame 146: 26px между соцсетями и лицензией при row-gap 30 между рейтингом и соцсетями */
      margin-top: -4px;
    }
  }

  @include md {
    grid-column: 1 / -1;
    align-items: center;
    text-align: center;
  }

  // 576–767: макет footer (124:2992/2994) — рейтинг и соцсети в одной строке
  @include viewport-mobile {
    display: grid;
    grid-template-columns: minmax(0, 248px) minmax(0, 1fr);
    column-gap: 16px;
    row-gap: 20px;
    align-items: start;

    .site-footer__logo,
    .site-footer__contact-wrap,
    .site-footer__license {
      grid-column: 1 / -1;
    }

    .site-footer__rating {
      grid-column: 1;
      margin-inline: 0;
      max-width: 248px;
      width: 248px;
      align-self: center;
    }

    .site-footer__social {
      grid-column: 2;
      align-self: center;
      justify-content: flex-start;
      flex-wrap: nowrap;
      gap: 12px;
    }

    .site-footer__license {
      margin-top: 0;
      max-width: none;
    }
  }

  // ≤576: после viewport-mobile, чтобы перебить row-gap: 20px на границе 576px
  @include sm {
    align-items: stretch;
    text-align: left;
    row-gap: 30px;

    .site-footer__social {
      gap: 15px;
      margin-left: 5px;
    }

    // На мобильном уменьшаем только отступ до лицензии (соцсети -> лицензия): 20px вместо общего row-gap 30px
    .site-footer__license {
      margin-top: -10px;
    }
  }

  @media (max-width: #{$bp-xs}) {
    .site-footer__social {
      margin-top: -12px;
      margin-left: 0;
    }
  }
}

// Группа адрес + телефон + кнопка записи (макет Figma, внутри site-footer__info)
.site-footer__contact-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  align-self: stretch;

  @include md {
    align-items: center;
  }

  @include sm {
    align-items: stretch;
  }
}

.site-footer__logo {
  display: block;
  line-height: 0;
  flex-shrink: 0;

  img {
    width: 100%;
    max-width: 282px;
    height: auto;
    display: block;
  }

  @include between($bp-lg, $until-1919) {
    img {
      max-width: 255px;
    }
  }

  @include md {
    margin-inline: auto;
  }

  @include sm {
    margin-inline: 0;

    img {
      margin-inline: auto;
    }
  }

  // Макет 576: логотип 329×146 (aspect-ratio 160/71)
  @include viewport-mobile {
    img {
      max-width: 329px;
      width: 329px;
      height: 146px;
      aspect-ratio: 160 / 71;
    }
  }

  @media (max-width: #{$bp-xs}) {
    img {
      max-width: 320px;
    }
  }
}

.site-footer__address {
  font-style: normal;
  text-align: left;

  @include md {
    text-align: center;
  }

  @include sm {
    text-align: left;
  }

  .site-footer__city {
    display: block;
    color: $color-blue;
    font-size: 11px;
    font-weight: 400;
    line-height: 1;
    margin-bottom: 3px;

    @include between($bp-md, $until-991) {
      margin-bottom: 8px;
    }

    @include between($bp-lg, $until-1919) {
      margin-bottom: 8px;
    }
  }

  ul {
    list-style: disc;
    padding-left: 8px;
    margin: 0;
    text-align: left;

    li {
      color: $color-white;
      font-size: 14px;
      line-height: normal;

      @include between($bp-md2, $until-1439) {
        line-height: 1.3;
      }

      @include sm {
        line-height: 1.4;
      }
    }
  }
}

.site-footer__phone-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  line-height: normal;

  @include md {
    align-items: center;
  }

  @include sm {
    align-items: flex-start;
  }
}

.site-footer__phone {
  display: block;
  color: $color-white;
  font-size: 17px;
  font-weight: 600;
  line-height: normal;
  text-decoration: none;
  white-space: nowrap;

  &:hover {
    opacity: 0.85;
  }

  @include between($bp-md2, $until-1439) {
    line-height: 1;
  }

  @include between($bp-md, $until-991) {
    line-height: 1;
  }

  @include sm {
    line-height: 1;
  }
}

.site-footer__hours {
  margin: 0;
  font-size: 11px;
  font-weight: 400;
  color: $color-blue;
}

.site-footer__cta {
  align-self: stretch;
  width: 100%;
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
}

// Виджет рейтинга: рамка, белая плашка слева (Figma)
.site-footer__rating {
  width: 100%;
  max-width: 190px;

  @include md {
    margin-inline: auto;
  }

  @include sm {
    margin-inline: 0;
    max-width: 248px;
  }
}

.site-footer__rating-badge {
  display: flex;
  align-items: stretch;
  border: 1px solid $color-white;
  border-radius: $radius-sm;
  overflow: hidden;
  min-height: 100%;
}

.site-footer__rating-scorebox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: $color-white;
  border-radius: $radius-sm;
}

.site-footer__rating-value {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: $color-dark-blue;
  line-height: 1;
  white-space: nowrap;
}

.site-footer__rating-frac {
  letter-spacing: 0.2px;
}

.site-footer__rating-reviews {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 400;
  color: $color-white;
  line-height: normal;
  white-space: nowrap;
}

.site-footer__social {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;

  @include between($bp-md2, $until-1439) {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0;
  }

  @include md {
    justify-content: center;
  }

  @include sm {
    justify-content: flex-start;
  }
}

.site-footer__social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: $color-white;
  transition: opacity 0.2s;

  img {
    width: 24px;
    height: 24px;
    display: block;
    object-fit: contain;
  }

  &:hover {
    opacity: 0.85;
  }
}

.site-footer__license {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  color: rgba($color-white, 0.5);
  max-width: 282px;

  @include md {
    max-width: none;
    text-align: center;
  }

  @include sm {
    text-align: left;
  }
}

.site-footer__nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 30px;

  @include between($bp-md2, $until-1439) {
    gap: 30px;
  }

  // 768–991: четыре колонки навигации на полную ширину контейнера (Frame 36, 124:2840)
  @include between($bp-md, $until-991) {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 30px;
  }

  @include md {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px 20px;
  }

  @include sm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  // 576–767: в макете 4 колонки навигации в ряд
  @include viewport-mobile {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 30px;
  }

  @include xs {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  @media (max-width: #{$bp-xs}) {
    gap: 33px 20px;
  }
}

.site-footer__nav-title {
  font-size: 14px;
  font-weight: 400;
  color: $color-blue;
  margin: 0 0 18px;
  line-height: normal;

  @include between($bp-md, $until-991) {
    margin: 0 0 20px;
  }

  @include between($bp-lg, $until-1919) {
    margin: 0 0 22px;
  }
}

.site-footer__nav-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;

  @include between($bp-md, $until-991) {
    gap: 11px;
  }

  // Макет 576: вертикальный ритм пунктов по 15px
  @include viewport-mobile {
    gap: 15px;
  }

  li {
    line-height: 1;

    @include between($bp-md, $until-991) {
      line-height: 1.25;
    }

    @include viewport-mobile {
      line-height: 1;
    }
  }

  a {
    color: $color-white;
    font-size: 14px;
    text-decoration: none;
    transition: opacity 0.2s;

    &:hover {
      opacity: 0.85;
    }
  }
}

.site-footer__bottom {
  padding: 0;
  border: none;
}

.site-footer__bottom .container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.site-footer__legal-pre {
  display: flex;
  gap: 30px;
  font-size: 12px;
  font-weight: 400;
  line-height: normal;
  color: $color-white;

  p {
    margin: 0;
    flex: 1 1 0;
    min-width: 0;
  }

  @include md {
    flex-direction: column;
    gap: 10px;
  }
}

.site-footer__disclaimer {
  margin: 0;
  font-family: $font-footer-disclaimer;
  font-size: 36px;
  font-weight: 300;
  line-height: normal;
  color: $color-white;
  text-transform: uppercase;

  @include between($bp-lg, $until-1919) {
    font-size: 33px;
  }

  @include lg {
    font-size: 33px;
  }

  // 768–991: блок предупреждения (124:2920): 688×78, межстрочный как в макете
  @include between($bp-md, $until-991) {
    font-size: 33px;
    line-height: 1.15;
    letter-spacing: 0.01em;
    text-align: center;
  }

  @media (max-width: #{$bp-xs}) {
    font-size: 23px;
    text-align: center;
  }
}

.site-footer__policy-links {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 12px;

  // 992–1439: ряд из 5 равных колонок как Figma Frame 39 (124:2631), ~182.4px при ширине 912px
  @include between($bp-md2, $until-1439) {
    flex-wrap: nowrap;
    gap: 0;
    justify-content: flex-start;
  }

  @include between($bp-lg, $until-1919) {
    gap: 10px 6px;
  }
  font-size: 12px;
  line-height: normal;

  a {
    color: rgba($color-white, 0.5);
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;

    &:hover {
      color: rgba($color-white, 0.85);
    }

    @include between($bp-md2, $until-1439) {
      flex: 1 1 0;
      min-width: 0;
      white-space: normal;
      text-align: center;
    }
  }

  // 768–991: Frame 39 (124:2921) — вертикальный список по центру, шаг 10px, 12px / line-height 14
  @include between($bp-md, $until-991) {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;

    a {
      flex: none;
      display: block;
      line-height: 14px;
      white-space: nowrap;
      text-align: center;
    }
  }

  @include md {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    white-space: normal;

    a {
      white-space: normal;
      text-align: center;
    }
  }
}

.site-footer__copyright {
  margin: 0;
  font-size: 10px;
  font-weight: 400;
  line-height: normal;
  text-align: center;
  color: $color-white;

  @media (max-width: #{$bp-xs}) {
    margin-top: -4px;
  }
}
