/* Landing page chrome. The picture itself is drawn by landing.js on #stage. */

/* Two faces only this page uses, both self-hosted Basic Latin subsets under
   the SIL Open Font License (see fonts/OFL.txt): the name's tall hand-cut
   capitals, and the monospace the word under the cat is built from. */
@font-face {
  font-family: "DCZ Display";
  src: url("/assets/fonts/DCZDisplay-Black.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: "DCZ Mono";
  src: url("/assets/fonts/DCZMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "DCZ Mono";
  src: url("/assets/fonts/DCZMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

.landing {
  --field: #181818; /* the first scene's field, and the loader's */
  --white: #f6f4ee;
  --font-name: "DCZ Display", "Londrina Solid", Impact, "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-word: "DCZ Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html,
body.landing {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body.landing {
  background: var(--field);
  color: var(--white);
  font-family: var(--font-mono);
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
}

/* With WebGL running the heading is drawn in the canvas; keep the real one for
   screen readers and search engines only. */
.gl .hero {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hero {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 4rem 1.25rem 3rem;
  text-align: center;
  pointer-events: none;
}

.hero-name {
  margin: 0;
  font-family: var(--font-name);
  font-weight: 900;
  font-size: clamp(2.6rem, 12vw, 11rem);
  line-height: 0.9;
  text-transform: uppercase;
}

.fallback-cat {
  width: min(84vw, 420px);
  height: auto;
}

/* no WebGL: a white sheet, the real heading in black, the cat on a 2D canvas */
.no-gl body.landing {
  background: var(--white);
  color: #0c0c0c;
}

.no-gl #stage {
  display: none;
}

/* Small print over the picture. It is set in white and blended by difference,
   so it comes out white on the dark fields and black on the light ones, and
   flips along the edge of a splash as it passes underneath. */
.chip {
  position: fixed;
  z-index: 2;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  mix-blend-mode: difference;
}

/* BUILDING, under the cat: a canvas of its own that ascii-text.js draws on and
   landing.js sizes and places. It is drawn pale and blended by difference like
   the small print, so it turns dark over the light fields; clicks pass through
   it to the picture. Without WebGL2 it holds the word as plain type instead. */
.building {
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  display: none;
  pointer-events: none;
  mix-blend-mode: difference;
}

.gl .building {
  display: block;
}

.gl .building.plain {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-word);
  font-weight: 600;
  line-height: 1;
  white-space: pre;
  color: #fff;
}

.about-btn {
  top: max(20px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  padding: 0.85em 1.25em 0.8em 1.4em;
  font-weight: 700;
  text-decoration: none;
  border: 1.5px solid #fff;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}

/* a white block under difference is the picture inverted; black type on it is the picture itself */
.about-btn:hover,
.about-btn:active {
  background: #fff;
  color: #000;
}

.about-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.caption {
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
}

.caption b {
  font-weight: 700;
}

.caption .hint {
  opacity: 0.72;
}

.caption .hint::before {
  content: "/";
  margin: 0 0.8em;
}

.caption .hint.seen {
  display: none;
}

/* the caption describes the WebGL picture; without one there is nothing to describe */
.caption {
  display: none;
}

.gl .caption {
  display: block;
}

@media (max-height: 430px) {
  .gl .caption {
    display: none;
  }
}

/* ---------- first-visit loader ----------
   A dark screen and the cat's head brushed on in white, stroke by stroke, on
   stepped frames. The script in <head> adds .loading before first paint (so a
   returning visitor never sees a dark flash), .loader-go when the picture
   behind is ready and the strokes may start, and .loader-out to fade away. */
#loader {
  display: none;
}

.loading #loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--field);
  cursor: default;
  transition: opacity 0.3s cubic-bezier(0.37, 0, 0.63, 1);
}

.loading.loader-out #loader {
  opacity: 0;
  pointer-events: none;
}

#loader svg {
  width: clamp(165px, 18.7vw, 275px);
  height: auto;
  overflow: visible;
}

#loader .mark {
  fill: none;
  stroke: var(--white);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#brush-a);
}

/* a pupil: one short downward press of a loaded brush */
#loader .mark .dab {
  stroke-width: 18;
}

/* a whisker: a flick with the tip of it */
#loader .mark .thin {
  stroke-width: 3.2;
}

/* each stroke is hidden behind its own dash gap until its turn comes */
#loader .mark path {
  stroke-dasharray: 1.02;
  stroke-dashoffset: 1.02;
}

.loader-go #loader .mark path {
  animation: loader-draw var(--d, 0.17s) steps(var(--n, 2)) var(--t, 0s) forwards;
}

/* the finished strokes keep boiling: three takes of the same drawing */
.loader-go #loader .mark {
  animation: loader-boil 0.36s step-end infinite;
}

@keyframes loader-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes loader-boil {
  0% {
    filter: url(#brush-a);
  }
  33.3% {
    filter: url(#brush-b);
  }
  66.6% {
    filter: url(#brush-c);
  }
}

@media (prefers-reduced-motion: reduce) {
  .about-btn {
    transition: none;
  }

  /* no drawing-on and no boil: the finished mark, then a plain fade */
  #loader .mark path {
    stroke-dashoffset: 0;
  }

  .loader-go #loader .mark,
  .loader-go #loader .mark path {
    animation: none;
  }
}
