/* Dark-only theme — near-black universe with glowing white accents (matches tools.fourfour3.cc) */

:root {
  color-scheme: dark;
  --ff-page: #050505;
  --ff-glow: #ffffff;
  --ff-glow-soft: rgba(255, 255, 255, 0.75);
  --ff-glow-dim: rgba(255, 255, 255, 0.12);
  --ff-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans",
    "Liberation Sans", Arial, sans-serif;
}

/* ——— Single fixed screen: no scrolling, bouncing, or pull-to-refresh ——— */
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background-color: var(--ff-page);
  color: #e8e8e8;
  font-family: var(--ff-font);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.universe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ——— Link stars ——— */
.link-star {
  --star-size: 60px;
  position: fixed;
  left: var(--x);
  top: var(--y);
  z-index: 1;
  width: var(--star-size);
  height: var(--star-size);
  display: grid;
  place-items: center;
  /* --dx / --dy are the live drift, parallax, and cursor pull set by js/link-stars.js */
  transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)));
  color: #fff;
  text-decoration: none;
  outline: none;
  touch-action: manipulation;
}

@media (max-width: 575.98px) {
  .link-star {
    --star-size: 52px;
    left: var(--x-sm, var(--x));
    top: var(--y-sm, var(--y));
  }
}

.link-star-glyph {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease, filter 0.35s ease;
  animation: starPulse 4.2s ease-in-out infinite;
}

/* Reacts to the cursor every frame (no transition, so it stays responsive) */
.link-star-ray {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  transform: scale(var(--boost, 1)) rotate(var(--tilt, 0deg));
  filter: brightness(var(--glow, 1));
}

/* Core */
.link-star-core {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #fff 45%, rgba(255, 255, 255, 0.85) 70%, rgba(255, 255, 255, 0) 100%);
  box-shadow:
    0 0 6px 1px rgba(255, 255, 255, 0.9),
    0 0 15px 3px rgba(255, 255, 255, 0.4),
    0 0 36px 9px rgba(255, 255, 255, 0.1);
}

/* Diffraction spikes */
.link-star-ray::before,
.link-star-ray::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  pointer-events: none;
}

.link-star-ray::before {
  width: 100%;
  height: 1.5px;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 50%, rgba(255, 255, 255, 0) 100%);
}

.link-star-ray::after {
  width: 1.5px;
  height: 100%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.95) 50%, rgba(255, 255, 255, 0) 100%);
}

/* Faint secondary diagonal spikes */
.link-star-core::before,
.link-star-core::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.link-star-core::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.link-star-core::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Site name — hidden until the star morphs */
.link-star-name {
  position: absolute;
  left: 50%;
  top: 50%;
  white-space: nowrap;
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.55), 0 0 18px rgba(255, 255, 255, 0.25), 0 0 36px rgba(255, 255, 255, 0.12);
  opacity: 0;
  filter: blur(8px);
  transform: translate(-50%, -50%) scale(0.35);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease, filter 0.4s ease;
  pointer-events: none;
}

/* Morphed state: hover (real pointers only), keyboard focus, or tapped */
@media (hover: hover) {
  .link-star:hover .link-star-glyph {
    opacity: 0;
    filter: blur(4px);
    transform: scale(0.15) rotate(45deg);
    animation-play-state: paused;
  }

  .link-star:hover .link-star-name {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
  }
}

.link-star:focus-visible .link-star-glyph,
.link-star.is-revealed .link-star-glyph {
  opacity: 0;
  filter: blur(4px);
  transform: scale(0.15) rotate(45deg);
  animation-play-state: paused;
}

.link-star:focus-visible .link-star-name,
.link-star.is-revealed .link-star-name {
  opacity: 1;
  filter: blur(0);
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* ——— Sound toggle ——— */
.sound-toggle {
  position: fixed;
  right: calc(0.75rem + env(safe-area-inset-right));
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 2;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.4s ease;
  animation: fadeIn 0.6s ease both;
}

.sound-toggle[hidden] {
  display: none;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  outline: none;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.sound-toggle svg {
  width: 0.7rem;
  height: 0.7rem;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
}

/* Keep a finger-sized tap target around the small visible button */
.sound-toggle::before {
  content: "";
  position: absolute;
  inset: -0.6rem;
}

.sound-toggle .icon-off {
  display: none;
}

.sound-toggle[aria-pressed="false"] .icon-on {
  display: none;
}

.sound-toggle[aria-pressed="false"] .icon-off {
  display: block;
}

/* Uses `scale` (not `transform`) so it composes with the morph transform. */
@keyframes starPulse {
  0%,
  100% {
    scale: 1;
  }
  50% {
    scale: 1.1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
