/* =========================
   Modals
========================= */

@use "../kit-deps" as *;

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: $space-4;

  &.a-show .modal-backdrop {
    opacity: 1;
  }
  &.a-show .modal-dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  &.a-hide .modal-backdrop {
    opacity: 0;
  }
  &.a-hide .modal-dialog {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }

  .modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba($neutral-900, 0.48);
    opacity: 0;
    transition: opacity $motion-base $motion-ease;
  }

  .modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - #{$space-8});
    display: flex;
    flex-direction: column;
    background-color: $neutral-0;
    border-radius: $radius-2xl;
    box-shadow: 0 24px 64px rgba($neutral-900, 0.24);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    transition:
      opacity $motion-base $motion-ease,
      transform $motion-base $motion-ease;
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: $space-3;
    padding: $space-4 $space-5;
    border-bottom: 1px solid $neutral-100;
  }

  .modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: $font-weight-bold;
    color: $neutral-900;
  }

  .modal-close {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: $radius-full;
    background-color: transparent;
    color: $neutral-700;
    cursor: pointer;
    transition: background-color $motion-base $motion-ease, color $motion-base $motion-ease;

    &:hover {
      background-color: $neutral-100;
      color: $neutral-900;
    }

    &:focus-visible {
      @include focus_ring;
    }
  }

  .modal-panel {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .modal-body {
    padding: $space-5;
    font-size: 15px;
    line-height: 1.5;
    color: $neutral-800;
  }

  .modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: $space-3;
    padding: $space-3 $space-5;
    border-top: 1px solid $neutral-100;
    background-color: $neutral-50;
  }
}
