/* ---- Nugget Simulator ---- */

/* The diorama takes over the whole screen (below the HUD). */
#simWorld {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: none;
  pointer-events: none;
  background: #0b1120; /* letterbox color while the SVG covers via slice */
}
#simWorld.active { display: block; }
#simWorld svg { display: block; }

/* 🕶️ Ultra Realistic mode. Nuggets cannot see. */
#simVoid {
  position: fixed;
  inset: 0;
  z-index: 9991;
  display: none;
  background: #000;
  pointer-events: none;
}
#simVoid.active { display: block; }

/* Sub-mode switch lives in the HUD, only while the simulator is running */
#simSubSwitch { display: none; }
#simSubSwitch.active { display: inline-flex; }

/* Twinkling stars */
@keyframes simTwinkle {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}
.sim-star { animation: simTwinkle 3s ease-in-out infinite; }

/* Firefly wander + blink */
@keyframes simFlyDrift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(26px, -20px); }
  50%  { transform: translate(-14px, -34px); }
  75%  { transform: translate(-30px, -10px); }
  100% { transform: translate(0, 0); }
}
@keyframes simFlyBlink {
  0%, 100% { opacity: 0.15; }
  12%, 22% { opacity: 1; }
  34%      { opacity: 0.2; }
}
.sim-fly {
  animation: simFlyDrift 11s ease-in-out infinite, simFlyBlink 4.5s ease-in-out infinite;
}

/* Canopy sway — anchored at the trunk so the tree leans, not slides */
@keyframes simSway {
  0%, 100% { transform: rotate(-0.7deg); }
  50%      { transform: rotate(0.9deg); }
}
.sim-canopy {
  animation: simSway 7s ease-in-out infinite;
  transform-origin: 1210px 640px;
  transform-box: view-box;
}

/* Grass shiver */
@keyframes simGrassSway {
  0%, 100% { transform: skewX(-3deg); }
  50%      { transform: skewX(4deg); }
}
.sim-sway {
  animation: simGrassSway 3.6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: bottom center;
}

/* The nugget's gentle idle breathing */
@keyframes simBreathe {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50%      { transform: translateY(1.6px) scale(1.012, 0.988); }
}
.sim-breathe {
  animation: simBreathe 4.2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center bottom;
}

/* Wing flap for passing flocks */
@keyframes simFlap {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(0.35); }
}
.sim-wing {
  animation: simFlap 0.6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* Aging accessories fade in gracefully */
#simGlasses, #simTuft, #simCane { transition: opacity 1.2s ease; }
#simNugImg { transition: filter 2s linear; }
#simCanopy { transition: filter 3s ease; } /* seasons recolor the tree */

/* ---- THE OVEN RELIGHT: weather overlays + enlightenment ---- */
.sim-wx { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.4s ease; }
.sim-wx.on { opacity: 1; }

/* Rain: fast diagonal streaks */
.sim-rain {
  background-image: repeating-linear-gradient(105deg,
    rgba(180, 205, 235, 0) 0 12px, rgba(180, 205, 235, 0.35) 12px 13px, rgba(180, 205, 235, 0) 13px 22px);
  background-size: 200px 200px;
  animation: simRain 0.4s linear infinite;
}
@keyframes simRain { from { background-position: 0 0; } to { background-position: -60px 200px; } }
.sim-rain.on { opacity: 0.55; }

/* Fog: a soft drifting bank */
.sim-fog {
  background: radial-gradient(120% 60% at 30% 72%, rgba(220, 228, 236, 0.5), rgba(220, 228, 236, 0) 60%),
              radial-gradient(120% 60% at 76% 62%, rgba(220, 228, 236, 0.4), rgba(220, 228, 236, 0) 60%);
  animation: simFog 18s ease-in-out infinite alternate;
}
@keyframes simFog { from { transform: translateX(-4%); } to { transform: translateX(4%); } }
.sim-fog.on { opacity: 0.7; }

/* Aurora: shimmering colored bands across the top of the sky */
.sim-aurora {
  background: linear-gradient(180deg, rgba(80, 255, 180, 0.3) 0%, rgba(90, 160, 255, 0.18) 18%, rgba(180, 120, 255, 0.12) 33%, transparent 46%);
  filter: blur(6px);
  animation: simAurora 6s ease-in-out infinite alternate;
  transform-origin: top;
}
@keyframes simAurora {
  from { transform: skewX(-6deg) scaleY(0.95); opacity: 0.7; }
  to   { transform: skewX(6deg) scaleY(1.08); opacity: 1; }
}

/* Enlightenment: the old nugget quietly glows */
#simNugget.sim-enlightened { filter: drop-shadow(0 0 22px rgba(255, 222, 130, 0.95)) drop-shadow(0 0 42px rgba(255, 200, 90, 0.5)); }
