/* ============================================================
   xmas-note.css : Hoshi's handwritten Christmas note over the hero
   ============================================================
   Shown ONLY while the app's demo carries the free Christmas story
   (xmas-note.js asks app.mukashi.world/api/public/christmas-demo).
   Until then nothing of it is in the page's layout: the markup sits in
   a <template> and is laid over the hero absolutely, so it can never
   shift anything when it arrives.

   PLACEMENT: two spots per width band, every number a fraction of the
   hero (the hero is a size container, so they scale with it):
     centre  --xc-x/--xc-y/--xc-w  where it writes itself on, in the
                                   space the faded headline leaves
     corner  --xk-x/--xk-y/--xk-w  where it glides to and stays
   x = left edge (% of hero width), y = top edge (% of hero height),
   w = width (% of hero width; the type scales with it).
   Set them with the preview's placement mode (?xmas-demo=1&place=1 on
   localhost or a vercel.app preview), which prints this exact CSS.

   MOTION: the note is LAID OUT at the corner. The centre is the same box
   moved and scaled by a transform (text wraps identically, because width
   and type scale together), so the glide is compositor-only: one
   transform transition, no layout.
   ============================================================ */

.xmas-note {
  /* desktop (Tom, 2026-11-14) */
  --xc-x: 34.6; --xc-y: 37.8; --xc-w: 31.1;
  --xk-x: 69.8; --xk-y: 70.2; --xk-w: 29;
  /* how long it is held in the centre once written, in ms (xmas-note.js);
     desktop is short (Tom, 2026-11-14: "5-6 seconds earlier") */
  --xn-hold: 2500;
  position: absolute;
  z-index: 2;
  left: calc(var(--xk-x) * 1%);
  top: calc(var(--xk-y) * 1%);
  width: calc(var(--xk-w) * 1cqw);
  margin: 0;
  /* the second line's size; the first is larger */
  font-size: calc(var(--xk-w) * 1cqw * 0.082);
  font-family: 'Caveat', 'Fredoka', cursive;
  font-weight: 600;
  line-height: 1.12;
  text-align: center;
  text-decoration: none;
  color: #FFE9B8;
  transform-origin: 0 0;
  /* the corner: the same function list as the centre, so they interpolate */
  transform: translate(0px, 0px) scale(1) rotate(-2.5deg);
  /* legibility over the moving sky: a close night-blue edge, then a wider
     soft one; the warm glow lives on ::before so it can swell cheaply */
  filter: drop-shadow(0 1px 1px rgba(8, 14, 40, 0.85))
          drop-shadow(0 0 0.35em rgba(8, 14, 40, 0.55));
  -webkit-tap-highlight-color: transparent;
}
.xmas-note.at-centre {
  transform:
    translate(calc((var(--xc-x) - var(--xk-x)) * 1cqw), calc((var(--xc-y) - var(--xk-y)) * 1cqh))
    scale(calc(var(--xc-w) / var(--xk-w)))
    rotate(-2.5deg);
}
/* waiting for the headline to fade: there, but not yet written */
.xmas-note.is-waiting { visibility: hidden; }
/* the glide: a calm ease, position and size together */
.xmas-note.is-gliding {
  transition: transform 1.15s cubic-bezier(0.45, 0.05, 0.2, 1);
  will-change: transform;
}
@media (max-width: 1024px) {
  .xmas-note {
    --xc-x: 12; --xc-y: 27.5; --xc-w: 66;
    --xk-x: 46; --xk-y: 68; --xk-w: 51;
    --xn-hold: 8000;
  }
}
/* An iPad held sideways (1024x768) is a landscape picture like the
   desktop's: the portrait tablet spots are too big for it and the
   centre would sit on the snowman. It takes the desktop spots. */
@media (max-width: 1024px) and (orientation: landscape) {
  .xmas-note {
    --xc-x: 34.6; --xc-y: 37.8; --xc-w: 31.1;
    --xk-x: 69.8; --xk-y: 70.2; --xk-w: 29;
    --xn-hold: 2500;
  }
}
@media (max-width: 600px) {
  .xmas-note {
    --xc-x: 6; --xc-y: 31; --xc-w: 88;
    --xk-x: 38.5; --xk-y: 71; --xk-w: 59;
    --xn-hold: 8000;
    /* phones: write on in the centre and stay there (Tom, 2026-11-14) */
    --xn-glide: 0;
  }
}

/* Lamplight behind the words: arrives once the note is written */
.xmas-note::before {
  content: '';
  position: absolute;
  inset: -18% -8%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(255, 214, 140, 0.30) 0%,
    rgba(245, 166, 35, 0.12) 55%,
    transparent 100%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.xmas-note .xmas-note__line {
  margin: 0;
  /* the site's own p/span rules set Nunito at body size: be explicit */
  font-family: 'Caveat', 'Fredoka', cursive;
  font-weight: 600;
  font-size: 1em;
  line-height: inherit;
  color: inherit;
}
.xmas-note .xmas-note__line--1 {
  font-size: 1.75em;
  line-height: 1;
  margin-bottom: 0.12em;
}
/* Japanese: Yomogi (.jp-hand, styles.css) is wider per character than
   Caveat is per letter, so it sets a touch smaller */
.xmas-note [lang="ja"] { font-size: 0.8em; line-height: 1.4; letter-spacing: 0.02em; }
.xmas-note .xmas-note__line--1 [lang="ja"] { font-size: 0.64em; line-height: 1.2; }
/* a phrase never breaks inside itself (the source marks breaks with <wbr>) */
.xmas-note .xp { white-space: nowrap; }
/* Yomogi is a fine pen: thicken the ink a touch and deepen its edge */
.xmas-note [lang="ja"] .xw { -webkit-text-stroke: 0.035em rgba(250, 200, 110, 0.95); }
.xmas-note:lang(ja),
.xmas-note:has([lang="ja"]:only-child) {
  filter: drop-shadow(0 1px 1px rgba(8, 14, 40, 0.9))
          drop-shadow(0 0 0.3em rgba(8, 14, 40, 0.7));
}

/* Every word (EN) or character (JA) is one stroke of the pen: gold ink,
   revealed left to right by a soft-edged mask. xmas-note.js sets each
   one's --t (start) and --d (duration). */
.xmas-note .xw {
  display: inline-block;
  padding: 0.04em 0.07em 0.16em;
  margin: -0.04em -0.07em -0.16em;
  background: linear-gradient(180deg, #FFE9B8 18%, #F5A623 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-mask-image: linear-gradient(90deg, #000 42%, transparent 58%);
  mask-image: linear-gradient(90deg, #000 42%, transparent 58%);
  -webkit-mask-size: 260% 100%;
  mask-size: 260% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
}
.xmas-note.is-writing .xw {
  animation: xmas-pen var(--d, 400ms) cubic-bezier(0.45, 0.05, 0.55, 0.95) var(--t, 0ms) forwards;
}
@keyframes xmas-pen {
  to { -webkit-mask-position: 0 0; mask-position: 0 0; }
}
.xmas-note.is-written .xw,
.xmas-note.is-still .xw {
  animation: none;
  -webkit-mask-image: none;
  mask-image: none;
}

/* The gentle glow once it is written: swells, then settles and breathes */
.xmas-note.is-written::before {
  animation: xmas-glow-in 2.4s ease-out forwards, xmas-glow-breathe 6s ease-in-out 2.4s infinite;
}
@keyframes xmas-glow-in {
  0%   { opacity: 0; }
  45%  { opacity: 1; }
  100% { opacity: 0.6; }
}
@keyframes xmas-glow-breathe {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 0.9; }
}
.xmas-note.is-still::before { opacity: 0.6; }

.xmas-note:focus-visible { outline: none; }
.xmas-note:focus-visible .xmas-note__line--1 { text-decoration: underline 2px rgba(245, 166, 35, 0.8); text-underline-offset: 0.12em; }

@media (prefers-reduced-motion: reduce) {
  .xmas-note { transition: none; }
  .xmas-note .xw { animation: none !important; -webkit-mask-image: none; mask-image: none; }
  .xmas-note::before { animation: none !important; opacity: 0.6; }
}
