/* Hartvig at the big moments of building (hartvig-moments.mjs): the block
   building in the preview, the sign with the link after a first publish, the
   empty wallet, the plaster after a failed build, the empty My projects and
   his face as the Agent's chat avatar. No sound; reduced motion is still. */
.hartvig-m-figure { display: block; }
.hartvig-m-figure svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* The Agent's avatar in the chat: his face (set as --hartvig-face by the module). */
html.hartvig-face .builder-message-agent-mark { color: transparent !important; font-size: 0 !important; background-color: rgba(240,68,145,.10); background-image: var(--hartvig-face); background-repeat: no-repeat; background-position: 50% 58%; background-size: 82%; }

/* 1. Building: he throws blocks into an app window until the app is there. */
.builder-preview-status.has-hartvig-build > .builder-spinner { display: none; }
.builder-preview-status.has-hartvig-caption > :not(.hartvig-build) { display: none; }
.hartvig-build { display: grid; justify-items: center; gap: 8px; margin-bottom: 4px; }
.hartvig-build-title { color: var(--bh-text, #f7f4fa); font-size: 18px; }
.hartvig-build-note { max-width: 380px; }
.hartvig-build-scene { position: relative; width: 300px; height: 180px; flex: none; }
.hartvig-build-window { position: absolute; left: 126px; top: 10px; width: 166px; height: 156px; overflow: hidden; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; background: linear-gradient(160deg, rgba(255,255,255,.065), rgba(255,255,255,.02)); box-shadow: 0 18px 40px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.06); }
.hartvig-build-bar { position: absolute; inset: 0 0 auto; height: 18px; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); }
.hartvig-build-bar i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.22); }
.hartvig-build-bar i:first-child { background: #f04491; }
.hartvig-build-progress { position: absolute; left: 0; right: 0; top: 18px; height: 2px; background: linear-gradient(90deg, #f04491, #b14cff); transform-origin: 0 50%; transform: scaleX(0); }
.hartvig-build-sheen { position: absolute; top: 0; bottom: 0; left: 0; width: 42%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.26), transparent); opacity: 0; pointer-events: none; }
.hartvig-build-slot { position: absolute; border: 1px dashed rgba(255,255,255,.14); border-radius: 5px; }
.hartvig-build-figure { position: absolute; left: 6px; top: 72px; width: 92px; height: 92px; transform-origin: 50% 100%; filter: drop-shadow(0 10px 16px rgba(240,68,145,.25)); }
.hartvig-build-block { position: absolute; left: 0; top: 0; border-radius: 5px; opacity: 0; box-shadow: inset 0 1px rgba(255,255,255,.35), 0 4px 10px rgba(0,0,0,.28); transform-origin: 50% 50%; will-change: transform, opacity; }
.hartvig-build-scene.is-still .hartvig-build-block { opacity: 1; }
.hartvig-build-scene.is-still .hartvig-build-progress { transform: scaleX(1); }
.hartvig-build-block.is-header { background: linear-gradient(90deg, #7c5cff, #b14cff); }
.hartvig-build-block.is-header::before { content: ''; position: absolute; left: 5px; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.9); }
.hartvig-build-block.is-header::after { content: ''; position: absolute; right: 6px; top: 5.5px; width: 44px; height: 3px; border-radius: 2px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.75) 0 10px, transparent 10px 16px); }
.hartvig-build-block.is-hero { background: linear-gradient(135deg, #ff7ab8, #f04491 60%, #c8287a); }
.hartvig-build-block.is-hero::before { content: ''; position: absolute; left: 8px; top: 9px; width: 46px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.92); box-shadow: 0 9px 0 -1px rgba(255,255,255,.55); }
.hartvig-build-block.is-hero::after { content: ''; position: absolute; left: 8px; bottom: 7px; width: 26px; height: 8px; border-radius: 6px; background: #fff; }
.hartvig-build-heart { position: absolute; right: 9px; top: 50%; margin-top: -10px; color: #fff; font-size: 17px; font-style: normal; line-height: 20px; text-shadow: 0 2px 8px rgba(120,0,60,.45); transform: scale(0); }
.hartvig-build-scene.is-still .hartvig-build-heart { transform: none; }
.hartvig-build-block.is-side { background: linear-gradient(160deg, #fcd34d, #f59e0b); }
.hartvig-build-block.is-side::before { content: ''; position: absolute; left: 7px; right: 7px; top: 8px; height: 22px; border-radius: 4px; background: rgba(255,255,255,.55); }
.hartvig-build-block.is-card::before { content: ''; position: absolute; left: 6px; top: 6px; width: 12px; height: 12px; border-radius: 4px; background: rgba(255,255,255,.8); }
.hartvig-build-block.is-card::after { content: ''; position: absolute; left: 6px; right: 8px; bottom: 6px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.6); }
.hartvig-build-block.is-a { background: linear-gradient(160deg, #5eead4, #14b8a6); }
.hartvig-build-block.is-b { background: linear-gradient(160deg, #93c5fd, #3b82f6); }
.hartvig-build-block.is-c { background: linear-gradient(160deg, #f9a8d4, #ec4899); }
.hartvig-build-block.is-footer { background: linear-gradient(90deg, rgba(167,139,250,.85), rgba(124,92,255,.85)); }
html[data-theme="light"] .hartvig-build-window { border-color: rgba(42,23,48,.14); background: linear-gradient(160deg, #ffffff, #f7f2fb); box-shadow: 0 16px 36px rgba(60,20,60,.12); }
html[data-theme="light"] .hartvig-build-bar { border-bottom-color: rgba(42,23,48,.08); background: rgba(42,23,48,.03); }
html[data-theme="light"] .hartvig-build-bar i { background: rgba(42,23,48,.18); }
html[data-theme="light"] .hartvig-build-bar i:first-child { background: #f04491; }
html[data-theme="light"] .hartvig-build-slot { border-color: rgba(42,23,48,.2); }
html[data-theme="light"] .hartvig-build-title { color: #1e2124; }

/* 2. Published: he holds up a sign with the link; hearts the first time. */
.publish-live.has-hartvig .publish-live-mark { display: none; }
.hartvig-publish-scene { position: relative; width: 260px; max-width: 100%; height: 178px; margin: -6px auto 2px; }
.hartvig-sign-lift { position: absolute; inset: 0; animation: hartvig-sign-bob 2.8s ease-in-out infinite; }
.hartvig-publish-scene.is-first .hartvig-sign-lift { animation: hartvig-sign-cheer .5s cubic-bezier(.3,.7,.3,1) 2, hartvig-sign-bob 2.8s ease-in-out 1.1s infinite; }
.hartvig-sign { position: absolute; left: 50%; top: 4px; z-index: 2; display: flex; align-items: center; gap: 7px; max-width: 250px; height: 40px; padding: 0 15px; transform: translateX(-50%) rotate(-2deg); border: 2px solid #f04491; border-radius: 11px; background: #fff; color: #2a1730; font-size: 14px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; box-shadow: 0 10px 24px rgba(240,68,145,.32), inset 0 -3px rgba(240,68,145,.08); }
.hartvig-sign-globe { flex: none; font-size: 15px; }
.hartvig-sign-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hartvig-sign-post { position: absolute; top: 40px; z-index: 1; width: 5px; height: 58px; border-radius: 3px; background: linear-gradient(90deg, #c9925f, #a06a3b); }
.hartvig-sign-post.is-left { left: calc(50% - 39px); }
.hartvig-sign-post.is-right { left: calc(50% + 35px); }
.hartvig-publish-figure { position: absolute; left: 50%; top: 66px; z-index: 3; width: 112px; height: 112px; margin-left: -56px; filter: drop-shadow(0 10px 18px rgba(240,68,145,.28)); }
.hartvig-publish-hearts { position: absolute; left: 50%; top: 110px; z-index: 0; width: 0; height: 0; }
.hartvig-publish-hearts i { position: absolute; left: -6px; top: -8px; color: #f04491; font-style: normal; line-height: 1; opacity: 0; text-shadow: 0 0 10px rgba(240,68,145,.45); animation: hartvig-heart-pop 1.5s cubic-bezier(.2,.7,.3,1) var(--d, 0ms) both; }
.hartvig-publish-hearts i.is-violet { color: #b14cff; }
@keyframes hartvig-sign-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes hartvig-sign-cheer { 0% { transform: none; } 30% { transform: translateY(4px) scale(1.03, .96); } 65% { transform: translateY(-16px); } 100% { transform: none; } }
@keyframes hartvig-heart-pop { 0% { opacity: 0; transform: translate(0, 0) scale(.3); } 18% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1); } }

/* 3. No Hearts: he holds his wallet upside down and shakes it. Only dust. */
.hartvig-wallet-scene { position: relative; display: block; flex: none; width: 108px; height: 106px; }
.hartvig-wallet-figure { position: absolute; left: 0; top: 18px; z-index: 2; width: 84px; height: 84px; }
.hartvig-wallet { position: absolute; left: 64px; top: 39px; z-index: 1; width: 42px; height: 33px; transform-origin: 10px 2px; animation: hartvig-wallet-shake 2.8s ease-in-out infinite; }
.hartvig-wallet svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); }
.hartvig-wallet-dust { position: absolute; left: 72px; top: 64px; z-index: 3; width: 30px; height: 2px; }
.hartvig-wallet-dust i { position: absolute; top: 0; width: 3px; height: 3px; border-radius: 50%; background: #cfc6dd; opacity: 0; animation: hartvig-dust 2.8s ease-in infinite; }
.hartvig-wallet-dust i:nth-child(1) { left: 2px; animation-delay: .05s; }
.hartvig-wallet-dust i:nth-child(2) { left: 10px; width: 2px; height: 2px; animation-delay: .2s; }
.hartvig-wallet-dust i:nth-child(3) { left: 17px; animation-delay: .12s; }
.hartvig-wallet-dust i:nth-child(4) { left: 24px; width: 2px; height: 2px; animation-delay: .3s; }
@keyframes hartvig-wallet-shake { 0%, 58%, 100% { transform: rotate(0); } 64% { transform: rotate(-12deg); } 70% { transform: rotate(10deg); } 76% { transform: rotate(-8deg); } 82% { transform: rotate(5deg); } 88% { transform: rotate(0); } }
@keyframes hartvig-dust { 0%, 64% { opacity: 0; transform: translateY(0); } 70% { opacity: .9; } 100% { opacity: 0; transform: translateY(34px); } }
.builder-preview-status > .hartvig-wallet-scene, .builder-preview-status > .hartvig-oops-scene { justify-self: center; margin-bottom: 4px; }
.heart-boost-message.has-hartvig > .hartvig-wallet-scene { float: inline-end; margin: -6px 0 6px 12px; }

/* 5. A failed build: a plaster on his head, and Try again. */
.hartvig-oops-scene { display: block; flex: none; width: 76px; height: 76px; }
.hartvig-oops-figure { width: 100%; height: 100%; transform-origin: 50% 95%; animation: hartvig-oops-sway 3.4s ease-in-out infinite alternate; }
@keyframes hartvig-oops-sway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }

/* The chat cards for 3 and 5. !important: the app clears every button's look. */
.hartvig-card { display: flex; align-items: center; gap: 14px; margin: 8px 0 4px; padding: 12px 14px; border: 1px solid rgba(240,68,145,.3); border-radius: 14px; background: linear-gradient(135deg, rgba(240,68,145,.10), rgba(177,76,255,.07)); color: #f3eef8; }
.hartvig-card-copy { display: grid; gap: 4px; min-width: 0; flex: 1; }
.hartvig-card-title { font-size: 14px; font-weight: 760; color: #fff; }
.hartvig-card .builder-note-error { margin: 0; padding: 0; border: 0; background: none; color: #d9cfe2; font-size: 12.5px; }
.hartvig-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.hartvig-card .hartvig-card-actions button { min-height: 32px; padding: 6px 14px; border-radius: 999px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.hartvig-card .hartvig-card-actions button:first-child { border: 0 !important; background: linear-gradient(90deg, #f04491, #b14cff) !important; color: #fff !important; box-shadow: 0 6px 16px rgba(240,68,145,.28); }
.hartvig-card .hartvig-card-actions button + button { border: 1px solid rgba(255,255,255,.18) !important; background: rgba(255,255,255,.05) !important; color: inherit !important; }
.hartvig-card .hartvig-card-actions button:hover { filter: brightness(1.08); }
.hartvig-card .hartvig-card-actions button:focus-visible { outline: 2px solid #ff8cc0; outline-offset: 2px; }
html[data-theme="light"] .hartvig-card { background: linear-gradient(135deg, #fff4fa, #f4eefc); color: #2a1730; }
html[data-theme="light"] .hartvig-card-title { color: #2a1730; }
html[data-theme="light"] .hartvig-card .builder-note-error { color: #5d4f66; background: none; border: 0; }
html[data-theme="light"] .hartvig-card .hartvig-card-actions button + button { border-color: rgba(42,23,48,.18) !important; background: #fff !important; }

/* 4. No projects yet: Hartvig waves beside an empty project card. */
#projectEmpty.has-hartvig > strong, #projectEmpty.has-hartvig > span { display: none; }
#projectEmpty:not(.has-hartvig) > .hartvig-empty { display: none; }
.hartvig-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px 26px; padding: 8px 0; }
.hartvig-empty-scene { position: relative; display: block; width: 214px; height: 128px; flex: none; }
.hartvig-empty-card { position: absolute; left: 0; top: 10px; display: grid; place-items: center; width: 98px; height: 112px; border: 2px dashed rgba(240,68,145,.5); border-radius: 16px; background: rgba(240,68,145,.06); animation: hartvig-empty-glow 2.6s ease-in-out infinite; }
.hartvig-empty-card b { color: #f04491; font-size: 30px; font-weight: 400; line-height: 1; }
.hartvig-empty-card i { display: none; }
.hartvig-empty-figure { position: absolute; left: 100px; top: 8px; width: 116px; height: 116px; filter: drop-shadow(0 10px 18px rgba(240,68,145,.25)); }
.hartvig-empty-copy { display: grid; justify-items: start; gap: 6px; max-width: 320px; text-align: start; }
.hartvig-empty-copy strong { font-size: 17px; }
.hartvig-empty-copy span { color: var(--muted, #aaa4b3); }
.hartvig-empty .hartvig-empty-go { margin-top: 6px; min-height: 40px; padding: 9px 20px; border: 0 !important; border-radius: 999px; background: linear-gradient(90deg, #f04491, #b14cff) !important; color: #fff !important; font: inherit; font-weight: 750; cursor: pointer; box-shadow: 0 8px 22px rgba(240,68,145,.3); }
.hartvig-empty .hartvig-empty-go:focus-visible { outline: 2px solid #ff8cc0; outline-offset: 3px; }
@keyframes hartvig-empty-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(240,68,145,0); } 50% { box-shadow: 0 0 22px 2px rgba(240,68,145,.22); } }
@media (max-width: 560px) { .hartvig-empty-copy { justify-items: center; text-align: center; } }

@media (prefers-reduced-motion: reduce) {
  .hartvig-sign-lift, .hartvig-publish-scene.is-first .hartvig-sign-lift, .hartvig-wallet, .hartvig-oops-figure, .hartvig-empty-card { animation: none !important; }
  .hartvig-wallet-dust, .hartvig-publish-hearts { display: none; }
}
.is-still .hartvig-sign-lift, .is-still .hartvig-wallet, .is-still .hartvig-oops-figure, .is-still .hartvig-empty-card { animation: none !important; }
.is-still .hartvig-wallet-dust { display: none; }
