/* Barber Nexus shared motion language (blue, silver, black).
   Canonical copy: prototype/web/motion.css
   Mirror (keep byte-identical): landing/assets/motion.css
   Transform and opacity only. Reduced motion is static. */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --nx-trace-opacity: 0.09;
}

/* Tile URL: dashboard/tap use the fallback. Landing sets --nx-board-tile to its local SVG. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--nx-board-tile, url("/brand/circuit-trace.svg")) repeat;
  background-size: 416px 416px;
  opacity: var(--nx-trace-opacity);
}

/* Brighter pulse lines, 3.5s cycle, every width. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, transparent 0 206px, rgba(201, 206, 214, 0.4) 206px 207px, rgba(0, 160, 255, 0.75) 207px 209px, rgba(201, 206, 214, 0.4) 209px 210px, transparent 210px 416px),
    repeating-linear-gradient(0deg, transparent 0 310px, rgba(201, 206, 214, 0.35) 310px 311px, rgba(0, 160, 255, 0.65) 311px 313px, rgba(201, 206, 214, 0.35) 313px 314px, transparent 314px 416px);
  opacity: 0.55;
}

@media (prefers-reduced-motion: no-preference) {
  body::after { animation: board-pulse 3.5s var(--ease-in-out) infinite; }
  body::before { animation: board-shimmer 8s var(--ease-in-out) infinite; }
  /* Travelling highlight on pages that have a main column. */
  main::after {
    content: "";
    position: absolute;
    left: 17px;
    top: 24px;
    height: calc((100% - 52px) * 0.3);
    width: 3px;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 160, 255, 0.55) 28%, rgba(244, 246, 248, 1) 50%, rgba(0, 160, 255, 0.55) 72%, transparent 100%);
    opacity: 0;
    transform: translateY(-10%);
    animation: trace-flow 10s linear infinite;
    z-index: 0;
  }
}

/* Coming-soon page: keep body clear for lockup screen-blend. Ambient motion
   runs on .grid-floor / .grid-pulse after the entrance settles (see landing style.css). */
html.nx-entrance body::before,
html.nx-entrance body::after {
  content: none;
  animation: none;
}
html.nx-entrance main::after { content: none; animation: none; }

@keyframes board-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.9; } }
@keyframes board-shimmer { 0%, 100% { opacity: 0.12; } 50% { opacity: 0.35; } }
@keyframes trace-flow {
  0% { opacity: 0; transform: translateY(-10%); }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translateY(233%); }
}

/* Review-modal backdrop uses the same board language. */
.rv-overlay { isolation: isolate; }
.rv-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--nx-board-tile, url("/brand/circuit-trace.svg")) repeat;
  background-size: 416px 416px;
  opacity: var(--nx-trace-opacity);
}
.rv-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, transparent 0 206px, rgba(201, 206, 214, 0.4) 206px 207px, rgba(0, 160, 255, 0.75) 207px 209px, rgba(201, 206, 214, 0.4) 209px 210px, transparent 210px 416px),
    repeating-linear-gradient(0deg, transparent 0 310px, rgba(201, 206, 214, 0.35) 310px 311px, rgba(0, 160, 255, 0.65) 311px 313px, rgba(201, 206, 214, 0.35) 313px 314px, transparent 314px 416px);
  opacity: 0.55;
}
.rv-overlay > * { position: relative; z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  .rv-overlay::before { animation: board-shimmer 8s var(--ease-in-out) infinite; }
  .rv-overlay::after { animation: board-pulse 3.5s var(--ease-in-out) infinite; }
}

/* Same-origin page transitions. First load uses a fade only where the API is missing. */
@view-transition { navigation: auto; }

::view-transition-old(root) {
  animation: nx-vt-out 280ms var(--ease-out) both;
}
::view-transition-new(root) {
  animation: nx-vt-in 360ms var(--ease-out) both;
}
@keyframes nx-vt-out {
  to { opacity: 0; transform: translateY(-8px); }
}
@keyframes nx-vt-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@supports not (view-transition-name: none) {
  @media (prefers-reduced-motion: no-preference) {
    html:not(.nx-entrance) body {
      animation: nx-page-enter 360ms var(--ease-out) both;
    }
  }
}
@keyframes nx-page-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  body::before,
  body::after,
  main::after,
  .rv-overlay::before,
  .rv-overlay::after {
    animation: none !important;
  }
  body::before,
  .rv-overlay::before { opacity: var(--nx-trace-opacity); }
  body::after,
  .rv-overlay::after { opacity: 0.4; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none !important; }
  html:not(.nx-entrance) body { animation: none !important; }
}
