/* ==========================================================================
   TBF Motion — shared premium motion layer for thinkbrandfirst.com pages.
   Loaded with /assets/tbf-motion.js. Every hidden state is gated on
   html.motion, which the page head sets and the failsafe removes.
   First used on /crm/ (2026-09-16).
   ========================================================================== */

html { scrollbar-width: thin; scrollbar-color: rgba(212,168,79,.45) #0B0D0F; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #0B0D0F; }
::-webkit-scrollbar-thumb { background: linear-gradient(#D4A84F, #38BDF8); border-radius: 8px; }
.no-scrollbar::-webkit-scrollbar { display: none; }

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

/* ---------- Ambient layers ---------- */
#tm-webgl { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
.tm-noise { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
html:not(.motion) #tm-webgl { display: none; }

/* ---------- Boot sequence ---------- */
#tm-boot { display: none; }
html.boot #tm-boot { display: block; position: fixed; inset: 0; z-index: 1000000; }
html.boot body { overflow: hidden; }
#tm-boot .tm-panel { position: absolute; left: 0; right: 0; height: 50.5%; background: #07090B; }
#tm-boot .tm-panel.top { top: 0; }
#tm-boot .tm-panel.bottom { bottom: 0; }
#tm-boot .tm-seam { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: linear-gradient(90deg, transparent, #F0C96A, transparent); transform: scaleX(0); box-shadow: 0 0 18px #F0C96A; }
#tm-boot .tm-core { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
#tm-boot .tm-mark { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 0 22px rgba(212,168,79,.55)); }
#tm-boot .tm-label { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; letter-spacing: .32em; color: #D4A84F; font-weight: 600; text-align: center; padding: 0 16px; }
#tm-boot .tm-bar { width: min(280px, 70vw); height: 2px; background: rgba(255,255,255,.07); border-radius: 2px; overflow: hidden; }
#tm-boot .tm-bar span { display: block; height: 100%; transform: scaleX(0); transform-origin: 0 50%; background: linear-gradient(90deg, #D4A84F, #F0C96A, #38BDF8); box-shadow: 0 0 14px rgba(240,201,106,.8); }
#tm-boot .tm-pct { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; color: #A7ADB4; font-variant-numeric: tabular-nums; letter-spacing: .12em; }

/* ---------- Scroll progress + header ---------- */
#tm-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 70; transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, #D4A84F, #F0C96A 50%, #38BDF8); box-shadow: 0 0 12px rgba(240,201,106,.6); pointer-events: none; }
html:not(.motion) #tm-progress { display: none; }
header.tm-header > div { transition: height .45s cubic-bezier(.16,1,.3,1), background-color .45s, box-shadow .45s, border-color .45s; }
header.tm-header.is-scrolled > div { height: 3.5rem; background-color: rgba(11,13,15,.72); border-color: rgba(212,168,79,.22);
  box-shadow: 0 18px 50px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(212,168,79,.1); }

/* ---------- Cursor ---------- */
#tm-cursor-svg { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999998; }
#tm-dot { position: fixed; top: 0; left: 0; width: 6px; height: 6px; border-radius: 50%; background: #F0C96A; pointer-events: none; z-index: 999999;
  box-shadow: 0 0 12px #F0C96A, 0 0 24px #D4A84F; }
#tm-ring { position: fixed; top: 0; left: 0; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(212,168,79,.45); pointer-events: none; z-index: 999997;
  transition: width .3s cubic-bezier(.16,1,.3,1), height .3s cubic-bezier(.16,1,.3,1), border-color .3s, background .3s; }
html.tm-hovering #tm-ring { width: 76px; height: 76px; background: rgba(56,189,248,.08); border-color: #38BDF8; }
html:not(.fine-pointer) #tm-cursor-svg, html:not(.fine-pointer) #tm-dot, html:not(.fine-pointer) #tm-ring,
html:not(.cursor-ready) #tm-dot, html:not(.cursor-ready) #tm-ring { display: none !important; }
html.fine-pointer.cursor-ready body, html.fine-pointer.cursor-ready a, html.fine-pointer.cursor-ready button,
html.fine-pointer.cursor-ready select, html.fine-pointer.cursor-ready label, html.fine-pointer.cursor-ready summary { cursor: none; }
html.fine-pointer.cursor-ready input, html.fine-pointer.cursor-ready textarea { cursor: text; }

/* ---------- Hero ---------- */
html.motion:not(.motion-ready) [data-tm-hero] > * { opacity: 0; }
#tm-aurora { position: absolute; left: 0; top: 0; width: 720px; height: 720px; margin: -360px 0 0 -360px; border-radius: 50%; pointer-events: none; z-index: 0;
  background: radial-gradient(circle at 40% 40%, rgba(212,168,79,.2), transparent 55%), radial-gradient(circle at 65% 65%, rgba(56,189,248,.12), transparent 55%);
  filter: blur(40px); transform: translate3d(38vw, 42vh, 0); }
[data-tm-hero] > .grid { position: relative; z-index: 1; }
.tm-word { display: inline-block; margin-right: .24em; transform-origin: 50% 100%; will-change: transform, opacity, filter; }
.tm-line { display: block; overflow: hidden; padding-bottom: .1em; margin-bottom: -.1em; perspective: 900px; }
.tm-grad { background: linear-gradient(92deg, #D4A84F 0%, #F0C96A 45%, #FDE68A 70%, #D4A84F 100%); background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: tmGrad 6s ease-in-out infinite; }
@keyframes tmGrad { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* Heading masks */
.tm-mask { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .12em; margin-bottom: -.12em; }
.tm-rw { display: inline-block; will-change: transform; }

/* ---------- Cards ---------- */
.tm-spot { position: relative; transition: border-color .35s, box-shadow .35s; }
.tm-spot::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 50%), rgba(212,168,79,.13), transparent 45%); }
.tm-spot:hover::before { opacity: 1; }
.tm-spot:hover { border-color: rgba(212,168,79,.45) !important; box-shadow: 0 14px 45px -14px rgba(212,168,79,.22); }
.tm-tilt { transform-style: preserve-3d; will-change: transform; }

/* Rotating light beam */
@property --tm-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.tm-beam { position: relative; }
.tm-beam::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none; z-index: 4;
  background: conic-gradient(from var(--tm-angle), transparent 0 64%, rgba(240,201,106,.95) 78%, rgba(56,189,248,.9) 86%, transparent 94%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: tmSpin 7s linear infinite; }
@keyframes tmSpin { to { --tm-angle: 360deg; } }

/* Live flow steps (lists and chip rows) */
.tm-step { transition: border-color .35s, box-shadow .35s, transform .35s cubic-bezier(.16,1,.3,1), background-color .35s; }
.tm-step.is-live { border-color: rgba(240,201,106,.9) !important; box-shadow: 0 0 0 1px rgba(240,201,106,.3), 0 0 26px rgba(212,168,79,.35); transform: translateX(4px); }
.tm-chip.is-live { transform: translateY(-3px); }
.tm-arrow { display: inline-block; transition: transform .3s, opacity .3s, color .3s; }
.tm-arrow.is-live { color: #F0C96A; text-shadow: 0 0 12px rgba(240,201,106,.9); }

/* Typing indicator in the inbox preview */
.tm-typing { display: inline-flex; gap: 4px; padding: 8px 12px; border-radius: 10px; background: rgba(18,22,26,.8); border: 1px solid #252B31; }
.tm-typing i { width: 5px; height: 5px; border-radius: 50%; background: #D4A84F; animation: tmType 1s infinite ease-in-out; }
.tm-typing i:nth-child(2) { animation-delay: .15s; } .tm-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes tmType { 0%,60%,100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Marquee ---------- */
.tm-marquee { position: relative; z-index: 10; overflow: hidden; border-block: 1px solid #252B31;
  background: linear-gradient(90deg, rgba(11,13,15,.92), rgba(24,29,34,.6), rgba(11,13,15,.92));
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.tm-marquee-track { display: flex; width: max-content; animation: tmMarquee 40s linear infinite; will-change: transform; }
.tm-marquee:hover .tm-marquee-track { animation-play-state: paused; }
.tm-marquee-group { display: flex; align-items: center; flex-shrink: 0; }
.tm-marquee-item { display: inline-flex; align-items: center; gap: 14px; padding: 18px 26px; white-space: nowrap;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #A7ADB4; font-weight: 600; }
.tm-marquee-item b { color: #F5F5F5; font-weight: 700; }
.tm-marquee-item::before { content: ""; width: 7px; height: 7px; transform: rotate(45deg); background: #D4A84F; box-shadow: 0 0 10px rgba(212,168,79,.8); }
.tm-marquee-item.cyan::before { background: #38BDF8; box-shadow: 0 0 10px rgba(56,189,248,.8); }
@keyframes tmMarquee { to { transform: translateX(-50%); } }

/* ---------- FAQ ---------- */
details.tm-faq > summary { list-style: none; }
details.tm-faq[open] { border-color: rgba(212,168,79,.4) !important; box-shadow: 0 10px 35px -15px rgba(212,168,79,.25); }

/* ---------- Form ---------- */
.tm-form input:focus, .tm-form select:focus, .tm-form textarea:focus { box-shadow: 0 0 0 1px rgba(240,201,106,.55), 0 0 22px rgba(212,168,79,.2); }

@media (max-width: 768px) {
  #tm-aurora { width: 460px; height: 460px; margin: -230px 0 0 -230px; }
}

@media (prefers-reduced-motion: reduce) {
  .tm-beam::after, .tm-grad, .tm-marquee-track, .tm-typing i { animation: none !important; }
  #tm-webgl, #tm-cursor-svg, #tm-dot, #tm-ring, #tm-aurora { display: none !important; }
  .tm-marquee { overflow-x: auto; }
}
