:root {
  color-scheme: dark;
  --text: #f4ede4;
  --muted: #a8b4c7;
  --dawn: #efba8a;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  --horizon: 62%;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  color: var(--text);
  background:
    radial-gradient(ellipse 16% 4.5% at 70% var(--horizon), #ffc58b68, #d38a5e28 52%, transparent),
    radial-gradient(ellipse 40% 17% at 70% var(--horizon), #bc695580, #854f5d50 42%, transparent),
    radial-gradient(ellipse 85% 35% at 66% calc(var(--horizon) + 2%), #40354a, transparent),
    linear-gradient(180deg, #060a14, #0b1225 43%, #171b30 64%, #080c15);
}

/* A thin break in the dark separates the sky from the foreground. */
body::before {
  content: "";
  position: fixed;
  inset: var(--horizon) 0 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 8%, #ad6f5650 42%, #e3a476 63%, #ffe0ac 70%, #a4665260 89%, transparent)
      top / 100% 1px no-repeat,
    radial-gradient(ellipse 41% 24% at 70% 0%, #86523e45, transparent),
    linear-gradient(180deg, #111624, #090e19 48%, #060911);
}

body::after {
  content: "";
  position: fixed;
  top: var(--horizon);
  left: 70%;
  width: min(62vw, 760px);
  height: clamp(44px, 11vh, 108px);
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, #ffd6a8b8 52%, transparent)
      bottom center / 82% 1px no-repeat,
    radial-gradient(ellipse at 50% 100%, #ffb77c6b, #d5836026 35%, transparent 72%);
  transform-origin: center bottom;
  animation: horizon-stir 13s ease-in-out infinite paused;
}

body.motion-playing::after { animation-play-state: running; }

@keyframes horizon-stir {
  0%, 100% { opacity: .3; transform: translate(-50%, -100%) scale(.82, .53); }
  20% { opacity: .6; transform: translate(-52%, -100%) scale(.98, .8); }
  34% { opacity: .42; transform: translate(-51%, -100%) scale(.89, .65); }
  63% { opacity: .92; transform: translate(-47%, -100%) scale(1.16, 1.18); }
  78% { opacity: .7; transform: translate(-48%, -100%) scale(1.05, .98); }
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
    opacity: .5;
    transform: translate(-50%, -100%) scale(.94, .72);
  }
}

#particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

main, footer { position: relative; z-index: 2; }
main { flex: 1; display: grid; place-items: center; padding: 40px 20px; }

h1 {
  margin: 0;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  font-weight: 300;
  letter-spacing: -.028em;
  line-height: 1.15;
  transform: translateY(-.3em);
  text-shadow: 0 2px 22px #060a14, 0 0 40px #060a14;
}

footer {
  padding: 24px 52px max(24px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  letter-spacing: .035em;
  line-height: 1.6;
}
footer a { color: #7d889a; text-decoration: none; }
footer a:hover { color: var(--text); text-decoration: underline; }
footer a:focus-visible, #motion-toggle:focus-visible, #fold-toggle:focus-visible {
  outline: 2px solid var(--dawn);
  outline-offset: 4px;
}

#motion-toggle {
  position: fixed;
  z-index: 3;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #a8b4c740;
  border-radius: 50%;
  background: #101625cc;
  color: var(--muted);
  cursor: pointer;
}
#motion-toggle[hidden] { display: none; }
#motion-toggle:hover { border-color: var(--muted); }
#motion-toggle span {
  width: 8px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
}
#motion-toggle[aria-pressed="true"] span {
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-left: 8px solid currentColor;
  border-right: 0;
  margin-left: 2px;
}

body.fold-active { --horizon: var(--manual-fold, 50%); min-height: 100dvh; }
@media (vertical-viewport-segments: 2) {
  body.fold-active { --horizon: env(viewport-segment-top 0 1, 50%); }
}

body.fold-active main {
  position: fixed;
  inset: 0 0 auto;
  height: var(--horizon);
  grid-template-rows: .75fr auto 1.25fr;
  padding-block: 0;
}
body.fold-active h1 { grid-row: 2; transform: none; }
body.fold-active footer { margin-top: auto; }

#fold-toggle {
  position: fixed;
  z-index: 3;
  left: 18px;
  color: var(--muted);
  background: #101625e6;
  border: 1px solid #a8b4c740;
  font: 12px/1.4 system-ui, sans-serif;
}
#fold-toggle {
  bottom: max(18px, env(safe-area-inset-bottom));
  min-width: 44px;
  min-height: 44px;
  border-radius: 18px;
  cursor: pointer;
}
#fold-toggle[aria-pressed="true"] { color: var(--dawn); border-color: #efba8a66; }
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  body:not(.fold-active) #fold-toggle { display: none; }
}

h1 {
  font-size: clamp(2.5rem, 6vw, 5.375rem);
  text-align: center;
  text-wrap: balance;
}
