/* Example Ui · scene.css
 * The little game world behind every generated UI. Pure CSS, sized in container units so it scales with
 * the device screen it sits in. data-scene="day" is a sunny simulator map, "night" a neon arena. */

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  container-type: size;
  pointer-events: none;
  background: linear-gradient(#4ea9f2 0%, #8fd0ff 40%, #d6f1ff 58%, #d6f1ff 100%);
}

.scene > i { position: absolute; display: block; }

/* ---------------------------------------------------------------- day */
.sc-sun {
  right: 10%; top: 7%;
  width: 11cqw; aspect-ratio: 1; border-radius: 50%;
  background: #fff6c2;
  box-shadow: 0 0 0 2.5cqw rgba(255, 246, 194, .28), 0 0 0 6cqw rgba(255, 246, 194, .14);
}

.sc-cloud {
  height: 4cqw; border-radius: 4cqw;
  background: #fff;
  box-shadow: 3.5cqw -1.800cqw 0 .6cqw #fff, 8cqw -.4cqw 0 -.3cqw #fff;
  opacity: .96;
  animation: sc-drift 46s linear infinite alternate;
}
.sc-cloud--a { left: 6%; top: 13%; width: 12cqw; }
.sc-cloud--b { left: 44%; top: 6%; width: 9cqw; opacity: .8; animation-duration: 64s; }
.sc-cloud--c { left: 70%; top: 24%; width: 14cqw; opacity: .7; animation-duration: 80s; animation-direction: alternate-reverse; }

@keyframes sc-drift { from { transform: translateX(-3cqw); } to { transform: translateX(5cqw); } }

/* stepped, blocky hills: every edge is a right angle, like terrain made of parts */
.sc-hills { left: 0; right: 0; }
.sc-hills--far {
  bottom: 40%; height: 22%;
  background: #8ed08f;
  clip-path: polygon(0 100%, 0 58%, 7% 58%, 7% 34%, 16% 34%, 16% 12%, 27% 12%, 27% 40%, 36% 40%, 36% 64%, 47% 64%, 47% 30%, 55% 30%, 55% 0, 68% 0, 68% 26%, 77% 26%, 77% 54%, 88% 54%, 88% 36%, 100% 36%, 100% 100%);
}
.sc-hills--near {
  bottom: 40%; height: 13%;
  background: #62bf6a;
  clip-path: polygon(0 100%, 0 30%, 11% 30%, 11% 0, 24% 0, 24% 46%, 40% 46%, 40% 70%, 58% 70%, 58% 38%, 71% 38%, 71% 8%, 86% 8%, 86% 52%, 100% 52%, 100% 100%);
}

.sc-ground {
  left: 0; right: 0; bottom: 0; height: 41%;
  background: linear-gradient(#55c263 0%, #3da552 45%, #2b8843 100%);
  overflow: hidden;
}
/* the baseplate grid, receding to the horizon */
.sc-ground::after {
  content: "";
  position: absolute; left: -60%; right: -60%; top: 0; height: 260%;
  background-image:
    linear-gradient(rgba(255, 255, 255, .2) 0, rgba(255, 255, 255, .2) .220cqw, transparent .220cqw),
    linear-gradient(90deg, rgba(255, 255, 255, .2) 0, rgba(255, 255, 255, .2) .220cqw, transparent .220cqw);
  background-size: 7cqw 7cqw;
  transform-origin: 50% 0;
  transform: perspective(60cqw) rotateX(68deg);
  -webkit-mask-image: linear-gradient(transparent 0, #000 22%);
  mask-image: linear-gradient(transparent 0, #000 22%);
}

/* props: square-crowned trees and a checkpoint pad */
.sc-prop { bottom: 41%; }
.sc-prop--tree {
  width: 7cqw; height: 13cqw;
  background:
    linear-gradient(#2f9c4c, #2f9c4c) 0 0 / 100% 62% no-repeat,
    linear-gradient(rgba(0, 0, 0, .16), rgba(0, 0, 0, .16)) 0 42% / 100% 20% no-repeat,
    linear-gradient(#8a5a33, #8a5a33) 50% 100% / 24% 44% no-repeat;
  border-radius: 1cqw 1cqw 0 0;
}
.sc-prop--1 { left: 5%; transform: translateY(26%) scale(1.5); transform-origin: 50% 100%; }
.sc-prop--2 { left: 21%; transform: translateY(8%) scale(.82); transform-origin: 50% 100%; }
.sc-prop--3 { right: 6%; transform: translateY(34%) scale(1.75); transform-origin: 50% 100%; }
.sc-prop--4 { right: 24%; transform: translateY(6%) scale(.7); transform-origin: 50% 100%; }
.sc-prop--pad {
  left: 50%; bottom: 12%;
  width: 26cqw; height: 5cqw; margin-left: -13cqw;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .5), rgba(255, 255, 255, .08) 70%, transparent);
}

/* ---------------------------------------------------------------- night */
.scene[data-scene="night"] {
  background:
    radial-gradient(.3cqw .3cqw at 12% 14%, #fff 50%, transparent 52%),
    radial-gradient(.220cqw .220cqw at 28% 30%, #cfe6ff 50%, transparent 52%),
    radial-gradient(.3cqw .3cqw at 41% 9%, #fff 50%, transparent 52%),
    radial-gradient(.220cqw .220cqw at 57% 22%, #cfe6ff 50%, transparent 52%),
    radial-gradient(.3cqw .3cqw at 66% 6%, #fff 50%, transparent 52%),
    radial-gradient(.220cqw .220cqw at 83% 30%, #cfe6ff 50%, transparent 52%),
    radial-gradient(.3cqw .3cqw at 93% 12%, #fff 50%, transparent 52%),
    linear-gradient(#0a0f2c 0%, #1c1f55 38%, #4a2a7a 56%, #7a3a8a 60%);
}
.scene[data-scene="night"] .sc-sun {
  left: 14%; right: auto; top: 10%; width: 9cqw;
  background: radial-gradient(circle at 35% 35%, #fdf6ff, #c9b6ff 70%);
  box-shadow: 0 0 0 2cqw rgba(201, 182, 255, .14), 0 0 0 5cqw rgba(201, 182, 255, .07);
}
.scene[data-scene="night"] .sc-cloud { display: none; }
.scene[data-scene="night"] .sc-hills--far {
  background: #1a1848;
  clip-path: polygon(0 100%, 0 46%, 5% 46%, 5% 20%, 10% 20%, 10% 58%, 17% 58%, 17% 8%, 23% 8%, 23% 40%, 31% 40%, 31% 24%, 37% 24%, 37% 62%, 46% 62%, 46% 0, 52% 0, 52% 34%, 60% 34%, 60% 14%, 66% 14%, 66% 52%, 74% 52%, 74% 28%, 81% 28%, 81% 6%, 87% 6%, 87% 44%, 94% 44%, 94% 30%, 100% 30%, 100% 100%);
}
.scene[data-scene="night"] .sc-hills--near {
  background:
    repeating-linear-gradient(90deg, transparent 0 1.400cqw, rgba(255, 214, 92, .5) 1.400cqw 1.800cqw, transparent 1.800cqw 3.200cqw),
    #0f0d33;
  background-size: 100% 22%, auto;
  background-repeat: repeat-y, no-repeat;
  clip-path: polygon(0 100%, 0 40%, 8% 40%, 8% 10%, 15% 10%, 15% 56%, 26% 56%, 26% 30%, 34% 30%, 34% 66%, 49% 66%, 49% 22%, 58% 22%, 58% 50%, 69% 50%, 69% 0, 77% 0, 77% 44%, 89% 44%, 89% 18%, 100% 18%, 100% 100%);
}
.scene[data-scene="night"] .sc-ground { background: linear-gradient(#1b1450 0%, #0d0a2c 60%, #07061a 100%); }
.scene[data-scene="night"] .sc-ground::after {
  background-image:
    linear-gradient(rgba(64, 232, 255, .55) 0, rgba(64, 232, 255, .55) .240cqw, transparent .240cqw),
    linear-gradient(90deg, rgba(255, 79, 216, .5) 0, rgba(255, 79, 216, .5) .240cqw, transparent .240cqw);
}
.scene[data-scene="night"] .sc-prop--tree {
  width: 1.200cqw; height: 26cqw; border-radius: 1cqw;
  background: linear-gradient(rgba(64, 232, 255, 0), rgba(64, 232, 255, .8));
  box-shadow: 0 0 2cqw rgba(64, 232, 255, .5);
}
.scene[data-scene="night"] .sc-prop--2,
.scene[data-scene="night"] .sc-prop--4 { background: linear-gradient(rgba(255, 79, 216, 0), rgba(255, 79, 216, .8)); box-shadow: 0 0 2cqw rgba(255, 79, 216, .5); }
.scene[data-scene="night"] .sc-prop--pad { background: radial-gradient(closest-side, rgba(64, 232, 255, .35), rgba(64, 232, 255, .05) 70%, transparent); }

/* ---------------------------------------------------------------- the same world in WebGL (js/hero3d.js)
 * .scene-gl is the live canvas of the hero, .scene-shot a single rendered frame on a card. Either one covers
 * the CSS world above, which stays underneath as the fallback. */
.scene-gl,
.scene-shot { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.scene-shot { object-fit: cover; }
.scene-gl { opacity: 0; transition: opacity .4s ease; }
.stage--3d-in .scene-gl { opacity: 1; }
.stage--3d .scene > i,
.scene[data-scene-3d] > i { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sc-cloud { animation: none; }
  .scene-gl { transition: none; }
}
