/* =============================================================
   ONBOARDING — tour do mascote Bento (cão fazendeiro) no primeiro acesso
   Usa os tokens e o visual de modal do painel (dashboard.css).
   ============================================================= */

.tour {
    position: fixed;
    inset: 0;
    z-index: 3100;
}

/* Sem alvo (boas-vindas e final): fundo igual ao do .modal */
.tour.sem-alvo {
    background: rgba(0, 0, 0, .45);
}

/* Recorte que destaca o elemento real da tela */
.tour-foco {
    position: fixed;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 4px var(--verde-claro), 0 0 0 9999px rgba(0, 0, 0, .45);
    pointer-events: none;
    transition: top .3s ease, left .3s ease, width .3s ease, height .3s ease;
}

.tour.sem-alvo .tour-foco {
    display: none;
}

/* ---------- BALÃO ---------- */

.tour-balao {
    position: fixed;
    width: min(430px, calc(100vw - 32px));
    padding: 24px;
    background: var(--branco);
    border-radius: var(--radius-lg);
    box-shadow: var(--sombra);
    animation: tour-entrar .3s ease;
}

.tour.sem-alvo .tour-balao {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tour-topo {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.tour-mascote {
    flex-shrink: 0;
    width: 112px;
    margin: -6px 0 -10px -6px;
}

.tour-mascote svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.tour-cabeca {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.tour-passo {
    color: var(--verde-medio);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.tour-balao h2 {
    margin-bottom: 8px;
    color: var(--verde);
    font-family: var(--fonte-display);
    font-size: 22px;
    line-height: 1.25;
}

.tour-balao p {
    color: var(--suave);
    font-size: 15px;
    line-height: 1.55;
}

/* ---------- RODAPÉ ---------- */

.tour-rodape {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.tour-rodape .modal-acoes {
    margin-top: 0;
    margin-left: auto;
}

/* Botões do próprio tour: valem também em páginas sem dashboard.css (ex.: Gestão da Fazenda). */
.tour .modal-acoes {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.tour .modal-acoes button {
    padding: 12px 20px;
    border: 1px solid var(--borda);
    border-radius: var(--radius-sm);
    background: var(--branco);
    color: var(--texto);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tour .modal-acoes button:last-child {
    background: var(--verde);
    border-color: var(--verde);
    color: #fff;
}

.tour .modal-acoes button[hidden] {
    display: none;
}

.tour-rodape button {
    white-space: nowrap;
}

.tour-pontos {
    display: flex;
    gap: 6px;
}

.tour-pontos span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--borda);
    transition: width .25s, background .25s;
}

.tour-pontos span.ativo {
    width: 22px;
    background: var(--verde);
}

.tour-pular {
    padding: 8px 4px;
    border: none;
    background: none;
    color: var(--suave);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.tour-pular:hover {
    color: var(--verde);
}

.tour-pular[hidden] {
    display: none;
}

/* ---------- MASCOTE ANIMADO ---------- */

/* O Bento tem uma pose por passo do tour. O onboarding.js põe no .tour-mascote
   uma classe pose-*: acenando, apontando, anotando, digitando e, no fim,
   festejando -> olhando -> tchau -> (parado, contente). */

/* Sempre: pisca, abana o rabo e inclina a cabeça de leve */
.tour-mascote .mascote-olhos {
    transform-box: fill-box;
    transform-origin: center;
    animation: tour-piscar 4s infinite;
}

.tour-mascote .mascote-cabeca {
    transform-box: fill-box;
    transform-origin: 50% 90%;
    animation: tour-inclinar 5s ease-in-out infinite;
}

.tour-mascote .mascote-rabo {
    transform-box: fill-box;
    transform-origin: 0% 100%;
    animation: tour-abanar .9s ease-in-out infinite;
}

.tour-mascote .mascote-pupilas {
    transition: transform .35s ease;
}

/* Qual braço/objeto aparece em cada pose (fora do tour vale o desenho padrão) */
.tour-mascote .mascote-braco { display: none; }
.tour-mascote .braco-direito { display: inline; }

.tour-mascote.pose-acenando .mascote-braco,
.tour-mascote.pose-tchau .mascote-braco { display: inline; }

.tour-mascote.pose-acenando .braco-direito,
.tour-mascote.pose-tchau .braco-direito { display: none; }

.tour-mascote.pose-apontando.lado-esq .apontar-esq,
.tour-mascote.pose-apontando.lado-dir .apontar-dir { display: inline; }

.tour-mascote.pose-apontando.lado-esq .braco-esquerdo,
.tour-mascote.pose-apontando.lado-dir .braco-direito { display: none; }

.tour-mascote.pose-anotando .prop-caderneta,
.tour-mascote.pose-digitando .prop-notebook,
.tour-mascote.pose-festejando .braco-festa { display: inline; }

.tour-mascote.pose-anotando :is(.braco-esquerdo, .braco-direito),
.tour-mascote.pose-digitando :is(.braco-esquerdo, .braco-direito),
.tour-mascote.pose-festejando :is(.braco-esquerdo, .braco-direito) { display: none; }

/* ---- Acenando (oi) e tchau ---- */
.tour-mascote .mascote-braco {
    transform-box: fill-box;
    transform-origin: 0% 100%;
}

.tour-mascote.pose-acenando .mascote-braco,
.tour-mascote.pose-tchau .mascote-braco {
    animation: tour-acenar 1.2s ease-in-out 2;
}

/* ---- Apontando: o braço gira até o alvo (--mira vem do onboarding.js) ---- */
.tour-mascote .apontar-esq,
.tour-mascote .apontar-dir {
    transform-box: view-box;
    transform: rotate(var(--mira, 0deg));
    transition: transform .35s ease;
}

.tour-mascote .apontar-esq { transform-origin: 70px 136px; }
.tour-mascote .apontar-dir { transform-origin: 130px 136px; }

.tour-mascote .apontar-esq .apontar-cutucar { animation: tour-cutucar-esq .8s ease-in-out infinite; }
.tour-mascote .apontar-dir .apontar-cutucar { animation: tour-cutucar-dir .8s ease-in-out infinite; }

.tour-mascote.pose-apontando .mascote-pupilas {
    transform: translate(var(--olho-x, 0px), var(--olho-y, 0px));
}

/* ---- Anotando na caderneta ---- */
.tour-mascote.pose-anotando .mascote-pupilas { transform: translate(1px, 3px); }

.tour-mascote.pose-anotando .mascote-cabeca {
    animation: tour-concentrar 3s ease-in-out infinite;
}

.tour-mascote .caderneta-lapis {
    animation: tour-escrever .5s ease-in-out infinite;
}

.tour-mascote .caderneta-escrita {
    stroke-dasharray: 26;
    animation: tour-tracar 2.4s ease-in-out infinite;
}

/* ---- Digitando no notebook ---- */
.tour-mascote.pose-digitando .mascote-pupilas { transform: translate(0, 3px); }

.tour-mascote.pose-digitando .mascote-cabeca {
    animation: tour-concentrar 3s ease-in-out infinite;
}

.tour-mascote .notebook-pata-esq,
.tour-mascote .notebook-pata-dir {
    animation: tour-digitar .3s ease-in-out infinite alternate;
}

.tour-mascote .notebook-pata-dir { animation-delay: .15s; }

/* ---- Fim do tour: pulinhos de festa ---- */
.tour-mascote.pose-festejando .mascote-corpo {
    animation: tour-pulo .6s ease-in-out 3;
}

.tour-mascote.pose-festejando .mascote-rabo {
    animation-duration: .35s;
}

.tour-mascote.pose-festejando .mascote-chapeu {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: tour-chapeu .6s ease-in-out 3;
}

.tour-mascote .festa-esq,
.tour-mascote .festa-dir {
    transform-box: view-box;
    animation: tour-festa .3s ease-in-out infinite alternate;
}

.tour-mascote .festa-esq { transform-origin: 70px 136px; }
.tour-mascote .festa-dir { transform-origin: 130px 136px; animation-direction: alternate-reverse; }

.tour-mascote .festa-confete > * {
    transform-box: fill-box;
    transform-origin: center;
    animation: tour-confete .6s ease-out 3 both;
}

/* ...para, olha para a pessoa... */
.tour-mascote.pose-olhando .mascote-cabeca {
    animation: tour-olhar 1s ease-out forwards;
}

.tour-mascote.pose-olhando .mascote-olhos {
    animation: tour-piscar-rapido .45s ease-in-out .45s 1;
}

/* ...e se despede, com o rabo ainda contente */
.tour-mascote.pose-tchau .mascote-rabo,
.tour-mascote.pose-contente .mascote-rabo {
    animation-duration: .5s;
}

@keyframes tour-entrar {
    from { opacity: 0; translate: 0 12px; }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes tour-piscar {
    0%, 92%, 100% { transform: scaleY(1); }
    96%           { transform: scaleY(.1); }
}

@keyframes tour-piscar-rapido {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(.1); }
}

@keyframes tour-acenar {
    0%, 100% { transform: rotate(0); }
    25%      { transform: rotate(-18deg); }
    75%      { transform: rotate(14deg); }
}

@keyframes tour-inclinar {
    0%, 60%, 100% { transform: rotate(0); }
    70%, 85%      { transform: rotate(-6deg); }
}

@keyframes tour-concentrar {
    0%, 100% { transform: rotate(3deg); }
    50%      { transform: rotate(5deg); }
}

@keyframes tour-olhar {
    0%   { transform: rotate(0); }
    45%  { transform: rotate(-10deg); }
    100% { transform: rotate(-7deg); }
}

@keyframes tour-abanar {
    0%, 100% { transform: rotate(-10deg); }
    50%      { transform: rotate(14deg); }
}

@keyframes tour-cutucar-esq {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-3px); }
}

@keyframes tour-cutucar-dir {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(3px); }
}

@keyframes tour-escrever {
    0%, 100% { transform: translate(0, 0); }
    33%      { transform: translate(-2px, 1px); }
    66%      { transform: translate(2px, -.5px); }
}

@keyframes tour-tracar {
    0%        { stroke-dashoffset: 26; }
    70%, 100% { stroke-dashoffset: 0; }
}

@keyframes tour-digitar {
    from { transform: translateY(0); }
    to   { transform: translateY(-3px); }
}

@keyframes tour-chapeu {
    0%, 100% { transform: translateY(0) rotate(0); }
    50%      { transform: translateY(-6px) rotate(-5deg); }
}

@keyframes tour-pulo {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

@keyframes tour-festa {
    from { transform: rotate(-8deg); }
    to   { transform: rotate(8deg); }
}

@keyframes tour-confete {
    0%   { opacity: 0; transform: translateY(8px) scale(.4); }
    40%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-8px) scale(1.1) rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
    .tour-balao,
    .tour-mascote,
    .tour-mascote * {
        animation: none !important;
        transition: none !important;
    }

    .tour-foco {
        transition: none;
    }
}

/* ---------- CELULAR: balão fixo embaixo ---------- */

@media (max-width: 599px) {
    .tour .tour-balao,
    .tour.sem-alvo .tour-balao {
        top: auto;
        left: 16px;
        right: 16px;
        bottom: 16px;
        width: auto;
        padding: 20px;
        transform: none;
    }

    .tour-mascote {
        width: 80px;
        margin: -4px 0 -6px -4px;
    }

    .tour-balao h2 {
        font-size: 19px;
    }

    .tour-balao p {
        font-size: 14px;
    }

    /* Botões de largura cheia como nos modais do celular, mas lado a lado; "Pular" embaixo */
    .tour-rodape {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 8px;
        margin-top: 16px;
    }

    .tour-rodape .modal-acoes {
        flex-direction: row;
        margin-left: 0;
    }

    .tour-rodape .modal-acoes button {
        flex: 1;
        padding: 12px 10px;
    }
}

/* ---------- MODO ESCURO ---------- */

body.dark .tour-balao {
    background: #1f2a1c;
    color: #fff;
}

body.dark .tour-balao h2 {
    color: #fff;
}

body.dark .tour-balao p,
body.dark .tour-pular {
    color: #c9d1c7;
}

body.dark .tour-passo {
    color: var(--verde-claro);
}

body.dark .tour-pontos span {
    background: #2a382c;
}

body.dark .tour-pontos span.ativo {
    background: var(--verde-claro);
}

body.dark .tour-rodape .modal-acoes button:first-child {
    background: transparent;
    border-color: #2a382c;
    color: #fff;
}

/* ---------- BOTÃO "VER TOUR" (topo da página, sempre visível) ---------- */

.btn-ver-tour {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 2px solid var(--verde);
    border-radius: var(--radius-pill);
    background: var(--branco);
    color: var(--verde);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.btn-ver-tour i {
    font-size: 20px;
}

.btn-ver-tour:hover,
.btn-ver-tour:focus-visible {
    background: var(--verde);
    color: #fff;
}

body.dark .btn-ver-tour {
    background: transparent;
    border-color: var(--verde-claro);
    color: var(--verde-claro);
}

body.dark .btn-ver-tour:hover,
body.dark .btn-ver-tour:focus-visible {
    background: var(--verde-claro);
    color: #101411;
}

/* No celular fica só o ícone (o nome continua para leitores de tela). */
@media (max-width: 599px) {
    .btn-ver-tour {
        width: 44px;
        padding: 0;
        justify-content: center;
    }

    .btn-ver-tour span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}
