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

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

  body,
  p {
    margin: 0;
  }
}

@layer tokens {
  :root {
    --color-page: oklch(27% 0.03 245);
    --color-paper-red: oklch(57% 0.19 30);
    --color-red-deep: oklch(46% 0.17 28);
    --color-cream: oklch(94% 0.04 88);
    --color-cream-shade: oklch(83% 0.05 78);
    --color-turquoise: oklch(72% 0.11 195);
    --color-teal: oklch(45% 0.08 205);
    --color-teal-deep: oklch(36% 0.07 210);
    --color-mustard: oklch(82% 0.15 85);
    --color-cherry: oklch(55% 0.2 27);

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

    --duration-orbit: 9s;
    --duration-burst: 60s;
    --duration-twinkle: 3.4s;

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

@layer base {
  body {
    min-block-size: 100dvh;
    display: grid;
    place-items: center;
    background: var(--color-page);
  }
}

@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 / 840;
    overflow: clip;
    background: var(--color-paper-red);
    font-family: var(--font-sign);
    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;
      }
    }
  }

  .halftone {
    --x: 0;
    --y: 0;
    --w: 600;
    --h: 840;

    background: radial-gradient(circle, var(--color-red-deep) 30%, transparent 34%) 0 0 / calc(10 * var(--u)) calc(10 * var(--u));
    mask: linear-gradient(transparent 25%, var(--color-red-deep) 90%);
  }

  .burst {
    --x: 384;
    --y: 168;
    --w: 150;
    --h: 150;

    background: var(--color-mustard);
    clip-path: polygon(59.8% 1%, 61.5% 22.3%, 77.8% 8.4%, 71.2% 28.8%, 91.6% 22.2%, 77.7% 38.5%, 99% 40.2%, 80% 50%, 99% 59.8%, 77.7% 61.5%, 91.6% 77.8%, 71.2% 71.2%, 77.8% 91.6%, 61.5% 77.7%, 59.8% 99%, 50% 80%, 40.2% 99%, 38.5% 77.7%, 22.2% 91.6%, 28.8% 71.2%, 8.4% 77.8%, 22.3% 61.5%, 1% 59.8%, 20% 50%, 1% 40.2%, 22.3% 38.5%, 8.4% 22.2%, 28.8% 28.8%, 22.2% 8.4%, 38.5% 22.3%, 40.2% 1%, 50% 20%);
    animation: turn var(--duration-burst) linear infinite;
  }

  .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: 64;
      --y: 214;
      --size: 28;
    }

    &[data-n="2"] {
      --x: 528;
      --y: 352;
      --size: 20;
      animation-delay: -1.4s;
    }

    &[data-n="3"] {
      --x: 60;
      --y: 470;
      --size: 18;
      animation-delay: -2.3s;
    }

    &[data-n="4"] {
      --x: 506;
      --y: 590;
      --size: 24;
      animation-delay: -0.7s;
    }
  }

  .orbit {
    border: calc(2 * var(--u)) solid var(--color-cream);
    border-radius: 50%;

    &[data-n="1"] {
      --x: 60;
      --y: 250;
      --w: 480;
      --h: 110;
      --turn: -12deg;
    }

    &[data-n="2"] {
      --x: 130;
      --y: 236;
      --w: 340;
      --h: 70;
      --turn: 9deg;

      opacity: 0.6;
    }
  }

  .kicker {
    --x: 30;
    --y: 46;
    --w: 540;
    --h: 30;

    color: var(--color-mustard);
    font-size: calc(20 * var(--u));
    font-weight: 700;
    letter-spacing: 0.5em;
    text-align: center;
    text-transform: uppercase;
  }

  .title {
    --x: 20;
    --y: 72;
    --w: 560;
    --h: 120;

    color: var(--color-cream);
    font-size: calc(94 * var(--u));
    font-stretch: condensed;
    font-weight: 900;
    letter-spacing: -0.01em;
    line-height: 1.2;
    text-align: center;
    text-shadow: calc(5 * var(--u)) calc(4 * var(--u)) 0 var(--color-turquoise);
    text-transform: uppercase;
  }

  .ground {
    --x: 0;
    --y: 760;
    --w: 600;
    --h: 80;

    background: var(--color-teal);
    box-shadow: inset 0 calc(5 * var(--u)) 0 var(--color-teal-deep);
  }

  .arch {
    border-block-end: 0;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;

    &[data-n="back"] {
      --x: 215;
      --y: 300;
      --w: 170;
      --h: 470;

      border: calc(12 * var(--u)) solid var(--color-cream-shade);
      border-block-end: 0;
    }

    &[data-n="front"] {
      --x: 110;
      --y: 300;
      --w: 380;
      --h: 470;

      border: calc(15 * var(--u)) solid var(--color-cream);
      border-block-end: 0;
    }
  }

  .column {
    --x: 290;
    --y: 440;
    --w: 20;
    --h: 330;

    background: var(--color-cream-shade);
  }

  .antenna {
    --x: 298;
    --y: 322;
    --w: 4;
    --h: 56;

    background: var(--color-cream);

    &::before {
      content: "";
      position: absolute;
      inset-inline-start: calc(-5 * var(--u));
      inset-block-start: calc(-10 * var(--u));
      inline-size: calc(14 * var(--u));
      block-size: calc(14 * var(--u));
      border-radius: 50%;
      background: var(--color-mustard);
    }
  }

  .dome {
    --x: 245;
    --y: 372;
    --w: 110;
    --h: 55;

    border: calc(4 * var(--u)) solid var(--color-cream);
    border-block-end: 0;
    border-radius: calc(55 * var(--u)) calc(55 * var(--u)) 0 0;
    background: var(--color-turquoise);
  }

  .saucer {
    --x: 150;
    --y: 404;
    --w: 300;
    --h: 64;

    border-radius: 50%;
    background:
      repeating-linear-gradient(90deg, var(--color-teal) 0 calc(12 * var(--u)), transparent 0 calc(22 * var(--u)))
        50% 45% / 84% calc(14 * var(--u)) no-repeat,
      linear-gradient(transparent 62%, var(--color-cream-shade) 0),
      var(--color-cream);
    box-shadow: calc(5 * var(--u)) calc(4 * var(--u)) 0 var(--color-turquoise);
  }

  .satellite-path {
    --x: 60;
    --y: 250;
    --w: 480;
    --h: 110;
    --turn: -12deg;
    --size: calc(22 * var(--u));
  }

  .satellite {
    position: absolute;
    inset-inline-start: 0;
    inset-block-start: 0;
    inline-size: var(--size);
    block-size: var(--size);
    border-radius: 50%;
    background: var(--color-mustard);
    box-shadow: inset calc(-4 * var(--u)) calc(-4 * var(--u)) 0 var(--color-cherry);
    offset-path: ellipse(50% 50% at 50% 50%);
    offset-rotate: 0deg;
    animation: orbit var(--duration-orbit) linear infinite;

    &::before {
      content: "";
      position: absolute;
      inset: calc(-14 * var(--u));
      background:
        linear-gradient(45deg, transparent 46%, var(--color-cream) 0 54%, transparent 0) 0 0 / 28% 28% no-repeat,
        linear-gradient(-45deg, transparent 46%, var(--color-cream) 0 54%, transparent 0) 100% 0 / 28% 28% no-repeat,
        linear-gradient(-45deg, transparent 46%, var(--color-cream) 0 54%, transparent 0) 0 100% / 28% 28% no-repeat,
        linear-gradient(45deg, transparent 46%, var(--color-cream) 0 54%, transparent 0) 100% 100% / 28% 28% no-repeat;
    }
  }

  .banner {
    --x: 100;
    --y: 776;
    --w: 400;
    --h: 38;

    display: grid;
    place-items: center;
    border-radius: calc(19 * var(--u));
    background: var(--color-cream);
    color: var(--color-cherry);
    font-size: calc(17 * var(--u));
    font-weight: 900;
    letter-spacing: 0.3em;
    text-transform: uppercase;
  }

  .frame {
    --x: 0;
    --y: 0;
    --w: 600;
    --h: 840;

    border: calc(12 * var(--u)) solid var(--color-cream);
    pointer-events: none;

    &::after {
      content: "";
      position: absolute;
      inset: calc(8 * var(--u));
      border: calc(2 * var(--u)) solid var(--color-cream);
    }
  }

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

  @keyframes orbit {
    to {
      offset-distance: 100%;
    }
  }

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

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

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