/* day-beach-words.css
 *
 * The words in the day beach's sky (js/scenes/day-beach/beach-words.js:
 * that script sets their sizes and places them), the paw over the "i" in
 * "Lai" (paw-dot.js), and the button over the cat's paw prints in the
 * sand.
 */

#scene-beach {
  /* (The words' colour and shadows, --warm-white, --words-shadow and
     --hand-shadow, are shared with the underwater scene: see base.css.) */

  /* The first time the day beach appears: the words fade in over
     --words-fade-in; "Dive with me" waits --dive-hint-after, then fades in
     over --dive-hint-fade-in. */
  --words-fade-in: 1.6s;
  --dive-hint-after: 3.5s;
  --dive-hint-fade-in: 2s;

  /* "Dive with me"'s arrow: its height (its width is half that), its
     line, and the gap before it; every --dive-arrow-bob-every it bobs
     down by --dive-arrow-bob and back. */
  --dive-arrow: 0.95em;
  --dive-arrow-stroke: 2.4;
  --dive-arrow-gap: 0.22em;
  --dive-arrow-bob-every: 2.6s;
  --dive-arrow-bob: 0.14em;

  /* "scroll down", beside the arrow: its size (a share of "Dive with
     me"'s) and how much lower it sits. */
  --scroll-hint-size: 0.55em;
  --scroll-hint-lower: 0.12em;

  /* The paw's wiggle on hover: how long, and how far it turns. */
  --paw-wiggle: 0.7s;
  --paw-wiggle-turn: 16deg;

  /* The paw prints in the sand, while they have keyboard focus: a soft
     ring around them. */
  --prints-focus-ring: rgba(244, 237, 224, 0.85);
}

/* ---- The headline and the intro ------------------------------------------ */

/* As the dive begins, the words fade out with it (--dive-fade, from 1 to
   0, set by beach-words.js as the page scrolls). That fade is a filter,
   so it follows the scroll at once, while the opacity keeps its own
   gentle transition for the words' first appearance. */
.beach-words {
  position: absolute;
  margin: 0;
  color: var(--warm-white);
  opacity: 0;
  filter: opacity(var(--dive-fade, 1));
  transition: opacity var(--words-fade-in) ease;
}

.beach-words.is-shown {
  opacity: 1;
}

.headline {
  /* Nanum Pen Script's letters sit high in their line, with room below
     them for tails; the intro comes up into that room. */
  margin: 0 0 -0.18em;
  /* The paint (--hand-paint, set by hand-paint.js once it is made), then
     the soft shadow. */
  filter: var(--hand-paint,) var(--hand-shadow);
}

.intro {
  max-width: 30em;
  margin: 0.4em 0 0;
  font-weight: 400;
  line-height: 1.45;
  text-shadow: var(--words-shadow);
  /* Straight and calm: no hand here. */
  text-wrap: pretty;
}

/* ---- "Dive with me" ------------------------------------------------------- */

/* Plain text, just above the sea: "Dive with me", its arrow, and a
   smaller "scroll down". Its letters still move when the pointer passes
   (letter-springs.js), so it takes the pointer, but nothing happens on a
   click. It fades out with the other words as the dive begins. */
.dive-hint {
  position: absolute;
  display: flex;
  align-items: center;
  gap: var(--dive-arrow-gap);
  margin: 0;
  color: var(--warm-white);
  white-space: nowrap;
  filter: opacity(var(--dive-fade, 1));
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  transition: opacity var(--dive-hint-fade-in) ease var(--dive-hint-after);
}

.dive-hint.is-shown {
  opacity: 1;
}

/* The words and the arrow, and "scroll down", each painted (--hand-paint,
   set by beach-words.js for each one's size), then the soft shadow. */
.dive-hint__lead,
.dive-hint__scroll {
  filter: var(--hand-paint,) var(--hand-shadow);
}

.dive-hint__lead {
  display: flex;
  align-items: center;
  gap: var(--dive-arrow-gap);
}

.dive-hint__scroll {
  font-size: var(--scroll-hint-size);
  translate: 0 var(--scroll-hint-lower);
}

/* The cat card's hand-drawn arrow, pointing down into the sea, a little
   askew. Every --dive-arrow-bob-every it bobs down --dive-arrow-bob and
   back, slowly, inviting a scroll. */
.dive-hint__arrow {
  flex: none;
  width: calc(var(--dive-arrow) / 2);
  height: var(--dive-arrow);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--dive-arrow-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  rotate: -8deg;
  animation: dive-arrow-bob var(--dive-arrow-bob-every) ease-in-out infinite;
}

@keyframes dive-arrow-bob {
  0%,
  45%,
  100% {
    translate: 0 0;
  }
  70% {
    translate: 0 var(--dive-arrow-bob);
  }
}

/* For less motion: the arrow stays still. */
@media (prefers-reduced-motion: reduce) {
  .dive-hint__arrow {
    animation: none;
  }
}

/* ---- The paw over the "i" in "Lai" -------------------------------------- */

.paw-dot {
  position: relative;
}

/* Until the paw is placed (the web font has arrived and its dot has been
   measured), the "i" keeps its own dot and there is no paw. */
.paw-dot__target {
  display: none;
}

/* The stem only: the top of the letter, down to just below its dot, is
   clipped off (the sides and the bottom are left well clear). */
.paw-dot--placed .paw-dot__stem {
  display: inline-block;
  clip-path: inset(var(--stem-from) -0.5em -0.5em -0.5em);
}

/* A larger area than the paw itself, centred on where the dot was, so it
   is easy to hit. */
.paw-dot--placed .paw-dot__target {
  position: absolute;
  left: var(--paw-x);
  top: var(--paw-y);
  display: grid;
  place-items: center;
  width: max(0.4em, 36px);
  height: max(0.4em, 36px);
  transform: translate(-50%, -50%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.paw-dot__paw {
  display: block;
  width: var(--paw-size);
  height: var(--paw-size);
  fill: currentColor;
  rotate: var(--paw-tilt);
}

@media (prefers-reduced-motion: no-preference) {
  .paw-dot__target:hover .paw-dot__paw {
    animation: paw-wiggle var(--paw-wiggle) ease-in-out;
  }
}

@keyframes paw-wiggle {
  0%, 100% {
    rotate: var(--paw-tilt);
  }
  25% {
    rotate: calc(var(--paw-tilt) - var(--paw-wiggle-turn));
  }
  55% {
    rotate: calc(var(--paw-tilt) + var(--paw-wiggle-turn) * 0.7);
  }
  80% {
    rotate: calc(var(--paw-tilt) - var(--paw-wiggle-turn) * 0.3);
  }
}

/* ---- The paw prints in the sand ------------------------------------------ */

/* Invisible: the prints themselves are in the painting (pressed in by
   day-beach-motion.js), and deepen a little on hover or focus. No hint
   that they are a button, other than the pointer. */
.paw-prints-button {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.paw-prints-button:focus-visible {
  outline: 2px solid var(--prints-focus-ring);
  outline-offset: 2px;
}
