/* ============================================
   ENVIRONMENT — Atmospheric Systems Layer
   ============================================ */

/* --- Grid Overlay --- */
.env-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 30%, transparent 80%);
}

/* --- Noise Texture --- */
.env-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.028;
  mix-blend-mode: overlay;
}

.env-noise svg {
  width: 100%;
  height: 100%;
}

/* --- Ambient Gradients --- */
.env-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.env-ambient__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  will-change: transform;
}

.env-ambient__orb--1 {
  width: 50vw;
  height: 50vh;
  top: -15%;
  left: -10%;
  background: radial-gradient(circle, rgba(74, 222, 128, 0.025) 0%, transparent 70%);
  animation: drift-1 25s ease-in-out infinite;
}

.env-ambient__orb--2 {
  width: 40vw;
  height: 40vh;
  bottom: -10%;
  right: -15%;
  background: radial-gradient(circle, rgba(103, 232, 249, 0.018) 0%, transparent 70%);
  animation: drift-2 30s ease-in-out infinite;
}

.env-ambient__orb--3 {
  width: 35vw;
  height: 35vh;
  top: 40%;
  left: 50%;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.015) 0%, transparent 70%);
  animation: drift-3 22s ease-in-out infinite;
}

@keyframes drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(8vw, 5vh) scale(1.05); }
  66% { transform: translate(-3vw, 8vh) scale(0.95); }
}

@keyframes drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-6vw, -4vh) scale(1.08); }
  66% { transform: translate(4vw, -7vh) scale(0.96); }
}

@keyframes drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(5vw, -6vh) scale(0.97); }
  66% { transform: translate(-7vw, 3vh) scale(1.04); }
}

/* --- Cursor Gradient --- */
.env-cursor {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.04) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  will-change: transform;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.env-cursor--visible {
  opacity: 1;
}

/* --- Cinematic Lighting — Per Section --- */
.section-light {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 1px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.section-light--bottom {
  top: auto;
  bottom: 0;
}

/* --- Vignette --- */
.env-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse 70% 60% at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
}

/* --- Star Field --- */
.env-stars {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 52vh;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 78%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 78%, transparent 100%);
}

.env-stars__dot {
  position: absolute;
  width: var(--size, 2px);
  height: var(--size, 2px);
  border-radius: 50%;
  background: rgba(228, 248, 240, 0.9);
  opacity: var(--op, 0.7);
  box-shadow: 0 0 8px rgba(167, 243, 208, 0.28);
  animation: star-twinkle var(--tw, 4.4s) ease-in-out var(--delay, 0s) infinite;
}

@keyframes star-twinkle {
  0%, 100% { opacity: calc(var(--op, 0.7) * 0.55); }
  50% { opacity: var(--op, 0.7); }
}

/* --- Moon --- */
.env-moon {
  position: fixed;
  top: 8vh;
  right: 10vw;
  width: clamp(56px, 7vw, 108px);
  height: clamp(56px, 7vw, 108px);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.96) 0%, rgba(230, 243, 248, 0.93) 44%, rgba(184, 214, 224, 0.76) 100%);
  box-shadow:
    0 0 34px rgba(197, 238, 247, 0.35),
    0 0 80px rgba(167, 243, 208, 0.18);
  animation: moon-drift 24s ease-in-out infinite;
}

.env-moon::before {
  content: '';
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 1px solid rgba(182, 211, 221, 0.25);
}

@keyframes moon-drift {
  0%, 100% { transform: translateY(0px) translateX(0px); }
  50% { transform: translateY(8px) translateX(-4px); }
}

/* --- Section Glow --- */
.section-glow {
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 222, 128, 0.02) 0%, transparent 70%);
  pointer-events: none;
  filter: blur(60px);
}

/* --- Calm Water Landscape --- */
.env-water {
  display: none !important;
  --rx: 50%;
  --ry: 72%;
  --water-drift-x: 0px;
  --water-drift-y: 0px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64vh;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  background: linear-gradient(
    to top,
    rgba(13, 10, 8, 0.98) 0%,
    rgba(20, 17, 13, 0.96) 12%,
    rgba(9, 32, 53, 0.9) 20%,
    rgba(7, 28, 47, 0.72) 48%,
    rgba(7, 28, 47, 0.1) 100%
  );
  mask-image: linear-gradient(to top, black 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, black 72%, transparent 100%);
}

.env-water__surface {
  position: absolute;
  inset: 0;
  transform-origin: center bottom;
  transform: perspective(1200px) rotateX(67deg) scale(1.1);
  background:
    linear-gradient(to top, rgba(10, 66, 98, 0.34), rgba(8, 58, 88, 0.03) 62%, transparent 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(188, 233, 255, 0.16) 0px,
      rgba(188, 233, 255, 0.16) 1px,
      transparent 1px,
      transparent 18px
    );
  opacity: 0.8;
}

.env-water__swells {
  position: absolute;
  inset: -6% -3%;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(210, 240, 255, 0.22) 0px,
      rgba(210, 240, 255, 0.22) 2px,
      transparent 1px,
      transparent 22px
    ),
    linear-gradient(to top, rgba(17, 58, 85, 0.24), transparent 76%);
  opacity: 0.46;
  transform: translate3d(var(--water-drift-x), var(--water-drift-y), 0);
  animation: water-flow 18s linear infinite;
}

.env-water__shimmer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 82% 14%, rgba(226, 245, 255, 0.35) 0%, rgba(226, 245, 255, 0.12) 18%, transparent 44%),
    linear-gradient(to bottom, rgba(220, 245, 255, 0.24) 0%, transparent 55%),
    radial-gradient(circle at var(--rx) var(--ry), rgba(186, 245, 255, 0.22) 0%, rgba(186, 245, 255, 0.08) 12%, transparent 26%),
    linear-gradient(to top, rgba(61, 141, 178, 0.12), transparent 72%);
  mix-blend-mode: screen;
  animation: water-calm 9s ease-in-out infinite;
}

.env-water::before {
  content: '';
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: 0;
  height: 16%;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(90, 128, 149, 0.38) 0%, transparent 60%),
    linear-gradient(to top, rgba(26, 21, 16, 0.98) 0%, rgba(26, 21, 16, 0.44) 65%, transparent 100%);
  border-top: 2px solid rgba(193, 232, 252, 0.3);
}

.env-water::after {
  content: '';
  position: absolute;
  top: 6%;
  bottom: 16%;
  right: 14%;
  width: 10%;
  background: linear-gradient(
    to bottom,
    rgba(232, 248, 255, 0.02) 0%,
    rgba(232, 248, 255, 0.3) 18%,
    rgba(232, 248, 255, 0.2) 50%,
    rgba(232, 248, 255, 0.05) 100%
  );
  filter: blur(2px);
  opacity: 0.8;
  transform: skewX(-4deg);
}

.env-horizon {
  position: fixed;
  left: 0;
  right: 0;
  bottom: min(40vh, 320px);
  height: 28vh;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(159, 236, 255, 0.24) 0%, rgba(159, 236, 255, 0.08) 36%, transparent 72%),
    linear-gradient(to top, rgba(10, 31, 47, 0.34) 0%, rgba(10, 31, 47, 0.05) 54%, transparent 100%);
  mask-image: linear-gradient(to top, black 0%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, black 0%, transparent 100%);
}

@keyframes water-flow {
  0% {
    transform: translate3d(calc(var(--water-drift-x) * 0.85), calc(var(--water-drift-y) * 0.6), 0);
  }
  50% {
    transform: translate3d(calc(var(--water-drift-x) * 1.1), calc(var(--water-drift-y) * 1.05), 0);
  }
  100% {
    transform: translate3d(calc(var(--water-drift-x) * 0.85), calc(var(--water-drift-y) * 0.6), 0);
  }
}

@keyframes water-calm {
  0%, 100% {
    opacity: 0.72;
  }
  50% {
    opacity: 0.92;
  }
}
