/* First-run tour. Flame colours (--flame-*) are the brand tokens in appearance.css. */
:root { --tour-shade: color-mix(in srgb, #121a27 62%, transparent); }
:root[data-appearance="evening"] { --tour-shade: color-mix(in srgb, #24160f 60%, transparent); }
:root[data-appearance="night"] { --tour-shade: color-mix(in srgb, #03070d 70%, transparent); }

.spark-tour { position: fixed; inset: 0; z-index: 140; cursor: pointer; opacity: 0; transition: opacity .3s ease; }
.spark-tour.is-shown { opacity: 1; }
.spark-tour.is-leaving { opacity: 0; transition-duration: .45s; pointer-events: none; }
.spark-tour [hidden] { display: none; }

/* The lit window: its own huge shadow is the dimmed screen around it. */
.tour-spot { position: fixed; pointer-events: none; box-shadow: 0 0 0 200vmax var(--tour-shade); transition: left .38s cubic-bezier(.3, .7, .2, 1), top .38s cubic-bezier(.3, .7, .2, 1), width .38s cubic-bezier(.3, .7, .2, 1), height .38s cubic-bezier(.3, .7, .2, 1), border-radius .38s; }
.spark-tour.has-target .tour-spot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--flame-2) 70%, transparent), 0 0 22px 6px var(--flame-glow), 0 0 0 200vmax var(--tour-shade); }
.tour-ring { position: fixed; pointer-events: none; border: 2px solid var(--flame-2); animation: tour-ring .9s ease-out infinite; }

.tour-arrow { position: fixed; width: 52px; height: 36px; pointer-events: none; transition: opacity .2s; filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--flame-3) 45%, transparent)); }
.tour-arrow svg { display: block; }
.tour-arrow-shape { animation: tour-float 1.6s ease-in-out infinite; }
.spark-tour[data-kind="action"] .tour-arrow-shape { animation: tour-poke .9s cubic-bezier(.5, 0, .5, 1) infinite; }
.spark-tour.is-moving .tour-arrow, .spark-tour.is-moving .tour-ring { opacity: 0; }

.tour-dialog { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); translate: -50% 0; width: min(680px, calc(100vw - 32px)); box-sizing: border-box; display: grid; grid-template-columns: 56px 1fr; grid-template-areas: "speaker body" "foot foot"; gap: 10px 16px; padding: 18px 20px 12px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 48px color-mix(in srgb, #000 22%, transparent); animation: tour-rise .35s ease-out; }
.spark-tour[data-place="top"] .tour-dialog { bottom: auto; top: max(16px, env(safe-area-inset-top)); }
.tour-speaker { grid-area: speaker; width: 56px; height: 56px; filter: drop-shadow(0 4px 10px var(--flame-glow)); animation: tour-bob 2.6s ease-in-out infinite; }
.tour-speaker.is-talking { animation: tour-bob 2.6s ease-in-out infinite, tour-talk .5s ease-in-out infinite; }
.tour-speaker.is-turning { animation: tour-bob 2.6s ease-in-out infinite, tour-turn .5s ease-out; }
.tour-speaker.is-turning.is-talking { animation: tour-bob 2.6s ease-in-out infinite, tour-talk .5s ease-in-out infinite, tour-turn .5s ease-out; }
.tour-body { grid-area: body; min-width: 0; }
.tour-name { display: block; margin-bottom: 4px; font-size: 12px; letter-spacing: .04em; color: var(--flame-ink); }
.tour-text { position: relative; margin: 0; font-size: 15px; line-height: 1.65; }
.tour-ghost { visibility: hidden; }
.tour-typed { position: absolute; inset: 0; }
.tour-sr { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tour-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }
.tour-hint:empty { display: none; }
.tour-foot { grid-area: foot; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.tour-skip { padding: 6px 4px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.tour-skip:hover { color: var(--ink); }
.tour-next { padding: 7px 16px; border: 0; border-radius: 999px; background: linear-gradient(90deg, var(--flame-2), var(--flame-3)); color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px color-mix(in srgb, var(--flame-3) 30%, transparent); }
.tour-skip:focus-visible, .tour-next:focus-visible { outline: 2px solid color-mix(in srgb, var(--flame-3) 55%, transparent); outline-offset: 2px; }
.tour-dots { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tour-dots li { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: width .25s; }
.tour-dots li.on { width: 18px; background: linear-gradient(90deg, var(--flame-1), var(--flame-3)); }

/* Finale: the speaker flies into Little Spark's chat avatar as a streak of fire. */
.tour-flyer { position: fixed; z-index: 141; pointer-events: none; }
.tour-flyer img { position: absolute; inset: 0; width: 100%; height: 100%; }
.tour-flyer-glow { position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(circle, #fff6c8 0%, var(--flame-1) 22%, var(--flame-2) 45%, color-mix(in srgb, var(--flame-3) 40%, transparent) 62%, transparent 72%); filter: blur(2px); opacity: 0; }
.tour-ember { position: fixed; z-index: 141; pointer-events: none; border-radius: 50%; background: radial-gradient(circle, #fff3b0 0%, #ffb347 45%, var(--flame-3) 80%, transparent 100%); box-shadow: 0 0 8px 2px color-mix(in srgb, var(--flame-2) 60%, transparent); }
.tour-halo { position: fixed; z-index: 141; width: 30px; height: 30px; margin: -15px 0 0 -15px; border: 2px solid var(--flame-2); border-radius: 50%; box-shadow: 0 0 16px 4px var(--flame-glow); pointer-events: none; animation: tour-halo .7s ease-out forwards; }
.tour-ignite { animation: tour-ignite .7s ease-out; }
/* The chat step: the message is empty until the spark lands, then the avatar lights and the words follow. */
.coach-message.tour-awaiting .coach-avatar, .coach-message.tour-awaiting > div { visibility: hidden; }
.coach-message.tour-revealing > div { animation: tour-bubble .45s ease-out .3s both; }


/* Tips: a small bubble beside the element, never blocking it. */
.spark-tip { position: fixed; z-index: 135; box-sizing: border-box; width: min(300px, calc(100vw - 24px)); display: grid; grid-template-columns: 28px 1fr; gap: 6px 10px; padding: 12px 14px 8px; background: var(--paper); color: var(--ink); border: 1px solid color-mix(in srgb, var(--flame-2) 45%, var(--line)); border-radius: 14px; box-shadow: 0 12px 30px color-mix(in srgb, #000 16%, transparent), 0 0 0 4px color-mix(in srgb, var(--flame-1) 16%, transparent); animation: tip-pop .3s ease-out; }
.spark-tip-face { width: 28px; height: 28px; animation: tour-bob 2.6s ease-in-out infinite; }
.spark-tip-text { margin: 3px 0 0; font-size: 13px; line-height: 1.6; }
.spark-tip-ok { grid-column: 2; justify-self: end; padding: 2px 4px; border: 0; background: none; color: var(--flame-ink); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.spark-tip-ok:focus-visible { outline: 2px solid color-mix(in srgb, var(--flame-3) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.spark-tip-nub { position: absolute; left: calc(var(--nub, 50%) - 6px); width: 12px; height: 12px; background: var(--paper); border: inherit; border-radius: 2px; transform: rotate(45deg); }
.spark-tip[data-side="below"] .spark-tip-nub { top: -7px; border-right: 0; border-bottom: 0; }
.spark-tip[data-side="above"] .spark-tip-nub { bottom: -7px; border-left: 0; border-top: 0; }
.spark-tip-target { outline: 2px solid color-mix(in srgb, var(--flame-2) 60%, transparent); outline-offset: 3px; }

@keyframes tour-ring { 0%, 66% { opacity: 0; transform: scale(.97); } 70% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.12); } }
@keyframes tour-float { 0%, 100% { transform: translateX(-8px); } 50% { transform: translateX(-1px); } }
@keyframes tour-poke { 0% { transform: translateX(-12px); } 50% { transform: translateX(-16px); } 70% { transform: translateX(3px); } 80% { transform: translateX(-1px); } 100% { transform: translateX(-12px); } }
@keyframes tour-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes tour-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }
@keyframes tour-talk { 0%, 100% { scale: 1; } 50% { scale: 1.06; } }
@keyframes tour-turn { 0% { rotate: -14deg; } 60% { rotate: 5deg; } 100% { rotate: 0deg; } }
@keyframes tip-pop { from { opacity: 0; transform: translateY(4px) scale(.96); } }
@keyframes tour-bubble { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes tour-halo { from { opacity: .95; transform: scale(.6); } to { opacity: 0; transform: scale(2.6); } }
@keyframes tour-ignite { 0% { scale: .7; filter: brightness(1.8) drop-shadow(0 0 10px #ffb347); } 45% { scale: 1.2; filter: brightness(1.3) drop-shadow(0 0 14px var(--flame-2)); } 100% { scale: 1; filter: none; } }

@media (max-width: 650px) {
  .tour-dialog { grid-template-columns: 44px 1fr; gap: 8px 12px; padding: 14px 14px 10px; border-radius: 16px; }
  .tour-speaker { width: 44px; height: 44px; }
  .tour-text { font-size: 14px; }
}
