/* talk-links.css
 *
 * The two "Let's talk" links to the night beach, both handwritten (lettered
 * and painted by hand, like the other handwriting), in the warm off-white:
 *
 * - on the day beach, out on the sea to the right of the campfire (or, on
 *   a narrow screen, below the intro), with a tiny flame doodled beside
 *   it (placed and sized by beach-words.js, with the words);
 * - floating in the bottom-right corner of the page once the visitor has
 *   scrolled on, glowing softly like a small lamp (talk-float.js shows and
 *   hides it).
 *
 * On hover or keyboard focus, each warms and glows as if lit by the fire
 * (the glow's colours, --fire-glow-near and --fire-glow-far, are typed in
 * fire-links.css, so they fade smoothly), and lifts a little.
 */

.talk-link,
.talk-float {
  /* Lit (hovered or focused): a warmer colour, a near and a far glow,
     lifted --talk-lift, over --talk-lights-up. */
  --talk-lit: #ffe3c2;
  --talk-glow-near: rgba(255, 168, 92, 0.85);
  --talk-glow-near-blur: 4px;
  --talk-glow-far: rgba(255, 168, 92, 0.5);
  --talk-glow-far-blur: 12px;
  --talk-lift: 3px;
  --talk-lights-up: 0.4s;

  /* The flame doodle's height (its width is about three quarters of
     that). */
  --talk-flame: 0.62em;

  display: inline-flex;
  align-items: center;
  gap: 0.16em;
  color: var(--warm-white);
  text-decoration: none;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* The words and the doodles: painted, the soft shadow, and the glow. */
:is(.talk-link, .talk-float) :is(.hand-written, svg) {
  filter: var(--hand-paint,) var(--hand-shadow)
    drop-shadow(0 0 var(--talk-glow-near-blur) var(--fire-glow-near))
    drop-shadow(0 0 var(--talk-glow-far-blur) var(--fire-glow-far));
  transition: --fire-glow-near var(--talk-lights-up) ease, --fire-glow-far var(--talk-lights-up) ease, color var(--talk-lights-up) ease, transform var(--talk-lights-up) ease;
}

.talk-link__flame,
.talk-float__flame {
  flex: none;
  width: calc(var(--talk-flame) * 0.77);
  height: var(--talk-flame);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  rotate: 6deg;
}

/* Lit: on hover (a mouse or trackpad), keyboard focus, or while pressed
   on a touch screen. */
@media (hover: hover) {
  :is(.talk-link, .talk-float):hover :is(.hand-written, svg) {
    --fire-glow-near: var(--talk-glow-near);
    --fire-glow-far: var(--talk-glow-far);
    color: var(--talk-lit);
    transform: translateY(calc(-1 * var(--talk-lift)));
  }
}

:is(.talk-link, .talk-float):focus-visible :is(.hand-written, svg) {
  --fire-glow-near: var(--talk-glow-near);
  --fire-glow-far: var(--talk-glow-far);
  color: var(--talk-lit);
}

@media (pointer: coarse) {
  :is(.talk-link, .talk-float):active :is(.hand-written, svg) {
    --fire-glow-near: var(--talk-glow-near);
    --fire-glow-far: var(--talk-glow-far);
    color: var(--talk-lit);
  }
}

:is(.talk-link, .talk-float):focus-visible {
  outline: 2px solid rgba(255, 227, 194, 0.85);
  outline-offset: 3px;
  border-radius: 8px;
}

/* For less motion: it lights up, but does not lift. */
@media (prefers-reduced-motion: reduce) {
  :is(.talk-link, .talk-float):hover :is(.hand-written, svg) {
    transform: none;
  }
}

/* ---- On the day beach ------------------------------------------------------ */

/* Its font size and place are set by beach-words.js. At least 44 pixels
   tall, so it is easy to tap. Below the intro, in the words' column; or,
   where there is room, out on the sea right of the campfire (--aside). */
.talk-link {
  min-height: 44px;
  margin-top: 0.15em;
  white-space: nowrap;
}

.talk-link--aside {
  position: absolute;
  margin: 0;
}

/* ---- Floating ------------------------------------------------------------- */

.talk-float {
  /* Its size; how far in from the corner (clear of a phone's rounded
     corners and home bar); its lamp's glow when unlit; and how long it
     takes to fade in or out. */
  --talk-float-size: clamp(1.7rem, 1.45rem + 0.7vw, 2.2rem);
  --talk-float-inset: 1rem;
  --talk-lamp-near: rgba(255, 168, 92, 0.45);
  --talk-lamp-far: rgba(255, 168, 92, 0.3);
  --talk-lamp-halo: rgba(255, 170, 100, 0.2);
  --talk-float-fade: 0.45s;

  --fire-glow-near: var(--talk-lamp-near);
  --fire-glow-far: var(--talk-lamp-far);

  position: fixed;
  right: max(var(--talk-float-inset), env(safe-area-inset-right));
  bottom: max(var(--talk-float-inset), calc(env(safe-area-inset-bottom) + 0.5rem));
  /* Above the scenes and the dive's overlay, with the other controls. */
  z-index: 4;
  isolation: isolate;
  min-width: 44px;
  min-height: 44px;
  padding: 0.15em 0.4em;
  font-size: var(--talk-float-size);
  opacity: 0;
  visibility: hidden;
  /* (visibility switches after the fade out, so it can still be seen
     fading; hidden, it is out of reach of the keyboard too.) */
  transition: opacity var(--talk-float-fade) ease, visibility 0s linear var(--talk-float-fade);
}

.talk-float.is-shown {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--talk-float-fade) ease, visibility 0s;
}

/* The lamp's soft warm light around it. */
.talk-float::before {
  content: "";
  position: absolute;
  inset: -0.35em -0.5em;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--talk-lamp-halo), transparent);
  pointer-events: none;
}
