@use '../base/variable';
@use '../base/token';
@use '../abstract';
@use '../sprite';

$gray-200: #eaecf0;

.cds-footer {
  // @include abstract.debug();
  @include abstract.relative();

  padding: 48px 16px;
  background-color: var(--gray-700);
  font-size: 1rem;
  line-height: 1.5;

  // link-gray override
  &__outlink .cds-link,
  .contact .link:last-of-type {
    color: var(--gray-300);
  }

  .cds-link {
    color: var(--gray-400);
  }

  .cds-link:hover:not(.disabled) {
    color: var(--base-white);
  }

  &__outlink {
    display: none;
  }

  &__logo {
    margin-bottom: 16px;
  }
}

.cds-contact {
  $gap: 10px;

  margin-left: -$gap;
  margin-bottom: 32px;
  color: var(--gray-400);
  font-weight: abstract.font-weight-to-number(token.$font-weights-commerce-sans-0);

  &__item {
    @include abstract.relative();

    display: inline-block;
    margin-left: $gap;

    &::after {
      display: inline-block;
      content: '';
      transform: translateY(2px);
      width: 2px;
      height: 1rem;
      margin-left: $gap;
      background-color: var(--gray-400);
    }

    &:last-child {
      color: var(--gray-300);
      &::after {
        content: none;
      }
    }

    &:first-child,
    &:last-child {
      font-weight: abstract.font-weight-to-number(token.$font-weights-commerce-sans-2);
    }

    a {
      font-size: 1rem;
    }
  }
}

.cds-mail-order-info {
  color: var(--gray-400);
  margin-block-end: 16px;
}

.cds-footer__inner {
  @include abstract.relative();
}

.cds-corp {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: auto;
  text-align: left;
  gap: 12px;
  margin-bottom: 48px;

  .cds-link {
    display: block;

    &:nth-child(2) {
      grid-row: 2;
      grid-column: 1;
      color: var(--gray-300);
      font-weight: abstract.font-weight-to-number(token.$font-weights-commerce-sans-2);
    }

    &:nth-child(3) {
      grid-row: 2;
      grid-column: 2;
    }

    &:nth-child(4) {
      @include abstract.absolute();
      clip: rect(0 0 0 0);
    }
  } // cds-link
}

.cds-footer .cds-nav-dropdown {
  display: inline-block;
}

.cds-footer .cds-menu-button,
.cds-footer .cds-menu-button:hover {
  color: var(--gray-300);
}

:where(.cds-footer:not(.cds-footer--simple)) .cds-nav-dropdown {
  display: block;
  margin-bottom: 48px;

  & > .cds-btn {
    width: 100%;
    justify-content: space-between;
  }

  &__content {
    z-index: 5;
    overflow-y: auto;
    width: 100%;
    height: 200px;
    -ms-overflow-style: none;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }
  }
} // dropdown :not(simple)

.cds-footer__global {
  display: none;
}

.cds-footer__marks {
  @include abstract.absolute($bottom: 40px, $right: 0);

  display: flex;
  gap: 20px;

  button {
    display: inline-flex;
    cursor: pointer;
  }

  span {
    @include abstract.bg2x-sprite();
    z-index: auto;
  }

  .mark-award {
    @include abstract.sprite2x(sprite.$mark-award-m);
  }
  .mark-large-sms {
    @include abstract.sprite2x(sprite.$mark-large-sms-m);
  }
  .mark-isms {
    @include abstract.sprite2x(sprite.$mark-isms-m);
  }
}

.cds-footer__bottom {
  @include abstract.relative();

  display: flex;
  flex-direction: column;
  padding-top: 32px;
  border-top: 1px solid var(--gray-500);
  color: var(--gray-400);
  font-weight: abstract.font-weight-to-number(token.$font-weights-commerce-sans-1);

  & > p {
    order: 2;
  }
}

.cds-footer__sns {
  order: 1;
  margin-bottom: 24px;

  .cds-sns:nth-child(n + 2) {
    margin-left: 24px;
  }
}

// ==================================================================
// pc
// ==================================================================
@include abstract.media-bp-up('ex') {
  .cds-footer {
    padding: 64px 112px 48px;

    &__content {
      max-width: variable.$max-width;
      margin-left: auto;
      margin-right: auto;
    }
  }

  .cds-footer__outlink {
    display: block;
    margin-bottom: 48px;
    font-size: abstract.rem(token.$font-size-1);

    & > div {
      display: flex;

      &:nth-child(n + 2) {
        margin-top: 35px;
      }

      dd {
        display: flex;
        gap: 24px;
      }
    }

    dt {
      margin-right: 16px;
      width: -webkit-max-content;
      width: -moz-max-content;
      width: max-content;
      min-width: 140px;
      color: var(--base-white);
    }
  }

  .cds-footer__logo {
    padding-top: 32px;
    border-top: 1px solid var(--gray-500);
  }

  .cds-contact {
    max-width: 708px;

    [href^='mailto'] {
      text-decoration: underline;
    }

    &__item {
      &:nth-child(2),
      &:nth-child(4),
      &:nth-child(6) {
        &::after {
          content: none;
        }
      }
    }
  } // contact

  .cds-corp {
    display: block;

    .cds-link {
      display: inline-block;

      &:nth-child(n + 2) {
        margin-left: 24px;
      }

      &:nth-child(4) {
        position: static;
        clip: auto;
      }
    }
  } // corp

  .cds-footer__inner {
    @include abstract.relative();
  }

  .cds-footer__marks {
    @include abstract.absolute($bottom: 0, $right: 0);

    gap: 24px;

    .mark-award {
      @include abstract.sprite2x(sprite.$mark-award);
    }
    .mark-large-sms {
      @include abstract.sprite2x(sprite.$mark-large-sms);
    }
    .mark-isms {
      @include abstract.sprite2x(sprite.$mark-isms);
    }
  }

  .cds-footer:not(.cds-footer--simple) .cds-nav-dropdown {
    @include abstract.absolute($top: 32px, $right: 0);
    z-index: 5;
  }

  .cds-footer .cds-header-nav__content {
    right: 0;
    transform: translateX(0);
    width: -webkit-max-content;
    width: -moz-max-content;
    width: max-content;
  }

  .cds-footer__bottom {
    flex-direction: row;
    justify-content: space-between;
    padding-top: 0;
    border-top-width: 0;

    & > p {
      order: 0;

      br {
        display: none;
      }
    }
  }

  .cds-footer__sns {
    margin-bottom: 0;
  }
}

// ============================================================
// g-footer--simple
// ============================================================
.cds-footer--simple {
  .cds-footer__outlink,
  .cds-footer__logo,
  .cds-contact,
  .cds-footer__sns,
  .cds-footer__marks {
    display: none;
  }

  .cds-corp {
    display: block;
    position: relative;
    padding-bottom: 48px;
    margin-bottom: 32px;

    &::after {
      position: absolute;
      bottom: 0;
      left: 0;
      content: '';
      width: 100%;
      height: 1px;
      background-color: var(--gray-500);
    }

    .cds-link:nth-child(n + 2) {
      margin-top: 12px;
    }
  } // corp

  .cds-header-nav {
    .cds-menu-button {
      color: var(--gray-300);
    }

    &__content {
      inset: auto auto calc(100% + 2px) 0;
      transform: translate(0);
    }
  } // dropdown

  .cds-footer__bottom {
    border-top-width: 0;
    padding-top: 18px;
  }

  @include abstract.media-bp-up('ex') {
    .cds-corp {
      text-align: center;

      .cds-link:nth-child(n + 2) {
        margin-top: 0;
      }
    }

    .cds-nav-dropdown {
      @include abstract.absolute($bottom: -55px, $right: 0);
      z-index: 5;

      &__content {
        inset: auto 0 calc(100% + 2px) auto;
      }
    }

    .cds-footer__bottom {
      padding-top: 0;
    }
  } // ex
}

// mark-large-sms 클릭시 노출 되는 모달 이미지
.cds-modal-authentication {
  padding: 0;
  border: 0;
  border-radius: 10px;
  background-color: #fff;

  header {
    padding: 20px 16px;
    border-block-end: 1px solid var(--gray-100);
  }

  img {
    vertical-align: top;
  }

  .cds-btn {
    @include abstract.absolute($top: 12px, $right: 12px);
  }

  &::backdrop {
    background-color: rgba(0 0 0 / 0.7);
  }
}

// ==============================
// btn-top
// ==============================
.cds-btn-top {
  $position: 16px;
  @include abstract.fixed($bottom: $position, $right: $position);

  padding: 0;
  background-color: var(--base-white);
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  z-index: 950;

  // sticky가 아닐 경우
  &.is-fixed {
    @include abstract.absolute($top: $position, $right: $position);
  }

  @include abstract.media-bp-up('md') {
    @at-root .cds-footer &.only-icon {
      width: calc(var(--button-height-md) + 8px);
      height: calc(var(--button-height-md) + 8px);
    }

    &.is-fixed {
      /* top: calc($position * -1); */
      top: calc((var(--button-height-xl) + $position) * -1);
    }
  }
}
