/* ────────────────────────────────────────────────────────────────
   Star-field mode switcher

   A button + dropdown menu in the hero's top-right that lets a visitor pin
   the background game mode instead of taking the random one. Built by
   js/main.js, which only inserts it on pages that actually have a hero
   star field.

   Deliberately quiet until hovered or focused: this sits on a marketing
   hero and must never compete with the primary CTA.
   ──────────────────────────────────────────────────────────────── */

.starfield-switch {
  position: absolute;
  right: 1.25rem;
  top: 1.25rem;
  z-index: 2; /* above .hero-particles (0), below the hero copy */
}

/* Toggle button (always visible) */
.starfield-switch-toggle {
  appearance: none;
  border: 2px solid rgba(255, 106, 26, 0.6);
  background: linear-gradient(135deg, rgba(10, 10, 14, 0.75), rgba(20, 15, 35, 0.75));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255, 106, 26, 0.25);

  display: flex;
  align-items: center;
  gap: 0.6rem;

  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgb(255, 255, 255);

  opacity: 0.9;
  transition: opacity 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease;
}

.starfield-switch-toggle:hover,
.starfield-switch-toggle:focus-visible {
  opacity: 1;
  border-color: rgba(255, 106, 26, 1);
  box-shadow: 0 0 24px rgba(255, 106, 26, 0.5);
  transform: scale(1.05);
}

.starfield-switch-toggle:focus-visible {
  outline: 2px solid rgba(255, 106, 26, 0.8);
  outline-offset: 1px;
}

.starfield-switch-icon {
  display: inline-block;
  font-size: 0.5rem;
  transition: transform 0.2s ease;
}

.starfield-switch-toggle[aria-expanded="true"] .starfield-switch-icon {
  transform: rotate(180deg);
}

/* Dropdown menu (hidden by default) */
.starfield-switch-menu {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  min-width: 140px;
  background: rgba(10, 10, 14, 0.95);
  border: 1px solid rgba(255, 106, 26, 0.3);
  border-radius: 6px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  max-height: 60vh;
  overflow-y: auto;
}

.starfield-switch-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.starfield-switch-menu hr {
  margin: 0.25rem 0;
  border: 0;
  border-top: 1px solid rgba(255, 106, 26, 0.15);
}

/* Menu items */
.starfield-switch-option {
  appearance: none;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  padding: 0.5rem 0.75rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.starfield-switch-option:hover {
  color: #fff;
  background: rgba(255, 106, 26, 0.12);
}

.starfield-switch-option:focus-visible {
  outline: 1px solid rgba(255, 106, 26, 0.6);
  outline-offset: -1px;
  background: rgba(255, 106, 26, 0.08);
}

/* Active/selected item */
.starfield-switch-option.is-active,
.starfield-switch-option[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 106, 26, 0.7), rgba(255, 138, 61, 0.5));
  box-shadow: inset 0 0 8px rgba(255, 106, 26, 0.25);
}

/* Screen-reader-only: names the mode actually on screen */
.starfield-switch-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .starfield-switch {
    right: 0.75rem;
    top: 0.75rem;
  }

  .starfield-switch-menu {
    right: -0.5rem;
    max-width: min(90vw, 200px);
  }
}

@media (hover: none) {
  .starfield-switch-toggle {
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  .starfield-switch-toggle,
  .starfield-switch-menu {
    transition: none;
  }
  .starfield-switch-icon {
    transition: none;
  }
  .starfield-switch-option {
    transition: none;
  }
}
