/* =========================================================
   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.3s;
  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: translateY(-20px);
  transition: transform 0.3s;
}

.modal.open .modal-content {
  transform: translateY(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;
}

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

/* =============================
   NAME PRONUNCIATION BUTTON
============================= */

.name-sound-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0 2.8rem 0.9rem 0;
}

.name-sound-wrapper h2 {
  margin: 0;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  background: #fff;
  color: #101010;
  border: 2px solid #fff;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.sound-button > [aria-hidden="true"] {
  font-size: 1.25rem;
  line-height: 1;
}

.sound-button:hover:not(:disabled),
.sound-button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(255, 255, 255, 0.35);
}

.sound-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.sound-button.is-disabled,
.sound-button:disabled {
  opacity: 0.55;
  box-shadow: none;
  cursor: not-allowed;
}

.sound-button-label {
  line-height: 1;
  font-size: 0.72rem;
}

@media (max-width: 640px) {
  .name-sound-wrapper {
    margin-right: 2.2rem;
  }

  .sound-button {
    font-size: 0.76rem;
  }

  .sound-button-label {
    font-size: 0.7rem;
  }
}

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