/* =============================================================================
   Portal Bertotto — Animações e micro-interações ("Pacote Vida")
   =============================================================================
   Adicionado em: abril/2026
   Foco: dar vida à UI sem comprometer a seriedade corporativa.
   Tudo respeita prefers-reduced-motion para acessibilidade.
   ============================================================================= */


/* ---------------------------------------------------------------------------
   1) Hero com padrão sutil de pontos
   ---------------------------------------------------------------------------
   Adiciona textura quase imperceptível no fundo do .page-hero já existente. */
.page-hero {
    position: relative;
    overflow: hidden;
}
.page-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(
        circle at 1px 1px,
        rgba(255, 255, 255, 0.08) 1px,
        transparent 0
    );
    background-size: 22px 22px;
    pointer-events: none;
    opacity: 0.9;
}
/* Brilho diagonal que passa lentamente no hero (só na home) */
.page-hero::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 45%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 55%,
        transparent 100%
    );
    transform: rotate(18deg);
    animation: hero-shine 9s linear infinite;
    pointer-events: none;
}
@keyframes hero-shine {
    0%   { left: -100%; }
    100% { left: 150%; }
}


/* ---------------------------------------------------------------------------
   2) Fade-in com stagger (cascata)
   ---------------------------------------------------------------------------
   Cada .fadein-stagger dentro de um container recebe delay incremental.
   Usado na home do portal e em grids de cards. */
.fadein-stagger {
    opacity: 0;
    transform: translateY(12px);
    animation: fadein-up 0.55s ease-out forwards;
}
.fadein-stagger:nth-child(1)  { animation-delay: 0.00s; }
.fadein-stagger:nth-child(2)  { animation-delay: 0.06s; }
.fadein-stagger:nth-child(3)  { animation-delay: 0.12s; }
.fadein-stagger:nth-child(4)  { animation-delay: 0.18s; }
.fadein-stagger:nth-child(5)  { animation-delay: 0.24s; }
.fadein-stagger:nth-child(6)  { animation-delay: 0.30s; }
.fadein-stagger:nth-child(7)  { animation-delay: 0.36s; }
.fadein-stagger:nth-child(8)  { animation-delay: 0.42s; }
.fadein-stagger:nth-child(9)  { animation-delay: 0.48s; }
.fadein-stagger:nth-child(10) { animation-delay: 0.54s; }
@keyframes fadein-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ---------------------------------------------------------------------------
   3) Cards de módulo (Commit 234)
   ---------------------------------------------------------------------------
   A barra colorida antiga (::before scaleX) e o hover scale+rotate do icone
   foram removidos — agora as linhas decorativas e o gradient do icone sao
   definidos em templates/portal/home.html via variaveis --portal-c1/c2.
   Mantemos so o reset estrutural pra nao conflitar com a especificidade. */


/* ---------------------------------------------------------------------------
   4) Tilt 3D sutil nos cards
   ---------------------------------------------------------------------------
   Inclinação de até 4° seguindo o mouse. JS calcula e aplica via --tiltX/Y. */
.card-tilt {
    transform-style: preserve-3d;
    transition: transform 0.12s ease-out, box-shadow 0.25s ease;
    will-change: transform;
}
.card-tilt:hover {
    transform: perspective(900px)
               rotateX(var(--tiltX, 0deg))
               rotateY(var(--tiltY, 0deg))
               translateZ(4px);
    box-shadow: 0 16px 40px rgba(18, 41, 64, 0.14);
}


/* ---------------------------------------------------------------------------
   5) Ripple effect nos botões
   ---------------------------------------------------------------------------
   JS adiciona <span class="ripple"> dinamicamente ao clicar. */
.btn {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.btn .ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple-effect 0.6s ease-out;
    background-color: rgba(255, 255, 255, 0.45);
    pointer-events: none;
    z-index: 0;
}
.btn-outline-primary .ripple,
.btn-outline-secondary .ripple,
.btn-outline-success .ripple,
.btn-outline-danger .ripple,
.btn-outline-warning .ripple,
.btn-outline-info .ripple,
.btn-light .ripple {
    background-color: rgba(18, 41, 64, 0.18);
}
@keyframes ripple-effect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}


/* ---------------------------------------------------------------------------
   6) Skeleton loader (placeholder pulsante)
   ---------------------------------------------------------------------------
   Usar em lugares onde dados vão carregar via fetch. */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(18, 41, 64, 0.06) 25%,
        rgba(18, 41, 64, 0.12) 50%,
        rgba(18, 41, 64, 0.06) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
    min-height: 1em;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ---------------------------------------------------------------------------
   7) Toast notifications modernas
   ---------------------------------------------------------------------------
   Substituem as flash messages. JS cria os elementos dinamicamente. */
.toast-container-modern {
    position: fixed;
    bottom: 1.2rem;
    right: 1.2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}
.toast-modern {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    background: #ffffff;
    border: 1px solid rgba(18, 41, 64, 0.08);
    border-left-width: 4px;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(18, 41, 64, 0.18);
    padding: 0.75rem 2.4rem 0.75rem 0.9rem;
    position: relative;
    pointer-events: auto;
    animation: toast-slide-in 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    min-width: 260px;
}
.toast-modern.is-leaving {
    animation: toast-slide-out 0.28s ease-in forwards;
}
.toast-modern .toast-modern-icon {
    width: 1.6rem;
    height: 1.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.95rem;
    flex-shrink: 0;
    color: #fff;
}
.toast-modern .toast-modern-body {
    flex: 1;
    min-width: 0;                 /* permite shrink no flex container */
    font-size: 0.9rem;
    line-height: 1.4;
    color: #1f2937;
    overflow-wrap: anywhere;      /* quebra strings longas (chaves, URLs) */
    word-break: break-word;
}
.toast-modern .toast-modern-title {
    font-weight: 700;
    margin-bottom: 0.1rem;
}
.toast-modern .toast-modern-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: transparent;
    border: none;
    color: #6f8297;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.45rem;
    border-radius: 4px;
    transition: background 0.15s ease;
}
.toast-modern .toast-modern-close:hover { background: rgba(0,0,0,0.06); }
.toast-modern .toast-modern-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: currentColor;
    opacity: 0.3;
    transform-origin: left;
    animation: toast-progress linear forwards;
}

/* Variantes por categoria */
.toast-modern--success { border-left-color: #10b981; }
.toast-modern--success .toast-modern-icon { background: #10b981; }
.toast-modern--danger,
.toast-modern--error   { border-left-color: #ef4444; }
.toast-modern--danger .toast-modern-icon,
.toast-modern--error .toast-modern-icon { background: #ef4444; }
.toast-modern--warning { border-left-color: #f59e0b; }
.toast-modern--warning .toast-modern-icon { background: #f59e0b; }
.toast-modern--info    { border-left-color: #3b82f6; }
.toast-modern--info .toast-modern-icon { background: #3b82f6; }

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(32px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-slide-out {
    to { opacity: 0; transform: translateX(32px) scale(0.95); }
}
@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}


/* ---------------------------------------------------------------------------
   8) Counter animation helper
   ---------------------------------------------------------------------------
   Marca elemento pra JS animar o número subindo. */
.counter-animate {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}


/* ---------------------------------------------------------------------------
   9) Smooth scroll global + focus visible acessível
   --------------------------------------------------------------------------- */
html { scroll-behavior: smooth; }
:focus-visible {
    outline: 2px solid rgba(18, 75, 112, 0.55);
    outline-offset: 2px;
    border-radius: 4px;
}


/* ---------------------------------------------------------------------------
   10) Respeita preferência do usuário
   ---------------------------------------------------------------------------
   Desliga TODAS as animações de ornamento para quem pede redução de movimento.
   As animações funcionais (toasts) continuam, só sem o slide. */
@media (prefers-reduced-motion: reduce) {
    .page-hero::after,
    .fadein-stagger,
    .skeleton,
    .card-tilt,
    .btn .ripple {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
    .fadein-stagger { opacity: 1; }
    html { scroll-behavior: auto; }
    .toast-modern { animation: none; }
    .toast-modern .toast-modern-progress { animation: none; }
}
