/* Display menu (light/dark and motion) and the motion switch, WCAG 2.2.2 Pause, Stop, Hide.
   Its own versioned file, not part of default.css/dark.css, so a returning visitor with a cached
   theme stylesheet (max-age 14400) still gets these rules with the new menu markup.
   Loaded right after #themeCSS, so at equal specificity these rules win over the theme's.
   Colours follow the theme: html.theme-dark is set before first paint by /js/site-theme-init.js
   and on every switch by /theme_selector.js. Values match themes/ergo/sass/default.scss and
   dark.scss ($background, $text, $outline, $accent, darken($accent, 6%)). */

:root {
  --ns-background: #fff;
  --ns-text: #000;
  --ns-outline: rgba(0, 0, 0, .2);
  --ns-accent: #1f7a1f;
  --ns-accent-edge: #196219;
}

html.theme-dark {
  --ns-background: #282a36;
  --ns-text: #f8f8f2;
  --ns-outline: rgba(248, 248, 242, .2);
  --ns-accent: #ff5555;
  --ns-accent-edge: #ff3636;
}

/* One round button pinned to the right end of the fixed bar, so it is on screen at every
   width; the link row is unchanged and passes underneath it where a screen is too narrow.
   /js/site-motion.js opens and closes the panel. */
.nav-settings {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  padding-left: 0.5rem;
  background: var(--ns-background);
  box-shadow: -14px 0 12px var(--ns-background);
}

.nav-settings-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--ns-outline);
  border-radius: 50%;
  background: transparent;
  color: var(--ns-text);
  cursor: pointer;
}

.nav-settings-button:hover,
.nav-settings-button[aria-expanded="true"] {
  background: var(--ns-accent);
  border-color: var(--ns-accent-edge);
  color: var(--ns-background);
}

.nav-settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2002;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.6rem;
  border: 1px solid var(--ns-outline);
  border-radius: 12px;
  background: var(--ns-background);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.nav-settings-panel[hidden] { display: none; }

/* Both switches show inside the panel at every width. Older theme CSS hides .theme-toggle on
   narrow screens (0,1,0); this (0,2,0) wins whichever theme file the browser has. */
.nav-settings-panel .theme-toggle,
.nav-settings-panel .motion-toggle {
  display: flex;
  justify-content: flex-start;
  min-height: 40px;
}

/* html.motion-off is set by /js/site-theme-init.js before the first paint and toggled by
   /js/site-motion.js. */
.motion-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--ns-outline);
  border-radius: 20px;
  background: transparent;
  color: var(--ns-text);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.motion-toggle:hover {
  background: var(--ns-accent);
  border-color: var(--ns-accent-edge);
  color: var(--ns-background);
}

.motion-toggle .motion-icon {
  font-size: 0.9rem;
  line-height: 1;
}

html.motion-off .motion-toggle {
  border-color: var(--ns-accent);
}

/* TownSquare: freeze its scene animations (clouds, birds, rain). Its own on/off switch hides it. */
html.motion-off #townsquare-root *,
html.motion-off #townsquare-root *::before,
html.motion-off #townsquare-root *::after {
  animation-play-state: paused !important;
}

/* Narrow screens (same breakpoint as the hamburger in _menu.scss): the display menu sits in the
   row, just left of the hamburger. */
@media (max-width: 1200px), (hover: none) and (pointer: coarse) {
  .nav-settings {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    padding-left: 0;
    box-shadow: none;
    order: 1;
  }

  .top-nav-hamburger {
    order: 2;
    margin-left: 0.25rem;
  }
}
