/* top.sy: one question mark, one secret. */

/* The two fonts are Bodoni Moda (SIL Open Font License, see fonts/OFL.txt),
   cut down to Latin letters and fixed at a 48pt optical size. */
@font-face {
  font-family: "Bodoni Moda";
  src: url("/fonts/bodoni-moda.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("/fonts/bodoni-moda-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

/* Design tokens: change a colour here and it changes everywhere. */
:root {
  --bg: #0e0d0c;
  --ink: #ece6dc;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1ede6;
    --ink: #161412;
    color-scheme: light;
  }
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Bodoni Moda", "Bodoni 72", Didot, Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* One full screen. The question and the answer share the same grid cell,
   so one can replace the other in exactly the same spot. */
.stage {
  min-height: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: clip;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.stage > * {
  grid-area: 1 / 1;
}

/* ---- The question mark ---------------------------------------------- */

.question {
  height: clamp(13rem, 54svh, 40rem);
  aspect-ratio: 960 / 1620; /* the SVG's viewBox */
  cursor: default;
  touch-action: manipulation; /* no double-tap zoom while clicking around */
  animation: arrive 1.2s var(--ease-out) both;
}
.question.is-gone {
  visibility: hidden;
}

.sway,
.tilt,
.shake {
  height: 100%;
}
.shake {
  position: relative;
}

.mark {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: currentColor;
}

/* A slow, barely-there wobble, like it's thinking. */
.sway {
  animation: ponder 7s ease-in-out infinite alternate;
}
.question.is-solving .sway {
  animation-play-state: paused;
}

/* The secret button: an invisible circle over the dot.
   Nothing about it says "click me": no pointer cursor, no hover effect. */
.key {
  position: absolute;
  /* The dot's centre in the viewBox: x (498 - 80) / 960, y (-100.5 + 1560) / 1620. */
  left: 43.54%;
  top: 90.09%;
  width: max(3rem, 34%);
  aspect-ratio: 1;
  translate: -50% -50%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.key:focus {
  outline: none;
}
/* Keyboard users still get a visible focus ring (only shown for keyboard). */
.key:focus-visible {
  outline: 1.5px solid currentColor;
  outline-offset: 2px;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
    filter: blur(10px);
  }
}
@keyframes ponder {
  from {
    transform: perspective(1100px) rotateY(-3deg) rotate(-1deg);
  }
  to {
    transform: perspective(1100px) rotateY(3deg) rotate(1deg);
  }
}

/* ---- The answer ------------------------------------------------------- */

.message {
  margin: 0;
  padding-inline: 1rem;
  font-size: clamp(2.25rem, 7.5vw, 5.5rem);
  font-weight: 400;
  line-height: 1.15;
  text-align: center;
  visibility: hidden;
}
.is-solved .message {
  visibility: visible;
}
.message em {
  font-style: italic;
}

.nowrap {
  white-space: nowrap;
}
/* Words animate one by one, and transforms need an inline-block. */
.word {
  display: inline-block;
}

/* The "i" in "broski" keeps its own dot hidden while the question's dot
   flies over to become it. Measured from the italic font (2000 units per em):
   the i's dot spans x 348-588 and sits 1269-1510 above the baseline, and this
   span's box starts 2250 above the baseline. */
.i {
  position: relative;
}
.tittle-cover {
  display: none;
  position: absolute;
  left: 0.174em;
  top: 0.37em;
  width: 0.12em;
  height: 0.1205em;
  border-radius: 50%;
  background: var(--bg);
  transform: scale(1.3); /* also covers the soft anti-aliased edge */
}
.message.is-landing .tittle-cover {
  display: block;
}

/* The question's dot while it is in the air. */
.flyer {
  position: fixed;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: var(--ink);
  pointer-events: none;
  will-change: transform;
}

/* ---- Helpers ---------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .question,
  .sway {
    animation: none;
  }
}
