@layer reset, tokens, base, layout, components, utilities, overrides;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body {
    margin: 0;
  }
}

@layer tokens {
  :root {
    --color-night: oklch(24% 0.06 255);
    --color-night-low: oklch(33% 0.07 225);
    --color-ink: oklch(24% 0.03 245);
    --color-cream: oklch(95% 0.035 90);
    --color-turquoise: oklch(72% 0.11 195);
    --color-teal: oklch(50% 0.085 205);
    --color-tangerine: oklch(71% 0.18 50);
    --color-tangerine-dark: oklch(60% 0.17 44);
    --color-soil: oklch(30% 0.04 50);
    --color-ground-shadow: oklch(14% 0.04 250 / 0.6);
    --color-shrub: oklch(50% 0.1 162);
    --color-shrub-light: oklch(62% 0.12 150);
    --color-cherry: oklch(58% 0.2 27);
    --color-mustard: oklch(82% 0.15 85);
    --color-flamingo: oklch(80% 0.11 5);
    --color-bulb-dim: oklch(52% 0.09 70);
    --color-bulb-lit: oklch(97% 0.09 95);
    --color-glow-warm: oklch(88% 0.16 85 / 0.85);
    --color-glow-pink: oklch(72% 0.2 10 / 0.8);
    --color-glow-cool: oklch(85% 0.12 190 / 0.6);

    --font-sign: "Futura", "Century Gothic", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;

    --duration-spin: 14s;
    --duration-chase: 0.9s;
    --duration-sputter: 7s;
    --duration-twinkle: 3.6s;

    --scene-grid: 600;
    --scene-size: min(100dvi - 2rem, (100dvb - 2rem) * 600 / 800, 42rem);
  }
}

@layer base {
  body {
    min-block-size: 100dvh;
    display: grid;
    place-items: center;
    background: linear-gradient(var(--color-night) 45%, var(--color-night-low));
  }
}

@layer components {
  .scene {
    --u: calc(100cqi / var(--scene-grid));

    position: relative;
    container-type: inline-size;
    isolation: isolate;
    inline-size: var(--scene-size);
    aspect-ratio: 600 / 800;
    forced-color-adjust: none;

    & > * {
      position: absolute;
      inset-inline-start: calc(var(--x) * var(--u));
      inset-block-start: calc(var(--y) * var(--u));
      inline-size: calc(var(--w) * var(--u));
      block-size: calc(var(--h) * var(--u));
      rotate: var(--turn, 0deg);
    }

    @media (hover: hover) {
      &:hover,
      &:hover * {
        animation-play-state: paused;
      }
    }
  }

  .sparkle {
    --w: var(--size);
    --h: var(--size);

    background: var(--color-cream);
    clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
    animation: twinkle var(--duration-twinkle) ease-in-out infinite alternate;

    &[data-n="1"] {
      --x: 60;
      --y: 110;
      --size: 26;
    }

    &[data-n="2"] {
      --x: 150;
      --y: 34;
      --size: 16;
      animation-delay: -1.2s;
    }

    &[data-n="3"] {
      --x: 486;
      --y: 168;
      --size: 22;
      animation-delay: -2.1s;
    }

    &[data-n="4"] {
      --x: 540;
      --y: 360;
      --size: 28;
      animation-delay: -0.6s;
    }

    &[data-n="5"] {
      --x: 34;
      --y: 560;
      --size: 18;
      animation-delay: -2.8s;
    }

    &[data-n="6"] {
      --x: 470;
      --y: 40;
      --size: 14;
      animation-delay: -1.7s;
    }
  }

  .pylon,
  .pylon-stripe {
    --x: 0;
    --y: 0;
    --w: 600;
    --h: 800;
  }

  .pylon {
    background: var(--color-cream);
    clip-path: polygon(46.3% 95%, 53.2% 95%, 56.67% 18.75%, 51.67% 17.5%);
  }

  .pylon-stripe {
    background: var(--color-turquoise);
    clip-path: polygon(48.6% 95%, 50.9% 95%, 54.33% 20%, 52.67% 19.5%);
  }

  .atom {
    --x: 255;
    --y: 55;
    --w: 150;
    --h: 150;

    & > * {
      position: absolute;
    }
  }

  .burst {
    inset: 0;
    background: var(--color-tangerine);
    clip-path: polygon(50% 0%, 54.9% 31.6%, 75% 6.7%, 63.4% 36.6%, 93.3% 25%, 68.4% 45.1%, 100% 50%, 68.4% 54.9%, 93.3% 75%, 63.4% 63.4%, 75% 93.3%, 54.9% 68.4%, 50% 100%, 45.1% 68.4%, 25% 93.3%, 36.6% 63.4%, 6.7% 75%, 31.6% 54.9%, 0% 50%, 31.6% 45.1%, 6.7% 25%, 36.6% 36.6%, 25% 6.7%, 45.1% 31.6%);
  }

  .orbits {
    inset: 0;
    animation: spin var(--duration-spin) linear infinite;
  }

  .ring {
    position: absolute;
    inset-inline: -4%;
    inset-block: 34%;
    border: calc(3.5 * var(--u)) solid var(--color-cream);
    border-radius: 50%;
    box-shadow: 0 0 calc(6 * var(--u)) var(--color-glow-cool);

    &::before,
    &::after {
      content: "";
      position: absolute;
      inset-block-start: calc(50% - 7 * var(--u));
      inline-size: calc(14 * var(--u));
      block-size: calc(14 * var(--u));
      border-radius: 50%;
      background: var(--color-flamingo);
      box-shadow: 0 0 calc(8 * var(--u)) var(--color-glow-pink);
    }

    &::before {
      inset-inline-start: calc(-9 * var(--u));
    }

    &::after {
      inset-inline-end: calc(-9 * var(--u));
    }

    &[data-n="2"] {
      rotate: 60deg;
    }

    &[data-n="3"] {
      rotate: 120deg;
    }
  }

  .nucleus {
    inset: 38%;
    border-radius: 50%;
    background: var(--color-mustard);
    box-shadow: 0 0 calc(10 * var(--u)) var(--color-glow-warm);
  }

  .boomerang {
    --x: 150;
    --y: 214;
    --w: 340;
    --h: 34;

    &::before,
    &::after {
      content: "";
      position: absolute;
      inset-block: 0;
      inline-size: 54%;
      border: calc(3 * var(--u)) solid var(--color-ink);
      border-radius: calc(17 * var(--u));
      background: var(--color-mustard);
      box-shadow: inset 0 calc(5 * var(--u)) 0 var(--color-cream);
    }

    &::before {
      inset-inline-start: 0;
      transform-origin: 92% 50%;
      rotate: -13deg;
    }

    &::after {
      inset-inline-end: 0;
      transform-origin: 8% 50%;
      rotate: 13deg;
    }
  }

  .arrow {
    --x: 300;
    --y: 578;
    --w: 300;
    --h: 46;
    --turn: -50deg;

    background: var(--color-cherry);
    clip-path: polygon(0 50%, 16% 0, 16% 22%, 100% 22%, 100% 78%, 16% 78%, 16% 100%);
  }

  .bulbs {
    --pitch: calc(20 * var(--u));

    position: absolute;
    inset-inline: 18% 2%;
    inset-block: 22%;

    &[data-lit="off"] {
      background: radial-gradient(circle calc(6 * var(--u)) at calc(var(--pitch) / 2) 50%, var(--color-bulb-dim) 90%, transparent)
        0 0 / var(--pitch) 100% repeat-x;
    }

    &[data-lit="on"] {
      background: radial-gradient(circle calc(6 * var(--u)) at calc(var(--pitch) / 2) 50%, var(--color-bulb-lit) 90%, transparent)
        0 0 / calc(var(--pitch) * 3) 100% repeat-x;
      filter: drop-shadow(0 0 calc(4 * var(--u)) var(--color-glow-warm));
      animation: chase var(--duration-chase) steps(3) infinite;
    }
  }

  .tile {
    --w: 76;
    --h: 76;

    display: grid;
    place-items: center;
    border: calc(4 * var(--u)) solid var(--color-ink);
    background: var(--color-cherry);
    box-shadow: inset 0 0 0 calc(4 * var(--u)) var(--color-cream);
    color: var(--color-cream);
    font: 900 calc(50 * var(--u)) / 1 var(--font-sign);
    text-shadow: 0 0 calc(8 * var(--u)) var(--color-glow-warm);

    &[data-n="1"] {
      --x: 272;
      --y: 446;
      --turn: -7deg;
    }

    &[data-n="2"] {
      --x: 269;
      --y: 534;
      --turn: 5deg;
    }

    &[data-n="3"] {
      --x: 265;
      --y: 622;
      --turn: -4deg;
    }
  }

  .panel {
    --x: 60;
    --y: 285;
    --w: 410;
    --h: 150;
    --turn: -5deg;

    display: grid;
    place-content: center;
    justify-items: center;
    border: calc(6 * var(--u)) solid var(--color-cream);
    border-radius: 55% 45% 50% 50% / 60% 55% 45% 40%;
    background: var(--color-turquoise);
    box-shadow:
      0 0 calc(14 * var(--u)) var(--color-glow-cool),
      calc(10 * var(--u)) calc(10 * var(--u)) 0 var(--color-ink);
    font-family: var(--font-sign);
  }

  .panel-name {
    color: var(--color-cream);
    font-size: calc(84 * var(--u));
    font-style: italic;
    font-weight: 900;
    line-height: 0.9;
    text-shadow:
      calc(3 * var(--u)) calc(3 * var(--u)) 0 var(--color-cherry),
      0 0 calc(12 * var(--u)) var(--color-glow-pink);
    animation: sputter var(--duration-sputter) linear infinite;
  }

  .panel-kind {
    color: var(--color-ink);
    font-size: calc(26 * var(--u));
    font-weight: 700;
    letter-spacing: 0.5em;
    margin-inline-start: 0.5em;
    text-transform: uppercase;
  }

  .planter-body {
    --x: 186;
    --y: 742;
    --w: 228;
    --h: 42;

    display: grid;
    place-items: center;
    padding-block-start: calc(10 * var(--u));
    clip-path: polygon(0 0, 100% 0, 93% 100%, 7% 100%);
    background:
      linear-gradient(var(--color-cream) 0 0) 50% 62% / calc(116 * var(--u)) calc(22 * var(--u)) no-repeat,
      repeating-linear-gradient(90deg, var(--color-tangerine) 0 calc(14 * var(--u)), var(--color-tangerine-dark) 0 calc(19 * var(--u)));
    color: var(--color-cherry);
    font: 900 calc(12 * var(--u)) / 1 var(--font-sign);
    letter-spacing: 0.22em;
    text-transform: uppercase;
  }

  .planter-shadow {
    --x: 150;
    --y: 772;
    --w: 300;
    --h: 22;

    border-radius: 50%;
    background: var(--color-ground-shadow);
  }

  .planter-top {
    --x: 180;
    --y: 728;
    --w: 240;
    --h: 30;

    border: calc(5 * var(--u)) solid var(--color-mustard);
    border-radius: 50%;
    background: var(--color-soil);
    box-shadow: 0 0 0 calc(3 * var(--u)) var(--color-ink);
  }

  .shrubs {
    --x: 204;
    --y: 686;
    --w: 192;
    --h: 60;

    background:
      radial-gradient(circle calc(17 * var(--u)) at 20% 72%, var(--color-shrub-light) 95%, transparent),
      radial-gradient(circle calc(20 * var(--u)) at 33% 55%, var(--color-shrub) 95%, transparent),
      radial-gradient(circle calc(15 * var(--u)) at 67% 50%, var(--color-shrub-light) 95%, transparent),
      radial-gradient(circle calc(19 * var(--u)) at 79% 70%, var(--color-shrub) 95%, transparent),
      radial-gradient(circle calc(13 * var(--u)) at 52% 78%, var(--color-shrub) 95%, transparent);
  }

  @keyframes spin {
    to {
      rotate: 1turn;
    }
  }

  @keyframes chase {
    to {
      background-position-x: calc(var(--pitch) * -3);
    }
  }

  @keyframes sputter {
    0%,
    88%,
    90%,
    93%,
    100% {
      opacity: 1;
    }

    89%,
    92% {
      opacity: 0.55;
    }
  }

  @keyframes twinkle {
    from {
      opacity: 0.45;
      scale: 0.65;
    }

    to {
      opacity: 1;
      scale: 1;
    }
  }
}

@layer overrides {
  @media (prefers-reduced-motion: reduce) {
    .scene * {
      animation: none;
    }
  }
}
