* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #191716;
  color: #f4e4c8;
  font: 16px system-ui, sans-serif;
}

main {
  max-width: 1180px;
  margin: auto;
  padding: clamp(18px, 5vw, 64px);
}

h1 {
  margin: 0 0 22px;
  font: clamp(3rem, 8vw, 6rem)/.95 Georgia, serif;
  letter-spacing: -.06em;
}

.sky {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(385px, 61vh, 540px);
  border: 1px solid #796652;
  background: #252226;
}

.light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 310px 260px at var(--x, 50%) var(--y, 62%), #5c423159, transparent);
}

.moon {
  position: absolute;
  top: 8%;
  right: 8%;
  width: clamp(60px, 11vw, 120px);
  aspect-ratio: 1;
  border-radius: 50%;
  rotate: -12deg;
  pointer-events: none;
  background: repeating-linear-gradient(125deg, #bc925740 0 1px, transparent 1px 4px), #efd19a;
  mask: radial-gradient(circle at 68% 34%, transparent 46%, black 47%);
}

.hanging-star {
  position: absolute;
  top: 0;
  left: var(--left, 5%);
  z-index: 1;
  display: grid;
  justify-items: center;
  width: max-content;
  color: #efd19a;
  perspective: 350px;
  transform-origin: top center;
  animation: star-sway var(--sway, 8s) ease-in-out var(--delay, 0s) infinite;
}

.hanging-star.edge-right {
  left: auto;
  right: 1%;
}

.hanging-star::before {
  content: "";
  width: 1px;
  height: min(var(--thread, 42px), 13vw);
  background: #efd19a80;
}

.hanging-star > span {
  display: block;
  font: clamp(1.25rem, var(--size, 4vw), 4rem)/1 Georgia, serif;
  text-shadow: 6px 13px 0 #0f0e1266;
  pointer-events: none;
  animation: star-breeze var(--twist, var(--sway, 8s))
    ease-in-out var(--delay, 0s) infinite;
}

/* One quick gust, followed by smaller and slower turns. */
.hanging-star:hover > span {
  animation: star-gust 1.4s ease-out forwards;
}

@keyframes star-sway {
  0%, 100% { rotate: -5deg; }
  50%      { rotate: 5deg; }
}

@keyframes star-breeze {
  0%, 100% { transform: rotateY(-8deg); }
  28%      { transform: rotateY(24deg) rotateZ(2deg); }
  57%      { transform: rotateY(-16deg) rotateZ(-2deg); }
  79%      { transform: rotateY(12deg); }
}

@keyframes star-gust {
  0%   { transform: rotateY(0deg); }
  13%  { transform: rotateY(48deg) rotateZ(5deg); }
  33%  { transform: rotateY(-25deg) rotateZ(-3deg); }
  58%  { transform: rotateY(12deg) rotateZ(1deg); }
  80%  { transform: rotateY(-4deg); }
  100% { transform: rotateY(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hanging-star,
  .hanging-star > span,
  .hanging-star:hover > span {
    animation: none;
  }
}

.cloud {
  position: absolute;
  left: var(--left);
  top: var(--top);
  width: 112px;
  height: 29px;
  border-radius: 48% 46% 26% 28%;
  background: #b1a1ac;
  opacity: var(--opacity);
  pointer-events: none;
  animation: clouds var(--period) ease-in-out infinite alternate;
  z-index: 2;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 3px;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  left: 15px;
  width: 49px;
  height: 43px;
}

.cloud::after {
  right: 13px;
  width: 58px;
  height: 54px;
}

.one {
  --left: 7%;
  --top: 22%;
  --opacity: .25;
  --period: 83s;
}

.two {
  --left: 53%;
  --top: 41%;
  --opacity: .16;
  --period: 116s;
  scale: .72;
  animation-delay: -51s;
}

.three {
  --left: 28%;
  --top: 76%;
  --opacity: .23;
  --period: 97s;
  scale: 1.12;
  animation-delay: -17s;
}

@keyframes clouds {
  to {
    translate: 34px -5px;
  }
}

.meteor {
  position: absolute;
  width: clamp(36px, 7vw, 84px);
  height: 2px;
  rotate: 19deg;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, #ffe3a7);
}

nav {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  justify-content: space-evenly;
  align-items: start;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
  z-index: 3;
}

.rig {
  --paper: #f1d7a6;
  --drop: 150px;
  --period: 8s;
  --delay: -2s;
  position: relative;
  padding-top: var(--drop);
  transform-origin: top center;
  animation: sway var(--period) ease-in-out infinite var(--delay);
}

.rig::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: var(--drop);
  background: #c3ae8c;
}

.rig:hover,
.rig:focus-within {
  animation-play-state: paused;
  z-index: 1;
}

.game {
  --paper: #d7ab96;
  --drop: 225px;
  --period: 9.5s;
  --delay: -5s;
}

.portfolio {
  --paper: #c9c8a6;
  --drop: 130px;
  --period: 7s;
  --delay: -1s;
}

@keyframes sway {

  0%,
  100% {
    transform: perspective(700px) rotateZ(calc(0deg - var(--wind-sway, 2deg))) rotateY(calc(0deg - var(--wind-turn, 4deg)));
  }

  50% {
    transform: perspective(700px) rotateZ(var(--wind-sway, 2deg)) rotateY(var(--wind-turn, 4deg));
  }
}

.cutout {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 12px clamp(7px, 2vw, 20px);
  border: 0;
  background: var(--paper);
  color: #2d241e;
  cursor: pointer;
  pointer-events: auto;
  text-align: center;
  text-decoration: none;
  font: clamp(.92rem, 2.8vw, 1.7rem)/1.05 Georgia, serif;
  box-shadow: 6px 13px 0 #0f0e1266;
  transition: scale .2s ease;
}

.cutout:hover,
.cutout:focus-visible {
  scale: 1.07;
}

.star {
  position: absolute;
  z-index: 1;
  translate: -50% -50%;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #efd290;
  font: 1.7rem Georgia, serif;
  cursor: pointer;
  animation: appear .35s ease-out;
  z-index: 1;
}

.star:hover,
.star:focus-visible {
  color: #fff0c6;
}

@keyframes appear {
  from {
    opacity: 0;
  }
}

.cutout:hover,
.cutout:focus-visible {
  animation: card-gust 1.3s ease-out;
}

@keyframes card-gust {
  0%, 100% { transform: perspective(650px) rotateY(0deg); }
  15%      { transform: perspective(650px) rotateY(16deg); }
  38%      { transform: perspective(650px) rotateY(-8deg); }
  65%      { transform: perspective(650px) rotateY(3deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cutout:hover,
  .cutout:focus-visible {
    animation: none;
  }
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

footer p {
  margin: 0;
  color: #dac5a8;
}

.plain {
  border: 1px solid #a38466;
  background: transparent;
  color: inherit;
  padding: 8px 13px;
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid #ffdc8a;
  outline-offset: 4px;
}

dialog {
  width: min(350px, 88vw);
  border: 0;
  padding: 27px;
  background: #eed8b6;
  color: #2d241e;
}

dialog::backdrop {
  background: #181317bb;
}

dialog h2 {
  margin: 0;
  font: 2rem Georgia, serif;
}

.cameos {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .24s ease;
}

.scene.visible {
  opacity: 1;
}

.motif {
  position: absolute;
  width: clamp(39px, 8vw, 95px);
  overflow: visible;
  translate: -50% -50%;
  rotate: var(--tilt);
  opacity: .55;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: bob 7s ease-in-out infinite alternate;
}

.scene[data-scene="teach"] {
  color: #edcb91;
}

.scene[data-scene="game"] {
  color: #dfa18d;
}

.scene[data-scene="portfolio"] {
  color: #c5ce9f;
}

@keyframes bob {
  to {
    transform: translateY(-9px);
  }
}

@media (max-width: 480px) {
  nav {
    gap: 5px;
    padding-inline: 8px;
  }

  .rig {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {

  .rig,
  .cloud,
  .star,
  .motif {
    animation: none;
  }

  .meteor {
    display: none;
  }

  .cutout,
  .scene {
    transition: none;
  }
}

.night-sky-quote {
  margin: auto;
  max-width: 38ch;
  color: #efd19a;
  font: italic clamp(1rem, 2vw, 1.25rem)/1.5 Georgia, serif;
  text-align: center;
}