/* Station console containment + tooltip portal fix
   Keep the bridge screenshot fully contained in its own card. Only the
   instruction tooltip is promoted above the rest of the interface; the
   screenshot/reference card never receives a high stacking level. */
.console-reference {
  position: relative;
  overflow: hidden !important;
  z-index: auto !important;
}

.console-image-frame {
  position: relative;
  overflow: hidden !important;
  z-index: auto !important;
}

.console-image-stage {
  position: relative;
  overflow: hidden !important;
  isolation: isolate;
  z-index: auto !important;
}

/* Keep the screenshot aligned with the hotspot coordinate system and prevent
   the old 1.04 transform from leaking beyond its 16:9 stage. */
.console-image-stage > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  transform: none !important;
}

.console-image-stage > .screen-hotspots {
  inset: 0;
  z-index: 4;
}

.screen-hotspot,
.screen-hotspot:hover,
.screen-hotspot:focus,
.screen-hotspot:focus-visible {
  z-index: 5;
}

/* The inline tooltip is retained in the markup for its accessible text, but
   visual rendering is handled by #ufn-hotspot-tooltip-portal outside all
   console stacking/clipping contexts. */
.screen-hotspot .screen-hotspot-popover,
.screen-hotspot:hover .screen-hotspot-popover,
.screen-hotspot:focus .screen-hotspot-popover,
.screen-hotspot:focus-visible .screen-hotspot-popover {
  display: none !important;
}

.console-reference figcaption {
  position: relative;
  z-index: auto;
  background: rgba(2, 10, 18, .98);
}

/* Viewport-level copy of the active hotspot help panel. This is the only
   station-orientation element deliberately forced above the application UI.

   The portal is a child of <body>, so it inherits --station-accent-rgb from
   station-colours.css. This keeps the same popup design while giving each
   station its own operational colour. */
.ufn-hotspot-tooltip-portal {
  --tooltip-accent-rgb: var(--station-accent-rgb, 105, 186, 255);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483000;
  display: none;
  width: min(310px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  padding: 12px 13px 13px;
  overflow: hidden;
  border: 1px solid rgba(var(--tooltip-accent-rgb), .78);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(var(--tooltip-accent-rgb), .13), transparent 42%),
    rgba(2,10,23,.985);
  color: var(--muted);
  text-align: left;
  box-shadow:
    inset 3px 0 0 rgba(var(--tooltip-accent-rgb), .88),
    0 18px 48px rgba(0,0,0,.68),
    0 0 22px rgba(var(--tooltip-accent-rgb), .14),
    0 0 0 1px rgba(3,21,37,.7);
  backdrop-filter: blur(10px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 80ms linear, transform 80ms linear;
}

.ufn-hotspot-tooltip-portal::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(var(--tooltip-accent-rgb), .96),
    rgba(var(--tooltip-accent-rgb), .28) 62%,
    transparent
  );
  box-shadow: 0 0 12px rgba(var(--tooltip-accent-rgb), .28);
}

.ufn-hotspot-tooltip-portal.visible {
  display: block;
  opacity: 1;
  transform: none;
}

.ufn-hotspot-tooltip-portal strong {
  display: block;
  margin-bottom: 5px;
  color: rgb(var(--tooltip-accent-rgb));
  font-size: .8rem;
  text-shadow: 0 0 12px rgba(var(--tooltip-accent-rgb), .20);
}

.ufn-hotspot-tooltip-portal span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .ufn-hotspot-tooltip-portal {
    width: min(270px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
  }
}
