/* ============================================================
   StyleKit — title-fx.css
   Titolo glitchato: fantasmi cromatici + lettere animate.
   HTML richiesto:
     <h1 id="title" data-text="IL TUO TITOLO">IL TUO TITOLO</h1>
   JS richiesto: js/title-engine.js (crea gli span .ch e gestisce
   i 4 effetti combinabili con idle casuale 3–8s).
   ============================================================ */

h1 {
    position: relative;
    /* FIX a-capo: clamp responsive + nowrap (1ch per lettera) */
    font-size: clamp(1.02rem, 2.55vw, 2.4rem);
    white-space: nowrap;
    line-height: 1.2;
    font-weight: 700;
    margin-bottom: 18px;
    text-shadow: 0 0 24px rgba(132, 99, 168, 0.25);
}

/* ogni lettera è un blocco da 1ch: il layout non salta mai */
h1 .ch {
    display: inline-block;
    width: 1ch;
    text-align: center;
    transition: transform 0.13s ease, opacity 0.09s steps(2, end);
}
/* effetto "wave": la lettera salta */
h1 .ch.hop { transform: translateY(-0.22em); }
/* effetto "blink": la lettera sfarfalla */
h1 .ch.dim { opacity: 0.15; }

/* effetto "rgb-burst": split cromatico dell'intero titolo */
h1.rgb-burst { animation: sk-rgbSplit 0.16s steps(2, end) infinite; }
@keyframes sk-rgbSplit {
    from { text-shadow: 2px 0 var(--glitch-a), -2px 0 var(--glitch-b); }
    to   { text-shadow: -2px 0 var(--glitch-a), 2px 0 var(--glitch-b); }
}

/* fantasmi cromatici: due copie del testo quasi sempre invisibili,
   che ogni ~4.4s tagliano la scritta a fette sfasandosi */
h1::before,
h1::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    pointer-events: none;
    opacity: 0;
    text-shadow: none;
}
h1::before { color: var(--glitch-a); animation: sk-ghostA 4.4s infinite steps(1, end); }
h1::after  { color: var(--glitch-b); animation: sk-ghostB 4.4s infinite steps(1, end) 0.35s; }

@keyframes sk-ghostA {
    0%, 84%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 100% 0); }
    85% { opacity: 0.75; transform: translate(-3px, 1px);  clip-path: inset(12% 0 52% 0); }
    89% { opacity: 0.75; transform: translate(3px, -1px);  clip-path: inset(58% 0 6% 0); }
    93% { opacity: 0.50; transform: translate(-2px, 0);    clip-path: inset(34% 0 38% 0); }
}
@keyframes sk-ghostB {
    0%, 78%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 100% 0); }
    79% { opacity: 0.70; transform: translate(3px, 1px);   clip-path: inset(48% 0 22% 0); }
    83% { opacity: 0.70; transform: translate(-3px, -1px); clip-path: inset(6% 0 74% 0); }
    87% { opacity: 0.45; transform: translate(2px, 1px);   clip-path: inset(70% 0 12% 0); }
}

/* nota: i fantasmi NON sono interattivi e l'h1 non è cliccabile,
   quindi qui il clip-path non crea problemi di hit-testing. */

/* caret per typing effect sul sottotitolo */
.sk-caret {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    margin-left: 2px;
    background: var(--accent);
    vertical-align: -0.15em;
    animation: sk-blink 1s step-end infinite;
}
.sk-caret.done { animation: sk-blinkFade 1s step-end 3 forwards; }
@keyframes sk-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes sk-blinkFade { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.tagline {
    color: var(--dim);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 44px;
    min-height: 3.4em;      /* spazio già riservato: niente salti layout */
}
