@use "../base/mixins" as *;
@use "../base/variables" as *;
@use "../base/typography" as *;

.modal {
  @include flexCenter();

  position: fixed;
  inset: 0;
  z-index: 110;
  padding: 0 1.6rem;
  background-color: rgba(#111, 0.7);

  &:has(.modal__jackpot) {
    [class*="btn-"] {
      height: 4.2rem !important;
    }
  }

  &:has(.modal__content.modal__type--d) {
    background-color: rgba(#000, 0.6);
  }

  &__content {
    position: relative;
    background-color: theme-color($modal-bg);
    border-radius: 1.2rem;
    border: 1px solid theme-color($border-low);

    [data-theme="light"] & {
      border: none;
    }

    &.modal__type--a {
      width: 48rem;

      @include media("lg") {
        width: 32.8rem;
      }
    }

    &.modal__type--b {
      width: 92rem;
    }

    &.modal__type--c {
      width: 64rem;
    }

    &-header {
      @include flexCenter(space-between);

      padding: 0 1.6rem;
      height: 5.8rem;
      border-bottom: 1px solid theme-color($border-low);

      @include media("lg") {
        height: 5rem;
        padding: 0 1.2rem;
      }
    }

    &-title {
      @include typography("h3");

      font-weight: 600;
      color: theme-color($text-high);
    }

    &-close {
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      width: 3.2rem;
      height: 3.2rem;
    }

    &-top {
      padding: 0.8rem 1.6rem;
      background-color: theme-color($modal-surface);

      @include media("lg") {
        padding: 0.8rem 1.2rem;
      }

      p {
        @include typography("p2");

        color: theme-color($text-high);
        font-weight: 500;

        strong {
          font-weight: 700;
        }

        .point-yellow {
          color: theme-color($text-yellow);
        }

        .point-primary {
          color: theme-color($primary);
        }

        & + & {
          margin-top: 0.2rem;
        }
      }
    }

    &-body {
      @include scrollbar(0.4rem);

      overflow-y: auto;
      padding: 2rem 1.6rem;
      max-height: calc(100dvh - 11.7rem);

      @include media("lg") {
        padding: 1.6rem 1.2rem;
      }

      &:has(+ .modal__content-footer) {
        padding-bottom: 2.4rem;

        @include media("lg") {
          padding-bottom: 2rem;
        }
      }

      &:has(.modal__edit-profile) {
        padding: 0;
      }

      &--login {
        padding: 6rem;

        @include media("lg") {
          padding: 4rem 1.6rem;
        }
      }
    }

    &-footer {
      padding: 0 1.6rem 2rem;
      gap: 0.8rem;

      @include media("lg") {
        padding: 0 1.2rem 2rem;
      }

      &--start {
        @include flexCenter(flex-start);
      }

      &--end {
        @include flexCenter(flex-end);
      }

      &--between {
        @include flexCenter(space-between);
      }
    }
  }
}

.modal__jackpot {
  &-title {
    @include flexCenter(flex-start);
    gap: 0.2rem;

    strong {
      color: theme-color($text-high);
      font-weight: 700;
    }

    span {
      @include typography("p2");

      translate: 0 0.2rem;
      color: theme-color($text-low);
    }

    &-question {
      align-self: center;
      border: none;
    }
  }

  &-body {
    margin-top: 0.4rem;
  }

  &-rank {
    display: flex;
    align-items: center;
    gap: 0.4rem;

    &--up {
      strong {
        color: theme-color($primary);
      }
    }

    &--down {
      strong {
        color: theme-color($secondary);
      }
    }

    strong {
      @include typography("h1");

      font-weight: 700;

      @include media("lg") {
        font-size: 2.4rem;
        line-height: 4.8rem;
      }
    }

    .badge {
      @include typography("p2");

      padding: 0 0.8rem;
      height: 2.8rem;
      font-weight: 400;

      @include media("lg") {
        height: 2.6rem;
      }

      &-chart {
        padding: 0;
        width: 2.8rem;
        border-radius: 10rem;

        @include media("lg") {
          width: 2.6rem;
        }
      }
    }
  }

  &-thumb {
    position: absolute;
    right: 1.6rem;
    bottom: 2rem;
    width: 16.9rem;
    height: 10.7rem;

    @include media("lg") {
      right: 1.2rem;
      bottom: 7.2rem;
      width: 10.3rem;
      height: 7.6rem;
    }

    img {
      @include img-fit(contain);
    }

    [lang="en"] & {
      right: 1.2rem;
      bottom: 7.2rem;
      width: 10.3rem;
      height: 7.6rem;

      @include media("lg") {
        right: 1.2rem;
        bottom: 7.2rem;
        width: 7.3rem;
        height: 4.6rem;
      }
    }
  }

  &-table-wrap {
    overflow: hidden;
    border-radius: 0.6rem;
  }

  &-table {
    width: 100%;
    table-layout: auto;

    &-caption {
      margin-bottom: 0.8rem;
      color: theme-color($text-high);

      p {
        @include flexCenter(flex-start);
        gap: 0.4rem;
      }

      strong {
        color: theme-color($primary);
        font-weight: 700;
      }
    }
    thead {
      tr {
        border-bottom: 1px solid theme-color($table-th-border);
      }
    }
    tbody {
      tr {
        border-bottom: 1px solid theme-color($table-tb-border);
      }
    }

    &-th {
      padding: 1.5rem 1.6rem;
      color: theme-color($text-low);
      font-weight: 500;
      background-color: theme-color($table-th-bg);

      @include media("lg") {
        padding: 1.4rem 0.8rem;
      }

      &:first-child {
        border-top-left-radius: 0.6rem;
      }

      &:last-child {
        border-top-right-radius: 0.6rem;
      }
    }

    &-td {
      padding: 1.1rem 1.2rem;
      font-weight: 600;
      color: theme-color($text-high);
      background-color: theme-color($table-tb-bg);

      @include media("lg") {
        padding: 1rem 0.8rem;
      }

      &--primary {
        color: theme-color($primary);
      }

      &:first-child {
        white-space: nowrap;
      }
    }
  }
  &-bonus-list {
    padding: 1.2rem 1.6rem;
    border-radius: 0.4rem;
    background-color: theme-color($modal-note);

    @include media("lg") {
      padding: 0.8rem 1.2rem;
    }
  }
  &-bonus-item {
    @include flexCenter(flex-start);

    gap: 0.4rem;
    color: theme-color($text-high);

    &:has(&--primary) {
      &::before {
        background-color: theme-color($primary);
      }
    }

    &::before {
      content: "";
      flex-shrink: 0;
      width: 0.3rem;
      height: 0.3rem;
      border-radius: 50%;
      background-color: theme-color($text-high);
    }

    &--primary {
      color: theme-color($primary);
    }

    & + & {
      margin-top: 0.2rem;
    }
  }

  &-bonus-note {
    margin-top: 0.8rem;
    color: theme-color($text-low);

    @include media("lg") {
      margin-top: 0.4rem;
    }

    strong {
      font-weight: 700;
      color: theme-color($text-high);
    }
  }

  &-alert {
    & + & {
      margin-top: 2rem;
    }
    &-title {
      display: block;
      font-weight: 700;
      color: theme-color($text-high);
    }
    &-desc {
      margin-top: 0.4rem;
      padding: 1.2rem 1.6rem;
      border-radius: 0.4rem;
      background-color: theme-color($modal-note);

      @include media("lg") {
        padding: 0.8rem 1.2rem;
      }

      p {
        @include typography("p2");

        color: theme-color($text-high);

        & + & {
          margin-top: 0.4rem;
        }
      }
    }
  }
}

.modal__edit-profile {
  &-crop {
    width: 100%;
    height: 25.6rem;

    [data-theme="dark"] & {
      background-color: theme-color($invert-container);
    }

    [data-theme="light"] & {
      background-color: #f7f8fa;
    }

    @include media("lg") {
      height: 16rem;
    }

    &-label {
      @include flexCenter();

      position: absolute;
      right: 0.8rem;
      bottom: 0.8rem;
      width: 4.6rem;
      height: 4.6rem;
      background-color: #111;
      box-shadow: 0 8px 20px rgba(#000, 0.16);
      border-radius: 50%;

      @include media("lg") {
        right: 0.7rem;
        bottom: 0.7rem;
        width: 3.5rem;
        height: 3.5rem;
      }

      &::before {
        --ico-size: 2.8rem;
      }
    }
  }

  &-thumb {
    width: 25.6rem;
    height: 100%;
    margin: 0 auto;
    position: relative;

    @include media("lg") {
      width: 16rem;
    }

    img {
      @include img-fit();
    }
  }

  &-avatar {
    padding: 2rem 1.6rem;

    @include media("lg") {
      padding: 1.6rem 1.2rem;
    }

    &-title {
      display: block;
      margin-bottom: 0.8rem;
      font-weight: 600;
      color: theme-color($text-high);
    }

    &-list {
      @include flexCenter(flex-start);
      gap: 1rem;
    }

    &-item {
      position: relative;
      aspect-ratio: 1;

      &--active {
        &::before {
          content: "";
          position: absolute;
          inset: 0;
          border-radius: 0.8rem;
          border: 2px solid theme-color($primary);
          pointer-events: none;
        }
      }

      img {
        @include img-fit();
      }
    }
  }
}

.modal__content-guide {
  overflow-x: hidden;
  padding-bottom: 1.6rem;

  &-item {
    & + & {
      @include media("lg") {
        margin-top: 4rem;
      }
    }

    img {
      @include media("lg") {
        max-width: 100%;
      }
    }
  }

  &-title {
    @include typography("h3");

    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    margin-bottom: 1.2rem;
    color: theme-color($text-high);
    font-weight: 700;
  }
  &-desc {
    text-align: center;

    &--flex {
      @include flexCenter(flex-start);
      gap: 2.4rem;

      @include media("lg") {
        flex-direction: column;
        gap: 1.2rem;

        br {
          display: none;
        }
      }
    }

    &-item {
      flex: 1;
      text-align: left;

      @include media("lg") {
        width: 100%;
      }

      p {
        @include typography("p2");

        margin-top: 0.8rem;

        @include media("lg") {
          @include typography("p1");
        }
      }
    }

    &-thumb {
      @include flexCenter();

      padding: 1.6rem;
      height: 16.8rem;
      border-radius: 0.8rem;
      background-color: #2c2c2c;
    }
  }
  &-thumb-wrap {
    @include flexCenter(flex-start);

    gap: 0.4rem;

    @include media("lg") {
      flex-direction: column;
      gap: 0.8rem;
    }
  }

  &-img-fit {
    @include img-fit(contain);
  }

  &-pagination {
    @include typography("h3");

    font-weight: 700;
  }

  &-nav {
    @include flexCenter();
    gap: 0.8rem;

    [class*="btn-"] {
      min-width: 12rem;
      color: theme-color($text-high);

      &.disabled {
        [data-theme="dark"] & {
          background-color: theme-color($invert-container);
          color: #414141;
        }
        [data-theme="light"] & {
          background-color: #e1e1e8;
          color: #999;
        }
      }
    }
  }
}
