/* clar.tax · Scroll-Aufbau, Bewegung, Schreibmaschine
 * Abgeleitet aus lavern.ai (site/index.html, Zeilen 361–785), Apache-2.0,
 * Copyright (c) 2025-2026 Antti Innanen. Für clar.tax angepasst, siehe NOTICE. */

/* ═══════════════════════════════════════════════════════════════════
   SCROLL-BUILT ANIMATIONS — content assembles as you scroll
   ═══════════════════════════════════════════════════════════════════ */

/* ─── WORD-BY-WORD REVEAL — awwwards-style headlines that read in ─── */
.word-reveal{display:block}
.word-reveal .word{
  display:inline-block;opacity:0;
  transform:translateY(35%) skewY(4deg);
  transform-origin:left bottom;
  transition:opacity .85s var(--ease),transform .85s var(--ease);
  will-change:transform,opacity
}
.word-reveal.v .word{opacity:1;transform:translateY(0) skewY(0)}
/* Container that holds an inline-block word — generous padding so
   italic slants and descenders are never clipped at the edges. */
.word-reveal .word-mask{
  display:inline-block;overflow:visible;vertical-align:baseline;
  padding:0.08em 0.12em 0.2em 0
}

/* Make headlines that lost the clip-path wipe still elegant on the
   feature card layer when no JS runs (graceful degradation). */
@media(prefers-reduced-motion:reduce){
  .word-reveal .word{opacity:1;transform:none;transition:none}
}

/* Feature CAPTION children — number / title / desc stagger in
   (was static before). The mockup itself already cascades; now the
   text below the mockup builds too. */
.feature-caption .feature-num,
.feature-caption .feature-title,
.feature-caption .feature-desc{
  opacity:0;transform:translateY(18px);
  transition:opacity .8s var(--ease),transform .8s var(--ease)
}
.feature.v .feature-caption .feature-num{
  opacity:1;transform:translateY(0);transition-delay:.25s
}
.feature.v .feature-caption .feature-title{
  opacity:1;transform:translateY(0);transition-delay:.35s
}
.feature.v .feature-caption .feature-desc{
  opacity:1;transform:translateY(0);transition-delay:.50s
}

/* Footer fade-in */
footer{
  opacity:0;transform:translateY(16px);
  transition:opacity .8s var(--ease),transform .8s var(--ease)
}
footer.v{opacity:1;transform:translateY(0)}

/* Section eyebrow pill — pop in */
.section-tag{
  opacity:0;transform:scale(.9) translateY(8px);
  transition:opacity .6s var(--ease),transform .6s var(--ease)
}
.section-tag.v,.v > .section-tag,.v .section-tag{
  opacity:1;transform:scale(1) translateY(0)
}

/* Feature mockup — INNER BUILD when card enters view. Explicit
   cascade so the user clearly SEES each piece arrive. */
.feature .feature-body > *{
  opacity:0;transform:translateY(40px) scale(.85);
  transition:opacity 1s var(--ease),transform 1s var(--ease)
}
.feature.built .feature-body > *{opacity:1;transform:translateY(0) scale(1)}
.feature.built .feature-body > *:nth-child(1){transition-delay:.25s}
.feature.built .feature-body > *:nth-child(2){transition-delay:.50s}
.feature.built .feature-body > *:nth-child(3){transition-delay:.75s}
.feature.built .feature-body > *:nth-child(4){transition-delay:1.00s}
.feature.built .feature-body > *:nth-child(5){transition-delay:1.25s}
.feature.built .feature-body > *:nth-child(6){transition-delay:1.50s}
.feature.built .feature-body > *:nth-child(7){transition-delay:1.75s}

/* Chat bubbles slide horizontally — "you" from right, "them" from left */
.feature .feature-body > .m-bubble.you{
  transform:translateX(60px) scale(.9);transform-origin:right center
}
.feature .feature-body > .m-bubble.them{
  transform:translateX(-60px) scale(.9);transform-origin:left center
}
.feature.built .feature-body > .m-bubble.you,
.feature.built .feature-body > .m-bubble.them{
  transform:translateX(0) scale(1)
}

/* Counter — stable digit widths during tween */
.count-up{font-variant-numeric:tabular-nums;display:inline-block}

/* Hero stats — values + labels both crossfade as the row rotates
   through different stat sets every ~6 seconds. */
.hero-meta-num,.hero-meta-label{
  transition:opacity .35s var(--ease),transform .45s var(--ease);
  will-change:opacity,transform
}
.hero-meta-item.swapping .hero-meta-num,
.hero-meta-item.swapping .hero-meta-label{
  opacity:0;transform:translateY(-6px)
}
@media(prefers-reduced-motion:reduce){
  .hero-meta-num,.hero-meta-label{transition:none}
}

/* ─── Signature animations per mockup (explicit & dramatic) ─── */

/* Verification: progress bar fills 0 → target on build */
.m-bar > span{
  width:0;
  transition:width 1.8s cubic-bezier(0.65,0,0.35,1) .9s
}
.feature.built .m-bar > span{width:var(--fill,70%)}

/* Avatars: pop in with overshoot scale */
@keyframes avatarPop{
  0%{transform:scale(0);opacity:0}
  60%{transform:scale(1.15);opacity:1}
  100%{transform:scale(1);opacity:1}
}
.feature .m-avatar,
.feature .m-avatar-img{transform:scale(0);opacity:0}
.feature.built .m-avatar,
.feature.built .m-avatar-img{animation:avatarPop .8s var(--ease) forwards}

/* Verification dots: each pops individually with cumulative delay */
@keyframes dotPop{
  0%{transform:scale(0);opacity:0}
  55%{transform:scale(1.35);opacity:1}
  100%{transform:scale(1);opacity:1}
}
.feature .feature-body .m-dot{transform:scale(0);opacity:0}
.feature.built .feature-body .m-dot{animation:dotPop .5s var(--ease) forwards}
.feature.built .feature-body .m-dot:nth-of-type(1){animation-delay:.5s;--d:.5s}
.feature.built .feature-body .m-dot:nth-of-type(2){animation-delay:.6s;--d:.6s}
.feature.built .feature-body .m-dot:nth-of-type(3){animation-delay:.7s;--d:.7s}
.feature.built .feature-body .m-dot:nth-of-type(4){animation-delay:.8s;--d:.8s}
.feature.built .feature-body .m-dot:nth-of-type(5){animation-delay:.9s;--d:.9s}
.feature.built .feature-body .m-dot:nth-of-type(6){animation-delay:1.0s;--d:1.0s}
.feature.built .feature-body .m-dot:nth-of-type(7){animation-delay:1.1s;--d:1.1s}
.feature.built .feature-body .m-dot:nth-of-type(8){animation-delay:1.2s;--d:1.2s}
.feature.built .feature-body .m-dot:nth-of-type(9){animation-delay:1.3s;--d:1.3s}
.feature.built .feature-body .m-dot:nth-of-type(10){animation-delay:1.4s;--d:1.4s}

/* Voice — much more dramatic waveform pulse */
@keyframes wavePulse{
  0%,100%{transform:scaleY(1)}
  50%{transform:scaleY(.15)}
}
.feature.built .wave-svg rect{
  animation:wavePulse 1.1s ease-in-out infinite;
  transform-origin:center;transform-box:fill-box
}
.feature.built .wave-svg rect:nth-child(2n){animation-delay:.10s}
.feature.built .wave-svg rect:nth-child(3n){animation-delay:.22s}
.feature.built .wave-svg rect:nth-child(4n){animation-delay:.34s}
.feature.built .wave-svg rect:nth-child(5n){animation-delay:.46s}
.feature.built .wave-svg rect:nth-child(7n){animation-delay:.58s}

/* Routinen card — bigger green status pulse */
@keyframes statusBlink{
  0%,80%,100%{box-shadow:0 0 0 0 rgba(15,77,46,0)}
  40%{box-shadow:0 0 0 7px rgba(15,77,46,0.18)}
}
/* clar.tax fix (also in upstream Lavern): the blink alone replaced dotPop, so green dots stayed at
   scale(0)/opacity 0. Chain the pop first; the nth-of-type rules above pass their delay in --d, so the stagger survives the shorthand. */
.feature.built .feature-body .m-dot.ok{animation:dotPop .5s var(--ease) var(--d,0s) forwards, statusBlink 2.4s ease-in-out calc(var(--d,0s) + 1.6s) infinite}

/* ═══════════════════════════════════════════════════════════════════
   MOVEMENT — life in every card. Each animation is subtle, but they
   compound into a sustained sense of motion across the grid.
   ═══════════════════════════════════════════════════════════════════ */

/* — Cursor blink — a steady |‎  at the end of typed text */
@keyframes caretBlink{
  0%,49%{opacity:1}50%,100%{opacity:0}
}
.m-caret{
  display:inline-block;width:1px;height:1em;
  background:var(--text);vertical-align:-2px;margin-left:2px;
  animation:caretBlink 1.05s steps(1) infinite
}

/* — Avatar bob — tiny up/down 2px float, suggests a "speaking" head.
   Every DiceBear avatar in every card bobs continuously, staggered
   across n-th positions so they don't all bob in unison. The bob
   chains after the initial pop-in. */
@keyframes avatarBob{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-2.5px)}
}
.feature.built .m-avatar-img{
  animation:avatarPop .8s var(--ease) forwards,
            avatarBob 3.4s ease-in-out 1.1s infinite
}
.feature.built .feature-body .m-avatar-img:nth-of-type(2n){animation-delay:0s, 1.7s}
.feature.built .feature-body .m-avatar-img:nth-of-type(3n){animation-delay:0s, 2.2s}
.feature.built .feature-body .m-avatar-img:nth-of-type(4n){animation-delay:0s, 2.8s}
/* Explicit class hooks (debate cards, voice mic) — still work for elements
   that aren't .m-avatar-img */
/* clar.tax fix (also in upstream Lavern): avatarBob alone replaced avatarPop, so bobbing avatars in
   the debate card never appeared. Pop first, then bob. */
.feature.built .m-bobber{animation:avatarPop .8s var(--ease) forwards, avatarBob 2.4s ease-in-out .9s infinite}

/* — Orbit spin — for "+" affordance + processing spinners */
@keyframes orbitSpin{
  to{transform:rotate(360deg)}
}
.m-spin{
  display:inline-flex;width:14px;height:14px;
  border:1.5px solid var(--hair-strong);
  border-top-color:var(--text);
  border-radius:50%;
  animation:orbitSpin 1.1s linear infinite;
  flex:none
}
.feature.built .m-plus-rotate{animation:orbitSpin 12s linear infinite;display:inline-block}

/* — Bar fill loop — a progress bar that fills 0→100% on a loop */
@keyframes barFillLoop{
  0%{width:0%;opacity:1}
  80%{width:100%;opacity:1}
  90%{width:100%;opacity:.3}
  100%{width:0%;opacity:0}
}
.feature.built .m-bar .m-bar-loop{
  animation:barFillLoop 3.6s cubic-bezier(.4,.0,.2,1) infinite
}

/* — Arrow swap — vertical ↕ flips emphasis between top/bottom */
@keyframes arrowSwap{
  0%,40%{transform:translateY(-2px) scale(1.0);opacity:1}
  50%,90%{transform:translateY(2px) scale(1.0);opacity:1}
  100%{transform:translateY(-2px) scale(1.0);opacity:1}
}
.feature.built .m-arrow-swap{animation:arrowSwap 2.6s ease-in-out infinite;display:inline-block}

/* — Status tag pulse — the small green "on" / "delivered" tags ripple
   through, drawing the eye through the team / clawern lists */
@keyframes tagPulse{
  0%,100%{filter:brightness(1)}
  50%{filter:brightness(1.18)}
}
.feature.built .m-tag.ok{animation:tagPulse 2.6s ease-in-out infinite}
.feature.built .m-row:nth-of-type(1) .m-tag.ok{animation-delay:0s}
.feature.built .m-row:nth-of-type(2) .m-tag.ok{animation-delay:.4s}
.feature.built .m-row:nth-of-type(3) .m-tag.ok{animation-delay:.8s}
.feature.built .m-row:nth-of-type(4) .m-tag.ok{animation-delay:1.2s}

/* — Bubble cascade — chat bubbles slide in one-by-one when card builds */
.feature .m-bubble{opacity:0;transform:translateY(8px)}
.feature.built .m-bubble{
  animation:bubbleIn .55s var(--ease) forwards
}
@keyframes bubbleIn{
  0%{opacity:0;transform:translateY(8px)}
  100%{opacity:1;transform:translateY(0)}
}
.feature.built .feature-body > .m-row:nth-of-type(1) .m-bubble,
.feature.built .feature-body > .m-bubble:nth-of-type(1){animation-delay:.30s}
.feature.built .feature-body > .m-row:nth-of-type(2) .m-bubble,
.feature.built .feature-body > .m-bubble:nth-of-type(2){animation-delay:.55s}
.feature.built .feature-body > .m-row:nth-of-type(3) .m-bubble,
.feature.built .feature-body > .m-bubble:nth-of-type(3){animation-delay:.80s}
.feature.built .feature-body > .m-row:nth-of-type(4) .m-bubble,
.feature.built .feature-body > .m-bubble:nth-of-type(4){animation-delay:1.05s}

/* — Card highlight ping — debate's findings briefly brighten in turn */
@keyframes cardPing{
  0%,100%{box-shadow:var(--shadow-sm);border-color:var(--hair)}
  50%{box-shadow:var(--shadow-md);border-color:var(--hair-strong)}
}
.feature.built .m-card-ping{animation:cardPing 4s ease-in-out infinite}
.feature.built .m-card-ping:nth-of-type(2){animation-delay:2s}

/* — Tap-shimmer — for the "Instruct →" button pop */
@keyframes tapShimmer{
  0%,100%{transform:scale(1);box-shadow:0 2px 4px rgba(20,19,16,0.15)}
  50%{transform:scale(1.03);box-shadow:0 4px 12px rgba(20,19,16,0.28)}
}
.feature.built .m-cta{animation:tapShimmer 2.4s ease-in-out infinite}

/* — Wave breath — the wave-svg ALSO subtly translates and the whole
   card gets a "voice is here" feel */
@keyframes voiceMicPulse{
  0%,100%{box-shadow:0 0 0 0 rgba(20,19,16,0.18)}
  60%{box-shadow:0 0 0 14px rgba(20,19,16,0)}
}
.feature.built .voice-avatar{animation:avatarBob 2.4s ease-in-out infinite, voiceMicPulse 2.4s ease-in-out infinite}

@media(prefers-reduced-motion:reduce){
  .feature.built .wave-svg rect,
  .feature.built .m-dot.ok,
  .feature.built .voice-avatar,
  .feature.built .m-bobber,
  .feature.built .m-plus-rotate,
  .feature.built .m-bar .m-bar-loop,
  .feature.built .m-arrow-swap,
  .feature.built .m-tag.ok,
  .feature.built .m-bubble,
  .feature.built .m-card-ping,
  .feature.built .m-cta,
  .feature.built .m-soul-line,
  .feature.built .m-doc-large-title,
  .feature.built .m-doc-large-body p,
  .feature.built .m-doc-large-body li,
  .feature.built .m-doc-large-footer,
  .feature.built .m-doc-stamp,
  .feature .m-type-instruct,
  .feature.briefing-card .m-bubble,
  .feature.briefing-card .m-typing,
  .m-caret,
  .m-spin{animation:none}
  .feature.built .m-soul-line,
  .feature.built .m-doc-large-title,
  .feature.built .m-doc-large-body p,
  .feature.built .m-doc-large-body li,
  .feature.built .m-doc-large-footer,
  .feature .m-type-instruct,
  .feature .m-soul-line,
  .feature.briefing-card .m-bubble{
    opacity:1;transform:none;clip-path:none
  }
}

/* ═══════════════════════════════════════════════════════════════════
   TYPEWRITER — text reveals itself left-to-right with stepped ticks,
   mimicking a keyboard typing the content out. clip-path inset is
   used so it works on multi-line text and respects line wrap.
   Step count is tuned per element to roughly match its character
   length so the "tick" feels right.
   ═══════════════════════════════════════════════════════════════════ */
@keyframes typeReveal{
  from{clip-path:inset(0 100% 0 0)}
  to{clip-path:inset(0 -2% 0 0)}
}

/* Card 1 — the instruct request types itself in (≈122 chars) */
.feature .m-type-instruct{clip-path:inset(0 100% 0 0)}
.feature.built .m-type-instruct{
  animation:typeReveal 2.4s steps(70) .4s forwards
}

/* Card 4 Soul — each principle types in sequence (overrides the prior
   slide-in stagger). After the type completes, lines 2 & 3 drift on a
   subtle opacity loop so the block keeps breathing. */
@keyframes soulDrift{
  0%,100%{opacity:1}
  50%{opacity:.82}
}
.feature .m-soul-line{
  clip-path:inset(0 100% 0 0);opacity:1;transform:none
}
.feature.built .m-soul-line:nth-of-type(1){
  animation:typeReveal 1.1s steps(28) .5s forwards
}
.feature.built .m-soul-line:nth-of-type(2){
  animation:typeReveal 1.7s steps(48) 1.8s forwards,
            soulDrift 5.5s ease-in-out 3.7s infinite
}
.feature.built .m-soul-line:nth-of-type(3){
  animation:typeReveal 1.4s steps(42) 3.7s forwards,
            soulDrift 5.5s ease-in-out 5.4s infinite
}

/* Card 8 Briefing — chat bubbles type in like a real conversation,
   alternating between the interviewer and the user. Overrides the
   universal bubbleIn fade cascade on this card only. */
.feature.briefing-card .m-bubble{
  opacity:1;transform:none;clip-path:inset(0 100% 0 0)
}
/* Children of .feature-body are all <div>s (m-row, m-bubble, m-bubble, m-bubble, m-typing),
   so :nth-of-type counts the div position, not the class. The selectors below use the
   actual div index for each turn of the chat. */
.feature.briefing-card.built .feature-body > .m-row:nth-of-type(1) .m-bubble{
  animation:typeReveal 1.5s steps(40) .5s forwards
}
.feature.briefing-card.built .feature-body > .m-bubble:nth-of-type(2){
  animation:typeReveal 1.0s steps(28) 2.3s forwards
}
.feature.briefing-card.built .feature-body > .m-row:nth-of-type(3) .m-bubble{
  animation:typeReveal 1.7s steps(46) 3.6s forwards
}
.feature.briefing-card.built .feature-body > .m-bubble:nth-of-type(4){
  animation:typeReveal .8s steps(17) 5.6s forwards
}
/* The typing indicator at the end shows AFTER the last reply lands */
.feature.briefing-card .m-typing{opacity:0}
.feature.briefing-card.built .m-typing{
  animation:lineWriteIn .4s ease-out 6.6s forwards
}

/* FAQ — same treatment */
.faq-item{
  opacity:0;transform:translateY(8px);
  transition:opacity .7s var(--ease),transform .7s var(--ease)
}
.faq-item.v{opacity:1;transform:translateY(0)}
/* Reveal observer adds .v to .faq-list (parent); propagate visibility
   to each item via descendant selector so children become visible too. */
.faq-list.v .faq-item{opacity:1;transform:translateY(0)}
.faq-list.v .faq-item:nth-child(1){transition-delay:.04s}
.faq-list.v .faq-item:nth-child(2){transition-delay:.10s}
.faq-list.v .faq-item:nth-child(3){transition-delay:.16s}
.faq-list.v .faq-item:nth-child(4){transition-delay:.22s}
.faq-list.v .faq-item:nth-child(5){transition-delay:.28s}
.faq-list.v .faq-item:nth-child(6){transition-delay:.34s}
.faq-list.v .faq-item:nth-child(7){transition-delay:.40s}
.faq-list.v .faq-item:nth-child(8){transition-delay:.46s}

/* Hero meta — staggered count-up appearance */
.hero-meta-item{
  opacity:0;transform:translateY(12px);
  transition:opacity .8s var(--ease),transform .8s var(--ease)
}
.hero-meta.v .hero-meta-item:nth-child(1){opacity:1;transform:translateY(0);transition-delay:.1s}
.hero-meta.v .hero-meta-item:nth-child(2){opacity:1;transform:translateY(0);transition-delay:.22s}
.hero-meta.v .hero-meta-item:nth-child(3){opacity:1;transform:translateY(0);transition-delay:.34s}
.hero-meta.v .hero-meta-item:nth-child(4){opacity:1;transform:translateY(0);transition-delay:.46s}

@media(prefers-reduced-motion:reduce){
  .r,.section-title,.hero h1,.closing h2,
  .feature .feature-body > *,
  .faq-item,.hero-meta-item{
    opacity:1;transform:none;clip-path:none;transition:none
  }
}
