/* Eliante — "Il metodo in 3D": pulsanti sulle fasi e visore */
:root { --m3d-ease: cubic-bezier(.22, 1, .36, 1); --m3d-sheet: cubic-bezier(.32, .72, 0, 1); }

/* ---------- Pulsanti sulle schede del metodo (fascia blu) ---------- */
.m3d-open {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
  margin-top: 1rem; padding: .45rem .8rem .45rem .6rem; border-radius: 999px;
  font: 600 .8125rem/1 'Montserrat', 'Instrument Sans', sans-serif; letter-spacing: .01em;
  color: #fff; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  transition: background-color 160ms var(--m3d-ease), border-color 160ms var(--m3d-ease), transform 120ms var(--m3d-ease);
}
.m3d-open svg { width: 16px; height: 16px; color: #F49158; flex: none; }
.m3d-open:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.32); }
.m3d-open:active { transform: scale(.96); }
.m3d-open:focus-visible { outline: 2px solid #F49158; outline-offset: 3px; }
.m3d-cta { display: flex; justify-content: center; margin-top: 2.25rem; }
.m3d-open--big { margin: 0; height: 48px; padding: 0 1.4rem; font-size: .9375rem; background: #C94E14; border-color: #C94E14; box-shadow: 0 8px 20px -8px rgba(201,78,20,.6); }
.m3d-open--big:hover { background: #B04310; border-color: #B04310; }
html:not(.rd) .m3d-open, html:not(.rd) .m3d-cta { display: none !important; }
@media (max-width: 900px) { .processo-step .m3d-open, .fv-process-step .m3d-open { grid-column: 2; justify-self: start; margin-top: .6rem; } }

/* ---------- Visore ---------- */
html.m3d-lock { overflow: hidden; }
.m3d { position: fixed; inset: 0; z-index: 2147482000; }
.m3d[hidden] { display: none; }
.m3d-backdrop { position: absolute; inset: 0; background: rgba(10,18,36,.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); opacity: 0; transition: opacity 320ms var(--m3d-ease); }
.m3d.is-open .m3d-backdrop { opacity: 1; }
.m3d-panel {
  position: absolute; inset: 16px; border-radius: 28px; overflow: hidden; background: #D6E0EA;
  box-shadow: 0 40px 120px -30px rgba(0,0,0,.6);
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  transform: scale(.88); opacity: 0;
  transition: transform 520ms var(--m3d-ease), opacity 260ms var(--m3d-ease);
  font-family: 'Montserrat', 'Instrument Sans', system-ui, sans-serif; color: #2B3650;
}
.m3d.is-open .m3d-panel { transform: none; opacity: 1; }
.m3d-stage { position: absolute; inset: 0; }
.m3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.m3d-canvas.is-grab { cursor: grabbing; }
.m3d-stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(255,255,255,.95) 0%, rgba(255,255,255,.82) 28%, rgba(255,255,255,0) 50%); }
.m3d-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: .75rem; font-size: .9375rem; font-weight: 600; color: #1F3A7A; z-index: 2; transition: opacity 400ms; }
.m3d-loading span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(31,58,122,.2); border-top-color: #E8621B; animation: m3dspin .8s linear infinite; }
@keyframes m3dspin { to { transform: rotate(360deg); } }
.m3d.is-ready .m3d-loading { opacity: 0; pointer-events: none; }
.m3d.is-fallback .m3d-loading { animation: none; }
.m3d.is-fallback .m3d-loading::after { content: 'Il 3D non è disponibile su questo dispositivo: qui sotto trovi la descrizione della fase.'; position: absolute; top: 60%; max-width: 30em; text-align: center; font-weight: 500; color: #4C566B; }
.m3d.is-fallback .m3d-loading span { display: none; }

.m3d-top { position: absolute; z-index: 4; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.25rem 0 2rem; pointer-events: none; }
.m3d-kicker { font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #C94E14; }
.m3d-close { all: unset; pointer-events: auto; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1rem; color: #14213D;
  background: rgba(255,255,255,.85); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 6px 18px -8px rgba(15,27,54,.45); transition: transform 120ms; }
.m3d-close:active { transform: scale(.92); }
.m3d-close:focus-visible { outline: 2px solid #C94E14; outline-offset: 3px; }
.m3d-grabber { display: none; }

/* Testo della fase */
.m3d-copy { position: absolute; z-index: 3; left: 2rem; top: 50%; transform: translateY(-50%); width: min(400px, 34vw); }
.m3d-copy.is-in > * { animation: m3din 520ms var(--m3d-ease) both; }
.m3d-copy.is-in > :nth-child(2) { animation-delay: 40ms; } .m3d-copy.is-in > :nth-child(3) { animation-delay: 80ms; } .m3d-copy.is-in > :nth-child(4) { animation-delay: 120ms; }
@keyframes m3din { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.m3d-num { font-size: .8125rem; font-weight: 600; letter-spacing: .06em; color: #C94E14; }
.m3d-copy h2 { font-family: 'Fraunces', serif; font-weight: 600; font-size: clamp(2rem, 1.4rem + 1.6vw, 2.875rem); line-height: 1.06; letter-spacing: -.022em; color: #14213D; margin: .55rem 0 .9rem; text-wrap: balance; }
.m3d-copy h2 em { font-style: italic; font-weight: 500; color: #C94E14; }
.m3d-text { font-size: 1rem; line-height: 1.6; color: #4C566B; margin: 0; }
.m3d-ctrl { margin-top: 1.5rem; }
.m3d-hint { font-size: .875rem; color: #4C566B; display: flex; gap: .5rem; align-items: center; margin: 0; }
.m3d-hint span { color: #C94E14; font-weight: 700; }
.m3d-range { display: grid; gap: .6rem; font-size: .875rem; font-weight: 600; color: #14213D; }
.m3d-range span { display: flex; justify-content: space-between; }
.m3d-range b { font-variant-numeric: tabular-nums; color: #C94E14; }
.m3d-range input { width: 100%; accent-color: #C94E14; }
.m3d-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(20,33,61,.07); }
.m3d-seg button { all: unset; cursor: pointer; padding: .55rem 1rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; color: #4C566B; transition: background-color 160ms, color 160ms, transform 100ms; }
.m3d-seg button[aria-pressed="true"] { background: #fff; color: #14213D; box-shadow: 0 2px 8px -3px rgba(15,27,54,.3); }
.m3d-seg button:active { transform: scale(.96); }
.m3d-seg button:focus-visible { outline: 2px solid #C94E14; outline-offset: 2px; }
.m3d-sub { font-size: .875rem; color: #4C566B; margin: .85rem 0 0; min-height: 2.8em; }
.m3d-curve { margin-top: 1rem; padding: .9rem 1rem .8rem; border-radius: 16px; background: rgba(255,255,255,.75); border: 1px solid rgba(20,33,61,.08); }
.m3d-curve svg { display: block; width: 100%; height: 56px; }
.m3d-curve p { margin: .4rem 0 0; font-size: .8125rem; font-weight: 600; color: #14213D; }
.m3d-curve small { font-size: .6875rem; color: #6B7385; }

/* Navigazione tra le fasi */
.m3d-nav { position: absolute; z-index: 4; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: flex; align-items: center; gap: .4rem; padding: .35rem;
  border-radius: 999px; background: rgba(255,255,255,.86); -webkit-backdrop-filter: blur(18px) saturate(180%); backdrop-filter: blur(18px) saturate(180%);
  box-shadow: 0 12px 34px -14px rgba(15,27,54,.5); max-width: calc(100% - 2rem); }
.m3d-nav ol { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; }
.m3d-nav ol button { all: unset; cursor: pointer; display: flex; align-items: baseline; gap: .4rem; padding: .6rem .9rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; color: #4C566B; white-space: nowrap; transition: background-color 160ms, color 160ms, transform 100ms; }
.m3d-nav ol button b { font-family: 'Fraunces', serif; font-weight: 600; color: #C94E14; }
.m3d-nav ol button[aria-current] { background: #1F3A7A; color: #fff; }
.m3d-nav ol button[aria-current] b { color: #F49158; }
.m3d-nav ol button:active, .m3d-arrow:active { transform: scale(.95); }
.m3d-nav button:focus-visible { outline: 2px solid #C94E14; outline-offset: 2px; }
.m3d-arrow { all: unset; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #1F3A7A; font-weight: 700; }
.m3d-arrow:disabled { opacity: .3; cursor: default; }

/* Etichette 3D */
.m3d-labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.m3d-label { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: .5rem; padding: .42rem .8rem .42rem .5rem; border-radius: 999px;
  background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid rgba(20,33,61,.08);
  box-shadow: 0 8px 24px -10px rgba(15,27,54,.4); font-size: .8125rem; font-weight: 600; color: #14213D; white-space: nowrap; opacity: 0; transition: opacity 300ms var(--m3d-ease); }
.m3d-label.is-on { opacity: 1; }
.m3d-label i { width: 8px; height: 8px; border-radius: 50%; background: #E8621B; box-shadow: 0 0 0 4px rgba(232,98,27,.18); flex: none; }
.m3d-label small { font-weight: 500; color: #6B7385; margin-left: .1rem; }

/* ---------- Telefono: foglio a tutto schermo che sale dal basso ---------- */
@media (max-width: 899px) {
  .m3d-panel { inset: 0; top: 0; border-radius: 0; transform: translateY(100%); opacity: 1; transform-origin: 50% 100%; transition: transform 460ms var(--m3d-sheet); }
  .m3d.is-open .m3d-panel { transform: none; }
  .m3d-stage { bottom: 46%; }
  .m3d-stage::after { background: linear-gradient(0deg, rgba(255,255,255,.7) 0%, rgba(255,255,255,0) 30%); }
  .m3d-grabber { display: block; position: absolute; z-index: 5; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: rgba(20,33,61,.25); }
  .m3d-top { padding: 1rem 1rem 0 1.25rem; pointer-events: auto; touch-action: none; }
  .m3d-copy { left: 0; right: 0; top: 54%; bottom: 0; transform: none; width: auto; padding: 1.1rem 1.25rem 5.5rem; background: #fff; overflow-y: auto; border-radius: 22px 22px 0 0; box-shadow: 0 -12px 30px -18px rgba(15,27,54,.35); }
  .m3d-copy h2 { font-size: 1.625rem; margin: .4rem 0 .5rem; }
  .m3d-text { font-size: .9375rem; line-height: 1.5; }
  .m3d-ctrl { margin-top: 1rem; }
  .m3d-nav { bottom: .75rem; padding: .25rem; }
  .m3d-nav ol button { padding: .55rem .7rem; }
  .m3d-nav ol button span { display: none; }
  .m3d-nav ol button[aria-current] span { display: inline; }
  .m3d-label { font-size: .75rem; padding: .35rem .65rem .35rem .45rem; }
  .m3d-label small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .m3d-panel { transition: opacity 200ms linear !important; transform: none !important; }
  .m3d:not(.is-open) .m3d-panel { opacity: 0; }
  .m3d-copy.is-in > * { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .m3d-backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(10,18,36,.8); }
  .m3d-nav, .m3d-close, .m3d-label { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (min-width: 901px) {
  .processo-step .m3d-open, .fv-process-step .m3d-open { margin-top: auto; }
  .processo-step p, .fv-process-step p { margin-bottom: 1.1rem !important; }
}
html.m3d-lock #rd-bar { display: none !important; } /* solo anteprima: la barra Prima/Dopo non copre il visore */
