/* ============================================================
   GAD | ORGANIC CURSOR V1.1
   Componente indipendente - non altera navbar o Page Transition
   Attivato soltanto da assets/js/gad-cursor.js su mouse fine.
   ============================================================ */

:root {
    --gad-cursor-blue: #302f8f;
    --gad-cursor-yellow: #f7c62f;
    --gad-cursor-small: 38px;
    --gad-cursor-hover: 66px;
    --gad-cursor-discover: 112px;
}

/* La freccia originale scompare SOLO dopo l'inizializzazione JS.
   Campi di testo, editor e pannello di amministrazione restano nativi. */
html.gad-cursor-enabled,
html.gad-cursor-enabled body,
html.gad-cursor-enabled body a,
html.gad-cursor-enabled body button,
html.gad-cursor-enabled body [role="button"],
html.gad-cursor-enabled body summary,
html.gad-cursor-enabled body .uk-button,
html.gad-cursor-enabled body .uk-navbar-toggle {
    cursor: none !important;
}

html.gad-cursor-enabled body :is(
    input, textarea, select, option, iframe,
    [contenteditable], [role="textbox"],
    [data-gad-cursor="native"]
) {
    cursor: auto !important;
}

html.gad-cursor-enabled body :is(
    input[type="text"], input[type="email"], input[type="search"],
    input[type="url"], input[type="tel"], input[type="number"],
    input[type="password"], textarea, [contenteditable], [role="textbox"]
) {
    cursor: text !important;
}

html.gad-cursor-enabled #wpadminbar,
html.gad-cursor-enabled #wpadminbar * {
    cursor: auto !important;
}

/* Il cursore resta indipendente dal layout e sopra al menu GAD.
   pointer-events:none non intercetta click, hover o focus. */
.gad-cursor,
.gad-cursor__dot {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2147483000;
    display: block;
    box-sizing: border-box;
    pointer-events: none !important;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0;
    visibility: hidden;
    will-change: transform, opacity;
}

.gad-cursor {
    --gad-cursor-size: var(--gad-cursor-small);
    --gad-cursor-ink: var(--gad-cursor-blue);
    --gad-cursor-fill: var(--gad-cursor-blue);
    --gad-cursor-letter: var(--gad-cursor-yellow);
    --gad-cursor-tilt: 0deg;

    width: var(--gad-cursor-size);
    height: var(--gad-cursor-size);
    border-radius: 50%;
    transform: translate3d(-100px, -100px, 0) translate(-50%, -50%);
    transition:
        width 280ms cubic-bezier(.22, 1, .36, 1),
        height 280ms cubic-bezier(.22, 1, .36, 1),
        opacity 160ms ease,
        visibility 0s linear 160ms;
}

.gad-cursor__blob {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    border: 2px solid var(--gad-cursor-ink);
    border-radius: 44% 56% 59% 41% / 48% 42% 58% 52%;
    background: transparent;
    transform-origin: center;
    animation: gad-cursor-breathe 2300ms ease-in-out infinite;
    transition:
        background-color 260ms ease,
        border-color 200ms ease,
        border-width 220ms ease;
}

.gad-cursor__label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gad-cursor-letter);
    font-family: Inter, Arial, sans-serif;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .035em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transform: scale(.84);
    transition:
        opacity 160ms ease,
        transform 260ms cubic-bezier(.22, 1, .36, 1),
        color 200ms ease;
}

/* Punto centrale: segue il puntatore senza ritardo percepibile. */
.gad-cursor__dot {
    width: 6px;
    height: 6px;
    margin-top: -3px;
    margin-left: -3px;
    background-color: var(--gad-cursor-blue);
    border-radius: 50%;
    transform: translate3d(-100px, -100px, 0);
    transition:
        opacity 150ms ease,
        background-color 160ms ease,
        visibility 0s linear 150ms;
}

.gad-cursor.is-visible,
.gad-cursor__dot.is-visible {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

/* Contrasto: sui blu/scuri il cursore è giallo,
   sugli sfondi chiari o gialli diventa blu. */
.gad-cursor.is-dark {
    --gad-cursor-ink: var(--gad-cursor-yellow);
    --gad-cursor-fill: var(--gad-cursor-yellow);
    --gad-cursor-letter: var(--gad-cursor-blue);
}

.gad-cursor.is-yellow,
.gad-cursor.is-light {
    --gad-cursor-ink: var(--gad-cursor-blue);
    --gad-cursor-fill: var(--gad-cursor-blue);
    --gad-cursor-letter: var(--gad-cursor-yellow);
}

.gad-cursor__dot.is-dark {
    background-color: var(--gad-cursor-yellow);
}

.gad-cursor__dot.is-yellow,
.gad-cursor__dot.is-light {
    background-color: var(--gad-cursor-blue);
}

/* HERO A CONTRASTO MISTO (blu + logo/pulsanti gialli).
   Non leggiamo il colore del singolo elemento: il contorno usa due
   tinte GAD simultaneamente. In questo modo almeno una rimane
   visibile anche se il cursore attraversa icone e scritte gialle.
   Lo stato si applica automaticamente nella .gad-hero o in un
   contenitore esplicitamente marcato data-gad-cursor-contrast="mixed". */
.gad-cursor.is-mixed {
    --gad-cursor-ink: var(--gad-cursor-yellow);
    --gad-cursor-fill: var(--gad-cursor-yellow);
    --gad-cursor-letter: var(--gad-cursor-blue);
}

.gad-cursor.is-mixed .gad-cursor__blob {
    border-color: var(--gad-cursor-yellow);
    box-shadow:
        0 0 0 1.5px var(--gad-cursor-blue),
        inset 0 0 0 1px var(--gad-cursor-blue);
}

.gad-cursor__dot.is-mixed {
    background-color: var(--gad-cursor-yellow);
    box-shadow: 0 0 0 1.5px var(--gad-cursor-blue);
}

/* Link, CTA e voci del menu: ingrandimento contenuto. */
.gad-cursor.is-interactive {
    --gad-cursor-size: var(--gad-cursor-hover);
}

/* Portfolio: forma piena + etichetta SCOPRI. */
.gad-cursor.is-discover {
    --gad-cursor-size: var(--gad-cursor-discover);
}

.gad-cursor.is-discover .gad-cursor__blob {
    background-color: var(--gad-cursor-fill);
    border-width: 0;
}

.gad-cursor.is-discover .gad-cursor__label {
    opacity: 1;
    transform: scale(1);
}

.gad-cursor__dot.is-discover {
    opacity: 0;
}

.gad-cursor.is-pressed .gad-cursor__blob {
    animation-duration: 1000ms;
}

/* Respirazione delicata, senza deformare il border-radius a ogni frame.
   Un minimo movimento rotatorio dà alla forma un carattere organico. */
@keyframes gad-cursor-breathe {
    0%, 100% {
        transform: rotate(var(--gad-cursor-tilt)) scale(.97);
    }
    50% {
        transform: rotate(var(--gad-cursor-tilt)) scale(1.035);
    }
}

/* Il cursor non si sovrappone all'animazione di caricamento GAD. */
html.gad-page-boot .gad-cursor,
html.gad-page-boot .gad-cursor__dot,
html.gad-page-leaving .gad-cursor,
html.gad-page-leaving .gad-cursor__dot {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Nessun effetto sui device touch o per chi richiede meno movimento. */
@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
    html.gad-cursor-enabled,
    html.gad-cursor-enabled body,
    html.gad-cursor-enabled body a,
    html.gad-cursor-enabled body button,
    html.gad-cursor-enabled body [role="button"],
    html.gad-cursor-enabled body summary,
    html.gad-cursor-enabled body .uk-button,
    html.gad-cursor-enabled body .uk-navbar-toggle {
        cursor: auto !important;
    }
    .gad-cursor,
    .gad-cursor__dot {
        display: none !important;
    }
}
