/* ---------- Tokens ---------- */
:root {
  --bg: #fbfbfd;
  --bg-alt: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --logo-gray: #7a7b7f;
  --logo-blue: #4a9de8;
  --accent-hover: #0077ed;
  --nav-bg: rgba(251, 251, 253, 0.72);
  --dark: #000000;
  --dark-surface: #1d1d1f;
  --dark-text: #f5f5f7;
  --dark-text-2: #a1a1a6;
  --grad: linear-gradient(90deg, #0071e3 0%, #8a3ffc 50%, #ff2d55 100%);
  --radius: 28px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --glass-bg: rgba(255, 255, 255, 0.48);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-hi: rgba(255, 255, 255, 0.95);
  --glass-shadow: 0 12px 40px -14px rgba(40, 50, 90, 0.22);
  --chip: rgba(255, 255, 255, 0.55);
  --ghost: rgba(0, 0, 0, 0.09);
  --orb-1: #8ec5ff; --orb-2: #d3b5ff; --orb-3: #ffc2d1; --orb-4: #9ef0e0;
  --orb-opacity: .75;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-alt: #0b0b0c;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #2997ff;
    --logo-gray: #a1a1a6;
    --logo-blue: #4a9de8;
    --accent-hover: #47a6ff;
    --nav-bg: rgba(22, 22, 23, 0.72);
    --dark: #0b0b0c;
    --dark-surface: #1c1c1e;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --grad: linear-gradient(90deg, #2997ff 0%, #a970ff 50%, #ff5c7a 100%);
    --glass-bg: rgba(38, 38, 44, 0.42);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-hi: rgba(255, 255, 255, 0.22);
    --glass-shadow: 0 16px 48px -16px rgba(0, 0, 0, 0.7);
    --chip: rgba(255, 255, 255, 0.07);
    --ghost: rgba(255, 255, 255, 0.09);
    --orb-1: #1f5fd6; --orb-2: #6a2fd1; --orb-3: #b02a5c; --orb-4: #0c7f8a;
    --orb-opacity: .45;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-alt: #0b0b0c;
  --surface: #1c1c1e;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #2997ff;
  --logo-gray: #a1a1a6;
  --logo-blue: #4a9de8;
  --accent-hover: #47a6ff;
  --nav-bg: rgba(22, 22, 23, 0.72);
  --dark: #0b0b0c;
  --dark-surface: #1c1c1e;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --grad: linear-gradient(90deg, #2997ff 0%, #a970ff 50%, #ff5c7a 100%);
  --glass-bg: rgba(38, 38, 44, 0.42);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-hi: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 16px 48px -16px rgba(0, 0, 0, 0.7);
  --chip: rgba(255, 255, 255, 0.07);
  --ghost: rgba(255, 255, 255, 0.09);
  --orb-1: #1f5fd6; --orb-2: #6a2fd1; --orb-3: #b02a5c; --orb-4: #0c7f8a;
  --orb-opacity: .45;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }

.container { width: min(1080px, 100% - 32px); margin-inline: auto; }
.container.narrow { width: min(760px, 100% - 32px); text-align: center; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: 56px;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner {
  width: min(1080px, 100% - 32px); height: 100%; margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo { display: flex; align-items: center; height: 100%; }
.nav-logo svg { width: 26px; height: 26px; overflow: visible; }
.nav-logo .v-blue { transition: transform .4s cubic-bezier(.2,.8,.2,1); }
.nav-logo:hover .v-blue { transform: translate(-14px, -18px); }
.nav-links { display: flex; gap: 36px; font-size: 15px; }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-links a { color: var(--text); opacity: .8; transition: opacity .2s; }
.nav-links a:hover, .nav-links a.active { opacity: 1; }
.nav-toggle { display: none; }

@media (max-width: 960px) {
  .nav-toggle {
    display: flex; flex-direction: column; justify-content: center; gap: 6px;
    width: 32px; height: 32px; padding: 0 6px;
    background: none; border: 0; cursor: pointer;
  }
  .nav-toggle span { display: block; height: 1.5px; background: var(--text); border-radius: 2px; transition: transform .3s; }
  .nav.open .nav-toggle span:first-child { transform: translateY(3.75px) rotate(45deg); }
  .nav.open .nav-toggle span:last-child { transform: translateY(-3.75px) rotate(-45deg); }
  .nav-links {
    position: fixed; top: 56px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    padding: 8px 24px 24px;
    background: var(--bg);
    font-size: 24px; font-weight: 600;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity .3s, transform .3s;
  }
  .nav-links a { padding: 10px 0; opacity: 1; }
  .nav.open .nav-links { opacity: 1; transform: none; pointer-events: auto; }
  .nav.open { background: var(--bg); }
}

/* ---------- Logo ---------- */
.v-gray { fill: var(--logo-gray); }
.v-blue { fill: var(--logo-blue); }

.brand {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  margin-bottom: 40px; padding: 0;
  background: none; border: 0; color: inherit; cursor: pointer;
}
.brand-mark { width: clamp(88px, 14vw, 128px); height: auto; overflow: visible; }
.brand-name {
  font-family: "Gill Sans", "Gill Sans MT", "Lato", Calibri, var(--font);
  font-size: clamp(14px, 1.6vw, 18px); font-weight: 400;
  letter-spacing: .32em; margin-right: -.32em;
  color: var(--logo-gray);
}

/* Intro: tratto del V che si disegna, poi riempimento, poi tassello blu */
.brand .v-gray {
  stroke: var(--logo-gray); stroke-width: 6; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  fill-opacity: 0;
}
.brand .v-blue { opacity: 0; transform: translate(-60px, -90px); }
.brand .brand-name { opacity: 0; letter-spacing: .9em; }

.brand.play .v-gray {
  animation: v-draw 1.1s cubic-bezier(.65,0,.35,1) forwards,
             v-fill .6s ease-out .9s forwards;
}
.brand.play .v-blue { animation: v-drop .8s cubic-bezier(.2,1.3,.4,1) 1.25s forwards; }
.brand.play .brand-name { animation: v-name 1s cubic-bezier(.2,.8,.2,1) 1.5s forwards; }

/* Riposo: leggero respiro del tassello blu */
.brand.idle .v-gray { stroke-dashoffset: 0; fill-opacity: 1; stroke-opacity: 0; }
.brand.idle .v-blue { opacity: 1; transform: none; animation: v-float 4s ease-in-out infinite; }
.brand.idle .brand-name { opacity: 1; letter-spacing: .32em; }
.brand:hover.idle .v-blue { animation-duration: 1.2s; }

@keyframes v-draw { to { stroke-dashoffset: 0; } }
@keyframes v-fill { to { fill-opacity: 1; stroke-opacity: 0; } }
@keyframes v-drop { to { opacity: 1; transform: none; } }
@keyframes v-name { to { opacity: 1; letter-spacing: .32em; } }
@keyframes v-float {
  0%, 100% { transform: none; }
  50% { transform: translate(-6px, -9px); }
}

/* ---------- Typography ---------- */
.eyebrow {
  font-size: 19px; font-weight: 600; color: var(--text-2);
  margin-bottom: 12px;
}
.gradient-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.section-title { font-size: clamp(40px, 6vw, 64px); line-height: 1.06; margin-bottom: 24px; }
.lead { font-size: clamp(19px, 2vw, 24px); line-height: 1.4; color: var(--text-2); max-width: 720px; font-weight: 500; }
.narrow .lead { margin-inline: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 22px;
  border-radius: 980px;
  font-size: 17px; font-weight: 400;
  transition: background .2s, transform .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.btn-secondary:hover { background: var(--accent); color: #fff; }
.link-arrow { color: var(--accent); font-size: 17px; }
.link-arrow::after { content: " ›"; transition: margin .2s; }
.link-arrow:hover { text-decoration: underline; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh; min-height: 100svh;
  padding: 120px 16px 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.hero-title {
  font-size: clamp(56px, 11vw, 128px);
  line-height: 1; font-weight: 700; letter-spacing: -0.04em;
}
.hero-sub {
  margin-top: 24px;
  font-size: clamp(19px, 2.4vw, 28px); line-height: 1.3;
  color: var(--text-2); font-weight: 500;
}
.hero-cta { margin-top: 32px; display: flex; gap: 28px; align-items: center; flex-wrap: wrap; justify-content: center; }
.hero-portrait {
  margin-top: 64px;
  width: min(320px, 70vw); aspect-ratio: 1;
  border-radius: 50%;
  padding: 4px;
  background: var(--grad);
  box-shadow: 0 30px 80px -20px rgba(138, 63, 252, 0.45);
}
.hero-portrait img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 6px solid var(--bg); }

/* ---------- Sections ---------- */
.section { padding: 120px 0; }

/* ---------- Bento ---------- */
.bento {
  margin-top: 64px;
  display: grid; gap: 20px;
  grid-template-columns: repeat(3, 1fr);
}
.tile {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px;
  min-height: 240px;
  display: flex; flex-direction: column; justify-content: flex-end;
  box-shadow: var(--shadow);
}
.section-alt .tile, .tile { border: 1px solid var(--line); }
.tile h3 { font-size: 32px; line-height: 1.1; margin: 6px 0 8px; }
.tile p { color: var(--text-2); }
.tile-kicker { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile-wide { grid-column: span 2; }
.tile-dark { background: #1d1d1f; color: #f5f5f7; border-color: transparent; }
.tile-dark p { color: #a1a1a6; }
.tile-dark h3 { font-size: clamp(36px, 5vw, 56px); }
.tile-gradient { background: var(--grad); color: #fff; border-color: transparent; }
.tile-gradient p { color: rgba(255,255,255,.85); }
.tile-blue { background: linear-gradient(160deg, #5ac8fa, #0071e3); color: #fff; border-color: transparent; }
.tile-blue p { color: rgba(255,255,255,.85); }
.big-number { font-size: 72px !important; font-weight: 700; letter-spacing: -0.04em; }
.bento .tile:nth-child(4) { grid-column: span 2; }
.bento .tile:nth-child(5) { grid-column: 1 / -1; min-height: 200px; }

@media (max-width: 860px) {
  .bento { grid-template-columns: 1fr 1fr; }
  .tile-wide, .bento .tile:nth-child(4) { grid-column: span 2; }
.bento .tile:nth-child(5) { grid-column: 1 / -1; min-height: 200px; }
}
@media (max-width: 560px) {
  .bento { grid-template-columns: 1fr; }
  .tile-wide, .bento .tile:nth-child(4), .bento .tile:nth-child(5) { grid-column: auto; }
  .tile { padding: 28px; min-height: 200px; }
}

/* ---------- Experience: timeline ---------- */
.timeline-wrap { position: relative; margin-top: 72px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px; }
.tl-line {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%);
  background: var(--line); border-radius: 2px; overflow: hidden;
}
.tl-fill {
  position: absolute; inset: 0 0 auto 0; height: 0;
  background: linear-gradient(180deg, #2997ff, #a970ff 60%, #ff5c7a);
  box-shadow: 0 0 12px rgba(41,151,255,.8);
  transition: height .15s linear;
}
.tl-item { position: relative; display: grid; grid-template-columns: 1fr 1fr; column-gap: 96px; }
.tl-left .job { grid-column: 1; }
.tl-right .job { grid-column: 2; margin-top: 120px; }
.tl-item + .tl-item { margin-top: -96px; }
.tl-node {
  position: absolute; left: 50%; top: 44px; z-index: 2;
  width: 22px; height: 22px; margin-left: -11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  transition: border-color .4s, box-shadow .4s;
}
.tl-right .tl-node { top: 164px; }
.tl-node::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background: transparent; transition: background .4s;
}
.tl-item.is-active .tl-node { border-color: var(--accent); box-shadow: 0 0 0 6px rgba(41,151,255,.15), 0 0 18px rgba(41,151,255,.55); }
.tl-item.is-active .tl-node::after { background: var(--accent); }
.tl-item.is-current .tl-node::before {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 1px solid var(--accent); opacity: 0; animation: ring 2.4s ease-out infinite;
}
@keyframes ring { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }

.job { display: grid; grid-template-columns: 116px 1fr; gap: 0; padding: 0; }
/* freccia verso la linea */
.job::after {
  content: ""; position: absolute; top: 42px; width: 14px; height: 14px;
  background: inherit; border: inherit; border-width: 1px 1px 0 0;
  -webkit-backdrop-filter: inherit; backdrop-filter: inherit;
}
.tl-left .job::after { right: -8px; transform: rotate(45deg); }
.tl-right .job::after { left: -8px; transform: rotate(-135deg); }
.job-logo {
  display: grid; place-items: center; padding: 24px 14px;
  border-right: 1px solid var(--line);
}
.job-logo img {
  width: 84px; height: 84px; object-fit: contain; padding: 10px;
  background: #fff; border-radius: 20px;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.35);
}
.job-body { padding: 28px 30px 30px; min-width: 0; }
.job-when {
  font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.job h3 { font-size: 22px; line-height: 1.2; margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-org { color: var(--text); opacity: .75; font-weight: 500; font-size: 15px; margin: 4px 0 12px; }
.job-body > p[data-i18n] { color: var(--text-2); font-size: 15px; line-height: 1.5; }
.now {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 980px;
  background: rgba(52, 199, 89, .16); color: #1f9d48;
}
:root[data-theme="dark"] .now { color: #4cd964; }
.now .dot { width: 6px; height: 6px; border-radius: 50%; background: #34c759; }
.tags { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: 12px; padding: 4px 11px; border-radius: 980px; background: var(--chip); border: 1px solid var(--glass-border); }

@media (max-width: 860px) {
  .tl-line { left: 11px; transform: none; }
  .tl-item { grid-template-columns: 1fr; padding-left: 44px; }
  .tl-item + .tl-item { margin-top: 0; }
  .tl-left .job, .tl-right .job { grid-column: 1; margin-top: 0; }
  .tl-node, .tl-right .tl-node { left: 0; margin-left: 0; top: 40px; }
  .tl-left .job::after, .tl-right .job::after { left: -8px; right: auto; transform: rotate(-135deg); }
}
@media (max-width: 520px) {
  .job { grid-template-columns: 1fr; }
  .job-logo { border-right: 0; border-bottom: 1px solid var(--line); justify-content: start; padding: 20px 24px 16px; }
  .job-body { padding: 20px 24px 26px; }
}

/* ---------- Education ---------- */
/* Intestazione di sezione: parola fantasma + sottotitolo spaziato + titolo maiuscolo */
.sec-head { position: relative; min-height: clamp(150px, 20vw, 230px); display: flex; align-items: flex-end; margin-bottom: 8px; }
.sec-ghost {
  position: absolute; top: -10px; z-index: 0; pointer-events: none;
  font-size: clamp(72px, 16vw, 200px); font-weight: 800; line-height: 1; letter-spacing: -0.04em;
  color: transparent; -webkit-text-stroke: 1.5px var(--ghost); user-select: none; white-space: nowrap;
}
.sec-heading { position: relative; }
.sec-eyebrow {
  display: inline-block; font-size: 14px; font-weight: 600; letter-spacing: .6em; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sec-title {
  font-size: clamp(44px, 8vw, 96px); font-weight: 800; line-height: 1; letter-spacing: -0.02em;
  text-transform: uppercase; margin-top: 10px;
}
.sec-title::after { content: "."; }
.sec-right { justify-content: flex-end; text-align: right; }
.sec-right .sec-ghost { left: -8px; }
.sec-right .sec-eyebrow { margin-right: -.6em; }
.sec-left { justify-content: flex-start; text-align: left; }
.sec-left .sec-ghost { right: -8px; }
.sec-center { justify-content: center; text-align: center; }
.sec-center .sec-ghost { left: 50%; transform: translateX(-50%); }
.sec-center .sec-eyebrow { margin-right: -.6em; }
.sec-sub { font-size: clamp(28px, 4vw, 44px); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin: 48px 0 20px; }
.sec-head + .lead, .sec-head + .timeline-wrap, .sec-head + .edu { margin-top: 40px; }
.sec-head + .lead { margin-top: 48px; }
.contact .sec-sub { margin-top: 40px; }
@media (max-width: 860px) {
  .sec-head { min-height: 140px; }
}

.edu { margin-top: 64px; display: grid; gap: 28px; grid-template-columns: repeat(3, 1fr); align-items: start; }
.edu-card {
  text-align: center; padding: 44px 30px 46px;
  display: flex; flex-direction: column; align-items: center;
}
.edu-card:nth-child(2) { margin-top: 60px; }
.edu-card:nth-child(3) { margin-top: 120px; }
.edu-logo {
  width: 104px; height: 104px; border-radius: 50%; margin-bottom: 22px;
  background: #fff; display: grid; place-items: center; padding: 6px;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.4);
  transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.edu-card:hover .edu-logo { transform: rotate(-8deg) scale(1.05); }
.edu-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.edu-logo { overflow: hidden; }
.edu-logo-square { border-radius: 26px; padding: 4px; }
.edu-logo-square img { border-radius: 20px; }
.edu-when { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--text-2); }
.edu-card h3 { font-size: 22px; line-height: 1.25; margin: 8px 0 6px; }
.edu-field { font-weight: 500; }
.edu-school { color: var(--text-2); font-size: 15px; margin-top: 14px; }
.edu-thesis { color: var(--text-2); font-size: 15px; line-height: 1.6; margin-top: 18px; }
.edu-thesis strong { color: var(--text); }
.edu-featured {
  background: linear-gradient(150deg, rgba(41,151,255,.85), rgba(169,112,255,.8) 55%, rgba(255,92,122,.78)) !important;
  border-color: rgba(255,255,255,.45) !important; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 30px 60px -24px rgba(138,63,252,.6) !important;
}
.edu-featured .edu-when, .edu-featured .edu-school, .edu-featured .edu-thesis { color: rgba(255,255,255,.85); }
.edu-featured .edu-thesis strong { color: #fff; }
@media (max-width: 860px) {
  .edu { grid-template-columns: 1fr; max-width: 520px; margin-inline: auto; }
  .edu-card:nth-child(2), .edu-card:nth-child(3) { margin-top: 0; }
}

/* ---------- Projects ---------- */
.projects { margin-top: 56px; display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; }
.projects .card { flex: 0 1 calc((100% - 40px) / 3); min-width: 280px; }
@media (max-width: 920px) { .projects .card { flex-basis: calc((100% - 20px) / 2); } }
@media (max-width: 620px) { .projects .card { flex-basis: 100%; min-width: 0; } }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform .4s cubic-bezier(.2,.8,.2,1), box-shadow .4s;
}
.card:hover { transform: translateY(-6px) scale(1.01); box-shadow: 0 24px 48px -12px rgba(0,0,0,.18); }
.card-media {
  aspect-ratio: 16 / 10;
  display: grid; place-items: center;
}
.app-icon {
  width: 132px; height: 132px; border-radius: 30px;
  background: #fff; object-fit: contain;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.35);
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
}
.card:hover .app-icon { transform: scale(1.06) rotate(-2deg); }
.media-spinoff { background: radial-gradient(circle at 30% 20%, #bfe0ff, #0a4c9c 70%); }
.app-icon-pad { padding: 10px; }
.media-cargo { background: radial-gradient(circle at 30% 20%, #e3c8ff, #7b5cff 70%); }
.media-newlang { background: radial-gradient(circle at 30% 20%, #ffd89a, #ff7a18 70%); }
.media-caz { background: radial-gradient(circle at 30% 20%, #c9f7ff, #30b0c7 70%); }
.media-n7 { background: radial-gradient(circle at 30% 20%, #b8f5c8, #1f8f4a 70%); }
.media-avatar { background: radial-gradient(circle at 30% 20%, #d9d4ff, #5e5ce6 70%); }
.card-body { padding: 24px 28px 30px; }
.card-tag { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.card h3 { font-size: 24px; margin: 6px 0 8px; }
.card-body p:last-child { color: var(--text-2); font-size: 15px; }
.more { margin-top: 40px; text-align: center; }

/* ---------- Clients ---------- */
.clients { margin-top: 56px; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.client {
  padding: 36px; border-radius: var(--radius);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .3s;
}
.client:hover { transform: translateY(-4px); }
.client h3 { font-size: 26px; }
.client-logo {
  height: 96px; border-radius: 18px; background: #fff;
  display: grid; place-items: center; padding: 12px 20px; margin-bottom: 8px;
  border: 1px solid rgba(0,0,0,.06);
}
.client-logo img { max-height: 72px; max-width: 100%; object-fit: contain; }
.client-logo .logo-square { height: 64px; border-radius: 14px; }
.client p { color: var(--text-2); flex: 1; }

/* ---------- Lang switch ---------- */
.lang-switch {
  display: inline-flex; padding: 3px; border-radius: 980px;
  background: var(--line);
}
.lang-switch button {
  font: inherit; font-size: 13px; font-weight: 600;
  min-width: 38px; height: 28px; padding: 0 10px;
  border: 0; border-radius: 980px; cursor: pointer;
  background: transparent; color: var(--text-2);
  transition: background .25s, color .25s;
}
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.15); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--line); color: var(--text);
  transition: background .25s, transform .4s cubic-bezier(.2,.8,.2,1);
}
.theme-toggle:hover { transform: rotate(20deg); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Badges ---------- */
.tile-certs { justify-content: center; padding-inline: 24px; }
.badge-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0 4px; }
.badge-mini { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; min-width: 0; }
.badge-mini svg { width: clamp(52px, 5vw, 64px); height: clamp(52px, 5vw, 64px); margin-bottom: 4px; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.badge-mini:hover svg { transform: rotate(-12deg) scale(1.06); }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbc05; box-shadow: 0 0 0 0 rgba(251,188,5,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(251,188,5,0); } 100% { box-shadow: 0 0 0 0 rgba(251,188,5,0); } }

.certs { margin-top: 56px; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cert {
  display: flex; align-items: center; gap: 24px;
  background: var(--dark-surface); border-radius: var(--radius); padding: 28px 32px;
}
.cert-badge { width: 96px; height: 96px; flex: none; }
.cert-issuer { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.cert h3 { font-size: 22px; line-height: 1.2; margin: 4px 0 10px; }
.cert .status { color: var(--text-2); }
.cert-link { transition: transform .4s cubic-bezier(.2,.8,.2,1), box-shadow .4s; }
.cert-link:hover { transform: translateY(-4px); box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 24px 48px -16px rgba(26,115,232,.45); }
.cert-view { margin-top: 10px; font-size: 14px; color: var(--accent); }
.cert-link:hover .cert-view { text-decoration: underline; }
.status.done .dot { background: #34c759; animation: none; }
.badge-mini .status { font-size: 11px; font-weight: 500; gap: 5px; margin-top: auto; }
.cert-done { font-size: 14px; color: var(--text-2); margin-bottom: 8px; }
.cert-done span { color: var(--text); font-weight: 600; }
.cert-other { margin-top: 20px; font-size: 15px; color: var(--text-2); }
.cert-other span { color: var(--text); font-weight: 600; }

/* ---------- Skills ---------- */
.skills { margin-top: 20px; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.skill-group { background: var(--dark-surface); border-radius: var(--radius); padding: 32px; }
.skill-group h3 { font-size: 21px; margin-bottom: 18px; }
.skill-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.skill-group li {
  font-size: 14px; padding: 6px 14px; border-radius: 980px;
  background: rgba(255,255,255,.08); color: var(--text);
}

/* ---------- Contact ---------- */
.contact { padding: 160px 0; }
.socials { margin-top: 40px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.footer { position: relative; border-top: 1px solid var(--line); padding: 20px 0; font-size: 12px; color: var(--text-2); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer a:hover { text-decoration: underline; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(32px); transition: opacity .9s cubic-bezier(.2,.8,.2,1), transform .9s cubic-bezier(.2,.8,.2,1); }
.reveal.visible { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .card, .client, .btn { transition: none; }
  .brand .v-gray, .brand .v-blue, .brand .brand-name { animation: none !important; }
  .brand .v-gray { stroke-dashoffset: 0; fill-opacity: 1; stroke-opacity: 0; }
  .brand .v-blue { opacity: 1; transform: none; }
  .brand .brand-name { opacity: 1; letter-spacing: .32em; }
}

@media (max-width: 560px) {
  .section { padding: 88px 0; }
  .contact { padding: 112px 0; }
  .hero-portrait { margin-top: 48px; }
}

/* =========================================================
   Liquid Glass
   ========================================================= */
body { background: var(--bg); }
main, .footer { position: relative; z-index: 1; }

/* Fondo ambientale: sfere di colore sfocate che si muovono lentamente */
.ambient { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.ambient span {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%;
  filter: blur(80px); opacity: var(--orb-opacity);
  animation: drift 28s ease-in-out infinite alternate;
}
.ambient span:nth-child(1) { background: var(--orb-1); top: -12vmax; left: -10vmax; }
.ambient span:nth-child(2) { background: var(--orb-2); top: 20vh; right: -14vmax; animation-duration: 34s; animation-delay: -8s; }
.ambient span:nth-child(3) { background: var(--orb-3); bottom: -16vmax; left: 20vw; animation-duration: 40s; animation-delay: -16s; }
.ambient span:nth-child(4) { background: var(--orb-4); top: 45vh; left: -18vmax; width: 34vmax; height: 34vmax; animation-duration: 31s; animation-delay: -4s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vw, 6vh) scale(1.12); }
  100% { transform: translate(-6vw, 10vh) scale(.95); }
}

/* Materiale vetro */
.glass, .tile, .card, .client, .job, .edu-card, .cert, .skill-group,
.nav-inner, .lang-switch, .theme-toggle, .btn-secondary, .nav-links-panel {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(26px) saturate(185%);
  backdrop-filter: blur(26px) saturate(185%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 rgba(255,255,255,.08), var(--glass-shadow);
  border-radius: var(--radius);
}
/* Riflesso speculare che segue il puntatore */
.tile::before, .card::before, .client::before, .job::before, .edu-card::before, .cert::before, .skill-group::before, .btn-primary::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1;
  background: radial-gradient(420px circle at var(--mx, 20%) var(--my, -20%), rgba(255,255,255,.28), transparent 45%);
  opacity: .7; transition: opacity .4s;
  mix-blend-mode: soft-light;
}
:root[data-theme="dark"] .tile::before, :root[data-theme="dark"] .card::before, :root[data-theme="dark"] .client::before,
:root[data-theme="dark"] .job::before, :root[data-theme="dark"] .edu-card::before, :root[data-theme="dark"] .cert::before,
:root[data-theme="dark"] .skill-group::before { mix-blend-mode: normal; background: radial-gradient(420px circle at var(--mx, 20%) var(--my, -20%), rgba(255,255,255,.09), transparent 45%); }
.tile:hover::before, .card:hover::before, .client:hover::before, .job:hover::before, .edu-card:hover::before, .cert:hover::before, .skill-group:hover::before { opacity: 1; }

/* Bordo rifrangente */
.tile, .card, .client, .job, .edu-card, .cert, .skill-group { isolation: isolate; }
.tile > *, .card > *, .client > *, .job > *:not(.job-logo), .edu-card > *, .cert > *, .skill-group > * { position: relative; z-index: 2; }
.job-logo { position: relative; z-index: 2; }

.tile, .card, .client, .job, .edu-card, .cert, .skill-group {
  transition: transform .5s cubic-bezier(.2,.8,.2,1), box-shadow .5s;
}
.tile:hover, .client:hover, .job:hover, .edu-card:hover, .cert:hover, .skill-group:hover { transform: translateY(-4px); }

/* Tile colorati: vetro tinto */
.tile-dark { background: rgba(20,20,24,.72); color: #f5f5f7; border-color: rgba(255,255,255,.16); }
.tile-gradient { background: linear-gradient(120deg, rgba(41,151,255,.82), rgba(169,112,255,.78) 50%, rgba(255,92,122,.78)); border-color: rgba(255,255,255,.4); }
.tile-blue { background: linear-gradient(160deg, rgba(90,200,250,.8), rgba(0,113,227,.82)); border-color: rgba(255,255,255,.4); }

/* Nav: pillola fluttuante */
.nav { height: auto; top: 12px; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.nav-inner { width: min(1120px, 100% - 24px); height: 56px; padding: 0 12px 0 20px; border-radius: 980px; }
.nav.scrolled .nav-inner { --glass-bg: color-mix(in srgb, var(--bg) 62%, transparent); }
html { scroll-padding-top: 84px; }
.lang-switch { border-radius: 980px; padding: 3px; box-shadow: inset 0 1px 0 var(--glass-hi); }
.lang-switch button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.6); }
.theme-toggle { border-radius: 50%; }
@media (max-width: 960px) {
  .nav-links {
    top: 76px; left: 12px; right: 12px; border-radius: 28px;
    background: var(--glass-bg); -webkit-backdrop-filter: blur(30px) saturate(185%); backdrop-filter: blur(30px) saturate(185%);
    border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  }
  .nav.open { background: none; }
}

/* Bottoni */
.btn-primary {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 24px -10px var(--accent);
}
.btn-primary::before { opacity: 1; mix-blend-mode: normal; background: linear-gradient(180deg, rgba(255,255,255,.25), transparent 55%); }
.btn-secondary { border-radius: 980px; color: var(--accent); }
.btn-secondary:hover { background: var(--glass-bg); color: var(--accent); transform: translateY(-1px); }

/* Ritratto con anello di vetro */
.hero-portrait { background: var(--glass-bg); border: 1px solid var(--glass-border); padding: 10px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 30px 80px -20px rgba(138,63,252,.45); }
.hero-portrait img { border: 0; }

/* Card progetti e collaborazioni */
.card-media { position: relative; }
.card-media::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; background: linear-gradient(transparent, rgba(255,255,255,.12)); }
.client-logo { background: rgba(255,255,255,.92); border-color: rgba(255,255,255,.8); }

.footer { background: none; }

@media (prefers-reduced-motion: reduce) {
  .ambient span { animation: none; }
  .tl-item.is-current .tl-node::before { animation: none; }
  .tl-fill { transition: none; }
}

/* Contatti: presentazione a scorrimento, stile keynote */
.contact-show { padding-bottom: 0; }
.show-track { position: relative; height: 280vh; margin-top: 8px; }
.show-stage {
  --p0: 1; --p1: 1; --p2: 1; --p3: 1;
  --dev-w: min(calc(100svh - 300px), 620px, 46vw);
  --copy-w: min(460px, 34vw);
  --gap: clamp(40px, 5vw, 80px);
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: grid; place-items: center; padding: 0 16px;
}
.show-title {
  position: absolute; top: 92px; left: 0; right: 0; margin: 0;
  font-size: clamp(40px, 6vw, 88px); font-weight: 700; letter-spacing: -.03em; line-height: 1.02; text-align: center;
  opacity: calc(var(--p0) * (1 - var(--p3)));
  filter: blur(calc((1 - var(--p0)) * 14px + var(--p3) * 8px));
  transform: translateY(calc((1 - var(--p0)) * 40px - var(--p3) * 60px));
}
.show-glow {
  position: absolute; left: 50%; top: 50%; width: min(1000px, 130vw); aspect-ratio: 1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(41,151,255,.55), rgba(138,63,252,.35) 45%, transparent 72%);
  filter: blur(40px);
  opacity: calc(.15 + var(--p1) * .75);
  transform: translate(calc(-50% - var(--p3) * (var(--copy-w) + var(--gap)) / 2), -50%) scale(calc(.6 + var(--p1) * .4));
}
.show-scene {
  position: relative; display: grid; align-items: center;
  grid-template-columns: var(--dev-w) var(--copy-w); gap: var(--gap);
  perspective: 1600px;
}
.show-device {
  position: relative; margin: 0; width: var(--dev-w); padding: 12px; border-radius: 52px;
  background: linear-gradient(145deg, rgba(255,255,255,.55), rgba(41,151,255,.35) 40%, rgba(138,63,252,.4) 70%, rgba(255,255,255,.3));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 0 0 1px rgba(255,255,255,.25),
    0 calc(20px + var(--p1) * 50px) calc(40px + var(--p1) * 100px) -30px rgba(20,30,80,.65);
  opacity: calc(.25 + var(--p1) * .75);
  transform:
    translate3d(calc((1 - var(--p3)) * (var(--copy-w) + var(--gap)) / 2), calc((1 - var(--p1)) * 26vh + (1 - var(--p3)) * 56px), 0)
    rotateX(calc((1 - var(--p1)) * 34deg))
    scale(calc(.6 + var(--p1) * .4));
  will-change: transform;
}
.show-device img { display: block; width: 100%; height: auto; border-radius: 40px; image-rendering: pixelated; }
.show-shine {
  position: absolute; inset: 12px; border-radius: 40px; overflow: hidden; pointer-events: none;
  opacity: calc(var(--p2) * (1 - var(--p2)) * 4);
}
.show-shine::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  transform: translateX(calc(-120% + var(--p2) * 360%)) skewX(-14deg);
}
.show-eye {
  position: absolute; top: 69.4%; width: 2.6%; height: 4.6%; border-radius: 3px;
  background: #bff3ff; box-shadow: 0 0 10px 3px rgba(90,220,255,.9), 0 0 28px 8px rgba(41,151,255,.6);
  opacity: 0; transition: opacity .6s;
}
.show-eye-l { left: 37.2%; }
.show-eye-r { left: 41.6%; }
.show-stage.is-live .show-eye { opacity: 1; animation: eye-blink 4.2s infinite; }
@keyframes eye-blink { 0%, 44%, 50%, 100% { transform: scaleY(1); } 47% { transform: scaleY(.1); } }
.show-copy {
  text-align: left; opacity: var(--p3); pointer-events: none;
  transform: translateX(calc((1 - var(--p3)) * 120px));
  filter: blur(calc((1 - var(--p3)) * 10px));
}
.show-stage.is-split .show-copy { pointer-events: auto; }
.show-copy-title { font-size: clamp(36px, 4.2vw, 64px); font-weight: 700; letter-spacing: -.03em; line-height: 1.04; margin: 0; }
.show-copy .lead { font-size: clamp(18px, 1.6vw, 22px); margin-top: 20px; }
.show-copy .socials { justify-content: flex-start; margin-top: 32px; }
.pixel-bubble {
  position: absolute; left: -18px; bottom: 36%; z-index: 2;
  font: 700 clamp(14px, 1.2vw, 18px)/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em;
  padding: 10px 14px; border-radius: 16px 16px 16px 4px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #8a3ffc);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 24px -8px rgba(41,151,255,.7);
  transform: scale(0); transform-origin: 0 100%; transition: transform .5s cubic-bezier(.3,1.6,.5,1);
}
.show-stage.is-live .pixel-bubble { transform: scale(1); }
@media (max-width: 820px) {
  .show-track { height: 240vh; }
  .show-stage { --dev-w: min(80vw, calc(100svh - 400px)); }
  .show-title { position: static; font-size: clamp(36px, 10vw, 52px); opacity: var(--p0); filter: blur(calc((1 - var(--p0)) * 14px)); transform: translateY(calc((1 - var(--p0)) * 40px)); }
  .show-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding-top: 64px; }
  .show-scene { display: flex; flex-direction: column; align-items: center; gap: 24px; }
  .show-device { border-radius: 36px; padding: 8px;
    transform: translate3d(0, calc((1 - var(--p1)) * 20vh), 0) rotateX(calc((1 - var(--p1)) * 34deg)) scale(calc(.6 + var(--p1) * .4)); }
  .show-device img, .show-shine { border-radius: 28px; }
  .show-shine { inset: 8px; }
  .show-glow { transform: translate(-50%, -50%) scale(calc(.6 + var(--p1) * .4)); }
  .show-copy { max-width: 520px; text-align: center; transform: translateY(calc((1 - var(--p3)) * 40px)); }
  .show-copy-title { display: none; }
  .show-copy .lead { margin-top: 0; }
  .show-copy .socials { justify-content: center; margin-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .show-track { height: auto; }
  .show-stage { position: relative; height: auto; min-height: 100vh; }
  .show-copy { pointer-events: auto; }
  .show-stage.is-live .show-eye { animation: none; }
}

/* Progetti: Flipper Zero Firmware Hub, presentazione a scorrimento */
.fz-track { position: relative; height: 280vh; margin-top: 24px; width: 100vw; margin-left: calc(50% - 50vw); }
.fz-stage {
  --p0: 1; --p1: 1; --p2: 1; --p3: 1;
  --dev-w: min(46vw, 600px, calc((100svh - 240px) * 1.5));
  --copy-w: min(440px, 34vw);
  --gap: clamp(40px, 5vw, 72px);
  --fz-orange: #ff8200;
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: grid; place-items: center; padding: 0 16px;
}
.fz-glow {
  position: absolute; left: 50%; top: 52%; width: min(1000px, 130vw); aspect-ratio: 1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,130,0,.5), rgba(255,92,122,.25) 45%, transparent 72%);
  filter: blur(40px);
  opacity: calc(.1 + var(--p1) * .7);
  transform: translate(calc(-50% - var(--p3) * (var(--copy-w) + var(--gap)) / 2), -50%) scale(calc(.5 + var(--p1) * .5));
}
.fz-term {
  position: absolute; top: 104px; left: 0; right: 0; margin: 0; text-align: center;
  font: 700 clamp(18px, 2.4vw, 34px)/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em;
  color: var(--text);
  opacity: calc(min(1, var(--p0) * 4) * (1 - var(--p3)));
  transform: translateY(calc(var(--p3) * -50px));
}
.fz-prompt { color: var(--fz-orange); }
.fz-caret { color: var(--fz-orange); animation: fz-caret 1s steps(1) infinite; }
@keyframes fz-caret { 50% { opacity: 0; } }
.fz-scene {
  position: relative; display: grid; align-items: center;
  grid-template-columns: var(--dev-w) var(--copy-w); gap: var(--gap);
  perspective: 1600px;
}
.fz-device {
  position: relative; display: block; width: var(--dev-w); border-radius: 24px;
  opacity: calc(.2 + var(--p1) * .8);
  transform:
    translate3d(calc((1 - var(--p3)) * (var(--copy-w) + var(--gap)) / 2), calc((1 - var(--p1)) * 34vh + (1 - var(--p3)) * 40px), 0)
    rotateX(calc((1 - var(--p1)) * 55deg))
    rotateZ(calc((1 - var(--p1)) * -28deg))
    scale(calc(.45 + var(--p1) * .55));
  filter: drop-shadow(0 calc(10px + var(--p1) * 40px) calc(20px + var(--p1) * 40px) rgba(120,50,0,.35));
  will-change: transform;
}
.fz-device img { display: block; width: 100%; height: auto; image-rendering: pixelated; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.fz-stage.is-live .fz-device img { animation: fz-float 6s ease-in-out infinite; }
.fz-stage.is-live .fz-device:hover img { animation: none; transform: translateY(-12px) rotate(-2deg) scale(1.03); }
@keyframes fz-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-14px) rotate(-1.2deg); } }
/* Schermo che si accende */
.fz-screen {
  position: absolute; left: 30%; top: 24%; width: 18%; height: 16%; border-radius: 50%; pointer-events: none;
  background: rgba(255,170,60,.9); filter: blur(28px); mix-blend-mode: screen; opacity: 0; transition: opacity .8s;
}
.fz-stage.is-live .fz-screen { opacity: .75; animation: fz-screen 2.4s ease-in-out infinite; }
@keyframes fz-screen { 50% { opacity: .4; } }
.fz-shine {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  -webkit-mask: url(assets/flipper.png) center / 100% 100% no-repeat; mask: url(assets/flipper.png) center / 100% 100% no-repeat;
  opacity: calc(var(--p2) * (1 - var(--p2)) * 4);
}
.fz-shine::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; width: 35%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.85), transparent);
  transform: translateX(calc(-120% + var(--p2) * 420%)) skewX(-14deg);
}
.fz-hint {
  position: absolute; left: 50%; bottom: -8px; transform: translate(-50%, 8px);
  font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace; padding: 8px 12px; border-radius: 980px;
  color: #fff; background: rgba(20,20,24,.78); border: 1px solid rgba(255,255,255,.2);
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; white-space: nowrap;
}
.fz-device:hover .fz-hint, .fz-device:focus-visible .fz-hint { opacity: 1; transform: translate(-50%, 0); }
.fz-copy {
  opacity: var(--p3); pointer-events: none;
  transform: translateX(calc((1 - var(--p3)) * 120px));
  filter: blur(calc((1 - var(--p3)) * 10px));
}
.fz-stage.is-split .fz-copy { pointer-events: auto; }
.fz-eyebrow { font: 700 13px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--fz-orange); margin: 0 0 14px; }
.fz-title { font-size: clamp(36px, 4.2vw, 60px); font-weight: 700; letter-spacing: -.03em; line-height: 1.04; margin: 0; }
.fz-accent { background: linear-gradient(90deg, #ff8200, #ff5c7a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fz-text { font-size: clamp(17px, 1.5vw, 20px); line-height: 1.45; color: var(--text-2); margin: 18px 0 14px; }
.fz-cta { margin-top: 20px; background: linear-gradient(180deg, #ff9a2e, #ff7300); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 24px -10px #ff8200; }
@media (max-width: 820px) {
  .fz-track { height: 240vh; }
  .fz-stage { --dev-w: min(86vw, calc((100svh - 470px) * 1.5)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding-top: 64px; }
  .fz-term { position: static; font-size: clamp(15px, 4.4vw, 20px); opacity: min(1, calc(var(--p0) * 4)); transform: none; }
  .fz-scene { display: flex; flex-direction: column; align-items: center; gap: 20px; }
  .fz-device { transform: translate3d(0, calc((1 - var(--p1)) * 24vh), 0) rotateX(calc((1 - var(--p1)) * 55deg)) rotateZ(calc((1 - var(--p1)) * -28deg)) scale(calc(.45 + var(--p1) * .55)); }
  .fz-glow { top: 45%; transform: translate(-50%, -50%) scale(calc(.5 + var(--p1) * .5)); }
  .fz-copy { max-width: 520px; text-align: center; transform: translateY(calc((1 - var(--p3)) * 40px)); }
  .fz-eyebrow { margin-bottom: 8px; }
  .fz-title { font-size: clamp(28px, 8vw, 40px); }
  .fz-title br { display: none; }
  .fz-text { font-size: 16px; margin: 10px 0 8px; }
  .fz-cta { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .fz-track { height: auto; }
  .fz-stage { position: relative; height: auto; min-height: 100vh; }
  .fz-copy { pointer-events: auto; }
  .fz-stage.is-live .fz-device img, .fz-stage.is-live .fz-screen, .fz-caret { animation: none; }
}
/* Progetti: raccordo tra il progetto in evidenza e la griglia */
.fz-track { height: 230vh; }
.projects-head {
  position: relative; z-index: 2; margin-top: -24vh;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap;
  padding-top: 28px; border-top: 1px solid var(--line);
}
.projects-sub { font-size: clamp(26px, 3vw, 36px); font-weight: 700; letter-spacing: -.02em; margin: 0; }
.projects-head p { margin: 0; color: var(--text-2); font-size: 17px; }
.projects.projects-after { margin-top: 28px; position: relative; z-index: 2; }
@media (max-width: 820px) {
  .fz-track { height: 200vh; }
  .projects-head { margin-top: -4vh; }
}
@media (prefers-reduced-motion: reduce) { .projects-head { margin-top: 48px; } }

/* Flipper: spazi calibrati sull'altezza reale del contenuto */
#projects {
  --dev-w: min(46vw, 720px, calc((100svh - 260px) * 1.5));
  --dev-h: calc(var(--dev-w) / 1.565);
  --fz-gap: calc((100svh - var(--dev-h)) / 2);
}
.fz-stage { --dev-w: inherit; }
.fz-track { margin-top: min(24px, calc(140px - var(--fz-gap))); }
.fz-term { position: absolute; top: auto; bottom: calc(100% + 28px); }
.fz-device {
  transform:
    translate3d(calc((1 - var(--p3)) * (var(--copy-w) + var(--gap)) / 2), calc((1 - var(--p1)) * 30vh), 0)
    rotateX(calc((1 - var(--p1)) * 55deg))
    rotateZ(calc((1 - var(--p1)) * -28deg))
    scale(calc(.45 + var(--p1) * .55));
}
.projects-head { margin-top: min(-24px, calc(64px - var(--fz-gap))); }
@media (max-width: 820px) {
  #projects { --dev-w: min(86vw, calc((100svh - 470px) * 1.5)); }
  .fz-track { margin-top: 0; }
  .fz-term { position: static; }
  .fz-device { transform: translate3d(0, calc((1 - var(--p1)) * 24vh), 0) rotateX(calc((1 - var(--p1)) * 55deg)) rotateZ(calc((1 - var(--p1)) * -28deg)) scale(calc(.45 + var(--p1) * .55)); }
  .projects-head { margin-top: -4vh; }
}
@media (prefers-reduced-motion: reduce) { .fz-track { margin-top: 24px; } .projects-head { margin-top: 48px; } }
/* Flipper: riga del terminale a metà tra la barra di navigazione e il dispositivo */
.fz-term { bottom: calc(100% + max(28px, (var(--fz-gap) - 100px) / 2)); font-size: clamp(18px, 2vw, 28px); }
@media (max-width: 820px) { .fz-term { font-size: clamp(15px, 4.4vw, 20px); } }
/* Flipper: prima dell'aggancio la riga del terminale resta sotto il testo introduttivo */
.fz-track { margin-top: min(24px, max(72px - var(--fz-gap) / 2, 150px - var(--fz-gap))); }
@media (max-width: 820px) { .fz-track { margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { .fz-track { margin-top: 24px; } }
/* Flipper: nel finale la riga del terminale resta e segue il dispositivo, senza lasciare vuoti */
@media (min-width: 821px) {
  .fz-term {
    opacity: min(1, calc(var(--p0) * 4));
    transform: translateX(calc(var(--p3) * (var(--copy-w) + var(--gap)) / -2));
  }
}

/* Prestazioni: niente filtri ricalcolati a ogni frame durante lo scroll */
.show-glow, .fz-glow { filter: none; }
.show-glow { background: radial-gradient(closest-side, rgba(41,151,255,.42), rgba(138,63,252,.24) 50%, transparent 80%); }
.fz-glow { background: radial-gradient(closest-side, rgba(255,130,0,.36), rgba(255,92,122,.16) 50%, transparent 80%); }
.show-title, .show-copy, .fz-copy { filter: none; }
.fz-device { filter: none; }
.fz-device::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: -10%; height: 22%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(120,50,0,.2), transparent);
  opacity: var(--p1);
}
.fz-screen { filter: none; mix-blend-mode: normal; background: radial-gradient(closest-side, rgba(255,170,60,.55), transparent); width: 30%; height: 34%; left: 24%; top: 14%; }
.show-stage, .fz-stage { contain: paint; }
.show-device, .fz-device, .show-copy, .fz-copy, .show-title, .fz-term { will-change: transform, opacity; }
.ambient span { will-change: transform; }
@media (max-width: 820px) {
  .ambient span { animation: none; }
  .fz-track { height: 170vh; }
  .show-track { height: 200vh; }
  .fz-term { margin-bottom: clamp(20px, 4vh, 40px); }
  .show-title { filter: none; }
}
/* Flipper: scalatura morbida durante l'animazione, evita lo sfarfallio dei pixel */
.fz-device img { image-rendering: auto; }

/* Altre certificazioni: link ai certificati */
.cert-other { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.cert-chip {
  display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 980px; font-size: 14px; font-weight: 500;
  color: var(--accent); background: var(--glass-bg); border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), background .3s;
}
.cert-chip:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--accent) 12%, var(--glass-bg)); }

/* dryflash featured: actions + companion hub */
.fz-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 20px; }
.fz-actions .fz-cta { margin-top: 0; }
.fz-code { border-color: #ff8200; color: #ff7300; box-shadow: inset 0 0 0 1px #ff8200; }
.fz-companion {
  display: grid; gap: 2px; margin-top: 22px; padding: 14px 18px; border-radius: 18px;
  text-decoration: none; color: inherit;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  transition: transform .25s ease, box-shadow .25s ease;
}
.fz-companion:hover { transform: translateY(-2px); border-color: rgba(255,130,0,.6); }
.fz-companion-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.fz-companion-name { font-weight: 600; font-size: 16px; color: #ff7300; }
.fz-companion-text { font-size: 14px; color: var(--text-2); line-height: 1.4; }
@media (max-width: 820px) {
  .fz-actions { justify-content: center; flex-wrap: nowrap; gap: 8px; margin-top: 10px; }
  .fz-actions .btn { padding: 10px 16px; font-size: 15px; white-space: nowrap; }
  .fz-companion { text-align: center; margin-top: 12px; padding: 10px 14px; }
  .fz-companion-text { display: none; }
}

/* Spazio extra quando il testo del progetto in evidenza è più alto del Flipper */
@media (min-width: 821px) {
  .projects-head { margin-top: min(-24px, calc(64px + var(--fz-over, 0px) - var(--fz-gap))); }
}

/* Flipper: la riga del terminale si aggancia al dispositivo, non alla colonna di testo (schermi bassi, es. MacBook 14") */
@media (min-width: 821px) {
  .fz-term { bottom: calc(50% + var(--dev-h) / 2 + max(28px, (var(--fz-gap) - 100px) / 2)); }
}
@media (min-width: 821px) and (max-height: 860px) {
  .fz-title { font-size: clamp(32px, min(4.2vw, 6.4vh), 60px); }
  .fz-text { margin: 14px 0 10px; }
  .fz-companion { margin-top: 16px; }
}
/* Flipper su colonna singola: il dispositivo si ridimensiona per lasciare spazio a riga del terminale e testo */
@media (max-width: 820px) and (prefers-reduced-motion: no-preference) {
  #projects { --dev-w: max(200px, min(86vw, 560px, calc((100svh - 84px - 16px - 72px - 40px - var(--fz-copy-h, 380px)) * 1.565))); }
  .fz-stage { padding-top: 84px; padding-bottom: 16px; }
  .projects-head { margin-top: 0; }
}
/* Flipper su desktop basso: pulsanti su una riga e box del Hub compatto */
@media (min-width: 821px) and (max-height: 760px) {
  .fz-actions { flex-wrap: nowrap; gap: 8px; }
  .fz-actions .btn { padding: 10px 16px; font-size: 15px; white-space: nowrap; }
  .fz-companion { padding: 10px 14px; }
  .fz-companion-text { display: none; }
}
