/* =====================================================================
   PREMIUM — camada visual extra (sobretudo mobile)
   Abertura animada, barra de progresso, barra inferior flutuante,
   carrossel de serviços, shimmer nas imagens, menu animado, toques.
   Tudo respeita prefers-reduced-motion.
   ===================================================================== */

/* ---------- 1. Abertura animada (uma vez por visita) ---------- */
.loader { display: none; }
html.show-loader body { overflow: hidden; }
html.show-loader .loader {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(120% 80% at 50% 38%, #12345a 0%, #0a1730 55%, #050c1a 100%);
  clip-path: inset(0 0 0 0);
  transition: clip-path .75s cubic-bezier(.76, 0, .24, 1);
  animation: loaderFailsafe .4s ease 4.5s forwards;
}
.loader.is-done { clip-path: inset(0 0 100% 0); }
.loader__inner { display: grid; justify-items: center; gap: 18px; }
.loader__mark { width: 96px; height: 96px; overflow: visible; filter: drop-shadow(0 18px 40px rgba(22, 168, 120, .35)); }
.loader__tile { fill: #16a878; transform-box: fill-box; transform-origin: center; animation: tileIn .55s cubic-bezier(.34, 1.56, .64, 1) .05s both; }
.loader__roof { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: roofDraw .6s cubic-bezier(.65, 0, .35, 1) .4s forwards; }
.loader__roof--in { animation-delay: .62s; }
.loader__coin { fill: #dfc176; transform-box: fill-box; transform-origin: center; animation: coinDrop .9s cubic-bezier(.3, 0, .3, 1) .95s both; }
.loader__word { font-family: var(--font-serif, Georgia, serif); font-size: 2rem; font-weight: 700; color: #fff; letter-spacing: .01em; display: flex; overflow: hidden; }
.loader__word span { display: inline-block; transform: translateY(110%); animation: letterUp .6s cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(1.05s + var(--i) * 45ms); }
.loader__tag { font-family: var(--font-sans, system-ui); font-size: .72rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: rgba(223, 193, 118, .85); opacity: 0; animation: fadeIn .6s ease 1.4s forwards; }
.loader__bar { width: 132px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.loader__bar i { display: block; height: 100%; background: linear-gradient(90deg, #16a878, #dfc176); transform-origin: left; transform: scaleX(0); animation: barFill 1.5s cubic-bezier(.65, 0, .35, 1) .2s forwards; }
@keyframes tileIn { from { transform: scale(0) rotate(-12deg); opacity: 0; } }
@keyframes roofDraw { to { stroke-dashoffset: 0; } }
@keyframes coinDrop {
  0% { transform: translateY(-34px) scale(.6); opacity: 0; }
  45% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(-7px) scaleY(1.05); }
  74% { transform: translateY(0) scale(1.15, .85); }
  86% { transform: translateY(-2px) scale(1); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes letterUp { to { transform: none; } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes barFill { to { transform: scaleX(1); } }
@keyframes loaderFailsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* ---------- 2. Barra de progresso de leitura ---------- */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1001; pointer-events: none;
  background: linear-gradient(90deg, #16a878, #dfc176); transform-origin: left; transform: scaleX(var(--p, 0)); }

/* ---------- 3. Toque: resposta táctil ---------- */
@media (hover: none) {
  .btn, .card--link, .mobile-bar a, .debt-chip, .radio-chip, .contact-fab__btn, .faq summary { transition: transform .18s cubic-bezier(.22, 1, .36, 1); -webkit-tap-highlight-color: transparent; }
  .btn:active, .mobile-bar a:active, .debt-chip:active, .radio-chip:active, .contact-fab__btn:active { transform: scale(.96); }
  .card--link:active { transform: scale(.98); }
}

/* ---------- 4. Mobile ---------- */
@media (max-width: 899px) {
  /* Barra inferior flutuante, em vidro */
  body.has-mobile-bar { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .mobile-bar {
    left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    gap: 6px; padding: 6px; border-radius: 20px;
    background: color-mix(in srgb, var(--surface) 74%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
    border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
    box-shadow: 0 18px 40px -16px rgba(5, 12, 26, .55);
    transition: transform .45s cubic-bezier(.22, 1, .36, 1), opacity .3s;
  }
  .mobile-bar a { background: transparent; border-radius: 14px; padding: .85rem .6rem; }
  .mobile-bar a.is-accent { background: linear-gradient(135deg, #18b382, #0e8a60); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 8px 18px -8px rgba(22, 168, 120, .7); }
  .mobile-bar.is-hidden { transform: translateY(calc(100% + 30px)); opacity: 0; }
  .contact-fab { bottom: calc(88px + env(safe-area-inset-bottom)); right: 16px; transition: transform .45s cubic-bezier(.22, 1, .36, 1); }
  body.bar-hidden .contact-fab { transform: translateY(72px); }

  /* Hero: movimento lento na fotografia */
  .hero__media img { animation: kenBurns 22s ease-in-out infinite alternate; }

  /* Menu: entrada em cascata, numeração e brilho */
  .mobile-menu { background: radial-gradient(90% 50% at 100% 0%, color-mix(in srgb, #16a878 16%, transparent), transparent 70%), var(--bg); }
  .mobile-menu__list { counter-reset: m; }
  .mobile-menu__list > li { opacity: 0; transform: translateY(16px); }
  .mobile-menu.is-open .mobile-menu__list > li { animation: menuItem .55s cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(60ms + var(--i, 0) * 45ms); }
  .mobile-menu__list > li > a { justify-content: flex-start; gap: .9rem; font-size: 1.85rem; }
  .mobile-menu__list > li > a::before { counter-increment: m; content: counter(m, decimal-leading-zero); font-family: var(--font-sans); font-size: .72rem; font-weight: 800; letter-spacing: .08em; color: #c9a44a; min-width: 1.6rem; }
  .mobile-menu__list > li > a svg { margin-left: auto; }
  .mobile-menu__actions { opacity: 0; }
  .mobile-menu.is-open .mobile-menu__actions { animation: menuItem .55s cubic-bezier(.22, 1, .36, 1) .45s both; }
}
@keyframes kenBurns { from { transform: scale(1.02); } to { transform: scale(1.14) translate(-2%, -1%); } }
@keyframes menuItem { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------- 5. Carrossel de cartões (mobile) ---------- */
@media (max-width: 699px) {
  .is-swipe {
    display: flex !important; gap: 14px; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter, 20px);
    margin-inline: calc(var(--gutter, 20px) * -1); padding: 8px var(--gutter, 20px) 14px;
    scrollbar-width: none;
  }
  .is-swipe::-webkit-scrollbar { display: none; }
  .is-swipe > * { flex: 0 0 84%; scroll-snap-align: start; grid-column: auto !important; }
  .is-swipe > *:last-child { margin-right: 0; }
  .swipe-ui { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
  .swipe-ui__track { position: relative; flex: 1; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
  .swipe-ui__thumb { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; background: linear-gradient(90deg, #16a878, #dfc176); transition: transform .2s linear; }
  .swipe-ui__count { font-size: .75rem; font-weight: 800; letter-spacing: .06em; color: var(--text-soft); font-variant-numeric: tabular-nums; }
  .swipe-ui__hint { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 700; color: var(--accent); transition: opacity .4s; }
  .swipe-ui__hint svg { width: 16px; height: 16px; animation: nudge 1.4s ease-in-out infinite; }
  .swipe-ui.is-used .swipe-ui__hint { opacity: 0; }
}
@media (min-width: 700px) { .swipe-ui { display: none; } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

/* ---------- 6. Imagens: shimmer enquanto carregam ---------- */
.img-loading { background: linear-gradient(100deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%) !important; background-size: 220% 100% !important; animation: shimmer 1.3s linear infinite; }
.img-loading > img { opacity: 0; }
.img-fade > img { transition: opacity .7s ease; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---------- 7. Moedas (diagnóstico do simulador) ---------- */
.coin-burst { position: fixed; z-index: 1200; width: 14px; height: 14px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff3c4, #dfc176 45%, #b08a2e 100%); box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  html.show-loader .loader { display: none; }
  .hero__media img, .swipe-ui__hint svg, .img-loading { animation: none !important; }
  .mobile-menu__list > li, .mobile-menu__actions { opacity: 1 !important; transform: none !important; animation: none !important; }
}
