/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 5rem 1rem 1rem 1rem;
  
  background-color: rgba(17, 17, 27, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  
  overflow-y: auto;
}

/* Modal Container */
.modal-container {
  position: relative;
  width: 100%;
  max-width: 36rem;
  margin: 1.25rem auto;

  display: flex;
  flex-direction: column;
  max-height: calc(90vh - 5rem); 
  overflow: hidden;
  
  background-color: var(--ctp-base);
  border: 1px solid var(--ctp-surface0);
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3),
              0 10px 10px -5px rgba(0, 0, 0, 0.2);
  
  animation: modal-popup 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  z-index: 50;
}

/* Modal Content */
#modal-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Modal Popup Animation */
@keyframes modal-popup {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Close Button */
.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  width: 2rem;
  height: 2rem;
  padding: 0;
  
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.modal-close-btn:hover {
  background-color: var(--ctp-surface0);
}

.modal-close-btn svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  stroke: var(--ctp-red);
  transition: stroke 0.2s ease, transform 0.2s ease;
}

.modal-close-btn:hover svg {
  stroke: var(--ctp-darkred);
  transform: scale(1.1);
}

/* Modal Header */
.modal-header {
  width: 100%;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ctp-text);
  line-height: 1.3;
}

/* Responsive Adjustments */
@media (max-width: 639px) {
  .modal-backdrop {
    padding: 1rem;
    align-items: center;
  }

  .modal-container {
    max-width: 100%;
    border-radius: 0.75rem;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .modal-close-btn {
    top: 0.75rem;
    right: 0.75rem;
    width: 1.75rem;
    height: 1.75rem;
  }

  .modal-close-btn svg {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* Tablet landscape and up */
@media (min-width: 768px) {
  .modal-backdrop {
    padding: 5rem 2rem 2rem 2rem;
  }

  .modal-title {
    font-size: 1.5rem;
  }
}

/* Prevent body scroll when modal is open */
body:has(.modal-backdrop) {
  overflow: hidden;
}