/* Truvian landing: scroll effects and hover states.
   Every hidden-before-reveal state is scoped to html.js-reveal, which
   landing.js adds only when IntersectionObserver exists and the visitor
   allows motion; .in is added once per element. With JS off or reduced
   motion, everything is visible and still. Transform, opacity and
   clip-path only. */

/* section label: types in, then its hairline draws left to right */
.sec-no { position: relative; padding-bottom: .9rem; }
.sec-no::after { content: ""; position: absolute; left: 0; bottom: 0; width: 56px; height: 1px; background: var(--gold); transform-origin: left; }
.js-reveal .sec-no { clip-path: inset(0 100% 0 0); }
.js-reveal .sec-no::after { transform: scaleX(0); }
/* driven by the parent header: a fully clipped element never reports as visible */
.js-reveal .in > .sec-no { clip-path: inset(0 0 0 0); transition: clip-path .7s steps(22, end); }
.js-reveal .in > .sec-no::after { transform: scaleX(1); transition: transform .6s cubic-bezier(.2,.8,.2,1) .6s; }

/* headlines: each word rises out of its own line mask, staggered */
.js-reveal .rw { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .14em; margin-bottom: -.14em; }
.js-reveal .rw > span { display: inline-block; transform: translate3d(0, 105%, 0); }
.js-reveal .in .rw > span { transform: none; transition: transform .8s cubic-bezier(.16,.84,.24,1) calc(var(--w, 0) * 45ms); }
.js-reveal .sec-head .sub { opacity: 0; transform: translate3d(0, 10px, 0); }
.js-reveal .sec-head.in .sub { opacity: 1; transform: none; transition: opacity .7s ease .35s, transform .7s ease .35s; }

/* desks: rise in sequence; on hover lift 3px, gold edge, stamps press in */
.desk { transition: background .2s, transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s; }
.js-reveal .desk { opacity: 0; transform: translate3d(0, 18px, 0); }
.js-reveal .desk.in { opacity: 1; transform: none; transition: opacity .6s ease calc(var(--i, 0) * 90ms), transform .7s cubic-bezier(.2,.8,.2,1) calc(var(--i, 0) * 90ms), background .2s, box-shadow .25s; }
.desk:not(.desk-soon):hover, .js-reveal .desk.in:not(.desk-soon):hover { transform: translate3d(0, -3px, 0); box-shadow: inset 0 0 0 1px var(--gold), 0 18px 30px -24px var(--shadow); z-index: 2; transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s, background .2s; }
.desk:not(.desk-soon):hover .vocab .stamp { animation: thunk .42s cubic-bezier(.2,.8,.2,1) both; }
.desk:not(.desk-soon):hover .vocab .stamp:nth-child(2) { animation-delay: .07s; }
.desk:not(.desk-soon):hover .vocab .stamp:nth-child(3) { animation-delay: .14s; }
@keyframes thunk { 0% { transform: scale(1.18) rotate(-5deg); opacity: .35; } 70% { transform: scale(.97) rotate(-1deg); opacity: 1; } 100% { transform: none; opacity: 1; } }

/* evidence: rows arrive in order and their stamps land; hover shows a paper edge */
.cases a { position: relative; }
.cases a::after { content: ""; position: absolute; left: -14px; top: 12%; bottom: 12%; width: 3px; background: var(--paper); transform: scaleY(0); transform-origin: top; transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.cases a:hover::after, .cases a:focus-visible::after { transform: scaleY(1); }
.js-reveal .cases li { opacity: 0; transform: translate3d(-10px, 0, 0); }
.js-reveal .cases li.in { opacity: 1; transform: none; transition: opacity .5s ease calc(var(--i, 0) * 70ms), transform .6s cubic-bezier(.2,.8,.2,1) calc(var(--i, 0) * 70ms); }
.js-reveal .cases li .stamp { opacity: 0; }
.js-reveal .cases li.in .stamp { animation: land .45s cubic-bezier(.2,.8,.2,1) calc(var(--i, 0) * 70ms + .25s) both; }
@keyframes land { 0% { opacity: 0; transform: scale(1.15) rotate(-7deg); } 100% { opacity: 1; transform: rotate(-2.5deg); } }

/* FIG. 01: each step's rule draws and its label lights up, in order */
.js-reveal .flow-steps li::before { transform: scaleX(0); transform-origin: left; }
.js-reveal .flow-steps .step-n { color: var(--bone-faint); }
.js-reveal .flow-steps li > :not(.step-n) { opacity: .2; }
.js-reveal .flow.in .flow-steps li::before { transform: scaleX(1); transition: transform .55s cubic-bezier(.2,.8,.2,1) calc(var(--i, 0) * 260ms + .2s); }
.js-reveal .flow.in .flow-steps .step-n { color: var(--gold); transition: color .3s ease calc(var(--i, 0) * 260ms + .45s); }
.js-reveal .flow.in .flow-steps li > :not(.step-n) { opacity: 1; transition: opacity .5s ease calc(var(--i, 0) * 260ms + .4s); }

/* tracks: rise in sequence; their figures and the stats strip count up (landing.js) */
.js-reveal .track { opacity: 0; transform: translate3d(0, 14px, 0); }
.js-reveal .track.in { opacity: 1; transform: none; transition: opacity .6s ease calc(var(--i, 0) * 110ms), transform .7s cubic-bezier(.2,.8,.2,1) calc(var(--i, 0) * 110ms); }

/* FIG. 02: the code prints line by line; a copy button with feedback */
.copy-btn { font: 500 .62rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--bone-dim); background: transparent; border: 1px solid var(--rule); padding: .45rem .6rem; cursor: pointer; transition: color .15s, border-color .15s; }
.copy-btn:hover, .copy-btn:focus-visible { color: var(--bone); border-color: var(--gold); }
.copy-btn.done { color: var(--ok); border-color: var(--ok); }
.js-reveal .code pre { clip-path: inset(0 0 100% 0); }
.js-reveal .code.in pre { clip-path: inset(0 0 0 0); transition: clip-path 1.2s steps(26, end) .2s; }

/* endpoint rows and limits: a quiet stagger */
.js-reveal .endpoints tr, .js-reveal .limits li { opacity: 0; }
.js-reveal .endpoints.in tr, .js-reveal .limits.in li { opacity: 1; transition: opacity .5s ease calc(var(--i, 0) * 70ms); }

/* links: an underline that grows from the left */
.track a, .limits a, .hero-memo figcaption a, .desk-foot a, .stats-note a {
  text-decoration: none;
  border-bottom: 0;
  background: linear-gradient(var(--gold), var(--gold)) 0 100% / 0 1px no-repeat, linear-gradient(var(--rule), var(--rule)) 0 100% / 100% 1px no-repeat;
  padding-bottom: 2px;
  transition: background-size .35s cubic-bezier(.2,.8,.2,1), color .15s;
}
.desk-foot a { background: linear-gradient(var(--gold-soft), var(--gold-soft)) 0 100% / 0 1px no-repeat, linear-gradient(var(--gold), var(--gold)) 0 100% / 100% 1px no-repeat; }
.track a:hover, .limits a:hover, .hero-memo figcaption a:hover, .desk-foot a:hover, .stats-note a:hover,
.track a:focus-visible, .limits a:focus-visible, .hero-memo figcaption a:focus-visible, .desk-foot a:focus-visible, .stats-note a:focus-visible { background-size: 100% 1px, 100% 1px; color: var(--gold-soft); }
.topnav a { position: relative; border-bottom: 0; }
.topnav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--gold); transform: scaleX(0); transform-origin: left; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.topnav a:hover::after, .topnav a:focus-visible::after { transform: scaleX(1); }

@media (prefers-reduced-motion: reduce) {
  .desk:not(.desk-soon):hover { transform: none; }
}

/* ---------- the hero memo, always in motion (landing.js adds .memo-live) ----------
   The paper floats on a 9 s sway with a shadow that drifts under it; a gold
   hairline sweeps down it continuously; each memo prints in order (header,
   rows, values, stamp, signature, hash) and the previous one lifts off over
   it. Transform, opacity and clip-path only. Hover/focus (.held) pauses all
   of it; reduced motion turns all of it off. */
.memo-float { position: relative; }
.memo-ink, .memo-scan { display: none; }
.memo-live .memo { transform: none; }
.memo-live .memo-float { animation: sway 9s ease-in-out infinite; transform-origin: 50% 60%; will-change: transform; }
.memo-live .memo-float::after {
  content: ""; position: absolute; z-index: -1; left: 6%; right: 6%; bottom: -30px; height: 46px;
  background: radial-gradient(50% 50% at 50% 50%, var(--shadow), transparent 72%);
  animation: sway-shadow 9s ease-in-out infinite; will-change: transform, opacity;
}
@keyframes sway { 0%, 100% { transform: translate3d(0, -6px, 0) rotate(-2.5deg); } 50% { transform: translate3d(0, 6px, 0) rotate(-.5deg); } }
@keyframes sway-shadow { 0%, 100% { transform: translate3d(-12px, 6px, 0) scale(.9, 1); opacity: .9; } 50% { transform: translate3d(12px, -4px, 0) scale(1.04, .8); opacity: .55; } }

/* the verification hairline */
.memo-live .memo-scan { display: block; position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
.memo-live .memo-scan::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 100%;
  background: linear-gradient(to bottom, transparent calc(100% - 44px), rgba(var(--gold-rgb),.10) calc(100% - 4px), rgba(var(--gold-rgb),.85) calc(100% - 1px), transparent 100%);
  transform: translate3d(0, -100%, 0);
  animation: scan 4.2s cubic-bezier(.45,0,.55,1) infinite; will-change: transform;
}
@keyframes scan { 0% { transform: translate3d(0, -100%, 0); opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { transform: translate3d(0, 0, 0); opacity: 0; } }

/* printing: header, title, then each row types in; values after their row */
.memo.printing .memo-top, .memo.printing .memo-title, .memo.printing .memo-fields > div {
  animation: print-in .42s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 120ms);
}
.memo.printing .memo-fields dd { animation: value-in .32s ease both; animation-delay: calc(var(--i, 0) * 120ms + 220ms); }
@keyframes print-in { 0% { opacity: 0; clip-path: inset(0 100% 0 0); transform: translate3d(-6px, 0, 0); } 100% { opacity: 1; clip-path: inset(0 0 0 0); transform: none; } }
@keyframes value-in { 0% { opacity: 0; transform: translate3d(4px, 0, 0); } 100% { opacity: 1; transform: none; } }

/* the stamp presses down after the rows, with a brief ink thunk under it */
.memo.printing .memo-stamp { animation: stamp-down .6s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--n, 6) * 120ms + 300ms); }
@keyframes stamp-down { 0% { opacity: 0; transform: rotate(-11deg) scale(1.25); } 55% { opacity: 1; transform: rotate(-6deg) scale(.96); } 100% { opacity: .92; transform: rotate(-7deg) scale(1); } }
.memo-live .memo-ink {
  display: block; position: absolute; left: 50%; bottom: 70px; width: 15rem; height: 5.6rem; margin-left: -7.5rem; z-index: 0; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, rgba(28,26,22,.22), transparent 70%); opacity: 0;
}
.memo.printing .memo-ink { animation: ink .9s ease-out both; animation-delay: calc(var(--n, 6) * 120ms + 560ms); }
@keyframes ink { 0% { opacity: 0; transform: scale(.6); } 25% { opacity: 1; transform: scale(1.05); } 100% { opacity: 0; transform: scale(1.2); } }

/* the signature line draws left to right, then the hash and cost fade in */
.memo.printing .sig-line { border-bottom-color: transparent; position: relative; }
.memo.printing .sig-line::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--paper-ink); transform-origin: left; animation: draw .6s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--n, 6) * 120ms + 950ms); }
.memo.printing .sig-line > * { animation: value-in .4s ease both; animation-delay: calc(var(--n, 6) * 120ms + 950ms); }
.memo.printing .sig-meta { animation: value-in .5s ease both; animation-delay: calc(var(--n, 6) * 120ms + 1450ms); }
@keyframes draw { 0% { transform: scaleX(0); } 100% { transform: scaleX(1); } }

/* the memo on show lifts away over the next one, like a tear-off sheet */
.memo-ghost { position: absolute; inset: 0; z-index: 4; padding: inherit; pointer-events: none; transform-origin: 50% 0; animation: tear .8s cubic-bezier(.55,0,.75,.2) forwards; box-shadow: 0 18px 30px -20px rgba(0,0,0,.6); }
/* the copy is already printed: nothing inside it animates again */
.memo.printing .memo-ghost *, .memo.printing .memo-ghost *::after { animation: none !important; }
@media (min-width: 861px) { .memo-ghost { display: flex; flex-direction: column; } .memo-ghost .memo-body { flex: 1; display: flex; flex-direction: column; } }
@keyframes tear { 0% { transform: none; opacity: 1; } 100% { transform: translate3d(0, -46px, 0) rotate(-3.5deg); opacity: 0; } }

/* phones: a smaller sway and a little inset, so the corners stay on screen */
@media (max-width: 600px) {
  .memo-live .memo-float { animation-name: sway-sm; margin: 0 8px; }
  @keyframes sway-sm { 0%, 100% { transform: translate3d(0, -4px, 0) rotate(-1.2deg); } 50% { transform: translate3d(0, 4px, 0) rotate(-.2deg); } }
}

/* hover, focus or a hidden tab: everything holds still */
.held .memo-float, .held .memo-float::after, .held .memo-scan::before { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .memo-live .memo-float, .memo-live .memo-float::after, .memo-live .memo-scan::before { animation: none; }
  .memo-live .memo-scan, .memo-live .memo-ink { display: none; }
}
