/* ===================================================================
   Autofy — Edição de Natal (sazonal). Só é carregado com NATAL ativo
   (includes/natal.php); desligado, o painel fica 100% original.
   =================================================================== */
:root {
  --xm-red: #e11d48;
  --xm-red-2: #9f1239;
  --xm-green: #10b981;
  --xm-gold: #fbbf24;
  --xm-violet: #8b5cf6;
  --xm-blue: #3b82f6;
}

/* ── Neve: camada única em <canvas>, nunca recebe clique ─────────────── */
.afy-snow {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 9990;
  opacity: 0; transition: opacity 1.2s ease;
}
.afy-snow.on { opacity: 1; }

/* ── Neve acumulada no topo, como na beira de um telhado (SVG repetido, sem JS) ── */
.afy-xm-lights {
  position: fixed; left: 0; right: 0; top: 0; height: 24px; z-index: 9995; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 26' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ffffff'/%3E%3Cstop offset='.65' stop-color='%23f1f6fc'/%3E%3Cstop offset='1' stop-color='%23c9d8ec'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath fill='url%28%23g%29' d='M0 0H240V10C228 14 220 9 210 12C204 14 203 22 199 22C195 22 196 14 190 13C176 11 168 17 154 14C142 11 134 16 122 13C114 11 112 19 108 19C104 19 105 12 98 12C84 11 76 16 62 13C50 10 42 15 30 12C22 10 14 13 0 10Z'/%3E%3Cpath fill='none' stroke='%23ffffff' stroke-opacity='.9' stroke-width='1.2' d='M0 3C40 5 80 2 120 4S200 2 240 3'/%3E%3C/svg%3E") 0 0 / 240px 24px repeat-x;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)) drop-shadow(0 0 6px rgba(191,219,254,.25));
}

/* ── Gorro de Papai Noel ─────────────────────────────────────────────── */
.afy-gorro-host { position: relative !important; overflow: visible !important; }
.afy-gorro-host > img { border-radius: inherit; }
/* 01/12/2026: sem o overflow:hidden do círculo, a foto (height:100% não resolve dentro do grid) vazava na proporção
   natural e o avatar do cabeçalho do perfil virava uma oval. A foto ganha o próprio quadrado. */
.pfx-av.afy-gorro-host > img { height: auto; aspect-ratio: 1 / 1; object-fit: cover; }
.afy-gorro-wrap { border-radius: 50%; position: relative; display: inline-block; flex-shrink: 0; line-height: 0; vertical-align: middle; }
.afy-gorro {
  display: block; position: absolute; z-index: 5; pointer-events: none;
  width: 96%; aspect-ratio: 360 / 225; left: -6%; top: -30%; /* 01/12/2026: mesma proporção do pódio (era 104%/-10%/-40%: grande e alto demais no perfil) */
  background: url("../images/natal-gorro.webp") no-repeat center / contain;
  transform: rotate(-6deg); transform-origin: 60% 90%;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.4));
  animation: xm-hat-drop .8s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes xm-hat-drop {
  from { opacity: 0; transform: translateY(-60%) rotate(-6deg); }
  to   { opacity: 1; transform: rotate(-6deg); }
}
/* card de meta (foto de 44 px a 12 px da borda do card): era 112%/-8%, mais largo que a foto, com o pelo sobre o rosto e o pompom para fora */
.afy-gorro-wrap > .afy-gorro { width: 92%; left: -1%; top: -27%; }
.rk-av > .afy-gorro { top: -30%; width: 96%; left: -6%; }
.rk-card.p1 .rk-av > .afy-gorro { top: -30%; width: 92%; left: -4%; }
.pf-avatar-preview > .afy-gorro { width: 80%; top: -26%; left: 2%; }
/* no admin o avatar é quadrado arredondado: o gorro assenta na borda de cima, sem passar da largura do avatar */
.adm-avatar > .afy-gorro { width: 96%; top: -36%; left: -8%; }
/* gorro junto ao nome (saudações) */
.afy-gorro-name { position: relative; display: inline-block; }
.afy-gorro-name > .afy-gorro { width: 1.15em; left: -.5em; top: -.62em; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }

/* Ícone de Natal (A com gorro) no lugar do ícone da logo, em todo lugar que usa logo-icon.png */
img[src*="assets/images/logo-icon.png"], #autofyLoaderGif, .afy-co-brand img[src*="assets/images/icon.png"] { content: url("../images/natal-logo-icon.webp"); object-fit: contain; }
.afy-lg .lg-i { height: calc(var(--lgh, 34px) * 1.25); margin-top: calc(var(--lgh, 34px) * -.25); }
html[data-theme="light"] img[src*="assets/images/logo-icon.png"], html[data-theme="light"] #autofyLoaderGif, html[data-theme="light"] .afy-co-brand img[src*="assets/images/icon.png"] {
  content: url("../images/natal-logo-icon-claro.webp");
  filter: drop-shadow(0 0 .6px rgba(15,23,42,.55)) drop-shadow(0 2px 4px rgba(15,23,42,.18)) !important;
}
/* login/cadastro: selo abaixo da marca */
.afy-xm-login { margin: 12px auto 0; padding: 6px 12px; font-size: 12px; }

/* selo discreto "Edição de Natal" */
.afy-xm-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px;
  font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(120deg, rgba(225,29,72,.22), rgba(16,185,129,.18));
  border: 1px solid rgba(255,255,255,.14);
  animation: xm-in .6s both;
}
.afy-xm-pill svg { width: 15px; height: 15px; color: #e0f2fe; }

/* botão da neve (fica junto do tema/idioma no topo) */
.afy-xm-snowbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); color: #e0f2fe; cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.afy-xm-snowbtn:hover { background: rgba(255,255,255,.12); }
.afy-xm-snowbtn[aria-pressed="false"] { color: rgba(255,255,255,.4); }
.afy-xm-snowbtn:focus-visible { outline: 2px solid var(--xm-violet); outline-offset: 2px; }
.afy-xm-snowbtn svg { width: 17px; height: 17px; }

/* ── Ranking: pódio de Natal ─────────────────────────────────────────── */
html.afy-natal .rk-floor {
  height: 26px; bottom: 6px; border-radius: 50%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255,255,255,.28), rgba(255,255,255,.06) 60%, transparent 72%);
  box-shadow: none;
}
html.afy-natal .rk-card.p1 .rk-crown { box-shadow: 0 10px 26px -10px var(--rk-gold), 0 0 0 4px rgba(225,29,72,.18); }
html.afy-natal .rk-list li.me { box-shadow: inset 3px 0 0 var(--xm-red); }

/* ── Tema claro ──
   neve do topo com sombra azulada (branco puro sumia no fundo branco) */
html[data-theme="light"] .afy-xm-lights { filter: drop-shadow(0 2px 2px rgba(71,85,105,.35)) drop-shadow(0 4px 10px rgba(59,130,246,.18)); }
/* ──────────────────────────────────────────────────────── */
html[data-theme="light"] .afy-xm-pill { color: #1e1b2e; border-color: rgba(30,27,46,.14); }
html[data-theme="light"] .afy-xm-pill svg { color: #2563eb; }
html[data-theme="light"] .afy-xm-snowbtn { color: #2563eb; background: rgba(30,27,46,.05); border-color: rgba(30,27,46,.1); }
html[data-theme="light"] .afy-xm-snowbtn[aria-pressed="false"] { color: rgba(30,27,46,.35); }
html[data-theme="light"].afy-natal .rk-floor { background: radial-gradient(60% 100% at 50% 100%, rgba(148,163,184,.35), transparent 72%); }

/* ── Celular: luzinhas menores ───────────────────────────────────────── */
@media (max-width: 768px) {
  .afy-xm-lights { height: 17px; background-size: 170px 17px; }
}

/* ── Animações reduzidas: tudo parado, decoração continua ────────────── */
@media (prefers-reduced-motion: reduce) {
  .afy-gorro, .afy-xm-pill, .afy-xm-noel img { animation: none !important; }
  .afy-snow { display: none !important; }
}

/* ── Login/cadastro: selo "Que bom te ver de volta" em versão de Natal ── */
html.afy-natal .ah-pill {
  position: relative; overflow: hidden; gap: 11px; padding: 9px 18px 9px 11px;
  border: 1px solid transparent; color: #fff; font-weight: 600; letter-spacing: .01em;
  background:
    linear-gradient(120deg, rgba(30,12,22,.92), rgba(22,14,40,.92)) padding-box,
    linear-gradient(110deg, rgba(225,29,72,.85), rgba(251,191,36,.55) 45%, rgba(139,92,246,.9)) border-box;
  box-shadow: 0 10px 30px -14px rgba(225,29,72,.75), 0 0 0 4px rgba(139,92,246,.08), inset 0 1px 0 rgba(255,255,255,.08);
}
/* a bolinha vira uma bola de árvore de Natal */
html.afy-natal .ah-pill i {
  width: 14px; height: 14px; flex: 0 0 auto; position: relative; margin-top: 3px;
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, #ff6b81 22%, #e11d48 55%, #8f0d2c 100%);
  box-shadow: 0 0 10px rgba(225,29,72,.75); animation: xm-ornament 3s ease-in-out infinite; transform-origin: 50% -4px;
}
html.afy-natal .ah-pill i::before { content: ""; position: absolute; left: 4px; top: -4px; width: 6px; height: 4px; border-radius: 1px; background: linear-gradient(#fde68a, #b45309); }
@keyframes xm-ornament { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
/* brilho que atravessa o selo de tempos em tempos */
html.afy-natal .ah-pill::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.18), transparent);
  animation: xm-shine 5s ease-in-out 1.2s infinite;
}
@keyframes xm-shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
html[data-theme="light"].afy-natal .ah-pill {
  color: #3b0764;
  background:
    linear-gradient(120deg, #fff7f9, #f5f0ff) padding-box,
    linear-gradient(110deg, rgba(225,29,72,.7), rgba(251,191,36,.5) 45%, rgba(139,92,246,.8)) border-box;
}
@media (prefers-reduced-motion: reduce) { html.afy-natal .ah-pill i, html.afy-natal .ah-pill::after { animation: none; } }

/* ── Neve acumulada na borda de cards + árvores e bonecos de neve (camada natal.js) ── */
.afy-xm-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 40; pointer-events: none; }
.afy-xm-layer > * { position: absolute; left: 0; top: 0; pointer-events: none; display: block; }
.afy-xm-layer .afy-neve-canto svg, .afy-xm-layer .afy-neve svg { max-width: none !important; display: block; }
.afy-neve-canto { line-height: 0; filter: drop-shadow(0 2px 2px rgba(0,0,0,.28)); }
.afy-neve-canto.dir svg { transform: scaleX(-1); }
.afy-neve { margin-top: -23px; line-height: 0; filter: drop-shadow(0 2px 2px rgba(0,0,0,.28)); }
/* enfeites: o translate (JS) põe o ponto (0,0) na borda de cima do botão; as margens assentam a base nele */
.afy-xm-layer svg { max-width: none !important; display: block; }
.afy-xm-sticker { line-height: 0; filter: drop-shadow(0 3px 3px rgba(0,0,0,.4)); }
.afy-xm-sticker.boneco { width: 40px; margin: -47px 0 0 -20px; }   /* corpo apoiado no botão */
.afy-xm-sticker.arvore { width: 34px; margin: -50px 0 0 -17px; }
.afy-xm-sticker svg { width: 100%; height: auto; }
/* ranking: Papai Noel sentado em cima do card do 1º lugar (assento = borda de cima do card) */
.afy-xm-layer .afy-xm-noel { width: 167px; margin: -144px 0 0 -80px; line-height: 0; filter: drop-shadow(0 10px 14px rgba(0,0,0,.5)); }
.afy-xm-noel img { width: 100%; height: auto; display: block; }
/* só aparece depois de posicionado no card (natal.js põe .on); a entrada anima a imagem, não o translate de posição */
.afy-xm-noel { visibility: hidden; }
.afy-xm-noel.on { visibility: visible; }
.afy-xm-noel.on img { animation: xm-in .45s both; }
@media (max-width: 900px) { .afy-xm-layer .afy-xm-noel { width: 109px; margin: -94px 0 0 -52px; } }
/* 02/12/2026 (dono): maior de novo, 104–170 px (era 56–118). ranking: boneco de neve ao lado do pódio. 01/12/2026 (pedido do dono): menor (era 158/128/96 px) e do tamanho que cabe na
   faixa livre à esquerda do pódio (1040 px centrado no palco), para não cobrir o card do 4º lugar; o monte de neve acompanha */
.afy-xm-gigante { position: absolute; left: .2%; bottom: 8px; width: clamp(104px, calc(50% - 440px), 170px); z-index: 3; pointer-events: none; line-height: 0; filter: drop-shadow(0 10px 18px rgba(0,0,0,.45)); animation: xm-in .9s .2s both; }
.afy-xm-gigante > img { width: 100%; height: auto; display: block; position: relative; z-index: 1; }
.afy-xm-gigante .afy-xm-chao { position: absolute; left: -19%; width: 139%; bottom: -14px; z-index: 2; }
.afy-xm-gigante .afy-xm-chao svg { width: 100%; height: auto; }
.afy-xm-gigante svg { max-width: none !important; }
html.afy-natal .rk-podium { z-index: 1; }
/* pódio em 2 colunas (ranking.css, 860 px): não há faixa livre ao lado; o boneco fica numa faixa de chão abaixo dos cards */
@media (max-width: 860px) { html.afy-natal .rk-stage { padding-bottom: 160px; } }
html[data-theme="light"] .afy-neve { filter: drop-shadow(0 2px 2px rgba(71,85,105,.32)) drop-shadow(0 3px 8px rgba(59,130,246,.15)); }

@keyframes xm-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* top 1: o Papai Noel substitui a coroa do card */
html.afy-natal .rk-card.p1 .rk-crown { display: none; }
/* troca ao vivo do pódio: gorros e boneco voltam sem repetir a entrada */
.rk-swap .afy-gorro, .rk-swap .afy-xm-gigante { animation: none; }

/* desempenho: sombras desenhadas uma vez (camada própria), sem redesenho a cada quadro das animações do pódio */
.afy-xm-noel, .afy-xm-gigante, .afy-xm-lights, .afy-snow { will-change: transform; }
