/* ==========================================================================
   Torinext — livello animazioni (caricato dopo style.css)
   Tutto rispetta prefers-reduced-motion (vedi fondo file).
   ========================================================================== */

/* ---------- Barra di avanzamento lettura ---------- */
.scroll-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 300;
  background: linear-gradient(90deg, var(--blue), var(--blue-400));
  transform-origin: 0 50%; transform: scaleX(var(--progress, 0));
  pointer-events: none;
}

/* ---------- Header che si nasconde scorrendo verso il basso ---------- */
.site-header { transition: transform .45s var(--ease); }
.site-header.is-hidden { transform: translateY(calc(-100% - 10px)); }
.nav-open .site-header.is-hidden { transform: none; }

/* ---------- Titolo hero parola per parola ---------- */
.hero-title .w {
  display: inline-block;
  animation: word-in .9s var(--ease) both;
  animation-delay: calc(var(--i) * 70ms + 120ms);
}
@keyframes word-in {
  from { opacity: 0; transform: translateY(.45em) rotate(2deg); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
.hero-title .accent {
  background: linear-gradient(100deg, var(--blue-300) 0%, #FFFFFF 45%, var(--blue-300) 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation-name: word-in, shimmer;
  animation-duration: .9s, 6s;
  animation-timing-function: var(--ease), ease-in-out;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: both, none;
  animation-delay: calc(var(--i) * 70ms + 120ms), 1.6s;
}
@keyframes shimmer { 0%, 100% { background-position: 0% 0; } 50% { background-position: 100% 0; } }


/* ---------- Keyframe condivisi (CTA, intestazioni interne, 404) ---------- */
.arw { transform-box: fill-box; transform-origin: center; }
@keyframes arrow-in { from { opacity: 0; transform: translate(-30%, 30%); } to { opacity: 1; transform: none; } }
@keyframes drift-a { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(5%, -5%); } }
@keyframes drift-b { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-4%, 4%); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- Varianti di comparsa ---------- */
.js .reveal--left { transform: translateX(-28px); }
.js .reveal--right { transform: translateX(28px); }
.js .reveal--scale { transform: translateY(20px) scale(.96); }
@media (max-width: 920px) { .js .reveal--left, .js .reveal--right { transform: translateY(18px); } }
.js .reveal[data-delay="4"] { transition-delay: .32s; }
.js .reveal[data-delay="5"] { transition-delay: .4s; }

/* ---------- Bottoni: riflesso al passaggio ---------- */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .7s var(--ease);
}
.btn:hover::after { transform: translateX(120%); }
.btn--ghost::after, .btn--light::after { background: linear-gradient(110deg, transparent 30%, rgba(28, 57, 187, .12) 50%, transparent 70%); }

/* ---------- Metodo: la linea si riempie e i passi si accendono ---------- */
.timeline-fill { transition: transform 2.2s var(--ease) .2s; }
.timeline.is-visible .timeline-fill { transform: scaleX(1); }
.js .timeline .step { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.timeline.is-visible .step { opacity: 1; transform: none; }
.timeline.is-visible .step:nth-child(2) { transition-delay: .25s; }
.timeline.is-visible .step:nth-child(3) { transition-delay: .5s; }
.timeline.is-visible .step:nth-child(4) { transition-delay: .75s; }
.timeline.is-visible .step-node { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 0 0 6px rgba(28, 57, 187, .25); }
.timeline.is-visible .step:nth-child(1) .step-node { transition-delay: .3s; }
.timeline.is-visible .step:nth-child(2) .step-node { transition-delay: .8s; }
.timeline.is-visible .step:nth-child(3) .step-node { transition-delay: 1.3s; }
.timeline.is-visible .step:nth-child(4) .step-node { transition-delay: 1.8s; }
@media (max-width: 640px) { .timeline.is-visible .timeline-fill { transform: scaleY(1); } }

/* ---------- Perché noi ---------- */
.stat { transition: transform .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease); }
.stat:hover { transform: translateY(-4px); border-color: var(--blue-200); box-shadow: var(--shadow); }
.stat-bar { transition: transform 1.4s var(--ease); }
.stats.is-visible .stat-bar { transform: scaleX(1); }
.stat-spark .ln { transition: stroke-dashoffset 2s var(--ease) .4s; }
.stats.is-visible .stat-spark .ln { stroke-dashoffset: 0; }
.stats.is-visible .stat:nth-child(2) .stat-bar { transition-delay: .15s; }
.stats.is-visible .stat:nth-child(3) .stat-bar { transition-delay: .3s; }
.stats.is-visible .stat:nth-child(4) .stat-bar { transition-delay: .45s; }
.why-item { transition: border-color .3s var(--ease), box-shadow .3s var(--ease), transform .35s var(--ease); }
.why-item:hover { transform: translateX(6px); }
.why-ico { transition: background-color .3s var(--ease), color .3s var(--ease); }
.why-item:hover .why-ico { background: var(--blue); color: #fff; }

/* ---------- Portfolio: inclinazione 3D + luce + griglia che scorre ---------- */
.work-grid { perspective: 1200px; }
.work-card.is-tilting { transition: transform .12s linear, box-shadow .3s, border-color .3s; }
.work-cover::before { transition: transform 1.2s var(--ease); }
.work-card:hover .work-cover::before { transform: translate(-14px, -14px); }
.work-cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .16), transparent 60%);
  opacity: 0; transition: opacity .3s;
}
.work-card:hover .work-cover::after { opacity: 1; }
.mock-media { background-image: linear-gradient(135deg, var(--blue-100), var(--blue-200), var(--blue-100)); background-size: 200% 200%; animation: gradient-shift 8s ease-in-out infinite; }
@keyframes gradient-shift { 0%, 100% { background-position: 0% 0%; } 50% { background-position: 100% 100%; } }
.work-card.is-filtered-in { animation: card-in .5s var(--ease) backwards; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.filter:active { transform: scale(.96); }

/* ---------- FAQ: apertura fluida (browser recenti; altrove apertura istantanea) ---------- */
.faq details { interpolate-size: allow-keywords; }
.faq details::details-content {
  height: 0; overflow: clip;
  transition: height .4s var(--ease), content-visibility .4s allow-discrete;
}
.faq details[open]::details-content { height: auto; }
.faq details[open] .answer { animation: fade-up .45s var(--ease) both; }
.faq summary { transition: color .2s var(--ease); }
.faq summary:hover { color: var(--blue); }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- CTA ---------- */
.cta-box {
  background: linear-gradient(120deg, var(--blue-800), var(--blue) 45%, var(--blue-500) 100%);
  background-size: 200% 200%; animation: gradient-shift 12s ease-in-out infinite;
}
.cta-box .arw-a { animation: drift-a 5s ease-in-out infinite; }
.cta-box .arw-b { animation: drift-b 5s ease-in-out infinite; }

/* ---------- Pagine interne: frecce decorative nell'intestazione ---------- */
.page-hero::after {
  content: ""; position: absolute; z-index: -1; top: 50%;
  right: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  width: clamp(140px, 22vw, 300px); aspect-ratio: 1; translate: 0 -50%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='16 14 70 70'%3E%3Cpath fill='%231C39BB' d='M44 18H82V56H70V30H44Z'/%3E%3Cpath fill='%231C39BB' fill-opacity='.35' d='M20 42H58V80H46V54H20Z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: .1; animation: arrow-in 1.2s .3s var(--ease) both, bob 7s 1.5s ease-in-out infinite;
  pointer-events: none;
}

/* ---------- Modulo contatti ---------- */
.choice input:checked + span { animation: chip-pop .3s var(--ease); }
@keyframes chip-pop { 50% { transform: scale(1.06); } }
.field.has-error .input { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.form-status.is-visible { animation: fade-up .4s var(--ease) both; }
.contact-card { transition: border-color .25s var(--ease), box-shadow .25s var(--ease), transform .3s var(--ease); }
a.contact-card:hover { transform: translateX(4px); }
a.contact-card .why-ico { transition: background-color .25s, color .25s; }
a.contact-card:hover .why-ico { background: var(--blue); color: #fff; }

/* ---------- 404 ---------- */
.notfound .code { animation: rise .8s var(--ease) both, bob 5s 1s ease-in-out infinite; }

/* ---------- Footer ---------- */
.socials a { transition: background-color .2s, border-color .2s, transform .3s var(--ease); }
.socials a:hover { transform: translateY(-3px); }
.footer-col a { display: inline-block; transition: color .2s, transform .25s var(--ease); }
.footer-col a:hover { transform: translateX(4px); }

/* ---------- Movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero-title .w, .hero-title .accent { animation: none; filter: none; }
    .work-card { transform: none !important; }
  .site-header.is-hidden { transform: none; }
  .scroll-progress { display: none; }
}
