/* fullscreen overlay */
body[data-modal="active"]::after {
  content: '';
  position: fixed;
  z-index: 1;
  top: 0; right: 0; bottom: 0; left: 0;
  background-color: rgba(0, 0, 0, 0.75);
}

body[modal-multiple="true"]::after {
  z-index: 9;
}

.modal {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  -webkit-transform: translateX(-50%) translateY(-50%);
          transform: translateX(-50%) translateY(-50%);
  width: calc(100% - 1rem);
  max-width: 30rem;
  max-height: calc(100vh - 1rem);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  background-color: #fff;
  -webkit-animation-name: scale-up;
          animation-name: scale-up;
  -webkit-animation-duration: 0.2s;
          animation-duration: 0.2s;
  -webkit-animation-timing-function: ease-in;
          animation-timing-function: ease-in;
  -webkit-animation-fill-mode: both;
          animation-fill-mode: both;
  /* delay needed for mobile (positioning) */
  -webkit-animation-delay: 0.1s;
          animation-delay: 0.1s;
}

.modal p a {
  /* force all links in paragraphs inside modals to wrap */
  overflow-wrap: break-word;
  word-wrap: break-word;
  /* match styling of content links */
  padding: 0 0.25rem 0.125rem;
  margin: 0 -0.25rem -0.125rem;
  color: #3d9fc1;
  background-color: transparent;
}
.modal p a:hover {
  background-color: rgba(61, 159, 193, 0.1875);
}

/* photo modals */
.modal[modal-type="photo"] {
  overflow: hidden;
  background-color: #444;
}
/* 2:3 aspect ratio */
.modal[modal-type="photo"]::before {
  content: '';
  display: block;
  padding-top: calc(100% / 3 * 2);
}
.modal[modal-type="photo"] img {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}
/* modal image just larger than modal, to ensure it covers modal div */
.modal[modal-type="photo"] img.wider  { max-height: 101%; }
.modal[modal-type="photo"] img.taller { max-width: 101%; }

.modal-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 1;
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.25;
  color: white;
  background-color: rgba(0, 0, 0, 0.66);
}

/* bio modals */
.modal[modal-type="bio"] {
  overflow-y: auto;
  padding: 1.5rem;
}

/* disclaimer modals */
.modal[modal-type="disclaimer"] {
  padding: 2.5rem;
  max-width: 32rem;
  overflow-y: auto;
}
.modal[modal-type="disclaimer"] h1 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: #3d9fc1;
}
.modal[modal-type="disclaimer"] p {
  margin-top: 1rem;
  font-size: 0.9375rem;
  line-height: 1.375;
  color: #444;
}
.modal[modal-type="disclaimer"] p a {
  padding: 0 0.25rem 0.25rem;
  margin: 0 -0.25rem -0.125rem;
  color: #3d9fc1;
  background-color: transparent;
}
.modal[modal-type="disclaimer"] p a:hover {
  background-color: rgba(61, 159, 193, 0.1875);
}
.modal[modal-type="disclaimer"] p a.external {
  display: block;
  padding: 0.375rem 0.25rem 0.5rem;
  margin-top: 0.5rem;
  text-align: center;
}
/* don't include pdf icon for external links in disclaimer modal popups */
.modal[modal-type="disclaimer"] span[data-link-type="pdf"] {
  display: none;
}


/* --- mmc-specific overrides --- */
/* keep modal centered below header layer */
.modal {
  /* just below header */
  z-index: 9;
  /* 50% + half of header height */
  top: calc(50% + 3rem);
  /* 100vh - header height + 1rem gap */
  max-height: calc(100vh - 7rem);
  /* 100% - 1rem gap */
  width: calc(100% - 1rem);
  /* keep width inside main section.card */
  max-width: 50rem;
}
@media (min-width: 50em) {
  .modal {
    /* 50% + half of header height */
    top: calc(50% + 4.375rem);
    /* 100vh - header height + 1rem gap */
    max-height: calc(100vh - 9.75rem);
  }
}


.modal .close-icon {
  position: absolute;
  z-index: 1;
  top: 0; right: 0;
  padding: 0.25rem 0.75rem;
  font-weight: 900;
  font-size: 1.75rem;
  line-height: 1.125;
  color: white;
  background-color: rgba(0, 0, 0, 0.66);
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.25);
  text-decoration: none;
  opacity: 0.5;
}
.modal .close-icon:hover { opacity: 1; }

.modal[data-state='closing'] {
  -webkit-animation-name: scale-down;
          animation-name: scale-down;
  -webkit-animation-delay: 0;
          animation-delay: 0;
}

/* keyframe animations */
@-webkit-keyframes whyyy { }

@-webkit-keyframes scale-up {
  from {
    opacity: 0;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(0);
            transform: translateX(-50%) translateY(-50%) scale(0);
  }
  to {
    opacity: 1;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(1);
            transform: translateX(-50%) translateY(-50%) scale(1);
  }
}

@keyframes scale-up {
  from {
    opacity: 0;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(0);
            transform: translateX(-50%) translateY(-50%) scale(0);
  }
  to {
    opacity: 1;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(1);
            transform: translateX(-50%) translateY(-50%) scale(1);
  }
}

@-webkit-keyframes scale-down {
  from {
    opacity: 1;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(1);
            transform: translateX(-50%) translateY(-50%) scale(1);
  }
  to {
    opacity: 0;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(0);
            transform: translateX(-50%) translateY(-50%) scale(0);
  }
}

@keyframes scale-down {
  from {
    opacity: 1;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(1);
            transform: translateX(-50%) translateY(-50%) scale(1);
  }
  to {
    opacity: 0;
    -webkit-transform: translateX(-50%) translateY(-50%) scale(0);
            transform: translateX(-50%) translateY(-50%) scale(0);
  }
}
