/* ======================================================
   CUSTOM CURSOR — mirino a 4 punti (cursor.js)
   Colore per pagina con --cursor-color
   ====================================================== */

/* Nasconde il cursore di sistema ovunque, anche su link e bottoni
   (il browser di suo mette la "manina" sui link).
   Solo con mouse/trackpad: sui touch resta tutto normale. */
@media (hover: hover) and (pointer: fine) {
    html,
    body,
    *,
    *::before,
    *::after {
        cursor: none !important;
    }
}

#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    width: 0;
    height: 0;
    color: var(--cursor-color, #fff);
    pointer-events: none;
    opacity: 0;  /* compare al primo movimento del mouse */
    transition: opacity 0.2s ease;
}

#custom-cursor.is-visible {
    opacity: 1;
}

.cursor-dot,
.cursor-core,
.cursor-ripple {
    position: absolute;
    top: 0;
    left: 0;
}

/* ---------- Punti ---------- */
.cursor-dot {
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    border-radius: 50%;
    background: currentColor;
    transition: border-radius 0.2s ease;
}

/* agganciati diventano quadratini "digitali" */
#custom-cursor.is-locked .cursor-dot {
    border-radius: 0;
}

/* staffe: due trattini per punto, rivolti verso l'interno del mirino.
   --sx / --sy (−1 o 1) li impostano cursor.js per ogni angolo */
.cursor-dot::before,
.cursor-dot::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    background: currentColor;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.cursor-dot::before {
    width: 8px;
    height: 1px;
    transform-origin: calc((var(--sx) + 1) * 50%) 50%;
    transform: translate(calc((var(--sx) + 1) * -50%), -50%) scaleX(0);
}

.cursor-dot::after {
    width: 1px;
    height: 8px;
    transform-origin: 50% calc((var(--sy) + 1) * 50%);
    transform: translate(-50%, calc((var(--sy) + 1) * -50%)) scaleY(0);
}

#custom-cursor.is-locked .cursor-dot::before {
    transform: translate(calc((var(--sx) + 1) * -50%), -50%) scaleX(1);
}

#custom-cursor.is-locked .cursor-dot::after {
    transform: translate(-50%, calc((var(--sy) + 1) * -50%)) scaleY(1);
}

/* ---------- Punto centrale (solo da agganciato) ---------- */
.cursor-core {
    width: 3px;
    height: 3px;
    margin: -1.5px 0 0 -1.5px;
    background: currentColor;
    transform: scale(0);
    transition: transform 0.2s ease;
}

#custom-cursor.is-locked .cursor-core {
    transform: scale(1);
    animation: cursor-blink 0.8s steps(1) infinite;
}

#custom-cursor.is-pressed .cursor-core {
    transform: scale(1.8);
}

@keyframes cursor-blink {
    50% { opacity: 0.15; }
}

/* ---------- Onda del click (rombo che si espande) ---------- */
.cursor-ripple {
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border: 1px solid currentColor;
    opacity: 0;
}

/* ---------- Etichetta (data-cursor="View") ---------- */
.cursor-label {
    position: absolute;
    top: 14px;
    left: 28px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.cursor-label::before { content: "[ "; }
.cursor-label::after  { content: " ]"; }

#custom-cursor.has-label .cursor-label {
    opacity: 1;
    transform: none;
}

/* ---------- Touch: niente cursore personalizzato ---------- */
@media (hover: none) {
    #custom-cursor {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #custom-cursor.is-locked .cursor-core {
        animation: none;
    }
}
