/* ==========================================================================
   MASTERSOFT — home.css
   Hero con computer animato, storytelling a scorrimento, statistiche, metodo orizzontale
   ========================================================================== */

@property --cube-color { syntax: "<color>"; inherits: true; initial-value: #2e8bff; }
@property --tint { syntax: "<color>"; inherits: true; initial-value: #2e8bff; }

/* ---------- HERO ---------- */
.hero {
  position: relative; min-height: 100svh; display: flex; align-items: center;
  padding: calc(var(--header-h) + 40px) 0 80px; overflow: hidden; isolation: isolate;
}
.hero__bg {
  position: absolute; inset: 0 0 -1px; z-index: -2; overflow: hidden;
  /* i bagliori si dissolvono gradualmente verso la sezione successiva */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, rgba(0,0,0,.45) 80%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 55%, rgba(0,0,0,.45) 80%, transparent 100%);
}
.hero::after { /* velo che fonde l'hero con il manifesto */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(5,5,7,0) 0%, rgba(5,5,7,.35) 35%, rgba(5,5,7,.75) 70%, var(--bg) 100%);
}

.hero__bg::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 60% at 60% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 60% 45%, #000 20%, transparent 75%);
}
.hero__orb { position: absolute; width: 46vw; height: 46vw; border-radius: 50%; filter: blur(100px); opacity: .35; animation: orb 18s var(--ease-io) infinite alternate; }
.hero__orb--1 { background: var(--c-ai);  top: -14vw; right: -6vw; }
.hero__orb--2 { background: var(--c-sw);  bottom: -10vw; left: -12vw; animation-delay: -6s; opacity: .25; }
.hero__orb--3 { background: var(--c-for); top: 30%; right: 30%; width: 22vw; height: 22vw; animation-delay: -11s; opacity: .16; }
@keyframes orb { 50% { transform: translate(6vw, 4vw) scale(1.12); } 100% { transform: translate(-4vw, -3vw) scale(.92); } }

.hero__grid { display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 40px; }
.hero__content { position: relative; z-index: 2; will-change: transform, opacity; }

.hero h1 { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -.055em; line-height: .92; }
.hero h1 .split-line:nth-child(2) > span { --d: .12s; }
.hero h1 .split-line:nth-child(3) > span { --d: .24s; }
.hero__lead { margin-top: 32px; max-width: 40ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; }

/* Computer con codice che si compila */
.hero__scene { position: relative; height: min(70vh, 620px); perspective: 1600px; display: grid; place-items: center; will-change: transform; }
.laptop {
  --w: min(560px, 37vw);
  position: relative; width: var(--w); transform-style: preserve-3d;
  transform: rotateX(var(--lrx, 6deg)) rotateY(var(--lry, -12deg));
  animation: laptopIn 1.6s var(--ease-out) .2s backwards;
}
@keyframes laptopIn { from { opacity: 0; transform: translateY(60px) rotateX(30deg) rotateY(-30deg) scale(.9); } }
.laptop__lid {
  position: relative; aspect-ratio: 16 / 10.4; padding: 2.4%; border-radius: 18px 18px 6px 6px;
  background: linear-gradient(180deg, #2a2a31, #17171c); 
  box-shadow: inset 0 0 0 1.5px #3a3a43, 0 0 0 1px #000, 0 40px 90px -30px rgba(0,0,0,.9);
  transform-origin: bottom center; animation: lidOpen 1.8s var(--ease-out) .5s backwards;
}
@keyframes lidOpen { from { transform: rotateX(-88deg); } }
.laptop__notch { position: absolute; top: 2.4%; left: 50%; width: 13%; height: 3.2%; transform: translateX(-50%); background: #0b0b0e; border-radius: 0 0 8px 8px; }
.laptop__screen { position: relative; width: 100%; height: 100%; border-radius: 8px; overflow: hidden; background: #0b0b10; }
.laptop__screen::after { /* riflesso del vetro */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.10) 0%, rgba(255,255,255,0) 32%, rgba(255,255,255,0) 70%, rgba(255,255,255,.04) 100%);
}
.laptop__base {
  position: relative; height: calc(var(--w) * .028); margin: 0 -7%; border-radius: 2px 2px 14px 14px;
  background: linear-gradient(180deg, #4a4a54 0%, #2b2b32 45%, #18181d 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset;
}
.laptop__base span { position: absolute; top: 0; left: 50%; width: 16%; height: 45%; transform: translateX(-50%); background: #1a1a20; border-radius: 0 0 8px 8px; }
.laptop__shadow { position: absolute; left: -4%; right: -4%; bottom: -40px; height: 50px; background: radial-gradient(closest-side, rgba(0,0,0,.75), transparent); filter: blur(14px); z-index: -1; }

.ide { display: grid; grid-template-rows: auto minmax(0, 1fr) 44%; height: 100%; font-family: var(--font-mono); font-size: clamp(6.5px, .7vw, 10.5px); color: #d4d4dc; }
.ide__bar { display: flex; align-items: center; gap: 6px; height: 2.4em; padding: 0 1em; background: #121218; border-bottom: 1px solid rgba(255,255,255,.06); }
.ide__bar i { width: .8em; height: .8em; border-radius: 50%; background: #ff5f57; }
.ide__bar i:nth-child(2) { background: #febc2e; } .ide__bar i:nth-child(3) { background: #28c840; margin-right: 1em; }
.ide__tab { padding: .35em .9em; border-radius: 5px; color: var(--dim); }
.ide__tab.is-on { background: rgba(255,255,255,.06); color: var(--text); }
.ide__body { display: grid; grid-template-columns: 2.6em 1fr; min-height: 0; overflow: hidden; }
.ide__side { display: flex; flex-direction: column; align-items: center; gap: .9em; padding-top: 1em; border-right: 1px solid rgba(255,255,255,.05); }
.ide__side span { width: 1.1em; height: 1.1em; border-radius: 3px; background: rgba(255,255,255,.12); }
.ide__side span.on { background: var(--c-sw); }
.ide__code { margin: 0; padding: .8em 1.2em; line-height: 1.6; white-space: pre; overflow: hidden; counter-reset: ln; }
.ide__code .cl { display: block; counter-increment: ln; opacity: 0; transform: translateX(-6px); transition: opacity .35s, transform .45s var(--ease-out); }
.ide__code .cl::before { content: counter(ln); display: inline-block; width: 2em; margin-right: 1em; text-align: right; color: #4a4a55; }
.ide__code .cl.is-in { opacity: 1; transform: none; }
.ide__code .cl.is-current { background: rgba(46,139,255,.08); }
.ide__term { min-height: 0; overflow: hidden; border-top: 1px solid rgba(255,255,255,.08); background: #08080c; display: flex; flex-direction: column; }
.ide__term-head { display: flex; justify-content: space-between; padding: .5em 1.2em; font-size: .85em; letter-spacing: .1em; color: var(--dim); }
.ide__status { color: var(--c-ads); letter-spacing: 0; transition: color .3s; }
.ide__status.ok { color: var(--c-web); }
.ide__log { flex: 1; padding: 0 1.2em .6em; line-height: 1.65; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.ide__log div { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: logIn .25s ease-out; }
@keyframes logIn { from { opacity: 0; transform: translateY(4px); } }
.ide__log .p { color: var(--c-sw); } .ide__log .ok { color: var(--c-web); } .ide__log .dim { color: #6b6b78; } .ide__log .warn { color: var(--c-ads); }
.ide__bar-prog { display: inline-block; width: 12em; height: .7em; margin-left: .6em; border-radius: 4px; background: rgba(255,255,255,.08); vertical-align: middle; overflow: hidden; }
.ide__bar-prog i { display: block; height: 100%; width: var(--w, 0%); background: linear-gradient(90deg, var(--c-ai), var(--c-sw), var(--c-web)); transition: width .12s linear; }
.tok-k { color: #c792ea; } .tok-s { color: #a5e3a0; } .tok-f { color: #82aaff; } .tok-c { color: #6b6b78; font-style: italic; } .tok-n { color: #f78c6c; }

.hero__chip {
  position: absolute; padding: 9px 15px; border-radius: 999px; font-family: var(--font-mono); font-size: .8rem; white-space: nowrap;
  background: rgba(20,20,26,.78); border: 1px solid var(--line-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 40px -20px rgba(0,0,0,.7); opacity: 0; transform: translateY(10px); transition: opacity .6s, transform .8s var(--ease-out);
  animation: chipBob 6s var(--ease-io) infinite alternate;
}
.hero__chip.is-on { opacity: 1; transform: none; }
.hero__chip--1 { top: 16%; right: 4%; color: var(--c-web); }
.hero__chip--2 { bottom: 18%; left: 2%; color: var(--c-ads); animation-delay: -3s; }
@keyframes chipBob { to { translate: 0 -12px; } }

.scroll-cue { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.scroll-cue i { width: 22px; height: 36px; border: 1.5px solid var(--line-2); border-radius: 12px; position: relative; }
.scroll-cue i::after { content: ""; position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 2px; background: var(--text); animation: wheel 1.8s var(--ease-io) infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translateY(-3px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(10px); } }

/* ---------- MANIFESTO (testo che si accende) ---------- */
.manifesto { padding-block: clamp(60px, 9vw, 100px); }

.manifesto .scrub-text { max-width: 26ch; }

/* ---------- STORY: un cubo, cinque facce, cinque mestieri ---------- */
.story { position: relative; height: 560vh; --tint: var(--c-ai); --cube-color: var(--c-ai); transition: --tint .8s, --cube-color .8s; }
.story__sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; display: flex; align-items: center; }
.story__glow { position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse 50% 60% at 70% 50%, color-mix(in srgb, var(--tint) 30%, transparent), transparent 70%); }
.story__inner { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 40px; }

.story__panels { position: relative; min-height: 440px; }
.story__panel {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  opacity: 0; transform: translateY(40px); pointer-events: none;
  transition: opacity .7s var(--ease-out), transform .9s var(--ease-out);
}
.story__panel.is-active { opacity: 1; transform: none; pointer-events: auto; }
.story__panel.is-past { transform: translateY(-40px); }
.story__panel .eyebrow { color: var(--c); }
.story__panel h3 { font-size: clamp(2.2rem, 4.6vw, 4.4rem); letter-spacing: -.045em; max-width: 13ch; }
.story__panel p { margin-top: 22px; color: var(--muted); font-size: var(--fs-lead); line-height: 1.45; max-width: 40ch; }
.story__panel ul { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.story__panel li { font-size: .82rem; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, transparent); color: color-mix(in srgb, var(--c) 70%, #fff); }
.story__panel .link-arrow { margin-top: 30px; color: var(--c); }

.story__stage { position: relative; height: 80vh; display: grid; place-items: center; perspective: 1600px; }
.big-cube { --s: clamp(200px, 26vw, 360px); --cube-color: inherit; transform: rotateX(var(--brx, -18deg)) rotateY(var(--bry, 30deg)); will-change: transform; }
.big-cube .cube__face { display: grid; place-items: center; }
.big-cube .cube__face--top { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)) rotateZ(90deg); }
.big-cube .cube__face svg { width: 42%; height: 42%; color: rgba(255,255,255,.92); position: relative; z-index: 1; filter: drop-shadow(0 6px 18px rgba(0,0,0,.25)); }
.big-cube .cube__face b { position: absolute; left: 9%; top: 8%; z-index: 1; font-family: var(--font-mono); font-size: calc(var(--s) * .06); font-weight: 500; color: rgba(255,255,255,.8); }
.story__ring { position: absolute; width: calc(var(--s, 300px) * 2.1); aspect-ratio: 1; border-radius: 50%; border: 1px dashed color-mix(in srgb, var(--tint) 45%, transparent); animation: spinSlow 40s linear infinite; }
.story__ring--2 { width: calc(var(--s, 300px) * 2.7); border-style: solid; border-color: rgba(255,255,255,.05); animation-duration: 70s; animation-direction: reverse; }
@keyframes spinSlow { to { transform: rotate(360deg); } }

.story__progress { position: absolute; right: var(--gutter); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 14px; z-index: 3; }
.story__progress button { width: 10px; height: 10px; border-radius: 3px; background: rgba(255,255,255,.18); transition: background .4s, transform .4s var(--ease-out), height .5s var(--ease-out); }
.story__progress button.is-active { background: var(--c); height: 34px; }
.story__counter { position: absolute; left: var(--gutter); bottom: 34px; font-family: var(--font-mono); font-size: .8rem; color: var(--dim); }
.story__counter b { color: var(--text); font-weight: 500; }

/* ---------- METODO (scroll orizzontale bloccato) ---------- */
.hscroll { position: relative; height: 380vh; }
.hscroll__sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.hscroll__head { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 50px; }
.hscroll__head h2 { font-size: var(--fs-h2); max-width: 14ch; }
.hscroll__bar { width: 200px; height: 2px; background: var(--line-2); border-radius: 2px; overflow: hidden; flex: none; }
.hscroll__bar i { display: block; height: 100%; width: 100%; background: var(--text); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
.hscroll__track { display: flex; gap: 22px; padding-left: max(var(--gutter), calc((100vw - var(--container)) / 2)); will-change: transform; }
.step-card {
  --c: var(--accent);
  flex: none; width: clamp(290px, 34vw, 460px); min-height: 440px; padding: 38px; border-radius: var(--radius-l);
  background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--line);
  display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.step-card__n { font-family: var(--font-display); font-size: 7rem; font-weight: 800; line-height: .8; letter-spacing: -.06em; color: transparent; -webkit-text-stroke: 1.5px color-mix(in srgb, var(--c) 70%, transparent); }
.step-card h3 { font-size: clamp(1.6rem, 2.4vw, 2.2rem); margin-top: auto; }
.step-card p { margin-top: 14px; color: var(--muted); }
.step-card::after { content: ""; position: absolute; width: 260px; height: 260px; right: -80px; top: -80px; border-radius: 50%; background: var(--c); filter: blur(90px); opacity: .22; }

/* ---------- BENTO "Perché" ---------- */
.bento { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(240px, auto); gap: 18px; }
.bento__item { position: relative; padding: 34px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; justify-content: flex-start; }
.bento__item h3 { font-size: clamp(1.35rem, 2vw, 1.9rem); max-width: 20ch; position: relative; }
.bento__item p { position: relative; }
.bento__item p { margin-top: 10px; color: var(--muted); max-width: 44ch; }
.bento__item--wide { grid-column: span 2; }
.bento__item--tall { grid-row: span 2; }
.bento__big { font-family: var(--font-display); font-weight: 800; font-size: clamp(4rem, 9vw, 8rem); letter-spacing: -.07em; line-height: .85; margin-bottom: auto; }
.bento__icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 28px; flex: none; background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); color: var(--c, var(--accent)); }
.bento__icon svg { width: 26px; height: 26px; }
.bento__map { position: absolute; inset: 0; opacity: .5; background: radial-gradient(circle at 50% 78%, var(--c-for) 0 5px, transparent 6px), radial-gradient(circle at 50% 78%, color-mix(in srgb, var(--c-for) 40%, transparent) 0 22px, transparent 23px); }
.bento__map::before { content: ""; position: absolute; left: 50%; top: 78%; width: 12px; height: 12px; margin: -6px; border-radius: 50%; border: 2px solid var(--c-for); animation: ping 2.4s var(--ease-out) infinite; }
@keyframes ping { to { transform: scale(9); opacity: 0; } }
.bento__item--loc { background: radial-gradient(ellipse at 50% 70%, rgba(255,61,90,.12), transparent 60%), var(--surface); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__scene { height: auto; padding: 20px 0 50px; order: -1; }
  .laptop { --w: min(560px, 86vw); }
  .hero { padding-top: calc(var(--header-h) + 10px); }
  .story { height: auto; }
  .story__sticky { position: relative; height: auto; display: block; padding-block: 60px; }
  .story__inner { grid-template-columns: 1fr; }
  .story__stage { display: none; }
  .story__progress, .story__counter { display: none; }
  .story__panels { min-height: 0; display: grid; gap: 18px; }
  .story__panel { position: relative; opacity: 1; transform: none; pointer-events: auto; padding: 34px 28px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c); }
  .story__glow { display: none; }
  .hscroll { height: auto; }
  .hscroll__sticky { position: relative; height: auto; padding-block: 100px; }
  .hscroll__track { overflow-x: auto; scroll-snap-type: x mandatory; padding-right: var(--gutter); padding-bottom: 10px; transform: none !important; scrollbar-width: none; }
  .hscroll__track::-webkit-scrollbar { display: none; }
  .step-card { scroll-snap-align: start; min-height: 360px; }
  .hscroll__bar { display: none; }
  .bento { grid-template-columns: 1fr 1fr; }
}
/* Desktop: respiro sopra la sezione Servizi */
@media (min-width: 1081px) {
  #servizi { padding-top: 80px; }
}
@media (max-width: 680px) {
  /* spazio tra hero e manifesto dimezzato: 80+60 → 40+30 */
  .hero { padding-bottom: 40px; min-height: 0; }
  .manifesto { padding-top: 30px; }
  .hero h1 { font-size: clamp(3rem, 15vw, 4.6rem); }
  .hero__chip { font-size: .7rem; padding: 6px 11px; }
  .scroll-cue { display: none; }
  .bento { grid-template-columns: 1fr; }
  .bento__item--wide, .bento__item--tall { grid-column: auto; grid-row: auto; }
  .step-card { width: 84vw; padding: 30px; }
  .step-card__n { font-size: 5rem; }
}
