/* AdvisorSEO motion layer. Loaded after site.css on pages that opt in.
   Every duration and easing comes from the tokens in site.css (spec 2.6).
   Only opacity and transform animate; hover may fade colour and background.
   With JavaScript off, the CSS radio states below still crossfade. */

@keyframes motion-rise {
  from { opacity: 0; transform: translateY(8px) }
}
@keyframes motion-fade {
  from { opacity: 0 }
}
@keyframes motion-progress {
  from { transform: translateX(-100%) }
  to { transform: translateX(0) }
}

/* Hover and press: colour only on hover, a 1px press, nothing grows. */
.btn {
  transition: background-color var(--d-hover) var(--ease-inout), border-color var(--d-hover) var(--ease-inout), color var(--d-hover) var(--ease-inout), transform var(--d-hover) var(--ease-out)
}
.btn:active {
  transform: translateY(1px)
}
.demo-rail label, .family-rail label, .billing-options label {
  transition: background-color var(--d-tab) var(--ease-inout), color var(--d-tab) var(--ease-inout)
}
.demo-rail label:hover, .family-rail label:hover {
  color: var(--ink)
}

/* Disclosures: content fades in with an 8px rise; closing is instant. */
.faq-item[open] > .body, .menu[open] > .menu-panel {
  animation: motion-rise var(--d-reveal) var(--ease-out)
}
.faq-item > summary::after {
  display: inline-block;
  transition: transform var(--d-hover) var(--ease-out)
}
.faq-item[open] > summary::after {
  content: '+';
  transform: rotate(45deg)
}

/* Radio stages: panels share one grid cell (site.css), so height never jumps. */
@supports selector(:has(a)) {
  .demo-panels > .demo-panel, .family-panels > .family-panel {
    opacity: 0;
    transition: opacity var(--d-tab) var(--ease-inout), transform 0s linear var(--d-tab), visibility 0s linear var(--d-tab)
  }
  .demo-panels > .demo-panel {
    transform: translateY(12px)
  }
  .hero-demo:has(#demo-1:checked) .panel-1,
  .hero-demo:has(#demo-2:checked) .panel-2,
  .hero-demo:has(#demo-3:checked) .panel-3,
  .hero-demo:has(#demo-4:checked) .panel-4 {
    opacity: 1;
    transform: none;
    transition: opacity var(--d-demo) var(--ease-out) 120ms, transform var(--d-demo) var(--ease-out) 120ms, visibility 0s
  }
  .family-switcher:has(#family-context:checked) .family-panel--context,
  .family-switcher:has(#family-planning:checked) .family-panel--planning,
  .family-switcher:has(#family-checks:checked) .family-panel--checks,
  .family-switcher:has(#family-readiness:checked) .family-panel--readiness,
  .family-switcher:has(#family-publishing:checked) .family-panel--publishing,
  .family-switcher:has(#family-leads:checked) .family-panel--leads {
    opacity: 1;
    transition: opacity var(--d-tab) var(--ease-inout), visibility 0s
  }

  /* Chips arrive in sequence, 60ms apart, opacity only. */
  .hero-demo:has(#demo-1:checked) .panel-1 .demo-chips > *,
  .hero-demo:has(#demo-2:checked) .panel-2 .demo-chips > *,
  .hero-demo:has(#demo-3:checked) .panel-3 .demo-chips > *,
  .hero-demo:has(#demo-4:checked) .panel-4 .demo-chips > * {
    animation: motion-fade var(--d-tab) var(--ease-out) 120ms both
  }
  .hero-demo:has(#demo-1:checked) .panel-1 .demo-chips > :nth-child(2),
  .hero-demo:has(#demo-2:checked) .panel-2 .demo-chips > :nth-child(2),
  .hero-demo:has(#demo-3:checked) .panel-3 .demo-chips > :nth-child(2),
  .hero-demo:has(#demo-4:checked) .panel-4 .demo-chips > :nth-child(2) {
    animation-delay: 180ms
  }
  .hero-demo:has(#demo-1:checked) .panel-1 .demo-chips > :nth-child(n+3),
  .hero-demo:has(#demo-2:checked) .panel-2 .demo-chips > :nth-child(n+3),
  .hero-demo:has(#demo-3:checked) .panel-3 .demo-chips > :nth-child(n+3),
  .hero-demo:has(#demo-4:checked) .panel-4 .demo-chips > :nth-child(n+3) {
    animation-delay: 240ms
  }

  /* Pricing: both figures sit in one grid cell, so the wider one holds the space. */
  .billing-toggle .plan-price {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: baseline;
    column-gap: .3em
  }
  .billing-toggle .plan-price > .price-monthly,
  .billing-toggle .plan-price > .price-annual {
    grid-area: 1 / 1;
    display: block;
    transition: opacity var(--d-tab) var(--ease-inout), visibility 0s
  }
  .billing-toggle .plan-price > .plan-price-period {
    grid-area: 1 / 2
  }
  .billing-toggle:has(#monthly:checked) .plan-price > .price-annual,
  .billing-toggle:has(#annual:checked) .plan-price > .price-monthly {
    display: block;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--d-tab) var(--ease-inout), visibility 0s linear var(--d-tab)
  }
}

/* --- Enhancements that exist only when assets/site.js has run --- */

/* Sliding 2px indicator under the checked label of a rail. */
.motion-rail {
  position: relative
}
.motion-rail > label {
  border-bottom-color: transparent !important
}
.rail-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100px;
  height: 2px;
  overflow: hidden;
  background: var(--ink);
  transform-origin: 0 0;
  transform: translate(var(--rx, 0), var(--ry, 0)) scaleX(var(--rs, 1));
  pointer-events: none
}
.rail-indicator.is-live {
  transition: transform var(--d-tab) var(--ease-inout)
}
.rail-fill {
  display: none
}

/* Hero demo autoplay: the indicator becomes a track with a filling bar. */
.hero-demo {
  position: relative
}
.hero-demo.is-autoplay .rail-indicator {
  background: var(--line-ui)
}
.hero-demo.is-autoplay .rail-fill {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: translateX(-100%);
  animation: motion-progress var(--dwell, 6s) linear forwards
}
.hero-demo.is-paused .rail-fill {
  animation-play-state: paused
}
.demo-toggle {
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-pill);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font: 600 var(--fs-micro)/1 var(--font);
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color var(--d-hover) var(--ease-inout), transform var(--d-hover) var(--ease-out)
}
.demo-toggle:hover {
  background: var(--surface-2)
}
.demo-toggle:active {
  transform: translateY(1px)
}
.demo-toggle::before {
  content: '';
  width: 8px;
  height: 10px;
  box-sizing: border-box;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor
}
.demo-toggle[data-state=paused]::before {
  width: 0;
  height: 0;
  border-right: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor
}

/* Streaming conversation lines: the whole line is laid out from the start,
   the part not yet streamed is transparent, so nothing below it moves. */
.motion-untyped {
  color: transparent
}
.demo-panel[data-typing=prompt] .demo-chips > * {
  animation: none !important;
  opacity: 0 !important
}

/* Scroll reveals, armed only by site.js; never on content above the fold. */
.motion-ready .reveal {
  transition: opacity var(--d-scroll) var(--ease-out) var(--reveal-delay, 0ms), transform var(--d-scroll) var(--ease-out) var(--reveal-delay, 0ms)
}
.motion-ready .reveal:not(.is-revealed):not(:focus-within) {
  opacity: 0;
  transform: translateY(12px)
}

.motion-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap
}

@media print {
  .motion-ready .reveal { opacity: 1 !important; transform: none !important }
  .demo-toggle, .rail-indicator { display: none }
}

/* Reduced motion: every state change is instant and nothing is hidden for effect. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important
  }
  .demo-panels > .demo-panel, .family-panels > .family-panel {
    transform: none !important
  }
  .demo-chips > *, .faq-item[open] > .body, .menu[open] > .menu-panel {
    animation: none !important;
    opacity: 1 !important
  }
  .motion-ready .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important
  }
  .motion-untyped {
    color: inherit
  }
  .btn:active, .demo-toggle:active {
    transform: none
  }
  .hero-demo.is-autoplay .rail-indicator {
    background: var(--ink)
  }
  .hero-demo.is-autoplay .rail-fill {
    display: none
  }
}
