/* nav phone line + starlight + top-bar pills · baa.business
   symmetric centre group in the top bar on every page that uses .site-nav:
       [🪐 loop me in]  torah to taiwan  [🚀 boost us]
   the number sits in the true centre of the bar; the two pills are identical
   (same width, height, border, type) with identical gaps, so it reads as a mirror.
   the number keeps its soft breathing glow; the pills only glow on hover/focus.

   widths (the group never touches the wordmark or the links):
     >= 1360   labelled pills, links inline
     1180-1359 emoji-only pills 🪐 · 🚀, links inline
     620-1179  links fold into the menu (hamburger), labelled pills
     470-619   emoji-only 40px pills on one row
     <= 469    number on top, the two labelled pills side by side under it */

/* ---------- layering ---------- */
.site-nav .container { position: relative; }
.site-nav .container > * { position: relative; z-index: 1; }

/* ---------- the centre group ---------- */
.site-nav { --pill-w: 112px; --pill-h: 32px; --grp-gap: 16px; }
.site-nav .container > .nav-center {
  flex: none;
  display: flex;
  align-items: center;          /* pills centred on the number's text line */
  justify-content: center;
  gap: var(--grp-gap);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

/* ---------- the number ---------- */
.site-nav .nav-center > .nav-torah {
  flex: none;
  position: relative;
  isolation: isolate;
  color: #8e8ea6;               /* a touch dimmer than the nav links */
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
  padding: 10px 4px;            /* comfy tap target without any visible box */
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, text-shadow 0.2s;
}
.site-nav .nav-center > .nav-torah:hover,
.site-nav .nav-center > .nav-torah:focus-visible {
  color: #e6e0f5;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.55);
  outline: none;
}

/* desktop spacing */
@media (min-width: 1180px) {
  .site-nav .container { width: min(1380px, calc(100% - 56px)); }
  .site-nav .nav-links { gap: 8px 22px; }
  .site-nav .nav-links a { letter-spacing: 0.04em; }
}
@media (min-width: 1180px) and (max-width: 1299px) {
  .site-nav .container { width: calc(100% - 40px); }
  .site-nav .nav-links { gap: 8px 14px; }
}

/* ---------- 861-1179: fold the links into the menu, like phones do ----------
   (mirrors styles.css + star-icon.css at <=860 so the centred group has room) */
@media (min-width: 861px) and (max-width: 1179px) {
  .site-nav .container > .nav-toggle { display: flex; order: 2; }
  .site-nav .container > .star-ufo { order: 1; margin-left: 0; margin-right: -6px; }
  .site-nav .container:has(> .nav-toggle) > .nav-links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 16px 24px 24px;
    background: rgba(5, 5, 8, 0.97);
    border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s var(--ease, ease), opacity 0.3s;
  }
  .site-nav .container:has(> .nav-toggle) > .nav-links.open { transform: none; opacity: 1; pointer-events: auto; }
  .site-nav .container:has(> .nav-toggle) > .nav-links a {
    padding: 14px 0;
    border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
    font-size: 0.95rem;
  }
  .site-nav .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
  .site-nav .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .site-nav .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
}
/* pages without a menu (dazzling data): links drop to their own row instead */
@media (max-width: 1179px) {
  .site-nav .container:not(:has(> .nav-toggle)) { flex-wrap: wrap; row-gap: 8px; padding: 0; }
  .site-nav .container:not(:has(> .nav-toggle)) > .star-ufo { order: 1; margin-right: 0; }
  .site-nav .container:not(:has(> .nav-toggle)) > .nav-links { order: 3; flex: 1 1 100%; flex-wrap: wrap; position: relative; }
  .site-nav .container:not(:has(> .nav-toggle)) > .wordmark { margin-right: auto; }
  .site-nav:has(> .container > .nav-links):not(:has(.nav-toggle)) { height: auto; min-height: var(--nav-h); padding: 10px 0; }
  /* row one is 32px tall (saucer): centre the group on it */
  .site-nav .container:not(:has(> .nav-toggle)) > .nav-center { top: 16px; }
}

/* phones/tablets with the menu */
@media (max-width: 860px) {
  .site-nav .nav-center > .nav-torah { font-size: 0.74rem; letter-spacing: 0.06em; }
  .site-nav .container > .nav-links { position: fixed; }
  .site-nav .container:not(:has(> .nav-toggle)) > .nav-links { position: relative; }
}
@media (max-width: 360px) {
  .site-nav .container { width: calc(100% - 28px); }
  .site-nav .wordmark { font-size: 0.86rem; }
  .site-nav .nav-center > .nav-torah { font-size: 0.7rem; letter-spacing: 0.04em; padding: 10px 2px; }
}

/* ---------- starlight ---------- */
/* soft violet-white glow behind the number that slowly breathes */
.site-nav .nav-center > .nav-torah::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(236, 226, 255, 0.16), rgba(192, 132, 252, 0.1) 45%, rgba(168, 85, 247, 0) 100%);
  transform: translate(-50%, -50%);
  z-index: -1;
  pointer-events: none;
  animation: nav-star-breathe 7s ease-in-out infinite;
}
@media (max-width: 860px) {
  .site-nav .nav-center > .nav-torah::before { width: 170px; height: 52px; }
}

/* tiny star points that twinkle out of step */
.site-nav .container::before,
.site-nav .container::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.site-nav .container::before {
  background:
    radial-gradient(1.4px 1.4px at 8% 22%, rgba(255, 255, 255, 0.9), transparent 100%),
    radial-gradient(1.2px 1.2px at 27% 78%, rgba(226, 210, 255, 0.85), transparent 100%),
    radial-gradient(1.6px 1.6px at 41% 16%, rgba(255, 255, 255, 0.9), transparent 100%),
    radial-gradient(1.2px 1.2px at 62% 84%, rgba(226, 210, 255, 0.8), transparent 100%),
    radial-gradient(1.4px 1.4px at 86% 14%, rgba(255, 255, 255, 0.85), transparent 100%);
  animation: nav-star-twinkle 5.5s ease-in-out infinite alternate;
}
.site-nav .container::after {
  background:
    radial-gradient(1.2px 1.2px at 17% 72%, rgba(255, 255, 255, 0.85), transparent 100%),
    radial-gradient(1.5px 1.5px at 35% 26%, rgba(226, 210, 255, 0.9), transparent 100%),
    radial-gradient(1.2px 1.2px at 57% 78%, rgba(255, 255, 255, 0.8), transparent 100%),
    radial-gradient(1.5px 1.5px at 73% 22%, rgba(226, 210, 255, 0.85), transparent 100%),
    radial-gradient(1.2px 1.2px at 95% 74%, rgba(255, 255, 255, 0.8), transparent 100%);
  animation: nav-star-twinkle 7.5s ease-in-out -3s infinite alternate;
}

/* faint shimmer drifting along the bottom edge of the bar */
.site-nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(192, 132, 252, 0) 0%, rgba(192, 132, 252, 0) 35%, rgba(224, 206, 255, 0.6) 50%, rgba(192, 132, 252, 0) 65%, rgba(192, 132, 252, 0) 100%);
  background-size: 200% 100%;
  background-position: 50% 0;
  opacity: 0.75;
  animation: nav-star-shimmer 14s linear infinite;
}

@keyframes nav-star-breathe {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.92); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes nav-star-twinkle {
  0% { opacity: 0.25; }
  60% { opacity: 0.85; }
  100% { opacity: 0.45; }
}
@keyframes nav-star-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .site-nav .nav-center > .nav-torah::before { animation: none; opacity: 0.85; }
  .site-nav .container::before,
  .site-nav .container::after { animation: none; opacity: 0.6; }
  .site-nav::after { animation: none; background-position: 50% 0; }
}

/* ---------- the pills: "🪐 loop me in" + "🚀 boost us" ----------
   identical outlined pills; no glow at rest (the number's star pulse stays the
   only moving light), soft violet glow on hover / focus / while the picker is open. */
.site-nav .nav-center > .nav-pill {
  flex: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.015);
  color: #8e8ea6;
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  text-transform: lowercase;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.site-nav .nav-center > .nav-pill .nav-pill-i {
  display: inline-block;
  width: 1.15em;
  text-align: center;
  font-size: 1.05em;
  line-height: 1;
  opacity: 0.85;
  filter: saturate(0.8);
  transition: opacity 0.2s, filter 0.2s;
}
.site-nav .nav-center > .nav-pill .nav-pill-t { line-height: 1; }
.site-nav .nav-center > .nav-pill:hover,
.site-nav .nav-center > .nav-pill:focus-visible,
.site-nav .nav-center > .nav-pill[aria-expanded="true"] {
  color: #e6e0f5;
  border-color: rgba(192, 132, 252, 0.62);
  background-color: rgba(192, 132, 252, 0.08);
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.32), inset 0 0 8px rgba(192, 132, 252, 0.12);
  outline: none;
}
.site-nav .nav-center > .nav-pill:hover .nav-pill-i,
.site-nav .nav-center > .nav-pill:focus-visible .nav-pill-i,
.site-nav .nav-center > .nav-pill[aria-expanded="true"] .nav-pill-i { opacity: 1; filter: none; }
.site-nav .nav-center > .nav-pill:focus-visible { box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.45), 0 0 14px rgba(192, 132, 252, 0.32); }


/* ---------- pill sizes per width ---------- */
.site-nav .nav-center > .nav-pill { width: var(--pill-w); height: var(--pill-h); }

/* 1180-1359: emoji-only so the mirror never reaches the inline links */
@media (min-width: 1180px) and (max-width: 1359px) {
  .site-nav { --pill-w: 40px; }
}
/* 470-619: emoji-only, bigger tap targets, one row */
@media (max-width: 619px) {
  .site-nav { --pill-w: 40px; --pill-h: 40px; --grp-gap: 14px; }
}
@media (min-width: 1180px) and (max-width: 1359px), (min-width: 470px) and (max-width: 619px) {
  .site-nav .nav-center > .nav-pill { padding: 0; gap: 0; }
  .site-nav .nav-center > .nav-pill .nav-pill-t { display: none; }
  .site-nav .nav-center > .nav-pill .nav-pill-i { font-size: 1.15em; }
}

/* <=469: number on top (level with the wordmark), the two pills side by side
   under it, loop left / boost right. the bar grows to 100px and --nav-h follows,
   so page padding, scroll offsets and the menu panel all clear it. */
@media (max-width: 469px) {
  :root { --nav-h: 100px; }
  .site-nav { --pill-w: 8.25rem; --pill-h: 40px; align-items: flex-start; }
  .site-nav .container { padding-top: 6px; min-height: 46px; }
  .site-nav .container > .nav-center {
    display: grid;
    grid-template-columns: var(--pill-w) var(--pill-w);
    grid-template-areas: "ph ph" "lo bo";
    justify-items: center;
    gap: 10px;
    top: 14px;
    transform: translateX(-50%);
  }
  .site-nav .nav-center > .nav-torah { grid-area: ph; padding: 6px 4px; }
  .site-nav .nav-center > .nav-loop { grid-area: lo; }
  .site-nav .nav-center > .nav-boost { grid-area: bo; }
  .site-nav .nav-center > .nav-torah::before { width: 160px; height: 44px; }
  .site-nav .nav-center > .nav-pill { padding: 0 10px; gap: 7px; font-size: 0.8rem; letter-spacing: 0.05em; }
  .site-nav .nav-center > .nav-pill .nav-pill-i { font-size: 1.1em; }
  /* dazzling data (no menu, nav in normal flow): the group becomes its own row,
     with the number riding up into the wordmark row */
  .site-nav .container:not(:has(> .nav-toggle)) > .nav-center {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    order: 2;
    margin: -34px auto 0;
  }
  .site-nav .container:not(:has(> .nav-toggle)) > .nav-links { margin-top: 4px; }
  .site-nav:has(> .container > .nav-links):not(:has(.nav-toggle)) { align-items: center; }
  /* dazzling data's nav is in normal flow and sizes itself (~130-156px here);
     --nav-h only feeds its anchor scroll offsets */
  :root:has(.bw-page) { --nav-h: 156px; }
  .site-nav:has(> .container > .nav-links):not(:has(.nav-toggle)) { min-height: 0; }
}
@media (max-width: 360px) {
  .site-nav { --pill-w: 8.1rem; }
  .site-nav .nav-center > .nav-torah { padding: 6px 2px; }
}

/* emoji parity: the ringed planet draws flatter than the rocket, so give it ~8% more size */
.site-nav .nav-center > .nav-loop .nav-pill-i { transform: scale(1.08); }
@media (prefers-reduced-motion: reduce) {
  .site-nav .nav-center > .nav-pill,
  .site-nav .nav-center > .nav-pill .nav-pill-i { transition: none; }
}

/* ---------- custom svg pill icons (js/nav-icons.js) ----------
   the loop pill's planet and the boost pill's rocket rotate per page load; pill sizes and symmetry are unchanged. */
.site-nav .nav-center > .nav-pill .nav-pill-i.ti-on {
  display: inline-grid;
  place-items: center;
  width: auto;
  opacity: 1;
  filter: none;
  transform: none;
}
.site-nav .nav-pill-i .ti {
  display: block;
  width: 18px;
  height: 18px;
  overflow: visible;
  filter: drop-shadow(0 0 2.5px rgba(192, 132, 252, 0.35));
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), filter 0.45s;
}
.site-nav .nav-center > .nav-pill:hover .nav-pill-i .ti,
.site-nav .nav-center > .nav-pill:focus-visible .nav-pill-i .ti {
  transform: scale(1.1);
  filter: brightness(1.12) drop-shadow(0 0 5px rgba(192, 132, 252, 0.55));
}
@media (min-width: 1180px) and (max-width: 1359px), (max-width: 619px) {
  .site-nav .nav-pill-i .ti { width: 20px; height: 20px; }
}
/* hold the emoji back for a beat so it doesn't flash before the svg; it shows if js never runs */
.site-nav .nav-center > .nav-pill .nav-pill-i:not(.ti-on) { animation: ti-wait 1.2s step-end both; }
@keyframes ti-wait { from { visibility: hidden; } to { visibility: visible; } }
@media (prefers-reduced-motion: reduce) {
  .site-nav .nav-pill-i .ti { transition: none; }
}
