/* night-words.css
 *
 * The words on the night beach (js/scenes/night-beach/night-words.js sets
 * their font sizes and places them): the handwritten "Let's talk." and a
 * few lines; and, on its own, the handwritten "Walk back to the beach"
 * with its little arrow. (The handwritten links around the fire are
 * fire-links.css.)
 *
 * Same system as the other scenes: the handwriting in Nanum Pen Script,
 * lettered and painted by hand (hand-lettering.js, hand-paint.js),
 * everything else in Inter, all in the warm off-white with a soft shadow
 * (--warm-white, --words-shadow and --hand-shadow, in base.css). Every
 * size in the block is in em, so it all scales with the font size
 * night-words.js gives it.
 */

#scene-night {
  /* Spacing: the line height; the room below the title; between the two
     paragraphs; and a little more before "Always happy to chat". */
  --line-height: 1.6;
  --title-gap: 0.45em;
  --paragraph-gap: 0.8em;
  --chat-gap: 1.5em;

  /* The panel behind the words where they have to reach down over the
     sand (see .is-on-panel): the night sky's deep blue, see-through. */
  --panel: rgba(10, 20, 50, 0.6);
  --panel-padding: 0.75em 1.05em;
  --panel-padding-bottom: 0.75em;
  --panel-radius: 14px;
  /* Its lines, and the larger gap, a little closer together (it is used
     where room is short). */
  --panel-line-height: 1.45;
  --panel-chat-gap: 1.2em;

  /* "Walk back to the beach": its arrow (its size, a share of the
     handwriting's, and how thick its strokes are), and how much it tilts.
     On hover or keyboard focus it warms, glows as if lit by the fire, and
     lifts --walk-back-lift, over --walk-back-lights-up. */
  --walk-back-arrow: 1.15em;
  --walk-back-arrow-stroke: 2.4;
  --walk-back-lit: #ffe3c2;
  --walk-back-glow-near: rgba(255, 160, 80, 0.85);
  --walk-back-glow-near-blur: 4px;
  --walk-back-glow-far: rgba(255, 160, 80, 0.5);
  --walk-back-glow-far-blur: 12px;
  --walk-back-lift: 3px;
  --walk-back-lights-up: 0.4s;
  /* Its tappable area: at least --tap-least tall (and around the words). */
  --tap-least: 44px;

  /* Keyboard focus: a clear ring. */
  --focus-ring: #f4ede0;

  /* Once the visitor has surfaced, the words wait --words-after, then
     fade in over --words-fade-in (at once, for less motion). */
  --words-after: 0.7s;
  --words-fade-in: 2s;
}

/* ---- The block ------------------------------------------------------------ */

/* Its place, width and font size are set by night-words.js. Hidden (and
   out of reach of the keyboard) until it fades in. Above the fire, it
   keeps room at its bottom for the way back (--walk-back-room, set by
   night-words.js). */
.night-words {
  position: absolute;
  margin: 0;
  padding-bottom: var(--walk-back-room, 0px);
  color: var(--warm-white);
  line-height: var(--line-height);
  text-shadow: var(--words-shadow);
  visibility: hidden;
  opacity: 0;
}

.night-words.is-shown,
.walk-back.is-shown {
  visibility: visible;
  opacity: 1;
  transition: opacity var(--words-fade-in) ease var(--words-after), visibility 0s linear var(--words-after);
}

/* Too tall for the sky even at its smallest (a small phone, or one on
   its side): it reaches lower, past the horizon, on a soft dark panel so
   it still reads over the pale sand. If even that is not enough, it
   scrolls (night-words.js sets its height). */
.night-words.is-on-panel {
  --line-height: var(--panel-line-height);
  --chat-gap: var(--panel-chat-gap);
  padding: var(--panel-padding);
  /* Above the fire, the panel keeps room at its bottom for the way back
     and for the links around the fire to arc in (--walk-back-room and
     --links-room, set by night-words.js). */
  padding-bottom: calc(var(--panel-padding-bottom) + var(--walk-back-room, 0px) + var(--links-room, 0px));
  border-radius: var(--panel-radius);
  background: var(--panel);
}

.night-words.is-scrolling {
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (prefers-reduced-motion: reduce) {
  .night-words.is-shown,
  .walk-back.is-shown {
    transition: none;
  }
}

.night-words p {
  margin: 0;
  text-wrap: pretty;
}

.night-words p + p {
  margin-top: var(--paragraph-gap);
}

.night-words p.night-words__chat {
  margin-top: var(--chat-gap);
}

/* ---- The title ------------------------------------------------------------ */

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

/* ---- "Walk back to the beach" --------------------------------------------- */

/* Placed (left, top) and sized (font size) by night-words.js. Hidden until
   it fades in with the words. */
.walk-back {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.25em;
  min-height: var(--tap-least);
  padding: 0.1em 0.3em;
  border-radius: 10px;
  color: var(--warm-white);
  text-decoration: none;
  line-height: 1;
  visibility: hidden;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* The arrow and the words, painted, with the soft shadow, and (on hover)
   the glow. (The glow's colours are typed in fire-links.css, so they fade
   smoothly.) */
.walk-back__arrow,
.walk-back__words {
  filter: var(--hand-paint,) var(--hand-shadow)
    drop-shadow(0 0 var(--walk-back-glow-near-blur) var(--fire-glow-near))
    drop-shadow(0 0 var(--walk-back-glow-far-blur) var(--fire-glow-far));
  transition: --fire-glow-near var(--walk-back-lights-up) ease, --fire-glow-far var(--walk-back-lights-up) ease, color var(--walk-back-lights-up) ease, transform var(--walk-back-lights-up) ease;
}

.walk-back__words {
  white-space: nowrap;
}

/* The same hand-drawn arrow as the cat card's, turned to point back. */
.walk-back__arrow {
  flex: none;
  width: var(--walk-back-arrow);
  height: calc(var(--walk-back-arrow) / 2);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--walk-back-arrow-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  scale: -1 1;
  rotate: 4deg;
}

@media (hover: hover) {
  .walk-back:hover :is(.walk-back__arrow, .walk-back__words) {
    --fire-glow-near: var(--walk-back-glow-near);
    --fire-glow-far: var(--walk-back-glow-far);
    color: var(--walk-back-lit);
    transform: translateY(calc(-1 * var(--walk-back-lift)));
  }
}

.walk-back:focus-visible :is(.walk-back__arrow, .walk-back__words) {
  --fire-glow-near: var(--walk-back-glow-near);
  --fire-glow-far: var(--walk-back-glow-far);
  color: var(--walk-back-lit);
}

.walk-back:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .walk-back {
    padding: 0.2em 0.45em;
  }

  .walk-back:active :is(.walk-back__arrow, .walk-back__words) {
    --fire-glow-near: var(--walk-back-glow-near);
    --fire-glow-far: var(--walk-back-glow-far);
    color: var(--walk-back-lit);
  }
}
