/* Mothman Interactive — one stylesheet, colours taken from the logo. */

@font-face {
  font-family: "Righteous";
  src: url("/fonts/righteous.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("/fonts/rubik-variable.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --space: #0a1416;      /* page */
  --space-2: #0f1f22;    /* cards */
  --space-3: #15292c;
  --ink: #050504;        /* the logo's outline */
  --teal: #1b6262;
  --teal-bright: #2f8f8a;
  --cream: #f6dca7;
  --cream-soft: #e6d6b4;
  --muted: #a7b8b2;
  --orange: #de541e;
  --gold: #f6a62d;
  --red: #e2402c;

  --display: "Righteous", "Trebuchet MS", system-ui, sans-serif;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 14px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: clamp(16px, 1.05vw + 12px, 18px);
  line-height: 1.6;
  color: var(--cream-soft);
  background-color: var(--space);
  /* the starfield: bright stars + sparkles on a 2300 px tile over faint dust on a 1100 px one, so the
     combined field never visibly repeats (made by tools/make_stars.py) */
  background-image: url("/img/stars-bright.svg"), url("/img/stars-dust.svg");
  background-size: 2300px 2300px, 1100px 1100px;
  background-position: 0 0, 430px 260px;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

/* --- the living sky -------------------------------------------------------------
   Fixed behind everything (it stays put while the page and its stars scroll past, which
   reads as depth). Each twinkle layer fades as a whole, a cheap GPU opacity change; the
   three run at unrelated speeds so their stars never pulse in step. The shooting stars
   are added here by /js/sky.js while the visitor is idle. */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.twinkle { position: absolute; inset: 0; background-repeat: repeat; opacity: .55; }
.twinkle--a { background-image: url("/img/twinkle-a.svg"); background-size: 900px 900px; }
.twinkle--b { background-image: url("/img/twinkle-b.svg"); background-size: 1300px 1300px; background-position: 210px 470px; }
.twinkle--c { background-image: url("/img/twinkle-c.svg"); background-size: 1700px 1700px; background-position: 640px 90px; }
@media (prefers-reduced-motion: no-preference) {
  .twinkle { will-change: opacity; animation: twinkle 3.7s ease-in-out infinite alternate; }
  .twinkle--b { animation-duration: 5.3s; animation-delay: -2.1s; }
  .twinkle--c { animation-duration: 7.9s; animation-delay: -4.6s; }
}
@keyframes twinkle { from { opacity: .12; } to { opacity: 1; } }

.shooting-star {
  position: absolute; left: 0; top: 0;
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgb(246 220 167 / 0), rgb(246 220 167 / .55) 70%, #fff4e0);
  will-change: transform, opacity;
}
.shooting-star::after {          /* the bright head */
  content: ""; position: absolute; right: -3px; top: 50%;
  width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: radial-gradient(circle, #fff4e0 0 30%, rgb(255 244 224 / 0) 70%);
}

a { color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--cream); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  padding: 10px 14px; background: var(--gold); color: var(--ink); font-weight: 600;
  border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* --- top bar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--gutter);
  background: rgb(10 20 22 / .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgb(246 166 45 / .18);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-size: 1.15rem; letter-spacing: .02em;
  color: var(--cream); text-decoration: none; white-space: nowrap;
}
.brand img { width: 36px; height: 36px; flex: none; }
.topbar nav { display: flex; gap: clamp(14px, 3vw, 32px); }
.topbar nav a {
  color: var(--cream-soft); text-decoration: none;
  font-weight: 500; font-size: .95rem; letter-spacing: .08em; text-transform: uppercase;
}
.topbar nav a:hover { color: var(--gold); }
@media (max-width: 560px) {
  .brand span { display: none; }
}

/* --- hero ----------------------------------------------------------------- */
.hero {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: min(92vh, 900px);
  padding: 56px var(--gutter) 72px;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}
.hero::before {          /* the teal planet behind the logo */
  content: ""; position: absolute; z-index: -2;
  width: min(820px, 120vw); aspect-ratio: 1; border-radius: 50%;
  left: 50%; top: 46%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgb(27 98 98 / .55), rgb(27 98 98 / .12) 55%, transparent 70%);
}
.orbits {
  position: absolute; z-index: -1; left: 50%; top: 46%;
  width: min(1200px, 140vw); transform: translate(-50%, -50%) rotate(-8deg);
  fill: none; stroke: rgb(246 166 45 / .22); stroke-width: 1.5;
}
.orbits .moon { fill: var(--red); stroke: none; }
.orbits .moon--teal { fill: var(--teal-bright); }
/* Both animations move on the GPU: `will-change` gives each its own layer, so the logo (and
   its shadow filter) is drawn once and then slid.
   The logo's float is ~0.07 px a frame at its fastest, and a browser snaps a layer that is
   only being TRANSLATED to whole pixels, so it moved in visible one-pixel steps. The constant
   0.02deg turn (a third of a pixel at the logo's edge, invisible) makes the compositor
   resample it at exact sub-pixel positions instead. Do not remove it. */
@media (prefers-reduced-motion: no-preference) {
  .orbits { will-change: transform; animation: drift 60s linear infinite alternate; }
  .hero__logo { will-change: transform; animation: hover 7s ease-in-out infinite; }
}
@keyframes drift {
  from { transform: translate3d(-50%, -50%, 0) rotate(-8deg); }
  to   { transform: translate3d(-50%, -50%, 0) rotate(4deg); }
}
@keyframes hover {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(.02deg); }
  50%      { transform: translate3d(0, -10px, 0) rotate(.02deg); }
}

@media (max-width: 600px) {
  .hero { min-height: 0; padding: 72px var(--gutter) 88px; }
}

.hero__logo { margin: 0; width: min(960px, 92vw); }
.hero__logo img { width: 100%; filter: drop-shadow(0 18px 30px rgb(0 0 0 / .55)); }
.hero__tag {
  margin: 18px 0 28px; max-width: 34ch;
  font-size: clamp(1.05rem, 1.4vw + .6rem, 1.4rem); color: var(--cream);
}

/* --- shared pieces ----------------------------------------------------------- */
.button {
  display: inline-block;
  padding: 14px 26px;
  font-family: var(--display); font-size: 1.1rem; letter-spacing: .04em;
  color: var(--ink); background: var(--gold); text-decoration: none;
  border: 3px solid var(--ink); border-radius: 999px;
  box-shadow: 4px 4px 0 var(--orange);
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
  overflow-wrap: anywhere;
}
.button:hover { color: var(--ink); background: var(--cream); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--orange); }
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--orange); }

.section {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(56px, 8vw, 104px) var(--gutter);
}
.section--narrow { width: min(760px, 100%); text-align: center; }

.eyebrow {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 8px;
  font-size: .85rem; font-weight: 600; letter-spacing: .3em; text-transform: uppercase;
  color: var(--gold);
}
.section--narrow .eyebrow, .lost .eyebrow { justify-content: center; }
.eyebrow::before, .eyebrow::after {     /* the logo's four-point sparkle */
  content: ""; width: 12px; height: 12px; flex: none; background: var(--gold);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}
.section:not(.section--narrow) .eyebrow::after { display: none; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; color: var(--cream); line-height: 1.1; }
h2 {
  margin: 0 0 32px;
  font-size: clamp(2.2rem, 4vw + 1rem, 3.4rem);
  text-shadow: 3px 3px 0 var(--orange), 6px 6px 0 var(--ink);
}
.lede { margin: 0 auto 28px; font-size: 1.1rem; max-width: 56ch; }

/* --- constellations -----------------------------------------------------------------
   Drawn by tools/make_constellations.py into index.html. Their stars twinkle out of step
   (five rhythms, .tw1-.tw5); the lines hold still. */
.constellation { margin: 0; pointer-events: none; }
.constellation__art { display: block; width: 100%; height: auto; overflow: visible; }
.constellation figcaption {
  margin-top: 4px; text-align: center;
  font-size: .66rem; font-weight: 600; letter-spacing: .32em; text-transform: uppercase;
  color: rgb(246 166 45 / .6);
}
@media (prefers-reduced-motion: no-preference) {
  .c-s { animation: c-twinkle 3.2s ease-in-out infinite alternate; }
  .c-s.tw2 { animation-duration: 4.1s; animation-delay: -1.3s; }
  .c-s.tw3 { animation-duration: 2.7s; animation-delay: -2.2s; }
  .c-s.tw4 { animation-duration: 5.2s; animation-delay: -.6s; }
  .c-s.tw5 { animation-duration: 3.6s; animation-delay: -3.1s; }
}
@keyframes c-twinkle { from { opacity: .55; } to { opacity: 1; } }

/* the easter egg: the Mothman constellation opens "Moth to the Light" (/js/egg.js) */
.constellation--mothman { pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.constellation--mothman .c-lines, .constellation--mothman figcaption { transition: stroke-opacity .4s ease, color .4s ease; }
.constellation--mothman:hover .c-lines { stroke-opacity: .7; }
.constellation--mothman:hover figcaption { color: var(--gold); }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.section-head h2 { margin-bottom: 0; }
.constellation--raccoon { flex: none; width: clamp(104px, 15vw, 170px); margin-bottom: -6px; }

.section--narrow { position: relative; }
.constellation--mothman { width: 140px; margin: 0 auto 18px; }
.constellation--sasquatch { display: none; }
.constellation--nessie { width: min(270px, 78vw); margin-bottom: 14px; }
@media (min-width: 1180px) {
  /* beside the narrow text columns, one on each side */
  .constellation--mothman, .constellation--sasquatch {
    position: absolute; top: 50%; transform: translateY(-50%); margin: 0;
  }
  .constellation--mothman { right: calc(100% + 8px); width: 190px; }
  .constellation--sasquatch { display: block; left: calc(100% + 24px); width: 150px; }
}

/* --- game card ------------------------------------------------------------------ */
.game {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  background: var(--space-2);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--gold), 8px 8px 0 2px var(--orange);
  overflow: hidden;
}
.game__art { background: var(--space-3); }
.game__art img { width: 100%; height: 100%; object-fit: cover; }
.game__text { padding: clamp(22px, 3vw, 36px); }
.game h3 { margin: 0 0 14px; font-size: clamp(1.7rem, 2vw + 1rem, 2.2rem); }
.game p { margin: 0 0 22px; }
.tag {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-family: var(--body); font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cream); background: var(--teal); border: 1px solid var(--teal-bright);
}
.facts { display: grid; grid-template-columns: repeat(3, auto); gap: 12px 24px; margin: 0; justify-content: start; }
.facts dt { font-size: .75rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; color: var(--cream); font-weight: 500; }
@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; }
  .game__art img { aspect-ratio: 16 / 9; height: auto; }
}
@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr 1fr; }
}

/* --- footer ------------------------------------------------------------------------------ */
.footer {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px var(--gutter) 48px;
  border-top: 1px solid rgb(246 166 45 / .18);
  color: var(--muted); font-size: .9rem; text-align: center;
}
.footer p { margin: 0; }

/* --- the game window (built by /js/game.js) ---------------------------------------------- */
html.moth-game-open { overflow: hidden; }
.moth-game {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent;
  place-items: center;
}
.moth-game[open] { display: grid; }
.moth-game::backdrop { background: rgb(5 10 11 / .85); backdrop-filter: blur(4px); }
.moth-game__frame {
  position: relative; line-height: 0; overflow: hidden;
  border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 0 0 0 2px var(--gold), 8px 8px 0 2px var(--orange);
}
.moth-game canvas { display: block; touch-action: none; cursor: pointer; outline: none; }
.moth-game__btn {
  position: absolute; top: 10px;
  padding: 6px 12px; line-height: 1.2;
  font: 600 .78rem/1.2 var(--body); letter-spacing: .08em; text-transform: uppercase;
  color: var(--cream); background: rgb(10 20 22 / .75);
  border: 1px solid rgb(246 166 45 / .55); border-radius: 999px; cursor: pointer;
}
.moth-game__btn:hover { background: var(--gold); color: var(--ink); }
.moth-game__close { right: 10px; }
.moth-game__sound { left: 10px; }

/* --- 404 ----------------------------------------------------------------------------------- */
.lost {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px var(--gutter); text-align: center;
}
.lost img { width: 180px; margin-bottom: 18px; }
.lost h1 { margin: 0 0 12px; font-size: clamp(2.4rem, 6vw, 4rem); text-shadow: 3px 3px 0 var(--orange), 6px 6px 0 var(--ink); }
