/* ==========================================
   SMARTOVAL // WINTER AIR
   Scene artwork + apparition + collectible
   ========================================== */

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #03070c; }
body { overflow: hidden; color: #e6edf2; font-family: "Courier New", monospace; }
button, a { font: inherit; }

.snowfield-page {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #03070c;
}

/* Keep the entire WIP visible. Percent-based overlays stay aligned. */
.snowfield-stage {
  
  --ghost-x: 84%;
  --ghost-bottom: 24%;
  --ghost-width: 14%;
  --ghost-height: 40%;


  --glow-x: 85%;
  --glow-y: 77%;

  position: relative;
  width: min(100vw, 208.4803dvh);
  max-height: 100dvh;
  aspect-ratio: 3073 / 1474;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.6s ease;
  background: #17222d;
}
.snowfield-stage.is-visible { opacity: 1; }


/* ==========================================
   SNOWFIELD / BACKGROUND CROSSFADE
   ========================================== */

/* Both backgrounds share the same position */

.snowfield-background,
.snowfield-background-glowing {
  position: absolute;
  inset: 0;

  background-color: #17222d;

  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;

  pointer-events: none;
}

/* Original background */

.snowfield-background {
  background-image:
    url("assets/snowfield.png");
}

/* Illuminated background */

.snowfield-background-glowing {
  z-index: 0;

  background-image:
    url("assets/snowfield2.png");

  opacity: 0;

  transition:
    opacity 3s ease-in-out;
}

/* Reveal the illuminated background */

.snowfield-background-glowing.is-visible {
  opacity: 1;
}



/* ghost.png should have a transparent background. */
.snowfield-ghost {
  position: absolute;
  z-index: 2;
  left: var(--ghost-x);
  bottom: var(--ghost-bottom);
  width: var(--ghost-width);
  height: var(--ghost-height);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 3s ease-in;
}
.snowfield-ghost.is-visible { opacity: 0.68; }
.snowfield-ghost-image {
  width: 100%;
  height: 100%;
  background: url("assets/ghost.png") center bottom / contain no-repeat;
  filter: drop-shadow(0 0 12px rgba(174, 208, 240, 0.22));
  animation:
    snowfield-float 5.8s ease-in-out infinite,
    snowfield-signal 8s steps(1, end) infinite;
}
@keyframes snowfield-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.5%); }
}
@keyframes snowfield-signal {
  0%, 44%, 46%, 70%, 72%, 100% { opacity: 1; }
  45%, 71% { opacity: 0.72; }
  45.5% { opacity: 0.9; }
}

/* Soft blue glow over the object already painted into the background. */

/* ==========================================
   BLUE GLOW / BREATHING + SMOOTH FADING
   ========================================== */

.snowfield-glow {
  position: absolute;
  z-index: 3;

  left: var(--glow-x);
  top: var(--glow-y);

  width: 14%;
  aspect-ratio: 2 / 1;

  transform: translate(-50%, -50%);

  opacity: 0;

  pointer-events: none;

  /* Fade the entire effect in and out */

  transition: opacity 3s ease-in-out;
}

/* Breathing effect lives on a separate layer */

.snowfield-glow::before {
  content: "";

  position: absolute;
  inset: 0;

  border-radius: 50%;

  background: radial-gradient(
    ellipse,
    rgba(194, 235, 255, 0.78) 0%,
    rgba(89, 169, 255, 0.35) 35%,
    rgba(58, 139, 240, 0) 74%
  );

  mix-blend-mode: screen;

  animation:
    snowfield-breathe 3.4s ease-in-out infinite;
}

/* Glow becomes visible */

.snowfield-glow.is-visible {
  opacity: 1;
}

/* Continuous breathing */

@keyframes snowfield-breathe {

  0%, 100% {
    opacity: 0.45;
    transform: scale(0.92);
    filter: blur(5px);
  }

  50% {
    opacity: 0.9;
    transform: scale(1.13);
    filter: blur(8px);
  }

}


.snowfield-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse at center,
    transparent 48%, rgba(0, 4, 12, 0.45) 100%);
  pointer-events: none;
}

.snowfield-location, .snowfield-audio-button {
  position: fixed;
  z-index: 15;
  top: 20px;
  color: #c3d1df;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-shadow: 0 2px 8px #02060a;
}
.snowfield-location { left: 22px; }
.snowfield-audio-button {
  right: 22px;
  padding: 9px 12px;
  background: rgba(8, 16, 25, 0.78);
  border: 1px solid rgba(153, 178, 203, 0.55);
  cursor: pointer;
}
.snowfield-audio-button:hover { background: #23394c; }

/* Reuses vn.css, with a cold palette regardless of older vn.css versions. */
.snowfield-dialogue.vn-panel {
  --vn-bg: rgba(8, 13, 20, 0.91);
  --vn-border: #8398ab;
  --vn-text-color: #e5edf4;
  --vn-accent: #aac7e2;
  --vn-button-bg: #1a2a39;
  --vn-button-hover: #293e51;
  z-index: 20;
  background: var(--vn-bg);
  border-color: var(--vn-border);
  color: var(--vn-text-color);
}
.snowfield-dialogue .vn-text {
  color: var(--vn-text-color);
  min-height: 3.1em;
}
.snowfield-dialogue.is-typing .vn-text::after { color: var(--vn-accent); }
.snowfield-dialogue .vn-text.is-narration { font-style: italic; }
.snowfield-dialogue-hint {
  margin: 10px 0 0;
  text-align: right;
  color: #a9bfd2;
  font-size: 10px;
  letter-spacing: 0.09em;
}
.snowfield-dialogue-hint[hidden] { display: none; }

/* Fragment floats over the same percentage coordinate as the blue glow. */
.snowfield-fragment {
  position: absolute;
  z-index: 25;
  left: var(--glow-x);
  top: var(--glow-y);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 150px;
  padding: 11px 15px;
  transform: translate(-50%, -35%);
  opacity: 0;
  background: rgba(8, 18, 30, 0.89);
  border: 1px solid #a4c8e6;
  box-shadow: 0 0 20px rgba(104, 180, 250, 0.26);
  color: #dcefff;
  cursor: pointer;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.snowfield-fragment[hidden] { display: none !important; }
.snowfield-fragment.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%);
}
.snowfield-fragment.is-collected {
  opacity: 0;
  transform: translate(-50%, -65%) scale(0.93);
  pointer-events: none;
}
.snowfield-fragment-heading, .snowfield-fragment-id,
.snowfield-fragment-prompt { font-size: 10px; white-space: nowrap; }
.snowfield-fragment-symbol {
  font-size: 38px;
  line-height: 1;
  text-shadow: 0 0 15px #8dd5ff;
}
.snowfield-fragment:focus-visible,
.snowfield-audio-button:focus-visible,
.snowfield-return:focus-visible {
  outline: 2px solid #b7e1ff;
  outline-offset: 4px;
}

.snowfield-notification {
  position: fixed;
  z-index: 40;
  top: 13%;
  left: 50%;
  transform: translate(-50%, -10px);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  background: rgba(7, 16, 27, 0.94);
  border: 1px solid #94bedf;
  color: #e2f2ff;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s;
}
.snowfield-notification.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.snowfield-return {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 12px 20px;
  background: rgba(8, 17, 27, 0.92);
  border: 1px solid #94bedf;
  color: #e3f0fa;
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}
.snowfield-return[hidden] { display: none !important; }
.snowfield-return:hover { background: #253c4e; }

@media (max-width: 600px) {
  .snowfield-location { top: 12px; left: 12px; font-size: 10px; }
  .snowfield-audio-button { top: 12px; right: 12px; font-size: 10px; padding: 8px; }
  .snowfield-dialogue.vn-panel { bottom: max(12px, env(safe-area-inset-bottom)); }
  .snowfield-fragment { min-width: 115px; padding: 8px; gap: 3px; }
  .snowfield-fragment-heading, .snowfield-fragment-id,
  .snowfield-fragment-prompt { font-size: 8px; }
  .snowfield-fragment-symbol { font-size: 29px; }
  .snowfield-return { font-size: 11px; padding: 12px 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .snowfield-stage, .snowfield-ghost, .snowfield-glow,
  .snowfield-fragment { transition-duration: 0.01ms; }
  .snowfield-ghost-image, .snowfield-glow { animation: none !important; }
}


/* ==========================================
   SNOWFIELD / LARGER DIALOGUE BOX
   ========================================== */

.snowfield-dialogue.vn-panel {

  /* Larger overall width */

  width: min(
    1080px,
    calc(100% - 36px)
  );

  /* Consistent height before typing */

  min-height: 230px;

  /* More breathing room */

  padding: 30px 36px 22px;

  /* Keep text at top, continue hint at bottom */

  display: flex;
  flex-direction: column;
  justify-content: space-between;

}

/* Dialogue text */

.snowfield-dialogue .vn-text {

  /* Reserve space before text appears */

  min-height: 5em;

  font-size: clamp(
    17px,
    1.7vw,
    21px
  );

  line-height: 1.65;

}

/* Mobile adjustments */

@media (max-width: 600px) {

  .snowfield-dialogue.vn-panel {

    width: calc(100% - 20px);

    min-height: 195px;

    max-height: 65dvh;
    overflow-y: auto;

    padding: 20px 18px 16px;

  }

  .snowfield-dialogue .vn-text {

    min-height: 5em;

    font-size: 16px;
    line-height: 1.6;

  }

}


/* ==========================================
   GHOST / MEMORY COLLECTION EFFECTS
   ========================================== */

/* Ghost slowly dissolves after collection */

.snowfield-ghost.is-dissolving {
  opacity: 0;
  transition: opacity 3s ease-out;
}

/* Return button inside revisit dialogue */

.snowfield-revisit-return {
  align-self: flex-end;
  margin-top: 18px;
}

.snowfield-revisit-return[hidden] {
  display: none !important;
}


/* ==========================================
   SNOWFIELD / GHOST SIGNAL INTERFERENCE
   ========================================== */

/* Brief disturbance when the ghost appears */

.snowfield-dialogue.is-interfering {
  animation:
    snowfield-panel-interference
    0.85s steps(1, end) 1;
}

/* Text shifts slightly during interference */

.snowfield-dialogue.is-interfering .vn-text {
  animation:
    snowfield-text-interference
    0.85s steps(1, end) 1;
}

@keyframes snowfield-panel-interference {

  0%, 100% {
    filter: brightness(1);
  }

  12% {
    filter: brightness(1.5);
  }

  18% {
    filter: brightness(0.65);
  }

  24% {
    filter: brightness(1.2);
  }

  42% {
    filter: brightness(0.85);
  }

  48% {
    filter: brightness(1.35);
  }

  60% {
    filter: brightness(1);
  }

}

@keyframes snowfield-text-interference {

  0%, 100% {
    transform: translateX(0);
    text-shadow: none;
  }

  18% {
    transform: translateX(3px);
    text-shadow: -2px 0 #77baff;
  }

  24% {
    transform: translateX(-4px);
    text-shadow: 2px 0 #d7eaff;
  }

  48% {
    transform: translateX(2px);
    text-shadow: -2px 0 #77baff;
  }

  60% {
    transform: translateX(0);
    text-shadow: none;
  }

}

/* Accessibility */

@media (prefers-reduced-motion: reduce) {

  .snowfield-dialogue.is-interfering,
  .snowfield-dialogue.is-interfering .vn-text {
    animation: none;
  }

}


/* ==========================================
   SNOWFIELD / RETURNING VISITOR ATMOSPHERE
   ========================================== */

/* Smooth transition for background lighting */

.snowfield-background {
  transition:
    filter 1.8s ease-in-out;
}

/* Darker, less saturated environment */

.snowfield-stage.is-revisit .snowfield-background {
  filter:
    brightness(0.78)
    saturate(0.65);
}

/* Slightly heavier vignette */

.snowfield-stage.is-revisit .snowfield-vignette {
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0, 4, 12, 0.65) 100%
  );
}
