/* ============================================================
   COPEILOT — laboratório de animações da landing (teste, 15/09/2026)
   Ativado por ?lab=1. Bases (html[data-anim]) são excludentes:
     reveal   · o atual: revelação única ao rolar (landing.css)
     none     · sem movimento de rolagem (tudo visível)
     parallax · camadas em velocidades diferentes + mouse na dobra
     scrolly  · animação presa ao progresso da rolagem (reversível)
     pinned   · perguntas empilham como cartões fixos
   Extras (html.fx-*) somam a qualquer base:
     hover · text · marquee · cursor · smooth · skeleton · micro
   Tudo desliga com prefers-reduced-motion (o JS não aplica nada).
   ============================================================ */

/* ── Base: none ─────────────────────────────────────────── */
html[data-anim="none"] [data-reveal], html[data-anim="none"] [data-stagger] > * { opacity: 1 !important; transform: none !important; clip-path: none !important; transition: none !important; }
html[data-anim="none"] .float-in, html[data-anim="none"] .fan .float-in { animation: none; }
html[data-anim="none"] .timeline::before { transform: none !important; transition: none; }
html[data-anim="none"] .ribbon > .ribbon-step.on { background: var(--g-soft); border-color: #bfe0cf; }

/* ── Base: parallax ─────────────────────────────────────── */
html[data-anim="parallax"] .hero { --mx: 0px; --my: 0px; }
html[data-anim="parallax"] .pcard,
html[data-anim="parallax"] .pill {
  translate: calc(var(--mx) * var(--depth, 0)) calc(var(--py, 0px) + var(--my) * var(--depth, 0));
  will-change: translate;
}
html[data-anim="parallax"] .pcard-1 { --depth: .6; }
html[data-anim="parallax"] .pcard-2 { --depth: .9; }
html[data-anim="parallax"] .pcard-3 { --depth: 1.2; }
html[data-anim="parallax"] .pcard-4 { --depth: 1.5; }
html[data-anim="parallax"] .pill { --depth: 2; }
html[data-anim="parallax"] .hero-text { translate: 0 var(--py, 0px); }
html[data-anim="parallax"] .hero::before {
  content: ''; position: absolute; inset: -20% -10%; pointer-events: none;
  background: radial-gradient(50% 55% at 75% 40%, rgba(0, 150, 63, .10) 0%, rgba(0, 150, 63, 0) 70%);
  translate: calc(var(--mx) * -.8) calc(var(--py, 0px) * .6 + var(--my) * -.8);
}
html[data-anim="parallax"] .qa-demo, html[data-anim="parallax"] .credits { translate: 0 var(--py, 0px); will-change: translate; }
html[data-anim="parallax"] .qa-text { translate: 0 calc(var(--py, 0px) * -.5); }

/* ── Base: scrolly (scroll-driven, CSS nativo) ──────────── */
@supports (animation-timeline: view()) {
  html[data-anim="scrolly"] .scroll-progress {
    position: fixed; left: 0; top: 0; height: 3px; width: 100%; z-index: 60;
    background: var(--g); transform-origin: left; transform: scaleX(0);
    animation: sd-progress linear both; animation-timeline: scroll(root);
  }
  @keyframes sd-progress { to { transform: scaleX(1); } }

  html[data-anim="scrolly"] [data-reveal], html[data-anim="scrolly"] [data-stagger] > * {
    opacity: 1; transform: none; clip-path: none; transition: none;
    animation: sd-rise linear both; animation-timeline: view();
    animation-range: entry 0% entry 65%;
  }
  html[data-anim="scrolly"] [data-reveal="fill"] { animation-name: sd-fill; }
  html[data-anim="scrolly"] [data-stagger] > * {
    animation-range: entry calc(5% + var(--i, 0) * 7%) entry calc(55% + var(--i, 0) * 7%);
  }
  /* Os filhos escalonados dentro de um painel cheio: a animação do pai já fez o trabalho */
  html[data-anim="scrolly"] .qa [data-stagger] > * { animation-timeline: view(); animation-range: entry 10% entry 60%; }
  @keyframes sd-rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
  @keyframes sd-fill {
    from { opacity: 0; transform: translateY(24px); clip-path: inset(0 0 30% 0 round var(--r, 12px)); }
    to { opacity: 1; transform: none; clip-path: inset(0 0 0 0 round var(--r, 12px)); }
  }
  html[data-anim="scrolly"] .timeline::before {
    transition: none; transform: scaleX(0);
    animation: sd-axis linear both; animation-timeline: view(); animation-range: entry 30% entry 100%;
  }
  @media (max-width: 799px) { html[data-anim="scrolly"] .timeline::before { transform: scaleY(0); animation-name: sd-axis-y; } }
  @keyframes sd-axis { to { transform: scaleX(1); } }
  @keyframes sd-axis-y { to { transform: scaleY(1); } }
  html[data-anim="scrolly"] .ribbon > .ribbon-step.on {
    background: var(--g-soft); border-color: #bfe0cf; transition: none;
    animation: sd-light linear both; animation-timeline: view();
    animation-range: entry calc(20% + var(--i, 0) * 15%) entry calc(50% + var(--i, 0) * 15%);
  }
  @keyframes sd-light { from { background: var(--bg); border-color: var(--border); } to { background: var(--g-soft); border-color: #bfe0cf; } }

  /* Dobra: o leque se abre e sobe conforme a página sai */
  html[data-anim="scrolly"] .hero-grid { animation: sd-hero-exit linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
  @keyframes sd-hero-exit { to { opacity: .2; transform: translateY(-60px) scale(.97); } }
  html[data-anim="scrolly"] .pcard { animation: float-in-card .55s var(--ease-out) both, sd-spread linear both; animation-delay: var(--d, 0ms), 0ms; animation-timeline: auto, view(); animation-range: normal, exit 0% exit 100%; }
  @keyframes sd-spread { to { translate: calc((var(--depth, 1) - 1) * 60px) calc(var(--depth, 1) * -40px); } }
  html[data-anim="scrolly"] .pcard-1 { --depth: .4; } html[data-anim="scrolly"] .pcard-2 { --depth: .8; }
  html[data-anim="scrolly"] .pcard-3 { --depth: 1.2; } html[data-anim="scrolly"] .pcard-4 { --depth: 1.6; }
}

/* ── Base: pinned (pilha de cartões) ────────────────────── */
@media (min-width: 900px) {
  html[data-anim="pinned"] .qa-list { gap: 0; }
  html[data-anim="pinned"] .qa-list > .qa {
    position: sticky; top: calc(96px + var(--i, 0) * 12px);
    min-height: calc(100vh - 180px);
    margin-bottom: 40px;
    transform-origin: top center;
    scale: calc(1 - var(--cover, 0) * .06); translate: 0 calc(var(--cover, 0) * -10px);
    filter: brightness(calc(1 - var(--cover, 0) * .12));
    transition: none;
    box-shadow: 0 -8px 30px -12px rgba(0, 40, 20, .18), var(--shadow-md);
  }
  html[data-anim="pinned"] .qa:last-child { margin-bottom: 0; }
  html[data-anim="pinned"] .qa-list::after { content: ''; display: block; height: 20vh; }
  /* A revelação do painel no modo pinned é só opacidade (o transform é da pilha) */
  html.js[data-anim="pinned"] [data-reveal="fill"] { transform: none; clip-path: none; }
  html.js[data-anim="pinned"] .in[data-reveal="fill"] { transition: opacity .5s ease-out; }
  html[data-anim="pinned"] .qa.in { transition: none; }
}

/* ── Extra: hover ───────────────────────────────────────── */
html.fx-hover .fan { perspective: 1200px; }
html.fx-hover .pcard { transition: transform .5s var(--ease-out), box-shadow .5s ease, z-index 0s .2s; cursor: default; }
html.fx-hover .pcard:hover { transform: rotate(0deg) translateY(-14px) scale(1.04); z-index: 9; box-shadow: 0 40px 70px -24px rgba(0, 60, 30, .5); }
html.fx-hover .demo, html.fx-hover .ledger-col, html.fx-hover .credits {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .35s var(--ease-out), box-shadow .35s ease;
  will-change: transform;
}
html.fx-hover .demo:hover { box-shadow: 0 24px 50px -22px rgba(0, 60, 30, .35); }
html.fx-hover .nav-links a { position: relative; background: none !important; }
html.fx-hover .nav-links a::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 5px; height: 2px; background: var(--g); transform: scaleX(0); transform-origin: right; transition: transform .3s var(--ease-out); }
html.fx-hover .nav-links a:hover::after, html.fx-hover .nav-links a[aria-current="true"]::after { transform: scaleX(1); transform-origin: left; }
html.fx-hover .btn-primary svg { transition: transform .3s var(--ease-out); }
html.fx-hover .btn-primary:hover svg { transform: translateX(4px); }
html.fx-hover .btn-primary { position: relative; overflow: hidden; }
html.fx-hover .btn-primary::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%); transform: translateX(-100%); transition: transform .6s ease; }
html.fx-hover .btn-primary:hover::after { transform: translateX(100%); }
html.fx-hover .chip { transition: transform .2s var(--ease-out), border-color .2s; }
html.fx-hover .chip:hover { transform: translateY(-2px); border-color: var(--g); }
html.fx-hover .layer { transition: transform .3s var(--ease-out), border-color .3s; }
html.fx-hover .layer:hover { transform: translateX(6px); border-color: #bfe0cf; }
html.fx-hover .role { transition: transform .3s var(--ease-out), box-shadow .3s; }
html.fx-hover .role:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* ── Extra: text (split de palavras) ────────────────────── */
html.fx-text .hero-title.float-in { animation: none; opacity: 1; }
html.fx-text .w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .08em; margin-bottom: -.08em; }
html.fx-text .wi { display: inline-block; transform: translateY(110%); animation: w-up .7s var(--ease-out) both; animation-delay: calc(var(--wi, 0) * 60ms + 80ms); }
@keyframes w-up { to { transform: translateY(0); } }
html.fx-text .hero-sub strong { background: linear-gradient(var(--g-soft), var(--g-soft)) no-repeat 0 88% / 0% 30%; transition: background-size .5s var(--ease-out); transition-delay: var(--sd, 0ms); padding: 0 2px; margin: 0 -2px; }
html.fx-text .hero-sub.hl strong { background-size: 100% 30%; }
html.fx-text .section-title .wi, html.fx-text .qa-q .wi { animation-play-state: paused; }
html.fx-text .in .section-title .wi, html.fx-text .section-title.in .wi, html.fx-text .in .qa-q .wi { animation-play-state: running; }
html.fx-text .in[data-reveal] .section-title, html.fx-text .in[data-reveal] .qa-q { transition-delay: 0ms; }

/* ── Extra: marquee (faixa legal) ───────────────────────── */
html.fx-marquee .legal-inner { flex-wrap: nowrap; overflow: hidden; gap: 0 28px; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
html.fx-marquee .legal-inner .lead { flex: none; padding-right: 8px; }
html.fx-marquee .legal-track { display: flex; gap: 0 28px; white-space: nowrap; animation: ticker 32s linear infinite; }
html.fx-marquee .legal-track > span { flex: none; }
html.fx-marquee .legal-inner:hover .legal-track { animation-play-state: paused; }
@keyframes ticker { to { transform: translateX(-50%); } }
html.fx-marquee .legal-inner > span, html.fx-marquee .legal-track > span { opacity: 1 !important; transform: none !important; transition: none !important; }

/* ── Extra: cursor ──────────────────────────────────────── */
@media (pointer: fine) {
  html.fx-cursor, html.fx-cursor a, html.fx-cursor button, html.fx-cursor textarea { cursor: none; }
  .cur-dot, .cur-ring { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 9999; border-radius: 50%; translate: -50% -50%; }
  .cur-dot { width: 8px; height: 8px; background: var(--g); }
  .cur-ring { width: 36px; height: 36px; border: 1.5px solid rgba(0, 150, 63, .6); transition: width .25s var(--ease-out), height .25s var(--ease-out), background .25s, border-color .25s; }
  html.fx-cursor.cur-link .cur-ring { width: 56px; height: 56px; background: rgba(0, 150, 63, .10); border-color: transparent; }
  html.fx-cursor.cur-ia .cur-ring { width: 56px; height: 56px; background: rgba(255, 203, 0, .22); border-color: transparent; }
  html.fx-cursor.cur-ia .cur-dot { background: var(--y); }
  html.fx-cursor.cur-text .cur-ring { width: 4px; height: 28px; border-radius: 2px; background: var(--g); border-color: transparent; }
  html.fx-cursor.cur-text .cur-dot { opacity: 0; }
}

/* ── Extra: smooth (rolagem suavizada) ──────────────────── */
html.fx-smooth { scroll-behavior: auto; }

/* ── Extra: skeleton (estado de carregamento da IA) ─────── */
html.fx-skeleton .ia-out.skel-on > * { display: none; }
html.fx-skeleton .ia-out.skel-on .skel { display: grid; gap: 9px; padding: 2px 0; }
.skel { display: none; }
.skel i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #f3e9b8 0%, #fff4c4 40%, #f3e9b8 80%); background-size: 200% 100%; animation: skel-shine 1.1s ease-in-out infinite; }
.skel i:nth-child(2) { width: 92%; } .skel i:nth-child(3) { width: 78%; } .skel i:nth-child(4) { width: 40%; height: 10px; margin-top: 4px; }
@keyframes skel-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
html.fx-skeleton .btn-ia[disabled] img { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Extra: micro (feedback pequeno) ────────────────────── */
html.fx-micro .btn:active { transform: scale(.97); transition-duration: .08s; }
html.fx-micro .btn-ia:active { transform: scale(.96); }
html.fx-micro .nav { transition: box-shadow .25s ease, background .25s ease; }
html.fx-micro .nav.scrolled .nav-inner { height: 64px; transition: height .3s var(--ease-out); }
html.fx-micro .nav-inner { transition: height .3s var(--ease-out); }
html.fx-micro .demo-ia textarea { transition: box-shadow .25s ease, border-color .25s ease; }
html.fx-micro .demo-ia textarea:focus { box-shadow: 0 0 0 4px rgba(0, 150, 63, .14); outline: none; border-color: var(--g); }
html.fx-micro #ia-count { display: inline-block; transition: transform .15s var(--ease-out); }
html.fx-micro #ia-count.tick { transform: scale(1.12); color: var(--g-dark); }
html.fx-micro .ia-out { animation: ia-in .45s var(--ease-out) both; }
@keyframes ia-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
html.fx-micro .ia-done { display: flex; align-items: center; gap: 8px; }
html.fx-micro .ia-done::before { content: ''; width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--g) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 10.5l3.2 3L15 7'/%3E%3C/svg%3E") center / 12px no-repeat; animation: pop .4s var(--ease-out) both; }
@keyframes pop { from { transform: scale(0); } 60% { transform: scale(1.2); } to { transform: scale(1); } }
html.fx-micro .btn-ia { transition: background .18s, border-color .18s, transform .12s var(--ease-out), box-shadow .3s; }
html.fx-micro .btn-ia:hover { box-shadow: 0 0 0 4px rgba(255, 203, 0, .25); }
html.fx-micro .ledger-col li::before { transition: transform .2s var(--ease-out); }
html.fx-micro .ledger-col li:hover::before { transform: scale(1.5) translateY(-1px); }

/* ── Painel do laboratório ──────────────────────────────── */
.lab {
  position: fixed; right: 16px; bottom: 16px; z-index: 10000;
  width: 300px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow: auto;
  background: rgba(32, 33, 35, .96); color: #fff; border-radius: 14px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .6);
  font: 500 13px/1.4 var(--font); padding: 14px 16px 12px;
  cursor: auto;
}
.lab * { cursor: auto; }
.lab h5 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #a9f0c6; display: flex; justify-content: space-between; align-items: center; }
.lab h5 button { background: none; border: 0; color: #bbb; font: inherit; cursor: pointer; text-transform: none; letter-spacing: 0; }
.lab fieldset { border: 0; margin: 0 0 10px; padding: 0; }
.lab legend { font-size: 11px; color: #9a9aa6; margin-bottom: 4px; padding: 0; }
.lab label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.lab label small { color: #9a9aa6; font-weight: 400; margin-left: auto; text-align: right; }
.lab input { accent-color: var(--g); margin: 0; }
.lab .lab-row { display: flex; gap: 6px; margin-top: 8px; }
.lab .lab-row button { flex: 1; background: #fff; color: #202123; border: 0; border-radius: 8px; padding: 8px; font: 600 12px var(--font); cursor: pointer; }
.lab .lab-row button.ghost { background: transparent; color: #fff; border: 1px solid #555; }
.lab .lab-note { margin-top: 8px; font-size: 11px; color: #9a9aa6; }
.lab.min { width: auto; padding: 8px 12px; }
.lab.min > *:not(h5) { display: none; }

@media (prefers-reduced-motion: reduce) {
  html[data-anim] .pcard, html[data-anim] .pill, html[data-anim] .hero-text, html[data-anim] .qa-demo, html[data-anim] .qa-text { translate: none !important; animation: none !important; }
  .scroll-progress { display: none; }
  .skel i, html.fx-skeleton .btn-ia[disabled] img { animation: none; }
  .legal-track { animation: none !important; }
}
