/* ================================================================
   Il Laboratorio del Sorriso APS — Custom Styles
   ================================================================ */

html { scroll-behavior: smooth; overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }

/* --- Scroll Progress Bar --- */
#scroll-progress {
    position: fixed; top: 0; left: 0; height: 3px; z-index: 9999;
    background: linear-gradient(90deg, #0D7377, #C9A84C, #5B8C5A, #0D7377);
    background-size: 300% 100%;
    animation: gradientShift 3s ease infinite;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(13, 115, 119, 0.5);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Hero --- */
.hero-gradient {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(13, 115, 119, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(201, 168, 76, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(91, 140, 90, 0.05) 0%, transparent 70%),
        linear-gradient(180deg, #FDF8EE 0%, #f5ecda 100%);
}

.hero-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0%   { opacity: 0; transform: translateY(0) scale(0); }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-100vh) scale(1); }
}

/* --- Navbar --- */
#navbar { background: transparent; }

#navbar.scrolled {
    background: rgba(253, 248, 238, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.06);
}

#navbar.scrolled .nav-link:hover {
    color: #0D7377;
    background: rgba(13, 115, 119, 0.08);
}

.nav-link { color: rgba(45, 52, 54, 0.7); }
.nav-logo-text { color: rgba(45, 52, 54, 0.8); }

/* --- Animated Gradient Text --- */
.gradient-text {
    background: linear-gradient(135deg, #0D7377 0%, #C9A84C 50%, #5B8C5A 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientText 4s ease infinite;
}

@keyframes gradientText {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Glow Ring on Logo --- */
.logo-glow {
    position: relative;
    isolation: isolate;
}
.logo-glow::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #0D7377, #C9A84C, #5B8C5A, #0D7377);
    animation: glowSpin 4s linear infinite;
    opacity: 0.6;
    z-index: -1;
    filter: blur(8px);
}

@keyframes glowSpin {
    to { transform: rotate(360deg); }
}

/* --- 3D Tilt Cards --- */
.tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tilt-card:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.tilt-card .tilt-inner {
    transform: translateZ(20px);
    transition: transform 0.3s ease;
}

/* --- Animated Border Cards --- */
.glow-border {
    position: relative;
    overflow: hidden;
}

.glow-border::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, #0D7377 10%, transparent 20%);
    animation: rotateBorder 4s linear infinite;
    opacity: 0;
    transition: opacity 0.4s;
}

.glow-border:hover::before {
    opacity: 1;
}

.glow-border > .glow-inner {
    position: relative;
    z-index: 1;
    background: inherit;
    border-radius: inherit;
}

@keyframes rotateBorder {
    to { transform: rotate(360deg); }
}

/* --- Counter Animation --- */
.counter-value {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

/* --- Stagger Reveal --- */
.reveal-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-up.revealed { opacity: 1; transform: translateY(0); }

.reveal-left { opacity: 0; transform: translateX(-60px); transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.reveal-left.revealed { opacity: 1; transform: translateX(0); }

.reveal-right { opacity: 0; transform: translateX(60px); transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.reveal-right.revealed { opacity: 1; transform: translateX(0); }

.reveal-scale { opacity: 0; transform: scale(0.85); transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.reveal-scale.revealed { opacity: 1; transform: scale(1); }

/* --- Parallax --- */
.parallax-slow { will-change: transform; }

/* --- Magnetic Buttons --- */
.magnetic-btn {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- WIP Badge --- */
.wip-dot {
    animation: wipBlink 1.5s ease-in-out infinite;
}
@keyframes wipBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* --- Hero Partecipa CTA --- */
.hero-partecipa {
    animation: heroCtaPulse 2.5s ease-in-out infinite;
}
.hero-partecipa::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,.15) 0%, transparent 50%);
    pointer-events: none;
}
@keyframes heroCtaPulse {
    0%, 100% { box-shadow: 0 8px 30px rgba(13,115,119,.3), 0 0 0 0 rgba(13,115,119,.2); }
    50% { box-shadow: 0 15px 50px rgba(13,115,119,.35), 0 0 0 12px rgba(13,115,119,0); }
}

/* --- Floating Shapes --- */
@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-25px) rotate(3deg); }
}

@keyframes floatDelayed {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-18px) rotate(-3deg); }
}

@keyframes pulseSlow {
    0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.08); }
}

@keyframes morphBlob {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
    50% { border-radius: 50% 60% 30% 60% / 40% 70% 50% 60%; }
    75% { border-radius: 60% 30% 50% 40% / 70% 40% 60% 30%; }
}

.animate-float { animation: float 6s ease-in-out infinite; }
.animate-float-delayed { animation: floatDelayed 8s ease-in-out infinite 1s; }
.animate-pulse-slow { animation: pulseSlow 10s ease-in-out infinite; }
.animate-morph { animation: morphBlob 8s ease-in-out infinite; }

/* --- Section Wave Dividers --- */
.wave-divider {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    overflow: hidden;
    line-height: 0;
}

.wave-divider svg {
    position: relative;
    display: block;
    width: calc(100% + 1.3px);
    height: 80px;
}

/* --- Flash Messages --- */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

.animate-slide-in { animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.flash-msg.fade-out { animation: fadeOut 0.4s ease-out forwards; }

/* --- Hover Shine Effect --- */
.shine-effect {
    position: relative;
    overflow: hidden;
}

.shine-effect::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(25deg);
    transition: left 0.6s ease;
}

.shine-effect:hover::after {
    left: 120%;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #FDF8EE; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #0D7377, #C9A84C); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #0a5c5f, #b8953a); }

/* --- Selection --- */
::selection { background: rgba(13, 115, 119, 0.15); color: #0D7377; }

/* --- Page Entry --- */
main { animation: fadeInPage 0.6s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Mobile Menu --- */
#mobile-menu { max-height: 0; transition: max-height 0.3s ease-out; }
#mobile-menu.open { max-height: 400px; }

/* --- Responsive --- */
@media (max-width: 640px) {
    .font-display { letter-spacing: -0.01em; }
    .wave-divider svg { height: 40px; }
    section, .aq-parallax-wrap, .ev-parallax-wrap { overflow-x: hidden; }
}

/* --- Loading Button --- */
.btn-loading { pointer-events: none; opacity: 0.7; }
.btn-loading::after {
    content: '';
    display: inline-block;
    width: 16px; height: 16px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Stat Card Pulse --- */
.stat-card { transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.stat-card:hover { transform: translateY(-8px) scale(1.02); }
