

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2100;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto; 
  }
  
  .modal-content {
    position: absolute;
    overflow-y: auto;  
    max-height: 80vh;    
    z-index: 2100; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(to bottom right, var(--panel-0), var(--panel-1)); 
    border-radius: 14px;
    padding: 30px 25px;
    width: 90%;
    max-width: 460px;
    text-align: center;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
    font-family: 'Georgia', 'Libre Baskerville', serif;
    animation: fadeInModal 0.4s ease-out;
    border: none;
  }
  
  .modal-header {
    font-size: 22px;
    font-weight: 600;
    font-family: 'Georgia', 'Libre Baskerville', serif;
    color: var(--ink);
    border-bottom: 2px solid var(--ink);
    padding-bottom: 6px;
    margin-bottom: 20px;
    display: inline-block;
    background: none;
    border-radius: 0;
    text-align: center;
  }
  
  .close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 20px;
    font-weight: bold;
    color: #777;
    cursor: pointer;
    transition: color 0.3s ease;
  }
  
  .close:hover,
  .close:focus {
    color: var(--ink);
    text-decoration: none;
  }
  
  @keyframes fadeInModal {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
  }

  @media (max-width: 600px) {
    .modal-content {
      width: 80%;
      padding: 24px 18px;
      font-size: 15px;
      max-height: 80vh
    }
  
    .modal-header {
      font-size: 20px;
    }
  
    .close {
      top: 10px;
      right: 12px;
      font-size: 18px;
    }
  }
/* Scope with the custom data-class */
.modal-header-swap[data-class="unique-header-123"] {
  --transition-speed: 0.4s;
  --bezier: cubic-bezier(0.19, 1, 0.22, 1);
  --br: 6px; /* Adjust this for more or less roundness */
  
  position: relative;
  display: inline-grid;
  padding: 8px 16px; /* Extra padding looks better with rounded corners */
  cursor: default;
  color: var(--ink);
  /* Remove the standard border; our ::before will be the border */
  border-bottom: none; 
}

/* The Underline that turns into the White Box */
.modal-header-swap[data-class="unique-header-123"]::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  
  /* INITIAL STATE: Looks like an underline */
  height: 2px; 
  background-color: var(--ink);
  border-radius: 0; /* Sharp for the underline */
  
  z-index: 1;
  /* Animate height, background, and radius for that "morphing" feel */
  transition: 
    height var(--transition-speed) var(--bezier),
    background-color var(--transition-speed) var(--bezier),
    border-radius var(--transition-speed) var(--bezier);
}

/* THE HOVER: The "Inflation" Effect */
.modal-header-swap[data-class="unique-header-123"]:hover::before {
  height: 100%; /* Fills the container */
  background-color: var(--ink); /* Turns white */
  border-radius: var(--br); /* Smooth rounded corners */
}

/* Grid Stacking for text remains the same */
.text-stack {
  display: inline-grid;
  grid-template-areas: "main";
  align-items: center;
  justify-items: center;
  position: relative;
  overflow: hidden; /* Clips the sliding text */
  z-index: 2; /* Ensures text is always above the expanding box */
}

.original, .replacement {
  grid-area: main;
  transition: transform var(--transition-speed) var(--bezier), 
              opacity var(--transition-speed) var(--bezier);
  white-space: nowrap;
}

/* Text Swapping Logic */
.replacement {
  transform: translateY(150%);
  opacity: 0;
  color: var(--bg-0);
  font-weight: 700;
}

.original {
  transform: translateY(0);
  opacity: 1;
}

.modal-header-swap:hover .original {
  transform: translateY(-150%);
  opacity: 0;
}

.modal-header-swap:hover .replacement {
  transform: translateY(0);
  opacity: 1;
}