/* Odontologia Rocha — MOVIMENTO (V2 · Fase 3). Guia completo: README.md › "Sistema de movimento".
   Famílias: A entrada · B reveal/parallax · C micro · D troca de aba · E atenção.
   Anima só transform/translate/scale, opacity, clip-path, --ang (filter: orbes + aro de refração).
   html.reduce-motion (sistema OU botão do rodapé): zero @keyframes, transições ≤ 200 ms.
   Estados escondidos só em @keyframes (fill backwards) ou com html.js. Cores: só as 9 do kit.
   Fase 4 — o que só 1–2 abas usam mora no page-*.css delas: entrada do hero, borda-luz girando e
   refração (page-home), tilt (page-home/page-servicos), copiar + toast (page-contato), --par/--drift
   e --cis de cada seção. Os @keyframes e @property continuam aqui. */

/* 0. Tokens (ease, --t-*, --stagger em tokens.css) */
:root { --t-press: 120ms; --t-reveal: 450ms; --t-pill: 450ms; --rise: 24px; --par: 30px; }
html.reduce-motion {
  --t-fast: 120ms; --t-base: 200ms; --t-slow: 200ms; --t-page: 200ms;
  --t-reveal: 200ms; --t-pill: 200ms; --stagger: 0ms; --rise: 0px;
  scroll-behavior: auto;
}
@property --ang    { syntax: '<angle>';  inherits: false; initial-value: 0deg; }
@property --spec-a { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --rx     { syntax: '<angle>';  inherits: false; initial-value: 0deg; }
@property --ry     { syntax: '<angle>';  inherits: false; initial-value: 0deg; }

/* 1. Keyframes */
@keyframes m-rise       { from { opacity: 0.001; translate: 0 var(--rise); } }
@keyframes m-fade-scale { from { opacity: 0.001; scale: 0.96; } }
@keyframes m-slide-in   { from { opacity: 0.001; translate: var(--rise) 0; } }
@keyframes m-wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(-0.35em -0.2em -0.35em -0.2em); } }
@keyframes m-wa-in      { from { opacity: 0.001; scale: 0.6; translate: 0 12px; } }
@keyframes m-page-enter { from { opacity: 0.001; } }
@keyframes m-spin       { to { --ang: 360deg; } }
@keyframes m-halo { 0% { opacity: 0; scale: 1; } 3% { opacity: 0.85; } 22%, 100% { opacity: 0; scale: var(--halo-sx, 1.55) var(--halo-sy, 1.55); } }
@keyframes m-shimmer { 0% { translate: -130% 0; } 16%, 100% { translate: 130% 0; } }
@keyframes m-dot { 0% { opacity: 0.55; scale: 1; } 70%, 100% { opacity: 0; scale: 3; } }
@keyframes m-orb-1 { 0%, 100% { transform: translate(-50%, -50%) translateZ(0); } 50% { transform: translate(-50%, -50%) translate3d(calc(3% * var(--drift, 1)), calc(-4% * var(--drift, 1)), 0) scale(calc(1 + 0.05 * var(--drift, 1))); } }
@keyframes m-orb-2 { 0%, 100% { transform: translate(-50%, -50%) translateZ(0); } 50% { transform: translate(-50%, -50%) translate3d(calc(-4% * var(--drift, 1)), calc(3% * var(--drift, 1)), 0) scale(calc(1 + 0.04 * var(--drift, 1))); } }
@keyframes m-orb-3 { 0%, 100% { transform: translate(-50%, -50%) translateZ(0); } 50% { transform: translate(-50%, -50%) translate3d(calc(3% * var(--drift, 1)), calc(3% * var(--drift, 1)), 0) scale(calc(1 - 0.04 * var(--drift, 1))); } }
@keyframes m-orb-par { from { translate: 0 calc(var(--par) * -1); } to { translate: 0 var(--par); } }
@keyframes vt-out      { to   { opacity: 0; transform: translateX(-16px); } }
@keyframes vt-in       { from { opacity: 0; transform: translateX(16px); } }
@keyframes vt-fade-out { to   { opacity: 0; } }
@keyframes vt-fade-in  { from { opacity: 0; } }

/* A. Entrada — só os filhos (opacidade .001→1); o container do hero nunca some (hero: page-home.css) */
/* Demais páginas: cabeçalho de página (o 1º bloco entra pelo data-reveal). Por view transition: não repete. */
html:not(.reduce-motion):not(.vt-arrived) .page-head .container > * { animation: m-rise var(--t-slow) var(--ease-out) backwards; }
html:not(.reduce-motion):not(.vt-arrived) .page-head .container > :nth-child(2) { animation-delay: 70ms; }
html:not(.reduce-motion):not(.vt-arrived) .page-head .container > :nth-child(3) { animation-delay: 140ms; }
html:not(.reduce-motion):not(.vt-arrived) .page-head .container > :nth-child(4) { animation-delay: 210ms; }
/* Reduzido: fade 200 ms (transição de entrada, sem keyframes); o hero aparece já. */
html.reduce-motion .page-head .container > * { transition: opacity 200ms linear; }
@starting-style { html.reduce-motion .page-head .container > * { opacity: 0.001; } }
/* Botão WA: surge após 600 ms com spring, só em carga nova. */
html:not(.reduce-motion):not(.vt-arrived):not(.pe) .floating-wa { animation: m-wa-in var(--t-slow) var(--ease-spring) 600ms backwards; }

/* B. Scroll-reveal — `translate` (não `transform`): não briga com hover/tilt */
html.js [data-reveal]:not(.is-in) { opacity: 0.001; translate: 0 var(--rise); }
html.js [data-reveal].revealing {
  transition: opacity var(--t-reveal) var(--ease-out), translate var(--t-reveal) var(--ease-out);
  transition-delay: calc(var(--d0, 0ms) + var(--i, 0) * var(--stagger));
}
html.js.reduce-motion [data-reveal].revealing { transition-timing-function: linear; transition-delay: 0s; }
/* Fallback sem View Transitions: html.pe (posto no <head>) / main.page-enter (motion.js). */
html:not(.reduce-motion).pe main,
html:not(.reduce-motion) main.page-enter { animation: m-page-enter var(--t-base) var(--ease-out) backwards; }

/* B. Orbes: deriva (transform, 18–26 s; off ≤ 480 px) + parallax (`translate`, ±--par; --par/--drift por seção no page-*.css) */
.orb-field { view-timeline: --orb-scroll block; }
@media (min-width: 481px) {
  html:not(.reduce-motion) .orb-field::before { animation: m-orb-1 22s ease-in-out infinite; }
  html:not(.reduce-motion) .orb-field::after  { animation: m-orb-2 26s ease-in-out -6s infinite; }
  html:not(.reduce-motion) .orb-field > .orb  { animation: m-orb-3 18s ease-in-out -3s infinite; }
}
@supports (animation-timeline: scroll()) {
  html:not(.reduce-motion) .orb-field::before,
  html:not(.reduce-motion) .orb-field::after,
  html:not(.reduce-motion) .orb-field > .orb { animation: m-orb-par linear both; animation-timeline: --orb-scroll; }
  @media (min-width: 481px) {
    html:not(.reduce-motion) .orb-field::before { animation: m-orb-1 22s ease-in-out infinite, m-orb-par linear both; animation-timeline: auto, --orb-scroll; }
    html:not(.reduce-motion) .orb-field::after  { animation: m-orb-2 26s ease-in-out -6s infinite, m-orb-par linear both; animation-timeline: auto, --orb-scroll; }
    html:not(.reduce-motion) .orb-field > .orb  { animation: m-orb-3 18s ease-in-out -3s infinite, m-orb-par linear both; animation-timeline: auto, --orb-scroll; }
  }
}
html.parallax-js:not(.reduce-motion) .orb-field::before,
html.parallax-js:not(.reduce-motion) .orb-field::after,
html.parallax-js:not(.reduce-motion) .orb-field > .orb { translate: 0 var(--py, 0px); }

/* C1. Press: scale(.98), 120 ms */
.btn { transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform var(--t-press) var(--ease-out); }
.floating-wa { transition: background-color 0.15s ease, transform var(--t-press) var(--ease-out); }
html .notfound-link { transition: border-color 0.15s ease, box-shadow 0.15s ease, transform var(--t-press) var(--ease-out); }
html .anchor-nav a { transition: background-color 0.15s ease, box-shadow 0.15s ease, transform var(--t-press) var(--ease-out); }
.menu-toggle { transition: transform var(--t-press) var(--ease-out); }
html:not(.reduce-motion) :is(.btn, .floating-wa, .chip, .notfound-link, .anchor-nav a, .menu-toggle, .lightbox-btn, .motion-toggle, .copy-value):active { transform: scale(0.98); }
html:not(.reduce-motion) :is(.service-card, .shortcut-card):not(.tilt):active { transform: scale(0.98); }

/* C2. Medalhões "respiram" no hover */
.card-icon img { transition: transform var(--t-base) var(--ease-spring); }
@media (hover: hover) {
  html:not(.reduce-motion) :is(.shortcut-card, .service-card, .value-card, .contact-card, .attend-block):hover .card-icon img { transform: scale(1.06); }
}

/* C4. Pílula líquida do menu: desliza (transform) e estica (width, spring) */
.main-nav { position: relative; }
.nav-pill {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  width: 0;
  height: var(--toque-min);
  border-radius: 999px;
  background: var(--or-nude);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 2px rgba(36, 34, 36, 0.06);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--t-pill) var(--ease-out), width var(--t-pill) var(--ease-spring), opacity var(--t-fast) var(--ease-out);
}
.nav-pill.is-on { opacity: 1; }
html.has-pill:not(.reduce-motion) .nav-list { position: relative; z-index: 1; }
html.has-pill:not(.reduce-motion) :is(.nav-link[aria-current="page"], .nav-link:hover) { background: none; }
html.reduce-motion :is(.nav-pill, .tab-drop) { display: none; }

/* C5. Gota da tab bar (WAAPI no motion.js) */
.tab-drop {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  border-radius: 999px;
  background: var(--or-nude);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  opacity: 0;
  pointer-events: none;
}
.tab-drop.is-on { opacity: 1; }
html.has-drop:not(.reduce-motion) .tab-list { position: relative; z-index: 1; }
html.has-drop:not(.reduce-motion) .tab-link[aria-current="page"] .tab-icon { background: none; box-shadow: none; }
.tab-bar { transition: transform var(--t-base) var(--ease-out); }

/* C8. Botão "Reduzir movimento" (rodapé) */
.footer-motion { margin-top: var(--espaco-2); }
.motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--toque-min);
  padding: 8px 18px 8px 12px;
  border: 1px solid rgba(216, 219, 223, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--or-prata-clara);
  font-family: var(--fonte-titulo);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform var(--t-press) var(--ease-out);
}
.motion-toggle:hover { border-color: var(--or-prata-clara); background: rgba(255, 255, 255, 0.08); }
.motion-toggle::before {
  content: "";
  flex-shrink: 0;
  width: 30px;
  height: 18px;
  border: 1px solid rgba(216, 219, 223, 0.5);
  border-radius: 999px;
  background: radial-gradient(circle at 8px 50%, var(--or-prata-clara) 0 5px, rgba(216, 219, 223, 0) 5.5px);
}
.motion-toggle[aria-pressed="true"] { color: var(--branco); border-color: var(--or-prata-clara); background: rgba(216, 219, 223, 0.12); }
.motion-toggle[aria-pressed="true"]::before {
  border-color: var(--branco);
  background: radial-gradient(circle at 20px 50%, var(--branco) 0 5px, rgba(255, 255, 255, 0) 5.5px), rgba(255, 255, 255, 0.18);
}
.motion-toggle[aria-disabled="true"] { cursor: default; }

/* D. Troca de aba — View Transitions entre documentos (nomes postos pelo layout.js só durante a transição) */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: var(--t-page); animation-timing-function: var(--ease-io); }
::view-transition-old(page) { animation: var(--t-page) var(--ease-io) both vt-out; }
::view-transition-new(page) { animation: var(--t-page) var(--ease-io) both vt-in; }
::view-transition-old(root) { animation: var(--t-page) var(--ease-io) both vt-fade-out; }
::view-transition-new(root) { animation: var(--t-page) var(--ease-io) both vt-fade-in; }
/* Cabeçalho/tab bar parados; a captura perde o desfoque (o nome isola), o grupo refaz o vidro. */
::view-transition-group(site-header),
::view-transition-group(tab-bar) {
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-sat));
}
/* Reduzido: crossfade, sem deslocamento */
html.reduce-motion::view-transition-group(*) { animation: none; }
html.reduce-motion::view-transition-old(page), html.reduce-motion::view-transition-old(root) { animation: 200ms linear both vt-fade-out; }
html.reduce-motion::view-transition-new(page), html.reduce-motion::view-transition-new(root) { animation: 200ms linear both vt-fade-in; }

/* E. Atenção — só o [data-attention] visível de maior prioridade recebe .is-live */
.btn[data-attention] { overflow: hidden; }
.btn[data-attention]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(105deg, rgba(233, 221, 216, 0) 20%, rgba(233, 221, 216, 0.75) 38%, rgba(255, 255, 255, 1) 50%, rgba(233, 221, 216, 0.75) 62%, rgba(233, 221, 216, 0) 80%);
  translate: -130% 0;
  pointer-events: none;
}
html:not(.reduce-motion) .btn[data-attention].is-live::after { animation: m-shimmer 6s var(--ease-io) 1.4s infinite; }
.floating-wa::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  box-shadow: 0 0 0 2px rgba(116, 24, 43, 0.5), 0 0 0 5px rgba(116, 24, 43, 0.14);
  opacity: 0;
  pointer-events: none;
}
@media (min-width: 1024px) { .floating-wa { --halo-sx: 1.18; --halo-sy: 1.5; } }
html:not(.reduce-motion) .floating-wa.is-live::after { animation: m-halo 8s var(--ease-out) 1.6s infinite; }
.urgency-link .dot { position: relative; }
.urgency-link .dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(116, 24, 43, 0.5);
  opacity: 0;
  pointer-events: none;
}
html:not(.reduce-motion) .urgency-link.is-live .dot::after { animation: m-dot 2.4s var(--ease-out) 1s infinite; }

/* G. Seções abaixo da dobra: content-visibility + altura típica (--cis de cada seção no page-*.css) */
@supports (content-visibility: auto) {
  .shortcuts-section, main#conteudo > section:nth-of-type(n + 3) {
    content-visibility: auto;
    contain-intrinsic-size: auto var(--cis, 520px);
    overflow-clip-margin: 48px;
  }
}

/* H. Rede de segurança do modo reduzido */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; }
  ::view-transition-group(*) { animation: none; }
  ::view-transition-old(page), ::view-transition-old(root) { animation: 200ms linear both vt-fade-out; }
  ::view-transition-new(page), ::view-transition-new(root) { animation: 200ms linear both vt-fade-in; }
}
html.reduce-motion :is(.shortcut-card, .service-card, .gallery-item):hover,
html.reduce-motion :is(.btn, .floating-wa, .shortcut-card, .service-card, .chip, .notfound-link, .anchor-nav a):active { transform: none; }
@media print { html.js [data-reveal] { opacity: 1 !important; translate: none !important; } }
