/**
 * Hero AI demo widget only (.ai-hero-desktop-shell) — restored from legacy ai-course-scope.
 * Scoped so page-wide minimal styles in ai-shell.css do not flatten this scene.
 */

@keyframes ai-demo-code-glow {
  0%, 100% { box-shadow: 0 0 20px color-mix(in srgb, var(--ai-color-accent) 30%, transparent); }
  50% { box-shadow: 0 0 30px color-mix(in srgb, var(--ai-color-accent) 55%, transparent); }
}

@keyframes ai-demo-building-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

@keyframes ai-demo-building-color-shift {
  0% { background-color: var(--ai-color-surface); }
  25% { background-color: color-mix(in srgb, var(--ai-color-gray) 25%, var(--ai-color-surface) 75%); }
  50% { background-color: color-mix(in srgb, var(--ai-color-gray) 45%, var(--ai-color-surface) 55%); }
  75% { background-color: color-mix(in srgb, var(--ai-color-gray) 25%, var(--ai-color-surface) 75%); }
  100% { background-color: var(--ai-color-surface); }
}

@keyframes ai-demo-building-width-change {
  0% { width: 4rem; }
  25% { width: 5rem; }
  50% { width: 3rem; }
  75% { width: 6rem; }
  100% { width: 4rem; }
}

@keyframes ai-demo-building-button-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px color-mix(in srgb, var(--ai-color-accent) 40%, transparent); }
  25% { transform: scale(1.02); box-shadow: 0 0 15px color-mix(in srgb, var(--ai-color-accent) 55%, transparent); }
  50% { transform: scale(1.05); box-shadow: 0 0 20px color-mix(in srgb, var(--ai-color-accent) 70%, transparent); }
  75% { transform: scale(1.02); box-shadow: 0 0 15px color-mix(in srgb, var(--ai-color-accent) 55%, transparent); }
}

@keyframes ai-demo-building-button-glow {
  0%, 100% {
    background: linear-gradient(135deg, var(--ai-color-accent), color-mix(in srgb, var(--ai-color-accent) 70%, var(--ai-color-black) 30%));
    box-shadow: 0 0 10px color-mix(in srgb, var(--ai-color-accent) 40%, transparent),
      inset 0 1px 0 color-mix(in srgb, var(--ai-color-white) 20%, transparent);
  }
  50% {
    background: linear-gradient(135deg, color-mix(in srgb, var(--ai-color-accent) 78%, var(--ai-color-white) 22%), var(--ai-color-accent));
    box-shadow: 0 0 20px color-mix(in srgb, var(--ai-color-accent) 65%, transparent),
      0 0 30px color-mix(in srgb, var(--ai-color-accent) 35%, transparent),
      inset 0 1px 0 color-mix(in srgb, var(--ai-color-white) 30%, transparent);
  }
}

@keyframes ai-demo-building-button-inner {
  0% {
    opacity: 0;
    transform: scale(0.8);
    background: linear-gradient(90deg, color-mix(in srgb, var(--ai-color-accent) 20%, var(--ai-color-white) 80%), color-mix(in srgb, var(--ai-color-accent) 35%, var(--ai-color-white) 65%));
  }
  15% { opacity: 1; transform: scale(1); }
  100% {
    background: linear-gradient(90deg, color-mix(in srgb, var(--ai-color-accent) 20%, var(--ai-color-white) 80%), color-mix(in srgb, var(--ai-color-accent) 35%, var(--ai-color-white) 65%));
  }
}

@keyframes ai-demo-ellipsis {
  0% { content: "."; }
  33% { content: ".."; }
  66% { content: "..."; }
  100% { content: "."; }
}

/* Outer shell */
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell.ai-code-glow {
  background: color-mix(in srgb, var(--ai-color-black) 90%, transparent) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  border-radius: 1rem !important;
  padding: 2rem !important;
  border: 1px solid color-mix(in srgb, var(--ai-color-gray) 35%, transparent) !important;
  box-shadow: none !important;
  animation: ai-demo-code-glow 2s ease-in-out infinite !important;
  will-change: box-shadow !important;
  transform: none !important;
}

/* Scroll rows — override prototype.css animation:none + transform:none.
   top+bottom 0 centers text on the AI orb; edge masks + z-index restore
   the fade-under-circle look from the legacy hero demo. */
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-code-row {
  position: relative;
  z-index: 1;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-code-col {
  position: relative;
  z-index: 1;
  min-width: 0;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-code-col:first-child .ai-hero-scroll-text {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 8%,
    black 55%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 8%,
    black 55%,
    transparent 100%
  );
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-code-col:last-child .ai-hero-scroll-text {
  -webkit-mask-image: linear-gradient(
    to left,
    transparent 0%,
    black 8%,
    black 55%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to left,
    transparent 0%,
    black 8%,
    black 55%,
    transparent 100%
  );
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .scroll-text-wrapper {
  display: flex !important;
  align-items: center !important;
  width: 200% !important;
  animation: ai-scroll-right-to-left 20s linear infinite !important;
  animation-play-state: running !important;
  will-change: transform, filter !important;
  backface-visibility: hidden !important;
  position: absolute !important;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  visibility: visible !important;
  filter: opacity(1);
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .scroll-text-wrapper * {
  opacity: 1 !important;
  visibility: visible !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .scroll-text-wrapper::after {
  content: attr(data-text);
  white-space: nowrap;
  flex-shrink: 0;
  padding-left: 2rem;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .scroll-text-container {
  position: relative !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .scroll-text-left {
  color: var(--ai-color-gray) !important;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif !important;
  font-weight: 500 !important;
  letter-spacing: 0.5px !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .code-syntax-glow {
  font-family: "JetBrains Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace !important;
  color: color-mix(in srgb, var(--ai-color-gray) 55%, var(--ai-color-white) 45%) !important;
  text-shadow: 0 0 2px color-mix(in srgb, var(--ai-color-accent) 90%, transparent),
    0 0 4px color-mix(in srgb, var(--ai-color-accent) 65%, transparent),
    0 0 6px color-mix(in srgb, var(--ai-color-accent) 45%, transparent) !important;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--ai-color-accent) 70%, transparent)) !important;
}

/* Right column — scrolling Lucide-style icon strip */
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-scroll-wrapper::after {
  content: none !important;
  display: none !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-track {
  display: flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
  flex-shrink: 0 !important;
  padding: 0 0.35rem !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-track + .ai-hero-icon-track {
  padding-left: 0.65rem !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-chip {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 2.1rem !important;
  height: 2.1rem !important;
  border-radius: 0.55rem !important;
  flex-shrink: 0 !important;
  background: color-mix(in srgb, var(--ai-color-accent) 14%, var(--ai-color-surface) 86%) !important;
  border: 1px solid color-mix(in srgb, var(--ai-color-accent) 35%, transparent) !important;
  box-shadow:
    0 0 10px color-mix(in srgb, var(--ai-color-accent) 25%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ai-color-white) 12%, transparent) !important;
  color: color-mix(in srgb, var(--ai-color-accent) 72%, var(--ai-color-white) 28%) !important;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--ai-color-accent) 45%, transparent)) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-chip:nth-child(3n + 1) {
  color: color-mix(in srgb, var(--ai-color-accent) 85%, var(--ai-color-white) 15%) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-chip:nth-child(3n + 2) {
  background: color-mix(in srgb, var(--ai-color-accent) 22%, var(--ai-color-surface) 78%) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-icon-svg {
  width: 1.15rem !important;
  height: 1.15rem !important;
  display: block !important;
}

/* AI orb — sits above scrolling text columns */
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-ai-circle-wrap {
  position: relative;
  z-index: 30;
  flex-shrink: 0;
  padding: 0 0.25rem;
  margin: 0 -0.75rem;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-circle {
  width: 3rem !important;
  height: 3rem !important;
  border-radius: 9999px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--ai-color-accent) 78%, var(--ai-color-white) 22%),
    var(--ai-color-accent),
    color-mix(in srgb, var(--ai-color-accent) 70%, var(--ai-color-black) 30%)
  ) !important;
  box-shadow: inset 0 0 20px color-mix(in srgb, var(--ai-color-white) 30%, transparent),
    0 4px 8px color-mix(in srgb, var(--ai-color-black) 40%, transparent),
    0 8px 16px color-mix(in srgb, var(--ai-color-black) 30%, transparent),
    0 0 20px color-mix(in srgb, var(--ai-color-accent) 90%, transparent),
    0 0 40px color-mix(in srgb, var(--ai-color-accent) 65%, transparent) !important;
  border: 2px solid color-mix(in srgb, var(--ai-color-white) 40%, transparent) !important;
  position: relative !important;
  z-index: 20 !important;
  animation: ai-demo-code-glow 2s ease-in-out infinite !important;
  will-change: box-shadow, transform !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-circle::before {
  content: "" !important;
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(
    45deg,
    color-mix(in srgb, var(--ai-color-accent) 78%, var(--ai-color-white) 22%),
    var(--ai-color-accent),
    color-mix(in srgb, var(--ai-color-accent) 70%, var(--ai-color-black) 30%),
    var(--ai-color-accent)
  );
  z-index: -1;
  filter: blur(8px);
  opacity: 0.7;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-ai-circle-text {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
  color: var(--ai-color-white) !important;
}

/* Building App — ai-course pattern: CSS-only loops + fade-in, anti-flash locks */
@keyframes ai-demo-fade-in-up {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section {
  position: relative !important;
  z-index: 20 !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section * {
  transition: opacity 0s !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-building-app-accent,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-ellipsis {
  color: var(--ai-color-accent) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-ellipsis::after {
  content: ".";
  animation: ai-demo-ellipsis 1.5s infinite;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-building-shell {
  background: var(--ai-color-surface) !important;
  border-radius: 0.5rem !important;
  padding: 1rem !important;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--ai-color-black) 35%, transparent) !important;
  border: 1px solid color-mix(in srgb, var(--ai-color-gray) 30%, transparent) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-building-line {
  background: color-mix(in srgb, var(--ai-color-gray) 30%, var(--ai-color-surface) 70%) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-building-line-inner {
  background: color-mix(in srgb, var(--ai-color-gray) 55%, var(--ai-color-surface) 45%) !important;
}

/* Combined entry + loop animations (prototype.css sets animation:none otherwise) */
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-1 {
  animation: ai-demo-building-pulse 7s ease-in-out infinite,
    ai-demo-building-color-shift 11s ease-in-out infinite,
    ai-demo-fade-in-up 0.5s ease-out forwards !important;
  animation-delay: 0s, 2s, 0.2s !important;
  animation-play-state: running !important;
  will-change: transform, background-color, opacity !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-2 {
  animation: ai-demo-building-pulse 11s ease-in-out infinite,
    ai-demo-building-color-shift 15s ease-in-out infinite,
    ai-demo-fade-in-up 0.5s ease-out forwards !important;
  animation-delay: 3s, 1s, 0.4s !important;
  animation-play-state: running !important;
  will-change: transform, background-color, opacity !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-3 {
  animation: ai-demo-building-pulse 11s ease-in-out infinite,
    ai-demo-building-color-shift 15s ease-in-out infinite,
    ai-demo-fade-in-up 0.5s ease-out forwards !important;
  animation-delay: 3s, 1s, 0.6s !important;
  animation-play-state: running !important;
  will-change: transform, background-color, opacity !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-button,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-building-button {
  background: linear-gradient(
    135deg,
    var(--ai-color-accent),
    color-mix(in srgb, var(--ai-color-accent) 70%, var(--ai-color-black) 30%)
  ) !important;
  animation: ai-demo-building-button-pulse 4s ease-in-out infinite,
    ai-demo-building-button-glow 6s ease-in-out infinite,
    ai-demo-fade-in-up 0.5s ease-out forwards !important;
  animation-delay: 0.8s, 0.2s, 0.8s !important;
  animation-play-state: running !important;
  border-radius: 0.375rem !important;
  overflow: hidden !important;
  position: relative !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-1 {
  animation: ai-demo-building-width-change 13s ease-in-out infinite !important;
  animation-delay: 0.5s !important;
  animation-play-state: running !important;
  width: 4rem !important;
  height: 0.5rem !important;
  border-radius: 0.25rem !important;
  will-change: width, transform !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-2 {
  animation: ai-demo-building-width-change 11s ease-in-out infinite !important;
  animation-delay: 1.5s !important;
  animation-play-state: running !important;
  width: 4rem !important;
  height: 0.5rem !important;
  border-radius: 0.25rem !important;
  will-change: width, transform !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-3 {
  animation: ai-demo-building-width-change 13s ease-in-out infinite !important;
  animation-delay: 0.5s !important;
  animation-play-state: running !important;
  width: 4rem !important;
  height: 0.5rem !important;
  border-radius: 0.25rem !important;
  will-change: width, transform !important;
  transform: translateZ(0) !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-button,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .ai-hero-building-button-inner {
  animation: ai-demo-building-button-inner 6s ease-in-out infinite !important;
  animation-delay: 1.5s !important;
  animation-play-state: running !important;
  width: 4rem !important;
  height: 0.5rem !important;
  border-radius: 0.25rem !important;
  position: relative !important;
  transform: translateZ(0) !important;
  will-change: width, background, opacity, transform !important;
}

/* Anti-flash — ported from ai-course globals.css */
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section .building-inner-1,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section .building-inner-2,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section .building-inner-3,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section .building-inner-button {
  opacity: 1 !important;
  visibility: visible !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-1.animate-fade-in-up,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-2.animate-fade-in-up,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-3.animate-fade-in-up,
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-button.animate-fade-in-up {
  animation-fill-mode: forwards !important;
  opacity: 1 !important;
}

body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section [class*="building-block"],
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section [class*="building-inner"],
body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-section [class*="building-button"] {
  visibility: visible !important;
}

@media (prefers-reduced-motion: reduce) {
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-1,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-2,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-block-3,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-button,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-1,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-2,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-3,
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-inner-button {
    animation: none !important;
  }

  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .building-app-ellipsis::after {
    content: "...";
    animation: none !important;
  }
}

@media (max-width: 768px) {
  body[data-ai-page="true"] #ai-prototype-root .ai-hero-desktop-shell .scroll-text-wrapper {
    animation-duration: 15s !important;
  }
}
