/* Gli Amici di Boyle · sistema di movimento (title-fx.css)
   Principio: poche cose si muovono, e si muovono bene.
   - Titoli: le parole salgono da dietro una maschera (stile editoriale).
   - Occhiello, barretta e sottotitolo: arrivano in sequenza, senza spostamenti vistosi.
   - Card: dissolvenza con lieve salita, a cascata nella stessa riga.
   - Immagini nelle card: si svelano dal basso con un leggero zoom che si assesta.
   - Testi lunghi, moduli, menu, footer: fermi. Si legge meglio.
   Curva unica per tutto il sito: expo-out. Nessun rimbalzo. */

:root {
  --ms-ease: cubic-bezier(.16, 1, .3, 1);
  --ms-soft: cubic-bezier(.33, 1, .68, 1);
}

/* ── 1. Le vecchie entrate (da sinistra, a mazzo di carte, a scatto) sono spente ───────
   Il prefisso :root:not(#a#b) da' a queste regole la precedenza sulle regole storiche,
   anche su quelle con !important e id. */
:root:not(#ms_a#ms_b) :is(.reveal, .reveal-left, .reveal-right, .reveal-scale, .info-card, .activity-card,
  .founder-card, .glass-card, .section-heading, .member-card, .content-card,
  .research-showcase-grid > *, .contact-grid-visible > *):not(.is-visible) {
  opacity: 1 !important;
  transform: none !important;
}
:root:not(#ms_a#ms_b) :is(.founder-card, .member-card, .section-heading) {
  animation: none !important;
}

/* ── 2. Titoli: parole che salgono da dietro una maschera ───────────────────────────── */
.msw {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* margine per discendenti e accenti, compensato per non spostare l'impaginazione */
  padding: .08em .05em .16em;
  margin: -.08em -.05em -.16em;
}
.msi { display: inline-block; will-change: transform; }
.ms-t-pre .msi { transform: translate3d(0, 112%, 0) rotate(2.5deg); transform-origin: 0 100%; }
.ms-t-on .msi {
  transform: none;
  transition: transform 1s var(--ms-ease);
  transition-delay: calc(var(--i, 0) * 45ms);
}
.ms-t-done .msw { overflow: visible; }
.ms-t-done .msi { will-change: auto; }

/* titolo intero (quando non si puo' dividere in parole) */
.ms-whole-pre { clip-path: inset(0 0 100% 0); translate: 0 .35em; }
.ms-whole-on { clip-path: inset(-.2em -.2em -.3em -.2em); translate: 0 0;
  transition: clip-path 1s var(--ms-ease), translate 1s var(--ms-ease); }

/* barretta sopra l'occhiello: si disegna da sinistra */
.ms-bar-pre::before { transform: scaleX(0); transform-origin: 0 50%; }
.ms-bar-on::before { transform: none; transition: transform .9s var(--ms-ease); }

/* occhiello, sottotitolo e testi d'accompagnamento */
:root:not(#ms_a#ms_b) .ms-f-pre { opacity: 0 !important; translate: 0 14px; }
:root:not(#ms_a#ms_b) .ms-f-on {
  opacity: 1 !important; translate: 0 0;
  transition: opacity .8s var(--ms-soft), translate 1s var(--ms-ease) !important;
  transition-delay: var(--ms-d, 0s) !important;
}

/* ── 3. Card ──────────────────────────────────────────────────────────────────────── */
:root:not(#ms_a#ms_b) .ms-c-pre { opacity: 0 !important; translate: 0 34px; scale: .965; }
:root:not(#ms_a#ms_b) .ms-c-on {
  opacity: 1 !important; translate: 0 0; scale: 1;
  transition: opacity .7s var(--ms-soft), translate 1.05s var(--ms-ease), scale 1.05s var(--ms-ease),
              transform .35s ease, box-shadow .35s ease, border-color .35s ease !important;
  transition-delay: var(--ms-d, 0s), var(--ms-d, 0s), var(--ms-d, 0s), 0s, 0s, 0s !important;
}

/* ── 4. Immagini nelle card: svelate dal basso, zoom che si assesta ─────────────────── */
.ms-i-pre { clip-path: inset(100% 0 0 0); scale: 1.14; }
.ms-i-on { clip-path: inset(0 0 0 0); scale: 1;
  transition: clip-path 1.15s var(--ms-ease), scale 1.6s var(--ms-ease);
  transition-delay: var(--ms-d, 0s); }
/* ritratti tondi: si aprono dal centro */
.ms-i-round.ms-i-pre { clip-path: circle(0% at 50% 50%); scale: 1.06; }
.ms-i-round.ms-i-on { clip-path: circle(71% at 50% 50%); }

/* ── 5. Numeri che contano ───────────────────────────────────────────────────────── */
.ms-count { font-variant-numeric: tabular-nums; }

/* ── 6. Avanzamento della pagina: una linea sottile in cima ─────────────────────────── */
.ms-progress { display: none; }
@supports (animation-timeline: scroll()) {
  .ms-progress {
    display: block; position: fixed; left: 0; top: 0; width: 100%; height: 2px; z-index: 10050;
    pointer-events: none; transform-origin: 0 50%; transform: scaleX(0);
    background: linear-gradient(90deg, #39e6c3, #7be4ff 45%, #4d8dff);
    box-shadow: 0 0 10px rgba(123, 228, 255, .55);
    animation: msProgress linear both; animation-timeline: scroll(root block);
  }
  @keyframes msProgress { to { transform: scaleX(1); } }
}

/* ── 7. Passaggio tra le pagine: dissolvenza morbida, il menu resta fermo ──────────── */
@view-transition { navigation: auto; }
header.site-header, header.header { view-transition-name: ms-nav; }
::view-transition-old(root) { animation: msPageOut .22s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: msPageIn .55s var(--ms-ease) both; }
@keyframes msPageOut { to { opacity: 0; } }
@keyframes msPageIn { from { opacity: 0; transform: translateY(14px); } }

/* ── Chi preferisce meno movimento: tutto subito visibile ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .ms-t-pre .msi, .ms-whole-pre, .ms-i-pre { transform: none !important; clip-path: none !important; translate: none !important; scale: none !important; }
  :root:not(#ms_a#ms_b) :is(.ms-f-pre, .ms-c-pre) { opacity: 1 !important; translate: none !important; scale: none !important; }
  .ms-bar-pre::before { transform: none !important; }
  .ms-progress { display: none !important; }
}

/* le animazioni di sezioni fuori schermo restano in pausa (motion.js) */
.is-offscreen, .is-offscreen *, .is-offscreen *::before, .is-offscreen *::after { animation-play-state: paused !important; }

/* ── 8. Titoli delle pagine: grandi e soli, come nella home ─────────────────────────── */
html body .ev-hero__content h1 { font-size: clamp(3rem, 6vw, 5.6rem); line-height: .92; letter-spacing: -.045em; }
html body .hero__content .hero__title { font-size: clamp(3.2rem, 9.6vw, 8.6rem); line-height: .9; letter-spacing: -.05em; }
html body .podHero__copy .podTitle { font-size: clamp(3rem, 7.6vw, 7.2rem); line-height: .9; }
html body .podHero__copy .podByline { font-size: clamp(1rem, 1.6vw, 1.3rem); letter-spacing: -.01em; }
html body .bb-hero h1 { font-size: clamp(3.2rem, 8.6vw, 7.6rem); line-height: .92; letter-spacing: -.045em; }
html body .db-hero__intro h1 { font-size: clamp(2.4rem, 8vw, 7.4rem); line-height: .92; letter-spacing: -.03em; white-space: nowrap; }
@media (max-width: 600px) {
  html body .ev-hero__content h1 { font-size: clamp(2.8rem, 14vw, 4.4rem); }
  html body .hero__content .hero__title { font-size: clamp(2.8rem, 15vw, 4.6rem); }
  html body .podHero__copy .podTitle { font-size: clamp(2.8rem, 14.5vw, 4.4rem); }
  html body .bb-hero h1 { font-size: clamp(2.8rem, 14vw, 4.4rem); }
  html body .db-hero__intro h1 { font-size: clamp(2rem, 11vw, 3.6rem); }
}
html body .hero__title .hero__grad {
  background: linear-gradient(135deg, #a8eeff 0%, #7be4ff 40%, #c4b0ff 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  display: inline-block; padding-bottom: .06em;
}

/* ── 9. Sfondo fisso che non "scatta" sul telefono ──────────────────────────────────
   Gli strati di sfondo erano alti quanto lo schermo visibile: quando la barra del browser
   si nasconde scorrendo, l'altezza cambia e l'immagine (in "cover") si ingrandiva di colpo.
   Ora sono alti quanto lo schermo piu' grande possibile e non cambiano mai misura. */
html::before, html::after, body::before, body::after {
  bottom: auto; height: 100vh; height: 100lvh;
  transform: translateZ(0);
}

/* ── 10. Menu mobile come nella home, su tutte le pagine ─────────────────────────────
   Pannello stretto quanto le voci, ancorato a destra sotto l'hamburger, voci allineate
   a destra; il pulsante flottante della Rete si nasconde quando il menu e' aperto. */
@media (max-width: 768px) {
  html body .nav-mobile-panel, html body .site-nav {
    left: auto !important; width: max-content !important; min-width: 150px !important; max-width: calc(100vw - 32px) !important;
  }
  html body .nav-mobile-panel > a, html body .site-nav > a {
    text-align: right !important; padding-left: 20px !important; padding-right: 14px !important;
  }
  html body .site-nav .nav-dropdown-btn { justify-content: flex-end !important; gap: 8px; text-align: right !important; padding-left: 20px !important; padding-right: 14px !important; }
  html body .site-nav .nav-dropdown-panel a { justify-content: flex-end; text-align: right; white-space: nowrap; }
  html body .site-nav .nav-dropdown-panel a::before { order: 2; }
  html body .site-nav .nav-dropdown:not(.is-open) .nav-dropdown-panel { display: none !important; }
  html body .nav-mobile-panel .lang-toggle--mobile, html body .site-nav .lang-toggle--mobile { justify-content: flex-end !important; margin-left: auto; }
  /* pulsante flottante della Rete: voci a destra, pannello stretto */
  #rete-qn-panel { min-width: 140px !important; width: max-content; }
  #rete-qn-panel a { text-align: right; padding-left: 20px !important; padding-right: 14px !important; }
  body:has(#navMobilePanel[aria-hidden="false"]) #rete-mobile-qn { opacity: 0; pointer-events: none; }
}
