/* fire-links.css
 *
 * The contact links handwritten around the night beach's campfire
 * (js/scenes/night-beach/fire-links.js places them, and sets their
 * sizes, tilts, drift, lift and glow: the --drift, --lift, --lit-colour and
 * --glow-* below come from there). Same hand as the headings: Nanum Pen
 * Script, lettered and painted by hand, in the warm off-white with a soft
 * shadow (--warm-white and --hand-shadow, in base.css).
 */

#scene-night {
  /* The links fade in --links-after the visitor has surfaced (a little
     after the words in the sky), over --links-fade-in (at once, for less
     motion). */
  --links-after: 1.3s;
  --links-fade-in: 2s;

  /* On hover or focus: how quickly a word lights up and lifts. */
  --link-lights-up: 0.4s;

  /* Each link's tappable area: at least --tap-least across and tall, and
     reaching --tap-reach around the word (more on a touch screen). */
  --tap-least: 44px;
  --tap-reach: 0.12em 0.25em;
  --tap-reach-touch: 0.3em 0.45em;

  /* The note after "Email" is clicked: the address's size and colour, and
     how quickly the note fades in and out. */
  --note-address-size: 0.8rem;
  --note-address-colour: rgba(244, 237, 224, 0.85);
  --note-fades: 0.35s;

  /* The doodle beside "Email": its size and stroke (in em of the word). */
  --doodle-size: 0.42em;
  --doodle-stroke: 1.7;
}

/* The glow's two colours, as properties the browser knows are colours, so
   they fade in and out smoothly (an unknown property would just switch). */
@property --fire-glow-near {
  syntax: "<color>";
  inherits: true;
  initial-value: rgba(255, 160, 80, 0);
}

@property --fire-glow-far {
  syntax: "<color>";
  inherits: true;
  initial-value: rgba(255, 160, 80, 0);
}

/* ---- The holder ----------------------------------------------------------- */

/* Covers the scene, but lets clicks through except on the links. Hidden
   (and out of reach of the keyboard) until it fades in. */
.fire-links {
  position: absolute;
  inset: 0;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

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

@media (prefers-reduced-motion: reduce) {
  .fire-links.is-shown {
    transition: none;
  }
}

/* ---- A link --------------------------------------------------------------- */

/* Its middle where fire-links.js puts it (left, top); its font size from
   there too. */
.fire-link {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-least);
  min-height: var(--tap-least);
  padding: var(--tap-reach);
  translate: -50% -50%;
  border-radius: 10px;
  color: var(--warm-white);
  text-decoration: none;
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (pointer: coarse) {
  .fire-link {
    padding: var(--tap-reach-touch);
  }
}

/* The word (and its doodle), floating gently up and down, with its paint,
   its soft shadow and (on hover) its glow. */
.fire-link__float {
  position: relative;
  display: block;
  filter: var(--hand-paint,) var(--hand-shadow)
    drop-shadow(0 0 var(--glow-near-blur) var(--fire-glow-near))
    drop-shadow(0 0 var(--glow-far-blur) var(--fire-glow-far));
  animation: fire-link-drift var(--drift-time) ease-in-out var(--drift-delay) infinite alternate;
  transition: --fire-glow-near var(--link-lights-up) ease, --fire-glow-far var(--link-lights-up) ease, color var(--link-lights-up) ease, transform var(--link-lights-up) ease;
}

.fire-link__word {
  display: block;
  white-space: nowrap;
}

@keyframes fire-link-drift {
  from {
    translate: 0 calc(-1 * var(--drift));
  }
  to {
    translate: 0 var(--drift);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fire-link__float {
    animation: none;
  }
}

/* Lit by the fire: warmer, glowing, lifted a little. */
@media (hover: hover) {
  .fire-link:hover .fire-link__float {
    --fire-glow-near: var(--glow-near);
    --fire-glow-far: var(--glow-far);
    color: var(--lit-colour);
    transform: translateY(calc(-1 * var(--lift)));
  }
}

.fire-link:focus-visible .fire-link__float {
  --fire-glow-near: var(--glow-near);
  --fire-glow-far: var(--glow-far);
  color: var(--lit-colour);
  transform: translateY(calc(-1 * var(--lift)));
}

.fire-link:focus-visible {
  outline: 2px solid var(--warm-white);
  outline-offset: 2px;
}

/* A tap on a touch screen lights it too, for the moment of the press. */
@media (pointer: coarse) {
  .fire-link:active .fire-link__float {
    --fire-glow-near: var(--glow-near);
    --fire-glow-far: var(--glow-far);
    color: var(--lit-colour);
  }
}

/* The little spark beside "Email", up and to the right of the word. */
.fire-link__doodle {
  position: absolute;
  top: -0.12em;
  right: calc(-1 * var(--doodle-size) - 0.08em);
  width: var(--doodle-size);
  height: var(--doodle-size);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--doodle-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  rotate: 8deg;
}

/* ---- The note after "Email" is clicked ------------------------------------ */

/* Placed beside the word by fire-links.js; its font size is the word's. */
.fire-link-note {
  position: absolute;
  margin: 0;
  color: var(--warm-white);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--note-fades) ease;
}

.fire-link-note.is-showing {
  opacity: 1;
  /* The address can be selected, to copy it by hand. */
  pointer-events: auto;
}

.fire-link-note__said {
  display: block;
  font-size: 0.72em;
  filter: var(--hand-paint,) var(--hand-shadow);
}

.fire-link-note__address {
  display: block;
  margin-top: 0.2em;
  color: var(--note-address-colour);
  font-size: var(--note-address-size);
  text-shadow: var(--words-shadow);
  user-select: text;
  -webkit-user-select: text;
}
