/* The header: three dark segments joined by concave necks, floating over every
 * page. Light page, dark bar; dark page, light bar. */

:root {
  --bar: #17181c;
  --bar-text: #f4f1ea;
  --bar-dim: rgba(244, 241, 234, 0.68);
  --bar-rule: rgba(244, 241, 234, 0.2);
  --bar-glow: rgba(244, 241, 234, 0.12);
  --bar-ok: #7ee2b0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bar: #f4f1ea;
    --bar-text: #17181c;
    --bar-dim: rgba(23, 24, 28, 0.68);
    --bar-rule: rgba(23, 24, 28, 0.22);
    --bar-glow: rgba(23, 24, 28, 0.08);
    --bar-ok: #0b7a4b;
  }
}

.bar {
  --h: 64px;
  --pad: 8px;
  position: fixed;
  z-index: 50;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

.bar-in {
  display: flex;
  align-items: center;
  pointer-events: auto;
  filter: drop-shadow(0 10px 22px rgba(10, 12, 24, 0.2));
  font-family: "Satoshi", system-ui, sans-serif;
  transition: transform 0.3s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.bar.is-tucked { --h: 54px; --pad: 6px; }

.seg {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  height: var(--h);
  padding: var(--pad);
  border: 0;
  border-radius: 999px;
  background: var(--bar);
  color: var(--bar-text);
  font: inherit;
  text-decoration: none;
  transition: height 0.3s cubic-bezier(0.3, 0.8, 0.3, 1), padding 0.3s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.seg-in {
  display: flex;
  align-items: center;
  height: 100%;
  border: 1px solid var(--bar-rule);
  border-radius: 999px;
}

/* The neck: a short bar with its top and bottom edges bitten away, tucked under
 * the two segments it joins. */
.neck {
  flex: none;
  width: 28px;
  height: 36px;
  margin: 0 -10px;
  background: var(--bar);
  clip-path: path("M0 0C9 13 19 13 28 0V36C19 23 9 23 0 36Z");
}

.seg-mark { width: var(--h); padding: 0; align-items: center; justify-content: center; transition: width 0.3s cubic-bezier(0.3, 0.8, 0.3, 1), height 0.3s cubic-bezier(0.3, 0.8, 0.3, 1); }
.seg-mark svg { width: 46%; height: 46%; transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
.seg-mark:hover svg { transform: rotate(-9deg) scale(1.08); }

.seg-nav .seg-in { position: relative; padding: 0 6px; }
.seg-nav a {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: calc(100% - 8px);
  padding: 0 14px;
  border-radius: 999px;
  color: var(--bar-dim);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
.seg-nav a:hover,
.seg-nav a[aria-current="true"] { color: var(--bar-text); }
.seg-nav a + a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: var(--bar-rule);
}

/* Slides under whichever link's section is on screen; home.js places it. */
.bar-spot {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--bar-glow);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.3, 0.9, 0.3, 1), width 0.35s cubic-bezier(0.3, 0.9, 0.3, 1), opacity 0.2s;
}

.seg-cta { cursor: pointer; }
.seg-cta .seg-in {
  gap: 8px;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.seg-cta:hover .seg-in { background: var(--bar-glow); }
.seg-cta.is-done .seg-in { border-color: var(--bar-ok); color: var(--bar-ok); }
.seg-cta svg { width: 16px; height: 16px; }

.bar .icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bar a:focus-visible,
.bar button:focus-visible { outline: 2px solid #4d7cff; outline-offset: 2px; }

@media (max-width: 560px) {
  .bar { --h: 52px; --pad: 5px; top: 10px; }
  .bar.is-tucked { --h: 48px; --pad: 4px; }
  .neck { width: 22px; height: 28px; margin: 0 -8px; clip-path: path("M0 0C7 10 15 10 22 0V28C15 18 7 18 0 28Z"); }
  .seg-nav .seg-in { padding: 0 2px; }
  .seg-nav a { padding: 0 9px; font-size: 13px; }
  .seg-cta .seg-in { padding: 0 12px; font-size: 13px; gap: 5px; }
  .seg-cta svg { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .neck { animation: neck-in 0.6s 0.15s cubic-bezier(0.3, 1.4, 0.5, 1) backwards; }
  .seg { animation: seg-in 0.55s cubic-bezier(0.3, 1.2, 0.5, 1) backwards; }
  .seg-mark { --from: 26px; }
  .seg-cta { --from: -26px; }
}

@keyframes neck-in { from { transform: scaleY(0); } }
@keyframes seg-in { from { transform: translateX(var(--from, 0)) scale(0.96); } }
