/* =========================================================
   MODAL
   Shared character modal layout, close button layering,
   slideshow spacing, and pronunciation button styling.
   ========================================================= */

/* =========================================================
   STACKING NOTE
   The close button must stay above the image, slideshow
   controls, and any injected credit text inside the modal.
   ========================================================= */

#modal {
  position: fixed;
  z-index: 1000;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--modal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease-out;
  z-index: 9999;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  position: relative;
  z-index: 1001;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 8px;
  transform: translate3d(0, -8px, 0);
  transition: transform 0.14s ease-out;
  will-change: transform;
}

.modal.open .modal-content {
  transform: translate3d(0, 0, 0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 9999 !important;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: darkred;
  border: none;
  font-size: 2.5rem;
  color: white;
  cursor: pointer;
}

/* ========================================
   CHARACTER CREDIT SPACING
======================================== */

.modal-content .character-credit {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

.character-credit {
  color: #888;
  font-size: 0.9em;
  text-align: center;
}

.modal-content .character-meta p {
  margin: 0.5rem 0;
  line-height: 1.5;
}

.modal-content #m-bio p {
  margin: 1rem 0;
}

.slideshow-controls,
.character-credit,
.modal-content * {
  z-index: auto;
}

/* Character art submission styles live in css/character-art-submit.css. */

/* Character modal header, badges, and sound button styles live in css/character-modal-header.css. */

.modal-content img {
  width: 100%;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.modal-atlas-link {
  color: rgb(var(--modal-atlas-link-rgb, 143, 207, 255));
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(var(--modal-atlas-link-rgb, 143, 207, 255), 0.72);
  text-underline-offset: 0.16em;
  text-shadow: 0 0 18px rgba(var(--modal-atlas-link-rgb, 143, 207, 255), 0.14);
  transition:
    color 0.22s ease,
    text-shadow 0.22s ease,
    text-decoration-color 0.22s ease;
}

.modal-atlas-link:hover,
.modal-atlas-link:focus-visible {
  color: rgb(var(--modal-atlas-link-hover-rgb, 202, 232, 255));
  text-decoration-color: rgba(var(--modal-atlas-link-hover-rgb, 202, 232, 255), 0.95);
  text-shadow: 0 0 22px rgba(var(--modal-atlas-link-rgb, 143, 207, 255), 0.24);
}

.modal-atlas-link:focus-visible {
  outline: 2px solid rgba(202, 232, 255, 0.9);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (max-width: 1024px) {
  .modal {
    width: 100vw;
    height: 100dvh;
    padding: 0.75rem;
    overflow-x: hidden;
  }

  .modal-content {
    width: 100%;
    max-width: 680px;
    max-height: calc(100dvh - 1.5rem);
    border-radius: 12px;
    padding: 1rem 0.95rem 1.1rem;
  }

  .modal-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 42px;
    height: 42px;
    font-size: 2rem;
  }

  .slideshow-controls button {
    min-width: 44px;
    min-height: 44px;
  }
}
