/* ===================================================================
   PENNISI & PARTNERS - WOW CSS ENHANCEMENTS v5.0
   Stili per animazioni avanzate GSAP
   Da includere DOPO style.css e style-optimizations.css
   =================================================================== */

/* ===== CUSTOM CURSOR ===== */
.custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 99999;
    mix-blend-mode: difference;
}

.cursor-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.2s, height 0.2s;
}

.cursor-ring {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

/* Hide default cursor on desktop */
@media (hover: hover) and (pointer: fine) {
    body:has(.custom-cursor) {
        cursor: none;
    }

    body:has(.custom-cursor) a,
    body:has(.custom-cursor) button,
    body:has(.custom-cursor) .service-item,
    body:has(.custom-cursor) .youtube-box,
    body:has(.custom-cursor) .formation-item {
        cursor: none;
    }
}

/* ===== PAGE OVERLAY (Preloader) ===== */
.page-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #932926;
    z-index: 9999;
    transform-origin: top;
}

/* ===== HERO ENHANCEMENTS ===== */
.hero-title {
    perspective: 1000px;
}

.title-line {
    display: block;
    transform-style: preserve-3d;
}

.title-line .char {
    display: inline-block;
    transform-origin: center bottom;
    will-change: transform, opacity;
}

.title-line .word-wrap {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    vertical-align: top;
}

/* ===== YOUTUBE BOX 3D EFFECT ===== */
.youtube-box {
    transform-style: preserve-3d;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* NOTA: Non usare transform qui - GSAP gestisce tutto */
    /* GPU acceleration viene applicata automaticamente da GSAP */
}

.youtube-box img {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ===== ZOOM IMAGE CLIP PATH ===== */
.zoom-image {
    will-change: clip-path, transform;
}

.zoom-container {
    perspective: 1500px;
    overflow: visible;
}

/* ===== SERVICE ITEMS ENHANCEMENTS ===== */
.service-item {
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: box-shadow 0.4s ease;
}

.service-svg {
    transform-style: preserve-3d;
    will-change: transform;
}

/* Glow effect on hover */
.service-item::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: radial-gradient(
        circle at center,
        rgba(147, 41, 38, 0.15) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    border-radius: 50%;
    z-index: -1;
}

.service-item:hover::before {
    opacity: 1;
}

/* Dark mode glow */
body.dark-mode .service-item::before {
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 70%
    );
}

/* ===== SVG TEXT ENHANCEMENT ===== */
.svg-text tspan {
    transform-origin: center center;
    will-change: transform, fill;
}

/* ===== SUCCESS STORIES PARALLAX ===== */
.success-stories {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.bg-article {
    will-change: transform;
    transform-style: preserve-3d;
}

.stories-number {
    will-change: transform, filter;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* ===== FORMATION 3D TILT ===== */
.formation-item {
    perspective: 1000px;
    transform-style: preserve-3d;
    overflow: hidden;
}

.formation-item img {
    transform-style: preserve-3d;
    will-change: transform;
    transition: box-shadow 0.4s ease;
}

.formation-item:hover img {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* ===== CONTACT FORM ENHANCEMENTS ===== */
.contact-form input,
.contact-form textarea {
    will-change: transform;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
    box-shadow: 0 4px 20px rgba(147, 41, 38, 0.15);
}

body.dark-mode .contact-form input:focus,
body.dark-mode .contact-form textarea:focus {
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

/* Contact image clip-path */
.contact-image {
    will-change: clip-path, transform;
}

/* ===== BUTTON MAGNETIC EFFECT ===== */
.btn-arrow,
.btn-primary,
.btn-secondary,
.btn-submit {
    will-change: transform;
    transition: box-shadow 0.3s ease;
}

.btn-arrow:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-submit:hover {
    box-shadow: 0 15px 40px rgba(89, 2, 0, 0.4);
}

/* ===== FOOTER SOCIAL LINKS ===== */
.social-links a {
    will-change: transform;
}

/* ===== TEXT SPLIT STYLES ===== */
.word-wrap {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
}

.word {
    display: inline-block;
    transform-origin: center bottom;
    will-change: transform, opacity;
}

.line-wrap {
    display: block;
    overflow: hidden;
}

.line {
    display: inline-block;
    transform-origin: center bottom;
    will-change: transform, opacity;
}

.char {
    display: inline-block;
    transform-origin: center bottom;
    will-change: transform, opacity;
}

/* ===== SCROLL TEXT GSAP MARQUEE ===== */
.scroll-content {
    will-change: transform;
}

/* ===== HEADER SMART HIDE ===== */
.header {
    will-change: transform;
    backface-visibility: hidden;
}

/* ===== HAMBURGER ANIMATION ===== */
.hamburger span {
    transform-origin: center center;
    will-change: transform, opacity;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* GPU acceleration for animated elements */
.zoom-image,
.bg-article,
.service-svg,
.youtube-box,
.formation-item img,
.stories-number,
.contact-image {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .custom-cursor {
        display: none !important;
    }

    body {
        cursor: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .zoom-image {
        clip-path: none !important;
    }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 1024px) {
    .cursor-ring {
        width: 30px;
        height: 30px;
    }

    .cursor-dot {
        width: 6px;
        height: 6px;
    }
}

@media (max-width: 768px) {
    /* Disable custom cursor on mobile */
    .custom-cursor {
        display: none !important;
    }

    body {
        cursor: auto !important;
    }

    /* Simplify effects on mobile */
    .service-item::before {
        display: none;
    }

    /* NOTA: Non forzare transform su youtube-box - GSAP deve poter animare */
    /* L'hover 3D e gia disabilitato via JS su mobile (prefersReducedMotion o width check) */

    /* Formation images - allow basic transforms but disable 3D effects */
    .formation-item img {
        transform: translateZ(0);
    }
}

/* ===== DARK MODE SCROLLBAR ===== */
body.dark-mode::-webkit-scrollbar-track {
    background: #7a1f1d;
}

body.dark-mode::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

body.dark-mode::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ===== SELECTION COLOR ===== */
::selection {
    background: rgba(147, 41, 38, 0.3);
    color: inherit;
}

body.dark-mode ::selection {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== LOADING STATE ===== */
body.loading * {
    animation-play-state: paused !important;
}

/* ===== FOCUS VISIBLE FOR ACCESSIBILITY ===== */
:focus-visible {
    outline: 3px solid rgba(147, 41, 38, 0.5);
    outline-offset: 3px;
}

body.dark-mode :focus-visible {
    outline-color: rgba(255, 255, 255, 0.5);
}

/* ===== SMOOTH TRANSITIONS FOR COLOR CHANGES ===== */
.section-title,
.section-title-large,
.contact-title,
.services-description,
.mission-left p,
.formation-text-column p,
.formation-text-column,
.formation-column,
.mission,
.header {
    /* GSAP handles these transitions, no CSS needed */
}

/* ===== SVG PATH ANIMATION SUPPORT - ENHANCED ===== */
.service-svg path,
.service-svg ellipse,
.service-svg rect,
.service-svg polygon {
    vector-effect: non-scaling-stroke;
    will-change: stroke-dashoffset, stroke-width, filter, stroke;
    transition: none; /* GSAP gestisce tutto */
}

/* ===== ARROW ICON SVG ENHANCEMENTS ===== */
.arrow-icon {
    overflow: visible;
    will-change: filter;
}

.arrow-icon path {
    transform-origin: left center;
    will-change: transform, opacity;
}

.arrow-icon circle {
    transform-origin: center center;
    will-change: stroke-dashoffset, stroke-width, transform;
}

/* ===== SVG GLOW EFFECTS SUPPORT ===== */
.service-svg {
    filter: none;
    transition: filter 0.3s ease;
}

/* Ensure SVG filters container is hidden but functional */
#svg-wow-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ===== SERVICE ITEM CLICK FEEDBACK ===== */
.service-item {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ===== DARK MODE SVG ADJUSTMENTS ===== */
body.dark-mode .arrow-icon {
    filter: none;
}

body.dark-mode .arrow-icon:hover {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.4));
}

body.dark-mode .service-svg path,
body.dark-mode .service-svg ellipse,
body.dark-mode .service-svg rect,
body.dark-mode .service-svg polygon {
    /* GSAP gestisce i colori in dark mode */
}

/* ===== SVG TEXT ANIMATION SUPPORT ===== */
.svg-text {
    pointer-events: none;
}

.svg-text tspan {
    transform-origin: center center;
    will-change: transform, fill, opacity;
}

/* ===== PRINT STYLES ===== */
@media print {
    .custom-cursor,
    .page-overlay {
        display: none !important;
    }

    * {
        transform: none !important;
        opacity: 1 !important;
        clip-path: none !important;
    }
}

/* ===== FULLSCREEN MENU OVERLAY ===== */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    pointer-events: none;
    visibility: hidden;
}

.menu-overlay.active {
    pointer-events: all;
    visibility: visible;
}

.menu-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #932926;
    transform: scaleY(0);
    transform-origin: top;
}

.menu-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 100px 10%;
    box-sizing: border-box;
    opacity: 0;
}

.menu-nav {
    flex: 1;
    display: flex;
    align-items: center;
}

.menu-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-links li {
    overflow: hidden;
    margin-bottom: 10px;
}

.menu-link {
    display: flex;
    align-items: baseline;
    gap: 20px;
    text-decoration: none;
    color: #fff;
    font-size: clamp(2rem, 6vw, 5rem);
    font-weight: 700;
    line-height: 1.2;
    transform: translateY(100%);
    opacity: 0;
    transition: color 0.3s ease;
}

.menu-link:hover {
    color: rgba(255, 255, 255, 0.7);
}

.menu-link.active .link-text {
    opacity: 0.5;
}

.link-number {
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    min-width: 30px;
}

.link-text {
    position: relative;
    display: inline-block;
}

.link-text::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: #fff;
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.menu-link:hover .link-text::after {
    width: 100%;
}

.menu-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    transform: translateY(30px);
}

.menu-contact {
    color: #fff;
}

.menu-contact p {
    margin: 0 0 8px 0;
    font-size: 1rem;
}

.menu-contact a {
    color: #fff;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.menu-contact a:hover {
    opacity: 0.7;
}

.menu-social {
    display: flex;
    gap: 30px;
}

.menu-social a {
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: opacity 0.3s ease;
}

.menu-social a:hover {
    opacity: 0.7;
}

/* ===== HAMBURGER ANIMATION ===== */
.hamburger {
    position: relative;
    z-index: 9999;
    width: 30px;
    height: 21px; /* 3 linee da 3px + 2 gap da 6px = 21px */
    background: none !important;
    border: none !important;
    cursor: pointer;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0 !important; /* Override style.css gap */
}

.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: #932926;
    border-radius: 2px;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.4s ease,
                background 0.3s ease;
    transform-origin: center;
}

.hamburger.active span {
    background: #fff;
}

/* Prima linea: sposta in basso di 9px (metà altezza) e ruota */
.hamburger.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

/* Linea centrale: nascondi */
.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

/* Terza linea: sposta in alto di 9px e ruota in senso opposto */
.hamburger.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* ===== BODY MENU OPEN STATE ===== */
body.menu-open {
    overflow: hidden;
}

body.menu-open .header {
    background: transparent !important;
    z-index: 10002; /* Sopra il menu overlay */
    border-bottom-color: transparent;
    pointer-events: none; /* Disabilita click sull'header */
}

body.menu-open .logo {
    opacity: 0;
}

/* Hamburger cliccabile quando menu aperto */
body.menu-open .hamburger {
    pointer-events: all; /* Riabilita click solo sull'hamburger */
}

/* ===== CONTACT PAGE STYLES ===== */
.contact-hero {
    padding: 150px 0 80px;
    background: var(--cream);
}

.contact-page {
    padding-top: 0;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.info-block h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #932926;
    margin-bottom: 10px;
}

.info-block p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0;
}

.info-block a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.info-block a:hover {
    color: #932926;
}

.map-section {
    width: 100%;
    background: #f5f5f5;
}

.map-container {
    width: 100%;
    height: 450px;
}

.map-container iframe {
    width: 100%;
    height: 100%;
    filter: grayscale(100%);
    transition: filter 0.5s ease;
}

.map-container:hover iframe {
    filter: grayscale(0%);
}

/* ===== MENU RESPONSIVE ===== */
@media (max-width: 768px) {
    .menu-content {
        padding: 100px 5%;
    }

    .menu-link {
        font-size: clamp(1.5rem, 8vw, 2.5rem);
    }

    .menu-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 30px;
    }

    .menu-social {
        gap: 20px;
    }

    .hamburger {
        width: 28px;
        height: 19px;
    }

    .hamburger.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .hamburger.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}

/* ===== MENU FIX PER SCHERMI CON ALTEZZA RIDOTTA ===== */
@media (max-height: 800px) {
    .menu-content {
        padding: 60px 10%;
        justify-content: flex-start;
        overflow-y: auto;
    }

    .menu-nav {
        flex: 0 0 auto;
    }

    .menu-link {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .menu-links li {
        margin-bottom: 5px;
    }

    .menu-footer {
        padding-top: 25px;
        margin-top: auto;
    }
}

@media (max-height: 650px) {
    .menu-content {
        padding: 40px 8%;
    }

    .menu-link {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }

    .menu-links li {
        margin-bottom: 2px;
    }

    .menu-footer {
        padding-top: 15px;
    }

    .link-number {
        font-size: 0.7rem;
    }
}

/* ===== FIX BUTTON ALIGNMENT ===== */
/* Desktop: allineato a sinistra */
@media (min-width: 769px) {
    .contact-form .btn-submit {
        margin-left: 0;
        align-self: flex-start;
        transform: none !important;
    }
}

/* Mobile: larghezza piena */
@media (max-width: 768px) {
    .contact-form .btn-submit {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        align-self: stretch !important;
        transform: none !important;
    }
}
