/* Modal overlay and dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 35, 75, 0.85); /* Arizona Blue with transparency */
  display: grid;
  place-items: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
}
.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.modal-dialog {
  width: 80vw;
  height: 80vh;
  background: #FFFFFF; /* White - UA brand neutral */
  border: 1px solid #E2E9EB; /* Cool Gray - UA brand neutral */
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(12, 35, 75, 0.3); /* Arizona Blue shadow */
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85);
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
.modal-overlay.is-open .modal-dialog {
  transform: scale(1);
  opacity: 1;
}
.modal-close {
  position: absolute;
  top: 6px; right: 10px;
  font-size: 28px;
  line-height: 1;
  border: 0;
  background: transparent;
  color: #0C234B; /* Arizona Blue */
  cursor: pointer;
  padding: 6px 10px;
}
.modal-close:hover {
  color: #AB0520; /* Arizona Red for hover */
}
.modal-iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* Make main content fill the dialog height (PDF iframe, fallback message, or
   internal modal content). Close button is absolutely positioned above. */
.modal-dialog > .modal-iframe,
.modal-dialog > .modal-message,
.modal-dialog > .modal-content {
  flex: 1;
  min-height: 0;
}

/* Ensure hidden overlay is not rendered */
.modal-overlay[hidden] { 
  display: none !important; 
  opacity: 0 !important;
  pointer-events: none;
}

/* Fallback message when a site blocks iframe embedding */
.modal-message {
  display: grid;
  gap: 12px;
  align-content: center;
  justify-items: center;
  padding: 16px;
  color: #0C234B; /* Arizona Blue */
  background: transparent; /* dialog provides the panel bg */
}
.modal-message p {
  margin: 0;
  text-align: center;
  font-size: clamp(16px, 1.2vw, 18px);
  line-height: 1.4;
  opacity: 0.9;
}

/* Action buttons inside the modal message */
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.modal-actions .tile-button {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 16px;
}

/* Accessibility focus for close button */
.modal-close:focus-visible {
  outline: 3px solid #0C234B; /* Arizona Blue */
  outline-offset: 2px;
  border-radius: 6px;
}

/* Responsive dialog size tweaks for small displays */
@media (max-width: 900px), (max-height: 700px) {
  .modal-dialog { width: 96vw; height: 92vh; }
}

/* Person modal layout: photo left, text right; back button only when from modal */
.modal-person-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.modal-person-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(16px, 2.5vw, 24px);
  align-items: start;
  min-height: 0;
  flex: 1;
}
.modal-person-main:not(:has(img)) {
  grid-template-columns: 1fr;
}
.modal-person-image {
  flex-shrink: 0;
}
.modal-person-photo {
  width: 100%;
  max-width: 180px;
  min-width: 120px;
  height: auto;
  border-radius: 12px;
  display: block;
  object-fit: cover;
}
.modal-person-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-person-body {
  overflow: visible;
  padding: 0;
}
/* Person modal: whole content scrolls, not text alone */
.modal-content:has(.modal-person-layout) {
  overflow: auto;
}

/* Internal content modal (used for node:ID links) */
.modal-content {
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: clamp(14px, 2vw, 22px);
  overflow: hidden; /* body scrolls, header sticks */
  transition: opacity 0.22s ease-out;
}
.modal-content.modal-content-fade {
  opacity: 0;
}
.modal-content-inner { min-height: 0; display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; }
/* Person modal with Back: back button above main content */
.modal-content-inner.modal-person-with-back {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-content-inner.modal-person-with-back .modal-back-button {
  margin-bottom: 0;
}
.modal-title { font-size: clamp(20px, 2.2vw, 28px); margin: 0; color: #0C234B; /* Arizona Blue */ }
.modal-meta { color: #001C48; /* Midnight - UA brand complementary */ font-size: 0.95em; opacity: 0.85; }
.modal-body { overflow: auto; padding: 14px 0; line-height: 1.7; color: #0C234B; /* Arizona Blue */ }
.modal-body p { margin: 0.6em 0; }
.modal-body a { color: #AB0520; /* Arizona Red */ }
.modal-body a:hover { color: #EF4056; /* Bloom - UA highlight color */ }

/* Person links in modal: Azurite for contrast on white background */
.modal-body a[data-person-id],
.modal-body a[href^="person:"] {
  color: #1E5288; /* Azurite - UA brand */
  padding: 4px 6px;
  margin: 0 5px;
  border-radius: 6px;
  background: rgba(30, 82, 136, 0.1);
}
.modal-body a[data-person-id]:hover,
.modal-body a[href^="person:"]:hover {
  background: rgba(30, 82, 136, 0.18);
  color: #2a6ab5;
}
.modal-body a[data-person-id]:active,
.modal-body a[href^="person:"]:active {
  background: rgba(30, 82, 136, 0.25);
}
.modal-body img, .modal-body video { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 0.5em auto; }

/* Back button (when viewing person from card/node modal) */
.modal-back-button {
  display: inline-block;
  margin-bottom: 12px;
  padding: 10px 16px;
  background: transparent;
  color: #0C234B;
  border: 2px solid #0C234B;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  align-self: start;
}
.modal-back-button:hover {
  background: #0C234B;
  color: #FFFFFF;
}
.modal-back-button:active {
  transform: scale(0.98);
}
.modal-back-button:focus-visible {
  outline: 3px solid #0C234B;
  outline-offset: 2px;
}

/* Navigation button at bottom of modal */
.modal-nav-button {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 24px;
  background: #AB0520; /* Arizona Red */
  color: #FFFFFF; /* White */
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  transition: background 0.2s ease, transform 0.1s ease;
  align-self: center;
  justify-self: center;
}
.modal-nav-button:hover {
  background: #8B0015; /* Chili - UA complementary red */
  transform: translateY(-1px);
}
.modal-nav-button:active {
  background: #EF4056; /* Bloom - UA highlight */
  transform: translateY(0);
}

/* Hide the iframe/message when showing internal content; JS toggles hidden attrs as needed */
.modal-iframe[hidden], .modal-message[hidden] { display: none !important; }