/* fx — livello di rifinitura e movimento sopra site.css.
   Additivo: togliere questo file e fx.js riporta il sito esattamente com'era.
   Si spegne anche per pagina con ?fx=0 (html.fx-off). */

:root {
  --fx-ease: cubic-bezier(.16, 1, .3, 1);
  --fx-spring: cubic-bezier(.34, 1.56, .64, 1);
  interpolate-size: allow-keywords;
}

/* ── Passaggio fra pagine: dissolvenza nativa (Chrome/Edge/Safari 18) ── */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: fxVtOut .28s var(--fx-ease) both; }
::view-transition-new(root) { animation: fxVtIn .42s var(--fx-ease) both; }
@keyframes fxVtOut { to { opacity: 0; transform: translateY(-6px); } }
@keyframes fxVtIn { from { opacity: 0; transform: translateY(10px); } }

/* ── Tipografia più fine ───────────────────────────────────────────── */
html.fx h1, html.fx h2 { text-wrap: balance; }
html.fx p, html.fx li { text-wrap: pretty; }
html.fx ::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ── Barra di avanzamento lettura ──────────────────────────────────── */
.fx-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; pointer-events: none;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7fd3ff));
  transform-origin: 0 50%; transform: scaleX(var(--fx-p, 0));
}
@supports (animation-timeline: scroll()) {
  .fx-progress { animation: fxGrow linear both; animation-timeline: scroll(root); transform: none; }
}
@keyframes fxGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ── Header: si stringe e prende ombra quando si scende ───────────── */
html.fx header.site { transition: box-shadow .35s var(--fx-ease), background-color .35s var(--fx-ease); }
html.fx.fx-scrolled header.site {
  box-shadow: 0 10px 30px -18px rgba(10, 30, 60, .35);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
}
html.fx header.site .wrap { transition: height .35s var(--fx-ease); }
html.fx.fx-scrolled header.site .wrap { height: 56px; }

/* sottolineatura che scorre anche sulla pelle RD */
body.brand-do nav.main a { position: relative; }
body.brand-do nav.main a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: right;
  transition: transform .35s var(--fx-ease);
}
body.brand-do nav.main a:hover::after { transform: scaleX(1); transform-origin: left; }

/* ── Bottoni: riflesso, pressione, onda ───────────────────────────── */
html.fx .btn, html.fx .bbtn { position: relative; overflow: hidden; isolation: isolate;
  transition: transform .45s var(--fx-spring), box-shadow .35s var(--fx-ease), background-color .3s, color .3s; }
html.fx .btn::before, html.fx .bbtn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.38) 50%, transparent 70%);
  transform: translateX(-120%);
}
html.fx .btn:hover::before, html.fx .bbtn:hover::before { transition: transform .8s var(--fx-ease); transform: translateX(120%); }
html.fx .btn:active, html.fx .bbtn:active { transform: scale(.96); transition-duration: .12s; }
.fx-ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
  width: 12px; height: 12px; margin: -6px 0 0 -6px;
  background: currentColor; opacity: .28; transform: scale(0);
  animation: fxRipple .7s var(--fx-ease) forwards;
}
@keyframes fxRipple { to { transform: scale(var(--fx-r, 30)); opacity: 0; } }

/* ── Carte: luce che segue il cursore ─────────────────────────────── */
html.fx .fx-spot { position: relative; isolation: isolate; }
html.fx .fx-spot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--accent) 13%, transparent), transparent 62%);
  opacity: 0; transition: opacity .4s var(--fx-ease);
}
html.fx .fx-spot:hover::after { opacity: 1; }
html.fx section.darkband .fx-spot::after, html.fx .band.fx-spot::after {
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.10), transparent 60%);
}

/* inclinazione 3D leggera su schermate e foto grandi */
html.fx .fx-tilt { transform-style: preserve-3d; will-change: transform;
  transition: transform .6s var(--fx-ease), box-shadow .6s var(--fx-ease); }
html.fx .fx-tilt.fx-tilting { transition-duration: .12s;
  box-shadow: 0 30px 60px -30px rgba(10, 30, 60, .45); }

/* ── Comparse allo scorrimento ────────────────────────────────────── */
/* Base: JS aggiunge .fx-in con IntersectionObserver.
   Dove il browser ha le animazioni legate allo scroll, le guida la vista stessa. */
html.fx [data-fx] { transition: opacity .9s var(--fx-ease), transform .9s var(--fx-ease), filter .9s var(--fx-ease), clip-path 1.1s var(--fx-ease); transition-delay: var(--fx-d, 0s); }
html.fx [data-fx="rise"]:not(.fx-in) { opacity: 0; transform: translateY(28px); }
html.fx [data-fx="blur"]:not(.fx-in) { opacity: 0; filter: blur(10px); transform: translateY(12px); }
html.fx [data-fx="mask"]:not(.fx-in) { clip-path: inset(0 0 100% 0 round var(--radius)); }
html.fx [data-fx="mask"] { clip-path: inset(0 0 0 0 round var(--radius)); }
html.fx [data-fx="line"] { transform-origin: left; }
html.fx [data-fx="line"]:not(.fx-in) { transform: scaleX(0); }

@supports (animation-timeline: view()) {
  html.fx.fx-sda [data-fx] { transition: none; opacity: 1; filter: none; }
  html.fx.fx-sda [data-fx="rise"] { animation: fxRise linear both; animation-timeline: view(); animation-range: entry 0% entry 70%; }
  html.fx.fx-sda [data-fx="blur"] { animation: fxBlur linear both; animation-timeline: view(); animation-range: entry 5% entry 80%; }
  html.fx.fx-sda [data-fx="mask"] { animation: fxMask linear both; animation-timeline: view(); animation-range: entry 0% cover 35%; }
  html.fx.fx-sda [data-fx="line"] { animation: fxLine linear both; animation-timeline: view(); animation-range: entry 20% cover 40%; }
  /* parallasse delle foto nelle bande prodotto: si usa translate, non transform, per non toccare lo zoom all'hover */
  html.fx.fx-sda .band img { animation: fxPar linear both; animation-timeline: view(); animation-range: cover; }
  html.fx.fx-sda .page-hero .photo img, html.fx.fx-sda .techsplit .photo img {
    animation: fxPar2 linear both; animation-timeline: view(); animation-range: cover; }
}
@keyframes fxRise { from { opacity: 0; transform: translateY(34px); } }
@keyframes fxBlur { from { opacity: 0; filter: blur(12px); transform: translateY(14px); } }
@keyframes fxMask { from { clip-path: inset(0 0 100% 0 round var(--radius)); } }
@keyframes fxLine { from { transform: scaleX(0); } }
@keyframes fxPar { from { translate: 0 -7%; } to { translate: 0 7%; } }
@keyframes fxPar2 { from { translate: 0 -4%; scale: 1.08; } to { translate: 0 4%; scale: 1.08; } }

/* titoli di sezione: la parola entra con un'ombra di colore */
html.fx h2 .fx-w { display: inline-block; }

/* ── Hero: tela WebGL dietro al testo ─────────────────────────────── */
html.fx .hero, html.fx .page-hero { position: relative; isolation: isolate; }
.fx-gl {
  position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none;
  opacity: 0; transition: opacity 1.6s var(--fx-ease);
  -webkit-mask-image: radial-gradient(70% 110% at 78% 45%, #000 25%, transparent 78%);
          mask-image: radial-gradient(70% 110% at 78% 45%, #000 25%, transparent 78%);
}
.fx-gl.on { opacity: 1; }

/* luce morbida nelle bande scure (costa zero, niente WebGL) */
html.fx section.darkband { background-image:
  radial-gradient(60% 50% at 12% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%),
  radial-gradient(50% 60% at 100% 100%, rgba(120, 200, 255, .10), transparent 70%); }

/* grana finissima: toglie il piatto digitale ai fondi */
html.fx body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 300; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── FAQ: apertura morbida ────────────────────────────────────────── */
html.fx .faq details::details-content {
  block-size: 0; overflow: hidden;
  transition: block-size .45s var(--fx-ease), content-visibility .45s allow-discrete;
}
html.fx .faq details[open]::details-content { block-size: auto; }
html.fx .faq summary { transition: color .25s; }
html.fx .faq summary:hover { color: var(--accent); }

/* ── Numeri che contano ───────────────────────────────────────────── */
[data-count] { font-variant-numeric: tabular-nums; }

/* ── WhatsApp: fumetto che saluta una volta ───────────────────────── */
.fx-bubble {
  position: fixed; right: 92px; bottom: 34px; z-index: 91; max-width: 240px;
  background: #fff; color: #1f2d3a; font-size: .88rem; line-height: 1.35; font-weight: 600;
  padding: 11px 16px; border-radius: 16px 16px 4px 16px;
  box-shadow: 0 16px 40px -12px rgba(10, 30, 60, .35);
  opacity: 0; transform: translateX(12px) scale(.9); transform-origin: right bottom;
  transition: opacity .45s var(--fx-ease), transform .55s var(--fx-spring); pointer-events: none;
}
.fx-bubble.on { opacity: 1; transform: none; pointer-events: auto; cursor: pointer; }
.fx-bubble small { display: block; font-weight: 400; color: #5a6878; margin-top: 2px; }
html.fx .wafab.fx-wave { animation: fxWave 1s var(--fx-ease) 2; }
@keyframes fxWave { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-14deg) scale(1.08); } 45% { transform: rotate(10deg) scale(1.08); } 70% { transform: rotate(-5deg); } }
html.fx .wafab::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #25d366;
  animation: fxRing 2.8s var(--fx-ease) infinite; pointer-events: none;
}
@keyframes fxRing { 0% { transform: scale(1); opacity: .6; } 70%,100% { transform: scale(1.6); opacity: 0; } }

/* ── Avviso breve (numero copiato) ────────────────────────────────── */
.fx-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 400; translate: -50% 0;
  background: #14202c; color: #fff; font-size: .9rem; padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 14px 40px -12px rgba(0,0,0,.45); display: flex; gap: 10px; align-items: center;
  opacity: 0; transform: translateY(14px); transition: opacity .35s var(--fx-ease), transform .45s var(--fx-spring);
}
.fx-toast.on { opacity: 1; transform: none; }
.fx-toast i { width: 18px; height: 18px; border-radius: 50%; background: #25d366; display: inline-grid; place-items: center; font-style: normal; font-size: 11px; }

/* ── Lottie ───────────────────────────────────────────────────────── */
[data-lottie] { display: inline-block; line-height: 0; }
[data-lottie] svg { width: 100% !important; height: 100% !important; }
.fx-lottie-inline { width: 30px; height: 30px; vertical-align: -9px; margin-right: 6px; }
.contact-ok .fx-okanim { width: 56px; height: 56px; display: block; margin-bottom: 6px; }

/* ── Accessibilità: chi chiede meno movimento lo ottiene ──────────── */
@media (prefers-reduced-motion: reduce) {
  html.fx [data-fx] { opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; animation: none !important; }
  html.fx .band img, html.fx .photo img { animation: none !important; }
  .fx-gl, .fx-progress { display: none; }
  html.fx .wafab::before, html.fx .wafab.fx-wave { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
@media (hover: none) { html.fx .fx-spot::after { display: none; } }
@media print { .fx-progress, .fx-gl, .fx-bubble, .fx-toast, html.fx body::after { display: none !important; } }

/* lucchetto Lottie nella striscia conformità */
.fx-lawlock { width: 56px; height: 56px; flex: none; }

/* ── Menu CH v3: una capsula, una pillola che scorre, un solo stile ─ */
body.brand-ch header.site { background: rgba(255, 255, 255, .9); border-bottom: 1px solid rgba(20, 42, 64, .07); }
body.brand-ch header.site .wrap { height: 76px; gap: 18px; }
html.fx.fx-scrolled body.brand-ch header.site .wrap { height: 64px; }
body.brand-ch .logo .agimg { height: 28px; }
body.brand-ch nav.main {
  position: relative; margin-left: auto; gap: 0; padding: 4px; border-radius: 999px;
  background: rgba(20, 42, 64, .035); border: 1px solid rgba(20, 42, 64, .07);
}
body.brand-ch nav.main a,
body.brand-ch nav.main a[href*="conformita"] {
  position: relative; z-index: 1; padding: 8px 15px; border-radius: 999px; background: none;
  font-family: var(--font-display); font-weight: 500; font-size: .9rem; letter-spacing: .005em;
  color: #4d5864; white-space: nowrap; transition: color .25s var(--fx-ease);
}
body.brand-ch nav.main a::after, body.brand-ch nav.main a::before { display: none !important; }
body.brand-ch nav.main a:hover, body.brand-ch nav.main a[href*="conformita"]:hover { color: #142a40; background: none; }
body.brand-ch nav.main a.fx-here { color: var(--accent); }
.fx-navpill {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 2px rgba(20, 42, 64, .08), 0 6px 16px -8px rgba(20, 42, 64, .25);
  opacity: 0; transition: transform .45s var(--fx-ease), width .45s var(--fx-ease), opacity .25s;
  pointer-events: none;
}
body.brand-ch header.site .btn.small { margin-left: 10px; padding: 11px 22px; font-family: var(--font-display); font-weight: 600; font-size: .9rem; }

/* intestazione scura della pagina storia */
body.brand-ch:has(.fx-story-page) nav.main { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .09); }
body.brand-ch:has(.fx-story-page) nav.main a, body.brand-ch:has(.fx-story-page) nav.main a[href*="conformita"] { color: rgba(234, 241, 248, .78); background: none; }
body.brand-ch:has(.fx-story-page) nav.main a:hover { color: #fff; }
body.brand-ch:has(.fx-story-page) nav.main a.fx-here { color: #fff; }
body.brand-ch:has(.fx-story-page) .fx-navpill { background: rgba(255, 255, 255, .12); box-shadow: none; }

/* ── Telefono: menu a scheda ──────────────────────────────────────── */
.fx-burger { display: none; }
.fx-sheet { display: none; }
@media (max-width: 860px) {
  body.brand-ch header.site .wrap { height: 62px; }
  body.brand-ch header.site .btn.small { margin-left: auto; padding: 9px 16px; font-size: .85rem; }
  .fx-burger {
    display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%;
    border: 1px solid rgba(20, 42, 64, .12); background: #fff; cursor: pointer; padding: 0;
  }
  .fx-burger i { display: block; width: 16px; height: 1.5px; background: #142a40; position: relative; transition: background .2s; }
  .fx-burger i::before, .fx-burger i::after { content: ""; position: absolute; left: 0; width: 16px; height: 1.5px; background: #142a40; transition: transform .35s var(--fx-ease); }
  .fx-burger i::before { transform: translateY(-5px); } .fx-burger i::after { transform: translateY(5px); }
  html.fx-menu .fx-burger i { background: transparent; }
  html.fx-menu .fx-burger i::before { transform: rotate(45deg); } html.fx-menu .fx-burger i::after { transform: rotate(-45deg); }
  body:has(.fx-story-page) .fx-burger { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
  body:has(.fx-story-page) .fx-burger i, body:has(.fx-story-page) .fx-burger i::before, body:has(.fx-story-page) .fx-burger i::after { background: #fff; }
  html.fx-menu body:has(.fx-story-page) .fx-burger i { background: transparent; }

  .fx-sheet {
    display: flex; flex-direction: column; position: fixed; inset: var(--fx-sheet-top, 62px) 0 0 0; z-index: 49; padding: 8px 24px 28px;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    opacity: 0; visibility: hidden; transition: opacity .35s var(--fx-ease), visibility .35s;
    overflow-y: auto;
  }
  html.fx-menu .fx-sheet { opacity: 1; visibility: visible; }
  html.fx-menu { overflow: hidden; }
  html.fx-menu .wafab, html.fx-menu .fx-bubble { opacity: 0; pointer-events: none; }
  .fx-sheet nav a {
    display: block; padding: 13px 0; border-bottom: 1px solid rgba(20, 42, 64, .08); text-decoration: none;
    font-family: var(--font-display); font-weight: 500; font-size: 1.4rem; letter-spacing: -.01em; color: #142a40;
    opacity: 0; transform: translateY(14px); transition: opacity .45s var(--fx-ease), transform .45s var(--fx-ease);
  }
  .fx-sheet nav a.fx-here { color: var(--accent); }
  html.fx-menu .fx-sheet nav a { opacity: 1; transform: none; }
  .fx-sheet .fx-sheet-foot { margin-top: auto; padding-top: 26px; display: grid; gap: 10px; }
  .fx-sheet .fx-sheet-foot .btn { text-align: center; }
  .fx-sheet .fx-sheet-langs { display: flex; gap: 18px; font-size: .9rem; color: #6e6f70; }
  .fx-sheet .fx-sheet-langs a { color: inherit; text-decoration: none; } .fx-sheet .fx-sheet-langs strong { color: var(--accent); }
  body:has(.fx-story-page) .fx-sheet { background: rgba(8, 20, 33, .97); }
  body:has(.fx-story-page) .fx-sheet nav a { color: #eaf1f8; border-color: rgba(255,255,255,.1); }
}
@media (prefers-reduced-motion: reduce) { .fx-navpill, .fx-sheet, .fx-sheet nav a { transition: none; } }
