/* Floating scene navigation — bottom-left, outside the collage */
.nav {
  position: absolute;
  z-index: var(--z-nav);
  right: calc(100% + 1.75rem);
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  pointer-events: auto;
  transition: translate 700ms var(--ease-scene);
}

/* During a scene change the navigation drifts slightly instead of disappearing. */
.nav.is-traveling {
  translate: -6px 8px;
}

.nav__item {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.25rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-white);
  /* Lifted off the world like the Factory cards: a hairline edge so white never melts into the
     paper, a crisp top highlight and a soft layered shadow beneath */
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent),
    var(--card-edge),
    var(--shadow-nav-raised);
}

.nav__item[aria-current="page"] {
  background: var(--ink);
  color: var(--bg);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.18),
    inset 0 0 0 1px rgb(255 255 255 / 0.06),
    var(--shadow-nav-raised);
}

/* Pulse ring: the active section pulses calmly, Vector a little faster. */
.nav__item::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.nav__item[aria-current="page"]::after {
  animation: nav-pulse 2.8s ease-out infinite;
}

.nav__item--vector::after {
  animation: nav-pulse 1.9s ease-out infinite;
}

@keyframes nav-pulse {
  from { opacity: 0.55; transform: scale(0.92); }
  to   { opacity: 0;    transform: scale(1.35); }
}

/* ---- Live previews (js/systems/nav-previews.js) -------------------------------------- */
.nav__preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
  pointer-events: none;
}

.nav__preview > * {
  grid-area: 1 / 1;
}

/* Factory: a tiny card, filled (alive) */
/* Factory: a tiny version of the collage, every card filled (alive) */
.mini-collage {
  position: relative;
  width: 28px;
  height: 20px;
}

.mini-collage__card {
  position: absolute;
  border-radius: 2.5px;
  box-shadow: 0 1px 1.5px rgb(17 17 17 / 0.14);
}

.mini-collage__card--about { left: 0;    top: 0;    width: 10px; height: 20px; background: var(--surface-purple); }
.mini-collage__card--media { left: 12px; top: 3px;  width: 16px; height: 8px;  background: var(--surface-media); }
.mini-collage__card--small { left: 12px; top: 13px; width: 6px;  height: 7px;  background: var(--surface-graphite); }
.mini-collage__card--dark  { left: 20px; top: 13px; width: 8px;  height: 7px;  background: var(--surface-black); }

/* On the active (ink) button the black card keeps a faint edge so it never disappears */
.nav__item[aria-current="page"] .mini-collage__card--dark {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.3);
}

/* Universe: a tiny solar system on its own canvas */
.mini-system {
  width: 46px;
  height: 46px;
}

/* Vector: canvas drawn by the shared entity engine */
.mini-vector {
  width: 48px;
  height: 48px;
}

/* Build Your: a tiny browser window with a skeleton that rebuilds */
.mini-window {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 28px;
  height: 21px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 4px;
  background: var(--surface-white);
  box-shadow: 0 1px 1.5px rgb(17 17 17 / 0.1);
}

.mini-window__bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 1.5px;
  height: 5px;
  padding-left: 2px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}

.mini-window__bar i {
  width: 1.6px;
  height: 1.6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}

.mini-window__page {
  position: relative;
  flex: 1;
}

.mini-window__block {
  position: absolute;
  border-radius: 1px;
  background: color-mix(in srgb, var(--ink) 30%, transparent);
}

.mini-window__block.is-accent {
  background: var(--surface-purple);
}

/* The scan layer is page-sized, so translating it by 100% sweeps its top edge down the page. */
.mini-window__scan {
  position: absolute;
  inset: 0;
  border-top: 1.5px solid var(--surface-purple);
  opacity: 0;
}

/* ---- Scene hints ---------------------------------------------------------------------- */
.nav__dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  aspect-ratio: 1;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  scale: 0.4;
  transition: opacity 180ms ease-out, scale 180ms ease-out;
  pointer-events: none;
}

.nav__item.has-dot .nav__dot,
.nav__item.is-thinking .nav__dot {
  opacity: 1;
  scale: 1;
}

.nav__item.is-thinking .nav__dot {
  animation: nav-thinking 0.9s ease-in-out infinite alternate;
}

@keyframes nav-thinking {
  from { opacity: 0.45; }
  to   { opacity: 1; }
}

/* Build Your progress: a thin arc around the item */
.nav__ring {
  position: absolute;
  inset: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  rotate: -90deg;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.nav__ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: var(--progress, 0) 1;
  transition: stroke-dasharray 400ms ease-out;
}

.nav__item.has-progress .nav__ring {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  /* As specific as the rules that start the pulse, so this always wins */
  .nav__item::after,
  .nav__item[aria-current="page"]::after,
  .nav__item--vector::after,
  .nav__item.is-thinking .nav__dot {
    animation: none;
  }

  .nav__ring circle {
    transition: none;
  }
}

/* ---- Labels ----------------------------------------------------------------------------- */
.nav__label {
  position: absolute;
  left: calc(100% + 0.75rem);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  box-shadow: 0 4px 14px rgb(17 17 17 / 0.12);
  color: var(--bg);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  translate: -6px 0;
  scale: 0.96;
  transform-origin: left center;
  pointer-events: none;
  transition: opacity 180ms ease-out, translate 180ms ease-out, scale 180ms ease-out;
}

.nav__item:hover .nav__label,
.nav__item:focus-visible .nav__label {
  opacity: 1;
  translate: 0 0;
  scale: 1;
}

.nav__item:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---- Theme toggle: a tiny round button in the bottom-right corner ------------------------ */
.theme-toggle {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: var(--z-nav);
  display: grid;
  place-items: center;
  width: 34px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-white);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent), var(--card-edge), var(--shadow-nav-raised);
  color: var(--ink);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
