/* Sprint 1 motion language — transforms & opacity only */
:root {
    --motion-fast: 120ms;
    --motion-normal: 240ms;
    --motion-slow: 500ms;
    --ease-playful: cubic-bezier(0.2, 0.9, 0.3, 1.2);
    --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@keyframes hp-fade-in {
    /* Opacity only — no transform. hp-fade-in is used on whole-screen root
       containers (home, stage picker) that host modals as descendants.
       Even an animated transform that *ends* at an identity value still
       reports as a resolved matrix (not the keyword "none") for as long
       as the animation is filling, and any non-"none" transform makes the
       element a containing block for position:fixed children — trapping
       modals inside the screen instead of the real viewport. Child
       elements get their slide-in motion from hp-rise instead.
    */
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes hp-rise {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@keyframes hp-bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    70% { transform: translateY(-4px); }
}

@keyframes hp-pop {
    0% { transform: scale(0.6); opacity: 0; }
    70% { transform: scale(1.12); opacity: 1; }
    100% { transform: none; }
}

@keyframes hp-float {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-14px) rotate(4deg); }
}

@keyframes hp-drift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(12px, -28px); }
}

@keyframes hp-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-6deg); }
    75% { transform: rotate(6deg); }
}

/* Sprint miss feedback: a quick zoom-in on the stave instead of a wobble — steadier to read at speed. */
@keyframes hp-zoom-nudge {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.07); }
}

@keyframes hp-pulse-once {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes hp-squash {
    0% { transform: scale(1, 1); }
    40% { transform: scale(1.08, 0.9); }
    70% { transform: scale(0.96, 1.04); }
    100% { transform: scale(1, 1); }
}

@keyframes hp-glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
    50% { filter: drop-shadow(0 0 10px rgba(62, 207, 142, 0.85)); transform: scale(1.04); }
}

@keyframes hp-note-in {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: none; }
}

@keyframes hp-sparkle {
    0% { transform: scale(0.2) rotate(0deg); opacity: 0; }
    40% { opacity: 1; }
    100% { transform: scale(1.4) rotate(40deg); opacity: 0; }
}

@keyframes hp-confetti-fall {
    0% { transform: translateY(-10%) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

@keyframes hp-key-hint {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); transform: translateY(0); }
    50% { box-shadow: 0 0 0 6px rgba(245, 166, 35, 0.45); transform: translateY(-2px); }
}

.hp-anim-fade-in { animation: hp-fade-in var(--motion-slow) var(--ease-soft) both; }
.hp-anim-rise { animation: hp-rise var(--motion-slow) var(--ease-playful) both; }
.hp-anim-bounce { animation: hp-bounce 0.7s var(--ease-playful); }
.hp-anim-pop { animation: hp-pop var(--motion-normal) var(--ease-playful) both; }
.hp-anim-wiggle { animation: hp-wiggle 0.45s var(--ease-playful); }
.hp-anim-zoom-nudge { animation: hp-zoom-nudge 0.25s var(--ease-soft); }
.hp-anim-pulse-once { animation: hp-pulse-once 1.2s var(--ease-soft) 1; }
.hp-anim-squash { animation: hp-squash var(--motion-normal) var(--ease-playful); }
.hp-anim-note-in { animation: hp-note-in 250ms var(--ease-playful) both; }
.hp-anim-glow { animation: hp-glow-pulse 0.55s var(--ease-soft); }

.hp-float-idle {
    animation: hp-float 3.8s var(--ease-soft) infinite;
}

.hp-btn-play {
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    letter-spacing: 0.02em;
    color: var(--color-on-play);
    background: linear-gradient(180deg, #ff9f55 0%, var(--color-play-orange) 55%, #f06a1a 100%);
    border-radius: var(--radius-pill);
    padding: var(--space-4) var(--space-6);
    min-width: min(280px, 86vw);
    box-shadow: 0 5px 1px var(--color-play-orange-deep), 0 12px 24px rgba(240, 106, 26, 0.35);
    transition: transform var(--motion-fast) var(--ease-soft), box-shadow var(--motion-fast) var(--ease-soft);
    will-change: transform;
}

.hp-btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 1px var(--color-play-orange-deep), 0 16px 28px rgba(240, 106, 26, 0.4);
}

.hp-btn-play:active {
    transform: translateY(4px) scale(0.98, 0.94);
    box-shadow: 0 1px 1px var(--color-play-orange-deep), 0 6px 12px rgba(240, 106, 26, 0.3);
}

.hp-btn-secondary {
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.05rem, 3.8vw, 1.3rem);
    color: var(--color-on-play);
    background: linear-gradient(180deg, #5b8fff 0%, var(--color-play-blue) 100%);
    border-radius: var(--radius-pill);
    padding: 0.65rem 1.4rem;
    box-shadow: 0 4px 1px var(--color-play-blue-deep);
    transition: transform var(--motion-fast) var(--ease-soft);
}

.hp-btn-secondary:active {
    transform: translateY(3px) scale(0.98);
    box-shadow: 0 1px 1px var(--color-play-blue-deep);
}

/* A button that is really a link (AnimatedButton with Href) must never look like a link:
   no underline at rest, on hover or on focus (Bootstrap's a:hover would otherwise add one). */
.hp-btn-play, .hp-btn-secondary, .hp-btn-parent, .hp-btn-danger, .hp-btn-quiet,
.hp-btn-play:hover, .hp-btn-secondary:hover, .hp-btn-parent:hover, .hp-btn-danger:hover, .hp-btn-quiet:hover,
.hp-btn-play:focus, .hp-btn-secondary:focus, .hp-btn-parent:focus, .hp-btn-danger:focus, .hp-btn-quiet:focus {
    text-decoration: none;
}

.hp-mascot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--hp-mascot-size, 120px);
    height: var(--hp-mascot-size, 120px);
    /* Keep filter off the wrapper — parent filters can flatten PNG alpha on mobile WebKit */
    background: transparent;
}

.hp-mascot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    background: transparent;
    /* Shadow on the bitmap so alpha stays a true cutout */
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
}

.hp-mascot--wave img { animation: hp-bounce 1.1s var(--ease-playful) 1; }
.hp-mascot--celebrate img,
.hp-mascot--happy img,
.hp-mascot--jump img,
.hp-mascot--star img,
.hp-mascot--doublethumbs img { animation: hp-bounce 0.65s var(--ease-playful) 2; }
.hp-mascot--encourage img,
.hp-mascot--sad img,
.hp-mascot--surprised img { animation: hp-wiggle 0.5s var(--ease-playful); }
.hp-mascot--thinking img { animation: hp-mascot-think 0.7s var(--ease-soft) 1; }
.hp-mascot--idle img { /* no continuous bounce — reactions only */ }
.hp-mascot--neutral img { /* still */ }

.hp-mascot--react-yes img { animation: hp-bounce 0.65s var(--ease-playful) 2; }
.hp-mascot--react-no img { animation: hp-wiggle 0.5s var(--ease-playful); }
.hp-mascot--react-wave img { animation: hp-bounce 1.1s var(--ease-playful) 1; }
.hp-mascot--react-think img { animation: hp-mascot-think 0.7s var(--ease-soft) 1; }

@keyframes hp-mascot-think {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    35% { transform: rotate(-6deg) translateY(-4px); }
    70% { transform: rotate(4deg) translateY(-2px); }
}

.hp-float-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.hp-float-item {
    position: absolute;
    opacity: 0.55;
    animation: hp-float 4s var(--ease-soft) infinite;
}

.hp-float-item img,
.hp-float-item svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hp-starburst {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: grid;
    place-items: center;
    z-index: 5;
}

.hp-starburst__spark {
    position: absolute;
    width: auto;
    height: auto;
    font-size: 1.1rem;
    line-height: 1;
    color: #f5b700;
    background: none;
    border-radius: 0;
    text-shadow: 0 0 8px rgba(255, 200, 40, 0.7);
    transform: rotate(var(--spark-angle, 0deg)) translateY(-52px) scale(0.2);
    animation: hp-sparkle-star 0.65s var(--ease-playful) forwards;
}

@keyframes hp-sparkle-star {
    0% { opacity: 0; transform: rotate(var(--spark-angle, 0deg)) translateY(-40px) scale(0.3); }
    40% { opacity: 1; transform: rotate(var(--spark-angle, 0deg)) translateY(-56px) scale(1.15); }
    100% { opacity: 0; transform: rotate(var(--spark-angle, 0deg)) translateY(-72px) scale(0.8); }
}

.hp-session-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.hp-session-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(47, 111, 237, 0.16);
    box-shadow: inset 0 0 0 2px rgba(47, 111, 237, 0.45);
    transition: transform var(--motion-normal) var(--ease-playful), background var(--motion-fast);
}

.hp-session-dot.is-filled {
    background: #ffe566;
    box-shadow: 0 0 0 2px rgba(255, 200, 40, 0.5);
    transform: scale(1.15);
    animation: hp-pop var(--motion-normal) var(--ease-playful);
}

.white-key.key-hint {
    animation: hp-key-hint 1s var(--ease-soft) infinite;
    z-index: 2;
}

.white-key.key-hint-strong {
    animation: hp-key-hint 0.7s var(--ease-soft) infinite;
    background: linear-gradient(180deg, #fff8e0, #ffe08a) !important;
}

.hp-btn--compact {
    font-size: 0.9rem;
    padding: var(--space-2) var(--space-3);
    min-width: 0;
    letter-spacing: 0;
    box-shadow: 0 3px 0 var(--color-play-orange-deep);
}

.hp-btn-secondary.hp-btn--compact {
    box-shadow: 0 3px 0 var(--color-play-blue-deep);
}

.hp-btn-secondary.hp-btn--compact:active {
    box-shadow: 0 1px 0 var(--color-play-blue-deep);
}

.hp-btn-parent,
.hp-btn-danger,
.hp-btn-quiet {
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    border-radius: var(--radius-pill);
    padding: 0.55rem 1.1rem;
    transition: transform var(--motion-fast) var(--ease-soft), box-shadow var(--motion-fast) var(--ease-soft);
}

.hp-btn-parent {
    color: var(--color-on-play);
    background: var(--color-parent-accent);
    box-shadow: 0 3px 0 var(--color-parent-accent-deep);
}

.hp-btn-parent:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--color-parent-accent-deep);
}

.hp-btn-danger {
    color: var(--color-on-play);
    background: var(--color-danger);
    box-shadow: 0 3px 0 var(--color-danger-deep);
}

.hp-btn-danger:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--color-danger-deep);
}

.hp-btn-quiet {
    color: var(--color-ink);
    background: var(--color-neutral-0);
    border: 2px solid var(--color-neutral-300);
    box-shadow: 0 3px 0 var(--color-neutral-300);
}

.hp-btn-quiet:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--color-neutral-300);
}

.hp-btn-play:disabled,
.hp-btn-secondary:disabled,
.hp-btn-parent:disabled,
.hp-btn-danger:disabled,
.hp-btn-quiet:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.hp-speech {
    margin: 0 0 var(--space-1);
    padding: var(--space-1) var(--space-3);
    max-width: 9rem;
    background: var(--color-neutral-0);
    color: var(--color-play-ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    border-radius: var(--radius-md);
    box-shadow: 0 3px 0 rgba(47, 111, 237, 0.18);
}

.hp-starburst--rain {
    overflow: hidden;
    border-radius: inherit;
}

.hp-confetti {
    position: absolute;
    top: 0;
    width: 10px;
    height: 14px;
    border-radius: 3px;
    animation: hp-confetti-in 1.15s var(--ease-soft) both;
}

.hp-confetti--0 { background: var(--color-play-orange); }
.hp-confetti--1 { background: var(--color-play-amber); height: 10px; border-radius: var(--radius-pill); }
.hp-confetti--2 { background: var(--color-play-success); }
.hp-confetti--3 { background: var(--color-play-blue-bright); width: 8px; }

@keyframes hp-confetti-in {
    0% { transform: translate3d(0, -12px, 0) rotate(0deg); opacity: 0; }
    18% { opacity: 1; }
    100% { transform: translate3d(var(--confetti-drift, 0px), 240px, 0) rotate(180deg); opacity: 0; }
}

.hp-mute-toggle {
    width: clamp(34px, 9vw, 40px);
    height: clamp(34px, 9vw, 40px);
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #6b7280;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
    transition: transform var(--motion-fast) var(--ease-soft);
}

/* Sound on reads as blue like the settings gear; muted is grey with a red slash (drawn in MuteToggle.razor). */
.hp-mute-toggle--on { color: #2f6fed; }
.hp-mute-toggle--muted { color: #8b95a3; }

.hp-mute-toggle:active {
    transform: scale(0.94);
    background: #eef1f5;
}

.home-screen__header .hp-mute-toggle {
    background: rgba(255, 255, 255, 0.9);
}
