@font-face {
  font-family: Fraunces;
  src: url("fonts/fraunces-text.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --fg: #1c2430;
  --muted: #3e4c5e;
  --glow: rgba(156, 178, 206, 0.45);
  --glow-edge: rgba(120, 142, 168, 0.16);
  --moon: #d7e3f0;
  --moon-bright: #f4f8fc;
  --phase: rgba(78, 102, 130, 0.28);
  --crater: rgba(62, 84, 112, 0.45);
  --ring: rgba(62, 84, 112, 0.42);
  --star: #5d7694;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c1016;
    --fg: #f3f6fb;
    --muted: #d5deea;
    --glow: rgba(150, 186, 230, 0.28);
    --glow-edge: rgba(90, 120, 170, 0.16);
    --moon: #c9d9ee;
    --moon-bright: #f7fbff;
    --phase: rgba(10, 16, 28, 0.42);
    --crater: rgba(18, 32, 52, 0.45);
    --ring: rgba(214, 226, 242, 0.42);
    --star: #e7eef8;
  }
}

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

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}

.atmosphere,
.grain {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.atmosphere {
  background:
    radial-gradient(680px 520px at 50% 46%, var(--glow), transparent 64%),
    radial-gradient(820px 420px at 88% 108%, var(--glow-edge), transparent 60%);
}

.grain {
  opacity: 0.22;
  background-image: url("grain.png");
  background-size: 180px 180px;
  mix-blend-mode: multiply;
}

main {
  position: relative;
  z-index: 1;
  width: min(34rem, 100%);
  margin: auto;
  padding: 2.5rem 1.5rem;
  text-align: center;
}

h1 {
  margin: 0 0 1.5rem;
  line-height: 0;
}

.moon {
  position: relative;
  display: inline-block;
  width: min(18.5rem, 86vw);
  aspect-ratio: 1;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wash circle { fill: var(--moon); }
.wash .bright { fill: var(--moon-bright); }
.wash .phase { fill: var(--phase); }

.craters {
  fill: none;
  stroke: var(--crater);
  stroke-width: 1.25;
}

.rings {
  fill: none;
  stroke: var(--ring);
  stroke-width: 1.2;
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: orbit 80s linear infinite;
}

.stars { fill: var(--star); }

.stars circle { animation: twinkle 3.6s ease-in-out infinite; }
.stars circle:nth-child(2) { animation-delay: 0.6s; }
.stars circle:nth-child(3) { animation-delay: 1.3s; }
.stars circle:nth-child(4) { animation-delay: 1.9s; }
.stars circle:nth-child(5) { animation-delay: 2.4s; }
.stars circle:nth-child(6) { animation-delay: 0.3s; }

.wash {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: breathe 8s ease-in-out infinite;
}

.moon img {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 42%;
  height: 42%;
  object-fit: cover;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

p {
  max-width: 28em;
  margin: 0 auto 1.75rem;
  color: var(--muted);
  font-family: Fraunces, Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  font-weight: 500;
  line-height: 1.45;
}

nav {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}

nav a {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  color: var(--fg);
  border-radius: 999px;
}

nav a svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

nav a:hover {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

::selection {
  background: #d5e0ee;
  color: #1c2430;
}

@media (prefers-color-scheme: dark) {
  .grain {
    opacity: 0.3;
    mix-blend-mode: overlay;
  }

  ::selection {
    background: #2c3c52;
    color: #f3f6fb;
  }
}

@media (forced-colors: active) {
  .scene { display: none; }

  .moon img,
  nav a {
    border: 1px solid CanvasText;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .atmosphere,
  .grain,
  .scene {
    display: none;
  }

  body {
    display: block;
    background: #fff;
    color: #000;
  }

  main {
    margin: 0;
    padding: 0;
  }
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.scene { animation: bloom 1.1s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes bloom {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}
