/* ---------- Lavori (portfolio) ----------
   Each card borrows its client's brand colours (--c0 background, --c1 accent, --c2 second accent)
   only inside the mockup stage; everything around it stays in the Invenyo system. */

.works {
  position: relative;
  padding: 18vh var(--gutter) 16vh;
  background: var(--bg);
}
.works:focus { outline: none; }
.works__title { margin: 0; max-width: 14ch; font: 500 clamp(2.6rem, 7vw, 6.8rem)/1 var(--display); letter-spacing: -0.03em; }
.works__title em, .works__title em .si {
  background: linear-gradient(100deg, #b79cff 0%, var(--cyan) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.works__title em .si { padding-right: 0.06em; }
.works__title em:has(.si) { background: none; }
.works__title em { font-size: 1.06em; }
.works__intro {
  margin-top: clamp(28px, 4vw, 44px); padding-top: 22px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; gap: 24px 48px; flex-wrap: wrap;
}
.works__intro p { margin: 0; max-width: 46ch; font-size: clamp(1.02rem, 1.2vw, 1.15rem); line-height: 1.55; color: var(--ink-dim); }
.works__intro .works__count { font: 500 12px/1 var(--sans); letter-spacing: 0.18em; text-transform: uppercase; }

.works__list {
  list-style: none; margin: clamp(56px, 9vh, 110px) 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(72px, 9vw, 140px) clamp(24px, 3vw, 44px);
}
.work--online { grid-column: 1 / -1; }
.work--online .work__card {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: clamp(32px, 4.5vw, 80px); align-items: center;
}
.work--soon .work__card { display: grid; gap: 30px; align-content: start; }

/* ---------- Stage + devices ---------- */
.work__stage {
  position: relative; display: block; overflow: hidden; isolation: isolate;
  aspect-ratio: 16 / 11; border-radius: 28px;
  container-type: inline-size;
  background:
    radial-gradient(70% 60% at 50% 100%, color-mix(in srgb, var(--c1, #7c3aed) 16%, transparent), transparent 70%),
    linear-gradient(160deg, #13131b 0%, #0c0c12 100%);
  border: 1px solid var(--line);
  text-decoration: none; color: inherit;
  transition: border-color .5s var(--ease-out);
}
.work--soon .work__stage { aspect-ratio: 16 / 10.5; }
a.work__stage:hover, a.work__stage:focus-visible { border-color: color-mix(in srgb, var(--c1) 55%, transparent); }
a.work__stage:focus-visible { outline-offset: 4px; }
.has-cursor [data-cursor] { cursor: none; }

/* light that follows the pointer inside the stage (a candle for the osteria, the brand accent for the others) */
.work__glow {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(38cqw 38cqw at var(--mx, 62%) var(--my, 40%), color-mix(in srgb, var(--c1, #7c3aed) 30%, transparent), transparent 70%);
  opacity: .55; transition: opacity .6s var(--ease-out);
}
a.work__stage:hover .work__glow { opacity: 1; }

.device { position: absolute; display: block; }
.device--laptop { left: 7%; top: 13%; width: 72%; }
.device__lid {
  display: block; padding: 1.25cqw 1.25cqw 1.6cqw;
  background: #0b0b0e; border: 1px solid rgba(255, 255, 255, .13); border-bottom: 0;
  border-radius: 1.6cqw 1.6cqw 0 0;
  box-shadow: 0 3cqw 6cqw -2cqw rgba(0, 0, 0, .7);
}
.device--laptop .device__screen { aspect-ratio: 16 / 10; border-radius: .4cqw; }
.device__base {
  display: block; position: relative; height: 1.5cqw; margin: 0 -7%;
  background: linear-gradient(#34343e, #18181e 60%, #0e0e12);
  border-radius: 0 0 1.4cqw 1.4cqw / 0 0 1.2cqw 1.2cqw;
  box-shadow: 0 1.6cqw 3cqw -1cqw rgba(0, 0, 0, .8);
}
.device__base::before { /* the notch to open the lid */
  content: ''; position: absolute; left: 50%; top: 0; width: 14%; height: 34%;
  transform: translateX(-50%); border-radius: 0 0 .8cqw .8cqw; background: #0b0b0e;
}
.device--phone {
  right: 7%; bottom: 8%; width: 20%;
  padding: .7cqw; border-radius: 3.4cqw;
  background: #0b0b0e; border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: -2cqw 3cqw 6cqw -1.5cqw rgba(0, 0, 0, .75);
}
.device--phone .device__screen { aspect-ratio: 660 / 1428; border-radius: 2.75cqw; }
.device--phone::after { /* dynamic island */
  content: ''; position: absolute; left: 50%; top: 1.5cqw; width: 30%; height: 1.4cqw;
  transform: translateX(-50%); border-radius: 1cqw; background: #000;
}
/* hover lift uses the independent `translate` property so it composes with GSAP's transforms */
.device--laptop, .device--phone { transition: translate .9s var(--ease-out); }
a.work__stage:hover .device--laptop { translate: 0 -1.2cqw; }
a.work__stage:hover .device--phone { translate: 0 -2.4cqw; }

.device__screen {
  position: relative; display: block; overflow: hidden;
  background:
    radial-gradient(90% 70% at 72% 18%, color-mix(in srgb, var(--c1, #7c3aed) 38%, transparent), transparent 60%),
    radial-gradient(70% 60% at 10% 100%, color-mix(in srgb, var(--c2, #22d3ee) 40%, transparent), transparent 65%),
    var(--c0, #0a0a0f);
}
.device__shot, .device__video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
}
.device__shot { opacity: 0; transition: opacity .8s var(--ease-out), transform 2.4s var(--ease-out); }
.device__shot.is-loaded { opacity: 1; }
.device__video { opacity: 0; transition: opacity .7s var(--ease-out); }
.is-playing .device__video { opacity: 1; }
/* no video file: a slow push-in on the screenshot instead */
a.work__stage.no-video:hover .device--laptop .device__shot,
a.work__stage:not(:has(video)):hover .device--laptop .device__shot { transform: scale(1.06); }

/* screenshot missing: a poster in the brand colours with the project name */
.device__screen.is-poster::after {
  content: attr(data-poster); position: absolute; inset: 0;
  display: grid; place-items: center; padding: 8%; text-align: center;
  font: italic 400 5cqw/1 var(--serif); color: color-mix(in srgb, var(--c1, #fff) 80%, #fff);
}
.device--phone .device__screen.is-poster::after { font-size: 2.6cqw; }

/* ---------- "In arrivo": blurred preview, not clickable ---------- */
.device__screen--soon { background: var(--c0); }
.device__screen--soon::after { /* frosted layer + skeleton lines of a page to come */
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, .18), rgba(255, 255, 255, .18)) 9% 30% / 34% 5% no-repeat,
    linear-gradient(rgba(255, 255, 255, .1), rgba(255, 255, 255, .1)) 9% 42% / 48% 3% no-repeat,
    linear-gradient(rgba(255, 255, 255, .1), rgba(255, 255, 255, .1)) 9% 49% / 40% 3% no-repeat,
    linear-gradient(rgba(10, 10, 15, .1), rgba(10, 10, 15, .35));
  backdrop-filter: blur(1.4cqw); -webkit-backdrop-filter: blur(1.4cqw);
}
.device--phone .device__screen--soon::after { background-size: 60% 3%, 76% 2%, 64% 2%, auto; background-position: 14% 22%, 14% 28%, 14% 32%, 0 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(3cqw); opacity: .85; animation: drift 14s ease-in-out infinite alternate; }
.blob--a { width: 70%; height: 90%; left: -10%; top: 20%; background: var(--c1); }
.blob--b { width: 60%; height: 80%; right: -15%; top: -25%; background: var(--c2); animation-duration: 18s; animation-delay: -6s; }
.blob--c { width: 40%; height: 50%; left: 40%; bottom: -20%; background: color-mix(in srgb, var(--c1) 50%, var(--c2)); animation-duration: 11s; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(8%, -6%) scale(1.12); } }

.badge {
  position: absolute; top: 4.5cqw; left: 4.5cqw; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  font: 500 11px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--ink);
  background: rgba(10, 10, 15, .55); border: 1px solid rgba(236, 235, 245, .18);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.badge--soon::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c1);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--c1) 70%, transparent); animation: ping 2.4s var(--ease-out) infinite;
}
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c1) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }

/* ---------- Text ---------- */
.work__info > * { margin: 0; }
.work__meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px;
  font: 500 12px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim);
}
.work__num { color: var(--cyan); }
.tag {
  padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: .14em; color: var(--ink);
}
.work__title { margin-top: 20px; font: 500 clamp(2.1rem, 3.6vw, 3.5rem)/1 var(--display); letter-spacing: -0.025em; }
.work--soon .work__title { font-size: clamp(1.7rem, 2.4vw, 2.3rem); color: var(--ink-dim); }
.work__title a {
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .6s var(--ease-out);
}
.work__title a:hover { background-size: 100% 1px; }
.work__desc { margin-top: 18px; max-width: 46ch; font-size: clamp(1.02rem, 1.15vw, 1.12rem); line-height: 1.55; color: rgba(236, 235, 245, .86); }
.work--soon .work__desc { color: var(--ink-dim); margin-top: 12px; }
.work__solves { margin-top: 26px; padding-left: 16px; border-left: 1px solid color-mix(in srgb, var(--c1) 60%, transparent); }
.work__solves p { margin: 0; max-width: 46ch; font-size: .98rem; line-height: 1.55; color: var(--ink-dim); }
.work__label, .work__solves .work__label { margin-bottom: 8px; font: 500 11px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--ink); }
.work__features { list-style: none; padding: 0; margin-top: 26px; display: flex; flex-wrap: wrap; gap: 8px; }
.work__features li { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 13.5px; line-height: 1; color: var(--ink); }
.work__palette { list-style: none; padding: 0; margin-top: 26px; display: flex; flex-wrap: wrap; gap: 10px 18px; }
.work--soon .work__palette { margin-top: 18px; }
.work__palette li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
.work__palette code { font: 500 12px/1 var(--sans); letter-spacing: .06em; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.work__actions { margin-top: 34px; display: flex; align-items: center; flex-wrap: wrap; gap: 16px 28px; }
.btn--sm { min-height: 48px; padding: 0 22px; gap: 10px; font-size: 14.5px; }
.link-arrow {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 0;
  font: 500 15px/1 var(--sans); text-decoration: none; color: var(--ink);
  background: linear-gradient(currentColor, currentColor) 0 calc(100% - 6px) / 100% 1px no-repeat;
  transition: background-size .6s var(--ease-out), gap .5s var(--ease-out);
}
.link-arrow:hover { gap: 14px; background-size: 0 1px; background-position: 100% calc(100% - 6px); }

/* ---------- "Visita" cursor ---------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none;
  width: 104px; height: 104px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font: 500 14px/1 var(--sans); letter-spacing: .02em; color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--indigo));
  box-shadow: 0 0 40px -6px rgba(124, 58, 237, .8), 0 0 70px -18px rgba(34, 211, 238, .7);
  will-change: transform;
}

/* ---------- Reduced motion ---------- */
.reduced .blob, .reduced .badge--soon::before { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .blob, .badge--soon::before { animation: none; }
  .device--laptop, .device--phone, .device__shot { transition: none; }
}

/* ---------- Tablet: one column ---------- */
@media (max-width: 960px) {
  .works__list { grid-template-columns: minmax(0, 1fr); }
  .work--online .work__card { grid-template-columns: minmax(0, 1fr); gap: 36px; }
}

/* ---------- Phone: taller stage so the phone mockup reads, chips scroll sideways ---------- */
@media (max-width: 600px) {
  .works { padding: 14vh var(--gutter) 12vh; }
  .works__title { font-size: clamp(2.5rem, 12vw, 3.2rem); }
  .work__stage, .work--soon .work__stage { aspect-ratio: 1 / 0.92; border-radius: 22px; }
  .device--laptop { left: 5%; top: 16%; width: 78%; }
  .device--phone { right: 5%; bottom: 7%; width: 28%; }
  .badge { top: 16px; left: 16px; }
  .work__title { margin-top: 16px; font-size: clamp(2rem, 9.5vw, 2.5rem); }
  .work__features {
    flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
    scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
  }
  .work__features::-webkit-scrollbar { display: none; }
  .work__features li { flex: none; }
  .work__actions { flex-direction: column; align-items: stretch; gap: 6px; }
  .link-arrow { justify-content: center; background: none; }
  .works__list { gap: 72px; }
}
.works__intro p strong { color: var(--ink); font-weight: 500; }
.works__intro p:first-child { max-width: 58ch; }
