/* ═══════════════════════════════════════════
   Helm dock — centered OS-style icon dock
   ═══════════════════════════════════════════ */

:root {
  --helm-clearance: 6.4rem;
  --helm-icon: 3.15rem;
  --helm-gap: 0.42rem;
  --helm-radius: 1.45rem;
}

.helm-dock {
  --helm-h: 8.4rem;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 48;
  height: var(--helm-h);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(28px);
  filter: blur(8px);
  will-change: opacity, transform, filter;
}

.helm-dock-glow {
  position: absolute;
  left: 50%;
  bottom: 0.2rem;
  width: min(28rem, 62vw);
  height: 4.4rem;
  transform: translateX(-50%);
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 60% 80% at 50% 100%,
      rgba(61, 224, 255, 0.16) 0%,
      rgba(20, 90, 180, 0.07) 50%,
      transparent 76%
    );
  mix-blend-mode: screen;
}

.helm-dock-readout {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.helm-dock-tray {
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  height: calc(var(--helm-icon) + 0.9rem);
  max-height: calc(var(--helm-icon) + 0.9rem);
  padding: 0.38rem 0.72rem 0.42rem;
  pointer-events: auto;
  background:
    linear-gradient(
      180deg,
      rgba(14, 36, 68, 0.52) 0%,
      rgba(6, 14, 32, 0.58) 100%
    );
  border: 1px solid rgba(180, 230, 255, 0.22);
  border-radius: var(--helm-radius);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.28),
    0 16px 36px rgba(0, 4, 16, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -10px 18px rgba(0, 8, 24, 0.28);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  overflow: visible;
}

.helm-dock-rail {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--helm-gap);
  list-style: none;
  margin: 0;
  padding: 0;
  height: var(--helm-icon);
  overflow: visible;
}

.helm-dock-item {
  --s: 1;
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--helm-icon) * var(--s));
  height: var(--helm-icon);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1;
}

.helm-dock.is-magnifying .helm-dock-item {
  z-index: 2;
}

.helm-dock-btn {
  position: relative;
  width: var(--helm-icon);
  height: var(--helm-icon);
  display: grid;
  place-items: center;
  color: var(--cyan);
  background:
    linear-gradient(
      165deg,
      rgba(70, 170, 255, 0.22) 0%,
      rgba(8, 24, 52, 0.78) 46%,
      rgba(2, 8, 22, 0.86) 100%
    );
  border: 1px solid rgba(61, 224, 255, 0.28);
  border-radius: 22%;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -8px 12px rgba(0, 6, 18, 0.28),
    0 6px 14px rgba(0, 0, 0, 0.38);
  overflow: visible;
  transform: scale(var(--s));
  transform-origin: 50% 100%;
  transition:
    color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    filter 0.18s var(--ease);
}

.helm-dock:not(.is-magnifying) .helm-dock-item {
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.helm-dock:not(.is-magnifying) .helm-dock-btn {
  transition:
    transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    filter 0.18s var(--ease);
}

.helm-dock-scan {
  display: none;
}

.helm-dock-pip {
  display: none;
}

.helm-dock-item:has(.helm-dock-btn.is-active)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.38rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e8fbff;
  box-shadow: 0 0 8px rgba(61, 224, 255, 0.85);
  transform: translateX(-50%);
  pointer-events: none;
}

.helm-dock-glyph {
  width: 58%;
  height: 58%;
  display: block;
  z-index: 1;
  filter: drop-shadow(0 0 8px var(--cyan-dim));
  pointer-events: none;
}

.helm-dock-glyph svg {
  width: 100%;
  height: 100%;
  display: block;
}

.helm-dock-name {
  position: absolute;
  left: 50%;
  bottom: calc(var(--helm-icon) * var(--s) + 0.52rem);
  transform: translateX(-50%) translateY(6px);
  padding: 0.28rem 0.62rem;
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #d8f7ff;
  background: rgba(4, 10, 22, 0.94);
  border: 1px solid rgba(61, 224, 255, 0.42);
  border-radius: 0.45rem;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.45),
    0 0 12px rgba(61, 224, 255, 0.12);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  z-index: 5;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease), visibility 0.16s;
}

.helm-dock-name::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 0;
  height: 0;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: rgba(61, 224, 255, 0.42);
  pointer-events: none;
}

.helm-dock-item.is-hot .helm-dock-name,
.helm-dock-item:focus-within .helm-dock-name {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Desktop hover tooltips (macOS-dock style); skip sticky-hover on touch */
@media (hover: hover) and (pointer: fine) {
  .helm-dock-item:hover .helm-dock-name {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

.helm-dock-btn:focus-visible {
  outline: none;
  border-color: var(--border-bright);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 0 2px rgba(61, 224, 255, 0.28),
    0 8px 18px rgba(0, 0, 0, 0.4);
}

.helm-dock-btn.is-active {
  border-color: rgba(61, 224, 255, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 18px rgba(61, 224, 255, 0.22),
    0 6px 14px rgba(0, 0, 0, 0.38);
}

.helm-dock-btn--helm {
  background:
    linear-gradient(
      165deg,
      rgba(90, 190, 255, 0.3) 0%,
      rgba(10, 32, 64, 0.82) 48%,
      rgba(2, 8, 22, 0.9) 100%
    );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 16px rgba(61, 224, 255, 0.16),
    0 6px 14px rgba(0, 0, 0, 0.38);
}

body.is-hud-in .helm-dock {
  animation: helm-dock-rise 1.35s cubic-bezier(0.16, 1, 0.3, 1) 0.72s both;
  visibility: visible;
  pointer-events: none;
}

body.is-hud-in .helm-dock .helm-dock-tray {
  pointer-events: auto;
}

body.is-hud-in.is-systems-settled .helm-dock {
  animation: none;
  opacity: 1;
  transform: none;
  filter: none;
  visibility: visible;
  will-change: auto;
}

body.is-loading .helm-dock,
body.is-bridge-ready:not(.is-hud-in) .helm-dock {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@keyframes helm-dock-rise {
  from {
    opacity: 0;
    transform: translateY(36px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .helm-dock,
  .helm-dock-item,
  .helm-dock-btn,
  .helm-dock-name {
    transition: none;
    animation: none !important;
  }

  body.is-hud-in .helm-dock,
  body.is-hud-in.is-systems-settled .helm-dock {
    opacity: 1;
    transform: none;
    filter: none;
    visibility: visible;
  }
}

@media (max-width: 900px) {
  .helm-dock {
    --helm-h: 6.6rem;
    --helm-icon: 2.55rem;
    --helm-gap: 0.28rem;
    --helm-radius: 1.2rem;
  }

  :root {
    --helm-clearance: 5.6rem;
  }

  .helm-dock-tray {
    bottom: 0.5rem;
    padding: 0.3rem 0.55rem 0.34rem;
  }

  .helm-dock-name {
    font-size: 0.46rem;
  }
}

@media (max-width: 560px) {
  .helm-dock {
    --helm-h: 5.9rem;
    --helm-icon: 2.15rem;
    --helm-gap: 0.16rem;
    --helm-radius: 1.05rem;
  }

  :root {
    --helm-clearance: 5rem;
  }

  .helm-dock-tray {
    bottom: 0.38rem;
    padding: 0.24rem 0.42rem 0.28rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .helm-dock-item {
    --s: 1 !important;
  }

  /* No sticky hover tooltips on touch — keep taps clear */
  .helm-dock-item:hover .helm-dock-name,
  .helm-dock-item.is-hot .helm-dock-name {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(6px);
  }

  .helm-dock-item:focus-within .helm-dock-name {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}
