:root {
  --page-color: #403879;
  --gradient-top: rgba(0, 0, 0, .70);
  --gradient-bottom: rgba(0, 0, 0, 0);

  --composition-width: min(68vw, 720px);
  --orbit-width: 1.08;
  --orbit-height: .78;
  --orbit-depth: 260px;
  --perspective: 1000px;
  --orbit-duration: 18s;
  --orbit-tilt: -7deg;
  --orbit-plane-rotation: -14deg;

  --language-width: 108px;
  --flag-width: 76px;
  --flag-height: 48px;
  --language-font-size: 18px;

  --banner-height: 118px;
  --banner-duration: 28s;

  --carousel-hold: 5s;
  --carousel-fade: 1.5s;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Arial, Helvetica, sans-serif;
  color: white;
  background: var(--page-color);
}

.page {
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--gradient-top), var(--gradient-bottom)),
    var(--page-color);
  display: flex;
  flex-direction: column;
}

.hero {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 44px) 20px 8px;
}

.scene {
  position: relative;
  width: var(--composition-width);
  aspect-ratio: 1521 / 1463;
  perspective: var(--perspective);
  perspective-origin: 50% 50%;
}

.composition {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.layer,
.carousel,
.carousel__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.layer--back { z-index: 1; }
.carousel { z-index: 2; }
.layer--front { z-index: 3; }
.carousel__image {
  opacity: 0;
  transition: opacity var(--carousel-fade) ease-in-out;
}
.carousel__image.is-active { opacity: 1; }

.orbit {
  position: absolute;
  inset: 0;
  z-index: 10;
  transform-style: preserve-3d;
  transform:
    rotateZ(var(--orbit-plane-rotation))
    rotateX(var(--orbit-tilt));
  pointer-events: none;
}

.language {
  --angle: var(--start-angle);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--language-width);
  min-height: 92px;
  margin-left: calc(var(--language-width) / -2);
  margin-top: -46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: white;
  text-decoration: none;
  font-size: var(--language-font-size);
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,.75);
  transform-style: preserve-3d;
  pointer-events: auto;
  will-change: transform, opacity;
}

.language:hover { filter: brightness(1.12); }
.language:focus-visible { outline: 3px solid white; outline-offset: 6px; border-radius: 8px; }

.flag {
  position: relative;
  display: block;
  width: var(--flag-width);
  height: var(--flag-height);
  overflow: hidden;
  border-radius: 7px;
  border: 2px solid rgba(255,255,255,.92);
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  background-size: 100% 100%;
}

/* Simple CSS flag approximations for the prototype. They can be replaced by SVG artwork later. */
.flag--hr { background: linear-gradient(#f00 0 33.33%, #fff 33.33% 66.66%, #171796 66.66%); }
.flag--sr { background: linear-gradient(#c6363c 0 33.33%, #0c4076 33.33% 66.66%, #fff 66.66%); }
.flag--sl { background: linear-gradient(#fff 0 33.33%, #0b4ea2 33.33% 66.66%, #ee1c25 66.66%); }

.flag--en { display: flex; background: none; }
.flag--en i,
.flag--en b { width: 50%; height: 100%; display: block; }
.flag--en i {
  background:
    linear-gradient(33deg, transparent 43%, #fff 43% 48%, #c8102e 48% 52%, #fff 52% 57%, transparent 57%),
    linear-gradient(-33deg, transparent 43%, #fff 43% 48%, #c8102e 48% 52%, #fff 52% 57%, transparent 57%),
    linear-gradient(90deg, transparent 38%, #fff 38% 44%, #c8102e 44% 56%, #fff 56% 62%, transparent 62%),
    linear-gradient(0deg, transparent 35%, #fff 35% 42%, #c8102e 42% 58%, #fff 58% 65%, transparent 65%),
    #012169;
}
.flag--en b {
  background:
    repeating-linear-gradient(0deg, #b22234 0 3.7px, #fff 3.7px 7.4px);
  position: relative;
}
.flag--en b::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 55%; height: 54%;
  background: #3c3b6e;
}

.banner {
  position: relative;
  flex: 0 0 var(--banner-height);
  width: 100%;
  overflow: hidden;
  background-image: url("assets/Appic_Adventure_WEB_Banner.png");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: 0 50%;
  animation: banner-scroll var(--banner-duration) linear infinite;
}

@keyframes banner-scroll {
  from { background-position: 0 50%; }
  to { background-position: calc(-1 * var(--banner-tile-width, 900px)) 50%; }
}

@media (max-width: 700px) {
  :root {
    --composition-width: min(82vw, 560px);
    --orbit-depth: 170px;
    --language-width: 82px;
    --flag-width: 60px;
    --flag-height: 38px;
    --language-font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .banner { animation-play-state: paused; }
  .carousel__image { transition: none; }
}
