/* Floating top bar: logo + animated name on the left, a glass icon dock in the centre.
   On phones the dock moves to the bottom so it sits under the thumb. See topbar.js. */

.topbar {
  position: fixed;
  z-index: 60;
  top: 16px;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding-inline: max(24px, calc((100% - 1180px) / 2));
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

/* ------------------------------------------------------------------ brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  padding: 5px 18px 5px 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  color: var(--ink);
  text-decoration: none;
  animation: tb-drop 800ms var(--ease) both;
  transition: background 400ms ease;
}

.topbar.is-scrolled .brand {
  background: linear-gradient(180deg, rgba(18, 28, 48, 0.78), rgba(10, 16, 28, 0.62));
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  overflow: hidden;
  border-radius: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: rotate 700ms var(--ease), box-shadow 300ms ease;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand:hover .brand-mark,
.brand:focus-visible .brand-mark {
  rotate: 360deg;
  box-shadow: 0 10px 34px rgba(91, 140, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.brand-text {
  display: grid;
  gap: 3px;
  line-height: 1;
}

.brand-name {
  display: inline-block;
  padding-bottom: 2px;
  background: linear-gradient(100deg, #ffffff 0%, #a9c7ff 22%, #67e2d1 44%, #ffffff 66%, #a9c7ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  background-size: 260% 100%;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  white-space: nowrap;
  clip-path: inset(0 100% 0 0);
  animation:
    tb-reveal 1000ms var(--ease) 250ms forwards,
    tb-shimmer 7s linear 1.2s infinite;
}

.brand:hover .brand-name,
.brand:focus-visible .brand-name {
  animation:
    tb-reveal 1ms forwards,
    tb-shimmer 2.2s linear infinite;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--signal);
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.08em;
  opacity: 0;
  animation: tb-fade 700ms ease 900ms forwards;
}

.brand-tag i {
  width: 6px;
  height: 11px;
  background: var(--signal);
  animation: tb-caret 1s steps(1) infinite;
}

@keyframes tb-reveal {
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes tb-shimmer {
  to {
    background-position: -260% 0;
  }
}

@keyframes tb-fade {
  to {
    opacity: 1;
  }
}

@keyframes tb-caret {
  50% {
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ dock */

.dock {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  backdrop-filter: blur(24px) saturate(1.7);
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(7, 12, 20, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  animation: tb-drop 900ms var(--ease) 150ms both;
  transition: background 400ms ease, box-shadow 400ms ease;
}

/* a slow sheen that travels along the glass */
.dock::before {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.18) 48%, transparent 66%);
  background-size: 260% 100%;
  content: "";
  animation: tb-sheen 6s ease-in-out 1.4s infinite;
  pointer-events: none;
}

.topbar.is-scrolled .dock {
  background: linear-gradient(180deg, rgba(18, 28, 48, 0.78), rgba(10, 16, 28, 0.62));
  box-shadow:
    0 26px 64px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(7, 12, 20, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@keyframes tb-drop {
  from {
    opacity: 0;
    translate: 0 -26px;
    scale: 0.94;
    filter: blur(8px);
  }
}

@keyframes tb-sheen {
  0%,
  55% {
    background-position: 160% 0;
  }
  100% {
    background-position: -60% 0;
  }
}

.dock-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 18%, rgba(160, 195, 255, 0.6), rgba(91, 140, 255, 0.25) 70%);
  box-shadow: 0 0 26px rgba(91, 140, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateX(var(--px, 0px));
  transition: transform 600ms cubic-bezier(0.34, 1.45, 0.64, 1), opacity 300ms ease;
}

.dock-pill.is-on {
  opacity: 1;
}

.dock-item {
  position: relative;
  z-index: 1;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  color: rgba(226, 236, 255, 0.78);
  outline: none;
  scale: var(--s, 1);
  translate: 0 var(--ty, 0px);
  transition: color 250ms ease;
  animation: tb-pop 700ms var(--ease) both;
  animation-delay: calc(450ms + var(--i, 0) * 70ms);
}

.dock-item:nth-of-type(1) { --i: 0; }
.dock-item:nth-of-type(2) { --i: 1; }
.dock-item:nth-of-type(3) { --i: 2; }
.dock-item:nth-of-type(4) { --i: 3; }
.dock-item:nth-of-type(5) { --i: 4; }
.dock-item:nth-of-type(6) { --i: 6; }

@keyframes tb-pop {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.5);
  }
}

.dock-item:hover,
.dock-item:focus-visible,
.dock-item.is-active {
  color: #ffffff;
}

.dock-item:focus-visible {
  box-shadow: 0 0 0 2px rgba(169, 199, 255, 0.9);
}

.dock-sep {
  width: 1px;
  height: 26px;
  margin: 0 3px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.28), transparent);
}

.ico {
  width: 24px;
  height: 24px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ico * {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 450ms var(--ease);
}

/* tooltip */
.dock-tip {
  position: absolute;
  top: calc(100% + 18px);
  left: 50%;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  background: rgba(10, 16, 28, 0.88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--ink);
  font: 600 12px/1 var(--display);
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  scale: calc(1 / var(--s, 1));
  translate: -50% -6px;
  transition: opacity 200ms ease, translate 320ms var(--ease);
  white-space: nowrap;
}

.dock-item:hover .dock-tip,
.dock-item:focus-visible .dock-tip {
  opacity: 1;
  translate: -50% 0;
}

/* ------------------------------------------------------------------ icon micro-animations */

.dock-item:hover .ico-work .i-l,
.dock-item:focus-visible .ico-work .i-l {
  transform: translateX(-2.2px);
}

.dock-item:hover .ico-work .i-r,
.dock-item:focus-visible .ico-work .i-r {
  transform: translateX(2.2px);
}

.dock-item:hover .ico-work .i-s,
.dock-item:focus-visible .ico-work .i-s {
  transform: rotate(14deg) scaleY(1.08);
}

.dock-item:hover .ico-lab .i-fl,
.dock-item:focus-visible .ico-lab .i-fl {
  animation: ico-wobble 900ms ease-in-out infinite;
}

.dock-item:hover .ico-lab .b1,
.dock-item:focus-visible .ico-lab .b1 {
  animation: ico-bubble 1100ms ease-in infinite;
}

.dock-item:hover .ico-lab .b2,
.dock-item:focus-visible .ico-lab .b2 {
  animation: ico-bubble 1100ms ease-in 450ms infinite;
}

.dock-item:hover .ico-exp .i-h,
.dock-item:focus-visible .ico-exp .i-h {
  transform: translateY(-2.4px);
}

.dock-item:hover .ico-about .i-hd,
.dock-item:focus-visible .ico-about .i-hd {
  transform: translateY(-1.6px) scale(1.08);
}

.dock-item:hover .ico-about .i-bd,
.dock-item:focus-visible .ico-about .i-bd {
  transform: translateY(0.6px) scaleX(1.06);
}

.dock-item:hover .ico-mail .i-fp,
.dock-item:focus-visible .ico-mail .i-fp {
  transform: translateY(-2px) scaleY(-0.65);
}

.dock-item:hover .ico-doc .i-l1,
.dock-item:focus-visible .ico-doc .i-l1 {
  animation: ico-draw 600ms var(--ease) both;
}

.dock-item:hover .ico-doc .i-l2,
.dock-item:focus-visible .ico-doc .i-l2 {
  animation: ico-draw 600ms var(--ease) 140ms both;
}

.ico-doc .i-l1,
.ico-doc .i-l2 {
  stroke-dasharray: 9;
}

@keyframes ico-wobble {
  0%,
  100% {
    transform: rotate(-7deg);
  }
  50% {
    transform: rotate(7deg);
  }
}

@keyframes ico-bubble {
  0% {
    opacity: 0;
    transform: translateY(2px);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-7px);
  }
}

@keyframes ico-draw {
  from {
    stroke-dashoffset: 9;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* the old right-hand section rail is redundant with the dock on small screens */
@media (max-width: 900px) {
  .section-rail {
    display: none;
  }
}

/* ------------------------------------------------------------------ phones: dock at the bottom */

@media (max-width: 760px) {
  .topbar {
    top: 12px;
    grid-template-columns: 1fr;
    padding-inline: 16px;
  }

  .dock {
    position: fixed;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    gap: 2px;
    padding: 6px;
    translate: -50% 0;
    animation: tb-rise 900ms var(--ease) 150ms both;
  }

  .dock-item {
    width: 44px;
    height: 44px;
  }

  .dock-pill {
    top: 6px;
    left: 6px;
    width: 44px;
    height: 44px;
  }

  .dock-tip {
    display: none;
  }

  .brand-text {
    display: grid;
  }

  /* keep the area around the bottom dock clear */
  .hero-story-bottom {
    display: none;
  }
}

@keyframes tb-rise {
  from {
    opacity: 0;
    translate: -50% 30px;
    filter: blur(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar *,
  .topbar *::before {
    animation: none !important;
  }

  .brand-name {
    clip-path: none;
  }

  .brand-tag {
    opacity: 1;
  }

  .dock-pill,
  .dock-item,
  .dock-tip,
  .ico * {
    transition: none;
  }
}
