/* Welcome and transient delight, 0.13.0. Every selector is presentation-scoped.
   The root owns body.is-welcoming; only that state hides the map navigation.
   No course charts, rules, navigation, or existing controls are restyled. */
body.is-welcoming #nav { display: none; }
.kp-welcome {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(230px, .85fr);
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
  max-width: 990px;
  margin: 26px auto 52px;
  padding: 28px 0 20px;
  color: var(--kp-ink, #17243B);
}
.kp-welcome-copy { min-width: 0; }
.kp-welcome .kp-welcome-kicker {
  margin: 0 0 14px;
  color: var(--kp-brand, #3155D9);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
}
.kp-welcome h1 {
  font-size: clamp(34px, 4.3vw, 54px);
  line-height: 1.2;
  letter-spacing: -.035em;
  font-weight: 750;
  overflow-wrap: break-word;
}
.kp-welcome .kp-welcome-description {
  max-width: 500px;
  margin: 22px 0 24px;
  font-size: 18px;
  line-height: 1.75;
  color: var(--kp-muted, #627189);
}
.kp-welcome-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 0;
  margin: 24px 0 0;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
}
.kp-welcome-steps li { display: flex; align-items: center; gap: 7px; }
.kp-welcome-steps li > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 1px solid var(--kp-line, #DBE3EE);
  border-radius: 50%;
  background: var(--kp-surface, #FFFFFF);
  color: var(--kp-brand, #3155D9);
  font-size: 12px;
}
.kp-welcome-actions { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.kp-welcome-actions button { min-height: 56px; padding: 13px 20px; font-size: 16px; }
.kp-welcome #welcome-enter { flex: 1 1 180px; background: var(--kp-brand, #3155D9); color: #FFFFFF; }
.kp-welcome #welcome-enter:hover { background: var(--kp-brandHover, #2848BE); }
.kp-welcome .kp-welcome-skip {
  flex: 1 1 175px;
  border: 1px solid var(--kp-line, #DBE3EE);
  background: var(--kp-surface, #FFFFFF);
  color: var(--kp-ink, #17243B);
  font-size: 14px;
  font-weight: 600;
}
.kp-welcome .kp-welcome-skip:hover { background: var(--kp-tint, #EDF1FF); }
.kp-welcome .kp-welcome-resume { margin: 14px 0 0; font-size: 13px; color: var(--kp-muted, #627189); }
.kp-welcome-art { align-self: center; text-align: center; min-width: 0; }
.kp-welcome-window {
  width: min(100%, 330px);
  aspect-ratio: 1 / 1.04;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 42% 42% 26px 26px;
  border: 1px solid #2848BE;
  background: var(--kp-brand, #3155D9);
  overflow: hidden;
  padding: 10px 18px 28px;
}
.kp-welcome-mark { display: block; flex: none; width: min(100%, 256px); height: auto; overflow: visible; }
.kp-welcome-name { font-size: clamp(21px, 2.5vw, 29px); font-weight: 700; letter-spacing: -.04em; color: #FFFFFF; line-height: 1.2; }
.kp-welcome .kp-welcome-caption { margin: 17px 0 1px; font-size: 13px; color: var(--kp-muted, #627189); }
.kp-welcome .kp-welcome-replay {
  min-height: 44px;
  padding: 8px 12px;
  background: transparent;
  color: var(--kp-brand, #3155D9);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.kp-welcome .kp-welcome-replay:hover { background: var(--kp-tint, #EDF1FF); }
.kp-welcome-replay[hidden] { display: none; }
.kp-welcome button:focus-visible, .kp-celebration button:focus-visible {
  outline: 2px solid var(--kp-ink, #17243B);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--kp-surface, #FFFFFF);
}

/* One 4-second cycle: pause, turn, peek/blink, return, pause. The maximum
   transform is the matrix produced by final-v1/build_final.py pose(1, 0). */
.kp-welcome-pose, .kp-welcome-eye, .kp-welcome-pupil { transform-origin: 0 0; }
.kp-welcome--animate .kp-welcome-pose { animation: kp-welcome-peek 4s ease-in-out 1 both; }
.kp-welcome--animate .kp-welcome-eye { animation: kp-welcome-blink 4s linear 1 both; }
.kp-welcome--animate .kp-welcome-pupil { animation: kp-welcome-look 4s ease-in-out 1 both; }
@keyframes kp-welcome-peek {
  0%, 22.5%, 80%, 100% { transform: matrix(1, 0, 0, 1, 0, 0); }
  42.5%, 60% { transform: matrix(.62, -.065, 0, 1, 32.32, 1.16); }
}
@keyframes kp-welcome-look {
  0%, 22.5%, 80%, 100% { transform: translateX(0); }
  42.5%, 60% { transform: translateX(2.2px); }
}
@keyframes kp-welcome-blink {
  0%, 48%, 54%, 100% { transform: matrix(1, 0, 0, 1, 0, 0); }
  51% { transform: matrix(1, 0, 0, .08, 0, 38.64); }
}

/* Inline and appended after the existing actions. It cannot cover the chart
   or place a layer over the next button. All moving shapes are clipped inside
   a dedicated, non-interactive SVG box; no page-sized canvas or overlay. */
.kp-celebration {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 7px 0 0;
  margin: 12px 0 0;
  border-top: 1px solid var(--kp-line, #DBE3EE);
  text-align: start;
  color: var(--kp-ink, #17243B);
}
.kp-celebration-art {
  display: block;
  flex: 0 0 100px;
  width: 100px;
  height: 64px;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.kp-celebration--lesson .kp-celebration-art { flex-basis: 128px; width: 128px; height: 86px; }
.kp-celebration-copy { min-width: 0; flex: 1; font-size: 14px; line-height: 1.55; font-weight: 650; overflow-wrap: anywhere; }
.kp-celebration .kp-celebration-skip {
  flex: none;
  min-height: 44px;
  padding: 8px 12px;
  background: transparent;
  color: var(--kp-muted, #627189);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.kp-celebration .kp-celebration-skip:hover { background: var(--kp-tint, #EDF1FF); color: var(--kp-ink, #17243B); }
.kp-celebration-static { display: none; }
.kp-confetti-piece { opacity: 0; animation: kp-confetti-fall 930ms ease-out var(--kp-piece-delay, 0ms) 1 both; }
@keyframes kp-confetti-fall {
  0% { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  16% { opacity: .95; }
  64% { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--kp-piece-x), var(--kp-piece-y)) rotate(var(--kp-piece-turn)); }
}
.kp-firework-burst { opacity: 0; animation: kp-firework-open 1300ms cubic-bezier(.16, .6, .3, 1) var(--kp-burst-delay, 0ms) 1 both; }
@keyframes kp-firework-open {
  0% { opacity: 0; transform: scale(.22); }
  22% { opacity: .9; }
  62% { opacity: .8; }
  100% { opacity: 0; transform: scale(1.15); }
}
.kp-celebration--settled .kp-confetti-piece, .kp-celebration--settled .kp-firework-burst { animation: none; opacity: 0; }
.kp-celebration--settled .kp-celebration-static { display: block; }
.kp-delight-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  body.is-welcoming .topbar { padding: 10px 0; gap: 12px; }
  .kp-welcome { grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 520px; margin: 0 auto 28px; padding-top: 4px; }
  /* Only the decorative window comes first. Entry is ahead of the learning
     steps and replay in both visual and keyboard order. */
  .kp-welcome-art { display: contents; }
  .kp-welcome-window { grid-row: 1; width: 96px; border-radius: 42% 42% 14px 14px; padding: 3px 4px 7px; }
  .kp-welcome-copy { grid-row: 2; }
  .kp-welcome-mark { width: 86px; }
  .kp-welcome-name, .kp-welcome .kp-welcome-caption { display: none; }
  .kp-welcome .kp-welcome-replay { grid-row: 3; justify-self: start; font-size: 12px; }
  .kp-welcome .kp-welcome-kicker { margin-bottom: 10px; }
  .kp-welcome h1 { font-size: clamp(32px, 7.5vw, 44px); }
  .kp-welcome .kp-welcome-description { font-size: 16px; line-height: 1.6; margin: 14px 0 18px; }
  .kp-welcome-steps { margin: 20px 0 0; gap: 10px 13px; }
}
@media (max-width: 420px) {
  .kp-welcome { gap: 14px; }
  .kp-welcome-actions { flex-direction: column; }
  .kp-welcome #welcome-enter, .kp-welcome .kp-welcome-skip { flex-basis: auto; width: 100%; }
  .kp-celebration { gap: 6px; }
  .kp-celebration-art, .kp-celebration--lesson .kp-celebration-art { flex-basis: 70px; width: 70px; height: 64px; }
  .kp-celebration-copy { font-size: 13px; }
  .kp-celebration .kp-celebration-skip { padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .kp-welcome *, .kp-celebration * { animation: none !important; transition: none !important; }
  .kp-welcome-pose, .kp-welcome-eye, .kp-welcome-pupil { transform: none !important; }
  .kp-welcome .kp-welcome-replay { display: none; }
  .kp-confetti-piece, .kp-firework-burst { display: none; }
  .kp-celebration-static { display: block; }
  .kp-welcome button:active, .kp-celebration button:active { transform: none; }
}
@media (forced-colors: active) {
  .kp-welcome-window { forced-color-adjust: none; }
  .kp-welcome button, .kp-celebration button { border: 1px solid ButtonText; }
  .kp-celebration-art { forced-color-adjust: none; }
}

/* Fixed native particle values in external CSS for the demo CSP. */
.kp-confetti-piece[data-demo-piece="0"]{--kp-piece-x:-55px;--kp-piece-y:16px;--kp-piece-turn:-115deg;--kp-piece-delay:0ms}
.kp-confetti-piece[data-demo-piece="1"]{--kp-piece-x:-41px;--kp-piece-y:-22px;--kp-piece-turn:130deg;--kp-piece-delay:35ms}
.kp-confetti-piece[data-demo-piece="2"]{--kp-piece-x:-28px;--kp-piece-y:25px;--kp-piece-turn:70deg;--kp-piece-delay:70ms}
.kp-confetti-piece[data-demo-piece="3"]{--kp-piece-x:-13px;--kp-piece-y:-30px;--kp-piece-turn:-150deg;--kp-piece-delay:0ms}
.kp-confetti-piece[data-demo-piece="4"]{--kp-piece-x:5px;--kp-piece-y:-24px;--kp-piece-turn:100deg;--kp-piece-delay:35ms}
.kp-confetti-piece[data-demo-piece="5"]{--kp-piece-x:24px;--kp-piece-y:-31px;--kp-piece-turn:-80deg;--kp-piece-delay:70ms}
.kp-confetti-piece[data-demo-piece="6"]{--kp-piece-x:40px;--kp-piece-y:-19px;--kp-piece-turn:145deg;--kp-piece-delay:0ms}
.kp-confetti-piece[data-demo-piece="7"]{--kp-piece-x:58px;--kp-piece-y:9px;--kp-piece-turn:-120deg;--kp-piece-delay:35ms}
.kp-confetti-piece[data-demo-piece="8"]{--kp-piece-x:-47px;--kp-piece-y:-4px;--kp-piece-turn:90deg;--kp-piece-delay:70ms}
.kp-confetti-piece[data-demo-piece="9"]{--kp-piece-x:-17px;--kp-piece-y:13px;--kp-piece-turn:-95deg;--kp-piece-delay:0ms}
.kp-confetti-piece[data-demo-piece="10"]{--kp-piece-x:26px;--kp-piece-y:18px;--kp-piece-turn:125deg;--kp-piece-delay:35ms}
.kp-confetti-piece[data-demo-piece="11"]{--kp-piece-x:45px;--kp-piece-y:27px;--kp-piece-turn:-65deg;--kp-piece-delay:70ms}
.kp-firework-burst[data-demo-burst-delay="0"]{--kp-burst-delay:0ms}
.kp-firework-burst[data-demo-burst-delay="280"]{--kp-burst-delay:280ms}
.kp-firework-burst[data-demo-burst-delay="570"]{--kp-burst-delay:570ms}
