/* macOS-style dock. Owned by the dock agent. */

#dock.dock {
  --dock-font: var(--font-ui, 'VT323', ui-monospace, Menlo, monospace);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 0 16px calc(14px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  font-family: var(--dock-font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.dock__shelf {
  --size: 56px;
  --gap: 6px;
  --pad-x: 11px;
  --pad-t: 7px;
  --pad-b: 11px;
  --radius: 24px;
  --dot: 4px;
  --tip-gap: 9px;
  position: relative;
  flex: none;
  height: calc(var(--size) + var(--pad-t) + var(--pad-b));
  padding: var(--pad-t) var(--pad-x) var(--pad-b);
  pointer-events: auto;
  touch-action: manipulation;
  /* entrance */
  opacity: 0;
  transform: translate3d(0, 46px, 0);
  transition:
    opacity 0.6s ease 0.35s,
    transform 0.9s cubic-bezier(0.2, 0.9, 0.25, 1.04) 0.35s;
}
body.is-ready .dock__shelf {
  opacity: 1;
  transform: none;
}

/* invisible band above the shelf so the magnification zone feels generous */
.dock__shelf::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 18px;
}

/* frosted, smoky glass shelf */
.dock__bg {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.04) 46%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(180deg, rgba(46, 50, 90, 0.58) 0%, rgba(24, 27, 58, 0.7) 100%);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  backdrop-filter: blur(24px) saturate(1.7);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 14px 34px -6px rgba(18, 22, 60, 0.45),
    0 2px 6px rgba(18, 22, 60, 0.22);
  pointer-events: none;
}

.dock__row {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
  height: var(--size);
}

/* ---------- items ---------- */
.dock__item {
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 23%;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.dock__icon {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 23%;
  will-change: transform;
}
/* soft drop shadow under each icon */
.dock__icon::before {
  content: '';
  position: absolute;
  inset: 2.5%;
  border-radius: 23%;
  box-shadow:
    0 2px 3px rgba(8, 10, 30, 0.28),
    0 5px 10px -2px rgba(8, 10, 30, 0.34);
}
.dock__svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transition: filter 0.1s ease;
}
.dock__item:active .dock__svg {
  filter: brightness(0.74);
}

.dock__item:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.96);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(60, 90, 255, 0.55);
}

/* running indicator */
.dock__dot {
  position: absolute;
  left: 50%;
  top: 100%;
  width: var(--dot);
  height: var(--dot);
  margin: calc(var(--pad-b) * 0.28) 0 0 calc(var(--dot) / -2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.55);
  opacity: 0;
  transform: scale(0.2);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
  pointer-events: none;
}
.dock__item.is-active .dock__dot,
.dock__item.is-running .dock__dot {
  opacity: 1;
  transform: none;
}
.dock__item--utility.is-off .dock__svg {
  opacity: 0.9;
}

/* separator */
.dock__sep {
  position: relative;
  flex: none;
  align-self: flex-end;
  pointer-events: none;
}
.dock__sep::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -0.5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4) 20%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0));
}

/* ---------- tooltip ---------- */
.dock__tip {
  position: absolute;
  left: 50%;
  bottom: var(--pad-b);
  width: max-content;
  max-width: calc(100vw - 16px);
  margin-bottom: var(--tip-gap);
  pointer-events: none;
  z-index: 2;
  will-change: transform;
}
.dock__tip-body {
  position: relative;
  padding: 6px 12px 6px;
  border-radius: 9px;
  background: rgba(28, 30, 40, 0.86);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 6px 16px rgba(10, 12, 30, 0.35);
  color: #f6f7fb;
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  opacity: 0;
  transform: translateY(5px) scale(0.96);
  transform-origin: 50% 100%;
  transition: opacity 0.12s ease, transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.dock__tip-body.is-on {
  opacity: 1;
  transform: none;
}
.dock__tip-body::after {
  content: '';
  position: absolute;
  left: calc(50% + var(--ax, 0px));
  top: 100%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: rgba(28, 30, 40, 0.86);
  border-radius: 0 0 2.5px 0;
  transform: rotate(45deg) scale(0.9);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  -webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

/* ---------- small screens / touch / reduced motion ---------- */
@media (max-width: 480px) {
  #dock.dock {
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .dock__tip-body {
    font-size: 17px;
  }
}
@media (hover: none) {
  .dock__tip {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dock__shelf {
    transform: none;
    transition: opacity 0.4s ease 0.2s;
  }
  .dock__tip-body,
  .dock__dot {
    transition: opacity 0.1s linear;
    transform: none;
  }
}

/* ---------- links + hidden helpers ---------- */
.dock [hidden] {
  display: none !important;
}
.dock__item {
  display: block;
  text-decoration: none;
}

/* ---------- "Connect" stack popover (narrow screens) ---------- */
.dock__stack {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 14px;
  z-index: 3;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.2s;
}
.dock__stack.is-open {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.dock__stack-panel {
  position: relative;
  display: flex;
  flex-direction: column-reverse; /* first item nearest the dock, like a macOS stack */
  gap: 2px;
  min-width: 190px;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(60, 64, 104, 0.74), rgba(28, 31, 62, 0.82));
  -webkit-backdrop-filter: blur(26px) saturate(1.7);
  backdrop-filter: blur(26px) saturate(1.7);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 18px 40px -8px rgba(12, 14, 44, 0.55);
  opacity: 0;
  transform: translateY(14px) scale(0.86);
  transform-origin: calc(50% + var(--ax, 0px)) 100%;
  transition: opacity 0.16s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.dock__stack.is-open .dock__stack-panel {
  opacity: 1;
  transform: none;
}
.dock__stack-caret {
  position: absolute;
  left: calc(50% + var(--ax, 0px));
  top: 100%;
  width: 14px;
  height: 14px;
  margin: -8px 0 0 -7px;
  background: rgba(30, 33, 64, 0.82);
  border-radius: 0 0 3px 0;
  transform: rotate(45deg);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  -webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.dock__stack-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px 6px 6px;
  border-radius: 14px;
  color: #f6f7fb;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.dock__stack-item:hover,
.dock__stack-item:active {
  background: rgba(255, 255, 255, 0.16);
}
.dock__stack-item:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}
.dock__stack-icon {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 23%;
  box-shadow: 0 2px 4px rgba(8, 10, 30, 0.35);
}
.dock__stack-icon .dock__svg {
  position: absolute;
  inset: 0;
}
@media (prefers-reduced-motion: reduce) {
  .dock__stack-panel {
    transform: none;
    transition: opacity 0.1s linear;
  }
}
