/*
 * New Standard Hospital contextual card visuals
 * Decorative media is chosen from each card's own heading and copy.
 */

.nshHasContextVisual {
  position: relative !important;
  isolation: isolate;
  min-height: 116px;
  overflow: hidden !important;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.nshHasContextVisual--compact {
  min-height: 126px;
}

.nshHasContextVisual--photo {
  min-height: 148px;
}

.nshHasContextVisual > :not(.nshContextVisual) {
  position: relative;
  z-index: 2;
}

.nshHasContextVisual::before,
.nshHasContextVisual::after {
  z-index: 2;
}

.nshContextVisual {
  --nsh-context-opacity: .64;
  position: absolute;
  z-index: 1;
  top: 50%;
  right: clamp(12px, 1.5vw, 22px);
  width: clamp(66px, 24%, 104px);
  aspect-ratio: 1;
  border-radius: 20px;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(10px, calc(-50% + 5px), 0) scale(.96);
  filter: saturate(.86) contrast(.96);
  transition: opacity 420ms ease, transform 520ms cubic-bezier(.2,.72,.2,1), filter 180ms ease;
}

.nshContextVisual::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -12%;
  border-radius: 28px;
  background: radial-gradient(circle at 58% 46%, rgba(80, 182, 163, .16), rgba(242, 248, 248, 0) 69%);
}

.nshContextVisual.is-visible {
  opacity: var(--nsh-context-opacity);
  transform: translate3d(0, -50%, 0) scale(1);
}

.nshContextVisual--sprite {
  --nsh-context-opacity: .72;
  background-image: url('/assets/img/contextual-v1/medical-card-icon-sprite.webp');
  background-size: 600% 400%;
  background-position: var(--nsh-sprite-x, 0%) var(--nsh-sprite-y, 0%);
}

.nshContextVisual--anatomy {
  --nsh-context-opacity: .3;
  top: 0;
  right: 0;
  width: min(39%, 176px);
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  background-image: var(--nsh-context-image);
  background-size: contain;
  background-position: right center;
  transform: translate3d(9px, 5px, 0) scale(.98);
  filter: saturate(.74) contrast(.96);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.42) 23%, #000 52%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.42) 23%, #000 52%);
}

.nshContextVisual--anatomy.is-visible {
  transform: translate3d(0, 0, 0) scale(1);
}

.nshContextVisual--photo {
  --nsh-context-opacity: .22;
  top: 0;
  right: 0;
  width: min(48%, 260px);
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  background-image: var(--nsh-context-image);
  background-size: cover;
  background-position: var(--nsh-context-position, center);
  transform: translate3d(8px, 0, 0) scale(1.025);
  filter: saturate(.72) contrast(.92);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.32) 25%, #000 60%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.32) 25%, #000 60%);
}

.nshContextVisual--photo.is-visible {
  transform: translate3d(0, 0, 0) scale(1);
}

/*
 * Keep the decorative span isolated from page-specific rules such as
 * `.card span { background: ... }`. The extra component specificity is
 * intentional; it avoids !important while leaving reveal/hover states free
 * to override only the properties they animate.
 */
.nshHasContextVisual > span.nshContextVisual.nshContextVisual {
  display: block;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  border-style: none;
  background-color: transparent;
  background-image: none;
  color: transparent;
  font-size: 0;
  line-height: 0;
  text-align: initial;
}

.nshHasContextVisual > span.nshContextVisual.nshContextVisual--sprite {
  height: auto;
  border-radius: 20px;
  background-color: transparent;
  background-image: url('/assets/img/contextual-v1/medical-card-icon-sprite.webp');
  background-repeat: no-repeat;
  background-size: 600% 400%;
  background-position: var(--nsh-sprite-x, 0%) var(--nsh-sprite-y, 0%);
}

.nshHasContextVisual > span.nshContextVisual.nshContextVisual--anatomy {
  height: 100%;
  border-radius: 0;
  background-color: transparent;
  background-image: var(--nsh-context-image);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: right center;
}

.nshHasContextVisual > span.nshContextVisual.nshContextVisual--photo {
  height: 100%;
  border-radius: 0;
  background-color: transparent;
  background-image: var(--nsh-context-image);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: var(--nsh-context-position, center);
}

.nshHasContextVisual.nshHasContextVisual--compact > span.nshContextVisual.nshContextVisual--sprite {
  right: 10px;
  width: 54px;
  border-radius: 15px;
}

.nshHasContextVisual[data-nsh-context-visual="icon-emergency"] .nshContextVisual--sprite {
  --nsh-context-opacity: .78;
  filter: saturate(.7) sepia(.08);
}

@media (hover: hover) and (pointer: fine) {
  .nshHasContextVisual:hover {
    border-color: rgba(45, 121, 137, .32) !important;
    box-shadow: 0 14px 32px rgba(16, 40, 61, .08);
    transform: translateY(-2px);
  }

  .nshHasContextVisual:hover .nshContextVisual--sprite {
    filter: saturate(1) contrast(1);
    transform: translate3d(0, -50%, 0) scale(1.025);
  }

  .nshHasContextVisual:hover .nshContextVisual--anatomy,
  .nshHasContextVisual:hover .nshContextVisual--photo {
    filter: saturate(.88) contrast(.98);
    transform: translate3d(0, 0, 0) scale(1.015);
  }
}

@media screen and (max-width: 640px) {
  .nshHasContextVisual,
  .nshHasContextVisual--photo {
    min-height: 120px;
  }

  .nshHasContextVisual > span.nshContextVisual.nshContextVisual--sprite,
  .nshHasContextVisual.nshHasContextVisual--compact > span.nshContextVisual.nshContextVisual--sprite {
    right: 10px;
    width: 62px;
  }

  .nshHasContextVisual > span.nshContextVisual.nshContextVisual--anatomy,
  .nshHasContextVisual > span.nshContextVisual.nshContextVisual--photo {
    top: auto;
    bottom: 0;
    width: 94px;
    height: 92%;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.42) 30%, #000 66%);
    mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.42) 30%, #000 66%);
  }
}

/* Professional full-card v2 treatment. The image is atmosphere, not an icon. */
.nshHasContextVisual > span.nshContextVisual.nshContextVisual--background {
  --nsh-context-opacity: .30;
  position: absolute;
  z-index: 1;
  inset: 0;
  top: 0;
  right: 0;
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  max-width: none;
  aspect-ratio: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background-color: transparent;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: right center;
  box-shadow: none;
  opacity: 0;
  transform: none;
  filter: saturate(.72) contrast(.92) brightness(1.04);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, transparent 52%, rgba(0, 0, 0, .54) 78%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, transparent 52%, rgba(0, 0, 0, .54) 78%, #000 100%);
  transition: opacity 420ms ease, transform 520ms cubic-bezier(.2,.72,.2,1), filter 180ms ease;
}

.nshHasContextVisual > span.nshContextVisual.nshContextVisual--background::before {
  content: none;
}

.nshHasContextVisual > span.nshContextVisual.nshContextVisual--background.is-visible {
  opacity: var(--nsh-context-opacity);
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .nshHasContextVisual:hover > .nshContextVisual--background {
    --nsh-context-opacity: .36;
    filter: saturate(.82) contrast(.95) brightness(1.03);
    transform: none;
  }
}

@media screen and (max-width: 640px) {
  .nshHasContextVisual > span.nshContextVisual.nshContextVisual--background {
    --nsh-context-opacity: .22;
    top: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    background-position: right center;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, transparent 58%, rgba(0, 0, 0, .48) 82%, #000 100%);
    mask-image: linear-gradient(90deg, transparent 0%, transparent 58%, rgba(0, 0, 0, .48) 82%, #000 100%);
  }
}

@media print {
  .nshHasContextVisual > .nshContextVisual--background {
    display: none !important;
    background-image: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nshHasContextVisual,
  .nshContextVisual {
    transition: none !important;
  }

  .nshContextVisual,
  .nshContextVisual.is-visible {
    opacity: var(--nsh-context-opacity);
  }

  .nshContextVisual--sprite,
  .nshContextVisual--sprite.is-visible {
    transform: translate3d(0, -50%, 0) scale(1);
  }

  .nshContextVisual--anatomy,
  .nshContextVisual--photo,
  .nshContextVisual--anatomy.is-visible,
  .nshContextVisual--photo.is-visible {
    transform: none;
  }
}
