/* FoxCloud — welcome page.
   One idea: the logo's low-poly world extends to the whole page. The night sky
   and the hills are made of facets (js/sky.js), the wordmark is cut from the
   fox's fur, and the fox breathes while it sleeps. */

@font-face {
  font-family: "Chakra Petch";
  src: url("../fonts/chakra-petch-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --night: #0f1438;
  --dusk: #252e6e;
  --violet: #4a4790;
  --rose: #a0688f;
  --dawn: #e8925f;
  --fur: #f26b1d;
  --fur-light: #ff9b45;
  --cream: #f7ebdd;
  --mist: #c9d0ee;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-settle: cubic-bezier(0.34, 1.32, 0.5, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  color: var(--cream);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  /* Shown until the faceted sky is drawn, and without JavaScript. */
  background: linear-gradient(180deg, var(--night) 0%, var(--dusk) 45%, var(--violet) 72%, var(--rose) 88%, var(--dawn) 100%) fixed;
  overflow-x: hidden;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* ---- Layout -------------------------------------------------------------- */

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vw, 5rem) clamp(1.25rem, 5vw, 4rem) clamp(5rem, 12vh, 8rem);
}

.copy {
  /* Keeps the text readable over the brighter facets near the horizon. */
  text-shadow: 0 1px 14px rgb(15 20 56 / 0.65);
}

.hero {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4.5rem);
}

/* ---- Wordmark: cut from the fox's fur ------------------------------------ */

.wordmark {
  margin: 0 0 0.35em;
  font-family: "Chakra Petch", "Atkinson Hyperlegible Next", sans-serif;
  font-weight: 700;
  font-size: clamp(3.25rem, 9.5vw, 8.25rem);
  line-height: 0.92;
  letter-spacing: -0.025em;
  color: var(--fur);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 120' preserveAspectRatio='none'%3E%3Cpolygon points='0,0 70,0 0,50' fill='%23ffb067'/%3E%3Cpolygon points='70,0 80,62 0,50' fill='%23ff9b45'/%3E%3Cpolygon points='70,0 150,0 80,62' fill='%23ff8a33'/%3E%3Cpolygon points='150,0 160,45 80,62' fill='%23f77a26'/%3E%3Cpolygon points='150,0 230,0 160,45' fill='%23ffa552'/%3E%3Cpolygon points='230,0 225,66 160,45' fill='%23f26b1d'/%3E%3Cpolygon points='230,0 300,0 225,66' fill='%23ff8a33'/%3E%3Cpolygon points='300,0 300,52 225,66' fill='%23e85f1b'/%3E%3Cpolygon points='0,50 80,62 0,120' fill='%23f77a26'/%3E%3Cpolygon points='80,62 65,120 0,120' fill='%23e85f1b'/%3E%3Cpolygon points='80,62 160,45 65,120' fill='%23f26b1d'/%3E%3Cpolygon points='160,45 145,120 65,120' fill='%23d9531a'/%3E%3Cpolygon points='160,45 225,66 145,120' fill='%23e85f1b'/%3E%3Cpolygon points='225,66 240,120 145,120' fill='%23c9481a'/%3E%3Cpolygon points='225,66 300,52 240,120' fill='%23d9531a'/%3E%3Cpolygon points='300,52 300,120 240,120' fill='%23c04317'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* A text-shadow would be painted over the clipped fill: glow with a filter. */
  text-shadow: none;
  filter: drop-shadow(0 0.08em 0.35em rgb(242 107 29 / 0.28));
  animation: facet-reveal 0.9s var(--ease-out) 0.85s both;
}

.lead {
  margin: 0 0 1rem;
  max-width: 34ch;
  font-size: clamp(1.125rem, 1.55vw, 1.375rem);
  line-height: 1.5;
  animation: appear 0.8s ease 1.3s both;
}

.hint {
  margin: 0;
  max-width: 42ch;
  color: var(--mist);
  animation: appear 0.8s ease 1.5s both;
}

/* ---- The sleeping fox ---------------------------------------------------- */

.fox {
  margin: 0;
  justify-self: center;
  width: min(520px, 100%);
  animation: land 1.1s var(--ease-settle) 0.45s both;
}

.fox-art {
  position: relative;
  animation: breathe 5.6s ease-in-out 1.6s infinite;
  transform-origin: 50% 72%;
}

.fox img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 1.5rem 2.5rem rgb(9 12 40 / 0.55));
}

.fox figcaption {
  /* The logo has transparent margins: pull the caption under the cloud. */
  margin-top: -9%;
  text-align: center;
  color: var(--mist);
  font-size: 0.95rem;
  animation: appear 0.8s ease 1.9s both;
}

/* Little faceted "z" rising from the fox's head. */
.z {
  position: absolute;
  left: 64%;
  top: 33%;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 2.2vw, 1.65rem);
  line-height: 1;
  color: var(--cream);
  opacity: 0;
  pointer-events: none;
  animation: zzz 5.4s var(--ease-out) infinite;
}
.z1 { animation-delay: 2.4s; }
.z2 { animation-delay: 4.2s; font-size: clamp(0.85rem, 1.8vw, 1.3rem); }
.z3 { animation-delay: 6s; font-size: clamp(1.15rem, 2.6vw, 1.95rem); }

/* ---- Footer, on the dark hills drawn by the sky ---------------------------- */

.foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem clamp(1.25rem, 5vw, 4rem) max(1.25rem, env(safe-area-inset-bottom));
  font-size: 0.875rem;
  color: var(--mist);
}

.foot a {
  color: var(--cream);
  text-decoration: underline;
  text-decoration-color: rgb(255 155 69 / 0.6);
  text-underline-offset: 0.25em;
  border-radius: 2px;
}
.foot a:hover {
  text-decoration-color: var(--fur-light);
}
a:focus-visible {
  outline: 2px solid var(--fur-light);
  outline-offset: 4px;
}

/* ---- Motion ------------------------------------------------------------------ */

@keyframes facet-reveal {
  /* A diagonal cut sweeps left to right; the final polygon is larger than the
     box so the glow under the letters is not clipped. */
  from {
    clip-path: polygon(-10% -40%, -10% -40%, -45% 140%, -45% 140%);
    transform: translateY(0.08em);
  }
  to {
    clip-path: polygon(-10% -40%, 145% -40%, 110% 140%, -45% 140%);
    transform: none;
  }
}

@keyframes appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes land {
  from {
    opacity: 0;
    transform: translateY(-2.5rem) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-0.4rem) scale(1.018); }
}

@keyframes zzz {
  0% { opacity: 0; transform: translate(0, 0) scale(0.55) rotate(-12deg); }
  14% { opacity: 0.95; }
  70% { opacity: 0.55; }
  100% { opacity: 0; transform: translate(2.8em, -4.6em) scale(1.25) rotate(14deg); }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark,
  .lead,
  .hint,
  .fox,
  .fox-art,
  .fox figcaption {
    animation: none;
  }
  .z {
    display: none;
  }
}

/* ---- Small screens: the fox first, text centered below ------------------- */

@media (max-width: 880px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 0.5rem;
  }
  .fox {
    order: -1;
    width: min(340px, 82vw);
  }
  .lead,
  .hint {
    margin-inline: auto;
  }
  .wordmark {
    font-size: clamp(3rem, 17vw, 4.75rem);
  }
  .foot {
    font-size: 0.8125rem;
  }
}
