/* The 12 × 12 contact sheet is rendered from normal/christmas-tree/src/scene.js. */
.jo-xmas-tree {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 21 / 25;
  background: center / 100% 100% no-repeat url("tree-front.webp");
  pointer-events: none;
}

/* Small pinlights wrap across the branches. Two separate clouds lift away from them. */
.jg-stardust, .jg-stardust::before, .jg-stardust::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.jg-stardust {
  --pin: #fff9cc 0 .55px, #ffc969 .8px, transparent 1.5px;
  background:
    radial-gradient(circle at 43% 26%, var(--pin)), radial-gradient(circle at 51% 28%, var(--pin)),
    radial-gradient(circle at 60% 32%, var(--pin)), radial-gradient(circle at 62% 39%, var(--pin)),
    radial-gradient(circle at 45% 45%, var(--pin)), radial-gradient(circle at 34% 48%, var(--pin)),
    radial-gradient(circle at 30% 54%, var(--pin)), radial-gradient(circle at 41% 58%, var(--pin)),
    radial-gradient(circle at 56% 61%, var(--pin)), radial-gradient(circle at 69% 65%, var(--pin)),
    radial-gradient(circle at 74% 73%, var(--pin)), radial-gradient(circle at 62% 78%, var(--pin)),
    radial-gradient(circle at 46% 82%, var(--pin)), radial-gradient(circle at 27% 85%, var(--pin));
}
.jg-stardust::before, .jg-stardust::after {
  content: "";
  --spark: #fff8c7 0 .65px, #ffcc72 1px, #ffc16445 1.6px, transparent 2.3px;
  background:
    radial-gradient(circle at 18% 70%, var(--spark)), radial-gradient(circle at 30% 44%, var(--spark)),
    radial-gradient(circle at 76% 58%, var(--spark)), radial-gradient(circle at 67% 33%, var(--spark)),
    radial-gradient(circle at 40% 81%, var(--spark)), radial-gradient(circle at 55% 18%, var(--spark));
  opacity: .7;
}
.jg-stardust::after {
  --spark: #ffffed 0 .5px, #b9efd9 .85px, transparent 1.55px;
  transform: scaleX(-1) translateY(4%);
}
.jg-glint {
  position: absolute;
  width: var(--diameter, 16%); aspect-ratio: 1;
  margin-left: calc(var(--diameter, 16%) / -2);
  transform: translateY(-50%); pointer-events: none;
  background: radial-gradient(circle, #fff 0 7%, #fff1ad 12%, #ffc05582 24%, transparent 66%);
}
.jg-glint::before, .jg-glint::after {
  content: ""; position: absolute; inset: 0;
  background: #fff3c1;
  clip-path: polygon(50% 0, 55% 41%, 100% 50%, 56% 56%, 50% 100%, 44% 57%, 0 50%, 44% 44%);
}
.jg-glint::after { transform: rotate(45deg) scale(.50); background: #fac96c; }
.jg-glint-crown { left: 50%; top: 8%; --diameter: 33%; --delay: -.5s; }
.jg-glint-upper { left: 64%; top: 39%; --delay: -2.2s; }
.jg-glint-middle { left: 32%; top: 56%; --diameter: 22%; --delay: -1.4s; }
.jg-glint-lower { left: 69%; top: 74%; --diameter: 19%; --delay: -3.1s; }

@media (prefers-reduced-motion: no-preference) {
  .jg-glint { animation: jg-starshine 3.8s ease-in-out var(--delay) infinite; }
  .jg-stardust::before { animation: jg-lift-gold 3.2s ease-in-out -1.1s infinite; }
  .jg-stardust::after { animation: jg-lift-ice 4.3s ease-in-out -2.8s infinite; }
  .jo-xmas-tree[data-turn-ready] {
    background-image: url("tree-turn.webp");
    background-size: 1200% 1200%;
    background-position: 0 0;
    animation: jo-tree-column 1.5s steps(12, end) infinite, jo-tree-row 18s steps(12, end) infinite;
  }

  button:focus-visible .jo-xmas-tree[data-turn-ready] {
    animation-play-state: paused;
  }

  @media (hover: hover) {
    button:hover .jo-xmas-tree[data-turn-ready] {
      animation-play-state: paused;
    }
  }
}

@keyframes jg-starshine {
  0%, 100% { opacity: .32; transform: translateY(-50%) scale(.52); }
  36% { opacity: 1; transform: translateY(-50%) scale(1.12); }
  68% { opacity: .52; transform: translateY(-50%) scale(.70); }
}
@keyframes jg-lift-gold {
  0% { opacity: 0; transform: translate(-2%, 9%) scale(.92); }
  28%, 58% { opacity: 1; }
  100% { opacity: 0; transform: translate(4%, -13%) scale(1.13); }
}
@keyframes jg-lift-ice {
  0% { opacity: 0; transform: translate(3%, 7%) scaleX(-.92); }
  32%, 62% { opacity: .95; }
  100% { opacity: 0; transform: translate(-5%, -17%) scaleX(-1.14); }
}

/* Run one step beyond the last tile so each of the twelve tiles gets equal time. */
@keyframes jo-tree-column {
  from { background-position-x: 0%; }
  to { background-position-x: 109.090909%; }
}

@keyframes jo-tree-row {
  from { background-position-y: 0%; }
  to { background-position-y: 109.090909%; }
}
