/* The old site's landscape behind the page (_atmosphere.html, atmosphere.js): the scene layers
 * only, so any page can take it without its page rules changing. COPIED from the old app's
 * web/static/css/atmosphere.css (the "Atmosphere", "moods", "Enchantment layer" and firefly
 * canvas rules, comments shortened); no reset, colour tokens, fonts or body rules here.
 * Layers: the scene at z-index 54 (birds too), the glow 45, the grain 48, the motes 60 and the
 * fireflies 61 (both pass clicks through). Page content goes at z-index 55 to sit on the scene.
 */

/* Pinned to the large viewport (lvh), so a phone's retracting address bar never opens a strip
   of page background at the bottom; the SVG is sliced, so painting past the fold is free. */
.atmosphere {
  position: fixed; top: 0; left: 0; right: 0; z-index: 54; pointer-events: none;
  height: calc(100vh + 2px);
  height: calc(100lvh + 2px);
  transition: filter 1.4s ease;
}
/* Between pages the old page fades into the new one, never cutting to an empty sky. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.atmosphere svg { display: block; width: 100%; height: 100%; pointer-events: none; }
#birdCanvas { position: fixed; inset: 0; z-index: 54; pointer-events: none; }
#particles { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#fireflyCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 61; opacity: 0;
                 transition: opacity 2s ease; }
#fireflyCanvas.visible { opacity: 1; }

.stone {
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center bottom;
  pointer-events: auto;
}
.stone:hover { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) {
  .stone { transition: none; }
  .stone:hover { transform: none; }
}
.stone, .stone .stone-hit { pointer-events: auto !important; }
.stone .stone-reflection { pointer-events: none; } /* rides with its stone, never widens the hover */
.mountain { transform-origin: center bottom; will-change: transform; }

/* The three tiers (data-tier on .atmosphere; the class is written by the server).
   Day ("active"): the cool misty baseline. */
.atmosphere:not(.is-caught-up):not(.is-night) { filter: saturate(1.12); }

/* Dusk ("caught_up"): the warm sunrise tint below, dimmed and pushed toward amber. */
.atmosphere.is-caught-up { filter: brightness(0.89) saturate(1.12); }
.atmosphere.is-caught-up ~ .home-vignette { opacity: 0 !important; }

/* Night: the sky is white, so a filter alone cannot add the blue; the night tint does. */
.atmosphere.is-night { filter: brightness(0.55) saturate(0.85); }

.atmosphere-night-tint {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s ease;
  background: linear-gradient(to bottom,
    rgba(6, 10, 28, 0.92) 0%,
    rgba(14, 22, 58, 0.82) 55%,
    rgba(28, 40, 88, 0.62) 100%);
}
.atmosphere.is-night .atmosphere-night-tint { opacity: 1; }

/* A violet sky warming down to a coral horizon, with a soft sun glow at the bottom edge. */
.atmosphere-dusk-tint {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
  background:
    radial-gradient(120% 58% at 50% 109%,
      rgba(255, 179, 121, 0.34) 0%,
      rgba(255, 149, 108, 0.15) 36%,
      rgba(255, 149, 108, 0) 64%),
    linear-gradient(to bottom,
      rgba(71, 63, 113, 0.64) 0%,
      rgba(102, 68, 119, 0.60) 34%,
      rgba(151, 83, 113, 0.56) 60%,
      rgba(213, 121, 104, 0.50) 85%,
      rgba(242, 168, 113, 0.45) 100%);
}
.atmosphere.is-caught-up .atmosphere-dusk-tint { opacity: 1; }

/* The soft pulsing glow and the light grain. */
@keyframes vignettePulse {
  0%,100% { opacity: 0.4; }
  50% { opacity: 0.55; }
}
.home-vignette {
  position: fixed; inset: 0; z-index: 45; pointer-events: none;
  background: radial-gradient(ellipse 80% 70% at 50% 50%, rgba(210,185,130,0.06) 0%, rgba(195,170,120,0.03) 40%, transparent 70%);
  animation: vignettePulse 20s ease-in-out infinite;
  transition: opacity 1.4s ease;
}
@media (prefers-reduced-motion: reduce) { .home-vignette { animation: none; } }
.noise-overlay {
  position: fixed; inset: 0; z-index: 48; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  transition: opacity 1.4s ease;
}
