/* Moving between the two nights (movie night / game night). The link is a
   pill with its own colour (--night-accent); on hover or keyboard focus a
   little sprite runs round its border: Pac-Man for game night, a film reel for
   movie night. The orbit uses percentages of the link, so it fits any width. */
.night-switch {
  --night-accent: var(--bulb, #ffc76e);
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  padding: 0 14px; border: 2px solid var(--night-accent); border-radius: 999px;
  color: var(--night-accent); text-decoration: none; font-size: inherit;
  transition: background-color 120ms ease, color 120ms ease;
}
/* a tint, not a fill: the sprite has to show against it */
.night-switch:not([aria-current]):is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--night-accent) 22%, transparent);
}
.night-switch[aria-current] { cursor: default; }

/* the sprite: hidden until the link is hovered or focused */
.night-switch .runner {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: 0;
  pointer-events: none; opacity: 0; transform: translate(-50%, -50%);
}
.night-switch:not([aria-current]):is(:hover, :focus-visible) .runner {
  opacity: 1; animation: orbit 1.8s linear infinite;
}

/* round the edge: corner to corner, rotating so the sprite faces its way */
@keyframes orbit {
  0%   { left: 0%;   top: 0%;   transform: translate(-50%, -50%) rotate(0deg); }
  25%  { left: 100%; top: 0%;   transform: translate(-50%, -50%) rotate(90deg); }
  50%  { left: 100%; top: 100%; transform: translate(-50%, -50%) rotate(180deg); }
  75%  { left: 0%;   top: 100%; transform: translate(-50%, -50%) rotate(270deg); }
  100% { left: 0%;   top: 0%;   transform: translate(-50%, -50%) rotate(360deg); }
}

/* Pac-Man: a yellow disc whose mouth opens and shuts as it goes */
@property --mouth { syntax: '<angle>'; inherits: false; initial-value: 30deg; }
.runner-pac {
  --mouth: 30deg;
  border-radius: 50%;
  background: conic-gradient(from calc(90deg + var(--mouth)), #ffd400 0 calc(360deg - 2 * var(--mouth)), transparent 0);
}
.night-switch:not([aria-current]):is(:hover, :focus-visible) .runner-pac {
  animation: orbit 1.8s linear infinite, chomp 260ms steps(1) infinite;
}
@keyframes chomp {
  0%   { --mouth: 4deg; }
  50%  { --mouth: 38deg; }
  100% { --mouth: 4deg; }
}

/* the film reel: a white disc with holes, the holes turning as it rolls */
.runner-reel {
  border-radius: 50%; background-color: #f4f1ea;
  background-image:
    radial-gradient(circle, #14101c 1.4px, transparent 1.9px),
    radial-gradient(circle, #14101c 1.2px, transparent 1.7px),
    radial-gradient(circle, #14101c 1.2px, transparent 1.7px),
    radial-gradient(circle, #14101c 1.2px, transparent 1.7px);
  background-size: 6px 6px, 3px 3px, 3px 3px, 3px 3px;
  background-position: 4px 4px, 5.5px 1px, 1px 8px, 9px 8px;
  background-repeat: no-repeat;
}

@media (prefers-reduced-motion: reduce) {
  .night-switch .runner { animation: none !important; }
}
