/* The "coming soon" page of بُشرى.
   One screen in the landing's sticker style (same tokens, Marhey + Baloo
   Bhaijaan 2, cream/sand, navy, sun and orange): the logo, the message in
   the middle, and a choir of six jelly blobs with faces. Each blob sings its
   own note when it is punched; its mouth opens into a parabola and notes fly
   out. The main character and Seif wave from the bottom corners, and
   listen with their eyes closed once someone has been playing a while.

   Portrait first (phones). One query at the end moves everything round for
   landscape screens (desktop). Everything is placed in % of the stage, and
   sized in vw / vmin, so it fits any one screen without scrolling. */

:root {
  --background: #F2E7D6;
  --ink: #17203F;
  --sun: #FECC39;
  --coral: #FD7F44;
  --peach: #FBDCC4;
  --paper: #FFF8EC;

  /* Blob tints: only blobs use these, so nothing sinks into its blob */
  --blob-sun: #F5D88E;
  --blob-sun-deep: #E9C26A;
  --blob-coral: #F3BC9E;
  --blob-coral-deep: #E6A07D;
  --blob-sky: #CFD3EA;
  --blob-sky-deep: #B7BCDD;
  --muted: #4B5269;

  --display: "Marhey", "Baloo Bhaijaan 2", "Segoe UI", sans-serif;
  --text: "Baloo Bhaijaan 2", "Segoe UI", Tahoma, sans-serif;
  --edge: 3px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Fast punches must not zoom the page */
  touch-action: manipulation;
  color-scheme: light;
  background: var(--background);
}

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.2rem;
  line-height: 1.75;
}

::selection {
  background: var(--ink);
  color: var(--sun);
}

h1,
p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 5px;
}

/* The stage: exactly one screen. A very short screen (a phone on its side)
   gets a floor so nothing squeezes into anything else; then it scrolls. */
.stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 34rem;
  overflow: hidden;
  /* Punching fast must never select the words or drag a picture */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.stage img {
  -webkit-user-drag: none;
}

/* Logo and message */

.top {
  position: absolute;
  inset-block-start: max(4.5%, env(safe-area-inset-top));
  inset-inline: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.logo {
  display: block;
  width: min(46vw, 15rem);
  height: auto;
}

.msg {
  position: absolute;
  inset-block-start: var(--msg-y, 27%);
  inset-inline: 0;
  z-index: 3;
  translate: 0 -50%;
  padding-inline: 1.25rem;
  text-align: center;
  /* Only the words and the links take taps; the empty space round them
     belongs to the blobs behind */
  pointer-events: none;
}

.msg h1,
.msg a {
  pointer-events: auto;
}

.msg h1 {
  width: fit-content;
  margin-inline: auto;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.1rem, 10.4vw, 3.6rem);
  line-height: 1.3;
  text-wrap: balance;
}

.msg h1 span {
  display: block;
}

/* The promise in orange letters with a navy drop, like the landing's
   headline: the drop keeps it readable on the sand */
.msg h1 .pop {
  color: var(--coral);
  text-shadow: -0.045em 0.045em 0 var(--ink);
  rotate: -2deg;
}

.follow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.1rem;
  margin-top: 0.9rem;
  font-size: 1.05rem;
}

.follow__link {
  font-weight: 600;
  color: var(--ink);
  text-decoration-color: var(--coral);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.35em;
}

/* The choir */

.choir {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.blob {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: var(--s);
  height: auto;
  aspect-ratio: 1;
  overflow: visible;
  translate: -50% -50%;
  will-change: transform;
}

.blob__back {
  translate: -7px 7px;
}

.blob--sun .blob__back { fill: var(--blob-sun-deep); }
.blob--sun .blob__front { fill: var(--blob-sun); }
.blob--coral .blob__back { fill: var(--blob-coral-deep); }
.blob--coral .blob__front { fill: var(--blob-coral); }
.blob--sky .blob__back { fill: var(--blob-sky-deep); }
.blob--sky .blob__front { fill: var(--blob-sky); }

/* Where each blob stands on a phone: two small ones up by the logo, four
   round the middle, above the two of us at the bottom (sizes are capped by
   the height too, so a wide tablet stays in scale) */
.b1 { --x: 31; --y: 51; --s: min(44vw, 19svh); }
.b2 { --x: 77; --y: 46; --s: min(34vw, 15svh); }
.b3 { --x: 17; --y: 67; --s: min(28vw, 12svh); }
.b4 { --x: 70; --y: 62; --s: min(25vw, 11svh); }
.b5 { --x: 87; --y: 12; --s: min(21vw, 10svh); }
.b6 { --x: 13; --y: 11; --s: min(20vw, 9.5svh); }

/* The faces */
.face {
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eye__white {
  fill: var(--paper);
  stroke-width: 2.6;
  vector-effect: non-scaling-stroke;
}

.eye__dot {
  fill: var(--ink);
  stroke: none;
}

.eye__open {
  transform-box: fill-box;
  transform-origin: center;
  transition: scale 0.09s;
}

.eye__happy {
  fill: none;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  transition: opacity 0.08s;
}

.is-blinking .eye__open {
  scale: 1 0.08;
}

/* While singing the eyes close into two happy arches */
.is-singing .eye__open {
  scale: 1 0.08;
  opacity: 0;
}

.is-singing .eye__happy {
  opacity: 1;
}

.mouth {
  fill: var(--ink);
  stroke-width: 2.8;
  vector-effect: non-scaling-stroke;
}

.tongue {
  fill: var(--coral);
  stroke: none;
}

/* The tap mark on the big blob: the landing's three small ")" arcs. Gone
   after the first punch, and on later visits. */
.blob__hint {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: opacity 0.4s;
}

.blob__hint.is-gone {
  opacity: 0;
}

.blob__wave {
  animation: wave 2.8s 2.6s ease-out infinite both;
}

.blob__wave--2 { animation-delay: 2.76s; }
.blob__wave--3 { animation-delay: 2.92s; }

@keyframes wave {
  0% {
    opacity: 0;
    transform: translateX(-4px);
  }

  12% {
    opacity: 1;
  }

  38%,
  100% {
    opacity: 0;
    transform: translateX(5px);
  }
}

/* The two of us, the same size, one in each bottom corner: me on the
   right, Seif on the left. Both wave; once someone has been playing for a
   while both slowly fade into listening with their eyes closed, and back
   when the music stops. No hopping, nothing but the fade. */
.pal {
  position: absolute;
  bottom: 0;
  z-index: 2;
  height: 26svh;
  aspect-ratio: 669 / 900;
  pointer-events: none;
}

.pal--me {
  right: 1vw;
}

.pal--seif {
  left: 1vw;
}

.pal__pose {
  position: absolute;
  bottom: 0;
  left: 50%;
  height: 100%;
  width: auto;
  translate: -50% 0;
  transition: opacity 0.9s ease;
}

.pal__pose--listen {
  opacity: 0;
}

.is-listening .pal__pose--wave {
  opacity: 0;
}

.is-listening .pal__pose--listen {
  opacity: 1;
}

/* Notes flying out of a singing mouth: they pass behind the words, so the
   message always stays readable */
.notes {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.note {
  position: absolute;
  width: var(--n, 26px);
  margin: calc(var(--n, 26px) * -0.6) 0 0 calc(var(--n, 26px) * -0.5);
  color: var(--ink);
  animation: rise var(--t, 1.4s) cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.note svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.note path,
.note ellipse {
  fill: currentColor;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.note--sun { color: var(--sun); }
.note--coral { color: var(--coral); }

/* The coloured ones are stickers: a hard navy drop, down and to the left */
.note--sun svg,
.note--coral svg {
  filter: drop-shadow(-2px 2px 0 var(--ink));
}

@keyframes rise {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotate(0deg);
  }

  12% {
    opacity: 1;
  }

  35% {
    transform: translate(calc(var(--dx) * 0.6), calc(var(--dy) * 0.18)) scale(1) rotate(calc(var(--r) * -0.5));
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.9) rotate(var(--r));
  }
}

/* Landscape screens: the message in the middle, the choir round it, the
   character in the right corner and Seif at the back on the left */
@media (min-aspect-ratio: 1/1) {
  /* everything is sized by the height here, so a phone on its side still
     fits on one screen */
  .stage {
    min-height: 20rem;
  }

  .logo {
    width: clamp(10rem, 20vmin, 19rem);
  }

  .top {
    inset-block-start: 6%;
  }

  .msg {
    --msg-y: 46%;
  }

  .msg h1 {
    font-size: clamp(2.6rem, 8.2vmin, 6.4rem);
  }

  .follow {
    margin-top: 1.4rem;
    font-size: 1.2rem;
  }

  .b1 { --x: 14; --y: 31; --s: 32vmin; }
  .b2 { --x: 86; --y: 27; --s: 27vmin; }
  .b3 { --x: 37; --y: 81; --s: 22vmin; }
  .b4 { --x: 69; --y: 13; --s: 16vmin; }
  .b5 { --x: 63; --y: 85; --s: 15vmin; }
  .b6 { --x: 33; --y: 14; --s: 14vmin; }

  .pal {
    height: 52vh;
  }

  .pal--me {
    right: 3vw;
  }

  .pal--seif {
    left: 3vw;
  }
}

/* No wobble, no breathing, no hops: the blobs still sing, and the notes
   simply fade in place */
@media (prefers-reduced-motion: reduce) {
  .blob__wave {
    animation: none;
  }

  .pal__pose {
    transition-duration: 0.2s;
  }

  .note {
    animation-name: fade;
  }

  @keyframes fade {
    0%,
    100% {
      opacity: 0;
    }

    20%,
    70% {
      opacity: 1;
    }
  }
}
