:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --ink: #1b1916;
  --muted: #5f5850;
  --line: #e7e1d9;
  --accent: #2f4ad0;
  --bw: #c73869;
  --pz: #c8341d;
  --st: #23746b;
  --radius: 22px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1b1a18;
    --ink: #efebe5;
    --muted: #a9a198;
    --line: #2e2b28;
    --accent: #93a5ff;
    --bw: #f07aa5;
    --pz: #f2765f;
    --st: #6cc3b8;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  position: relative;
  isolation: isolate;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wrap { width: 100%; max-width: 1100px; margin-inline: auto; padding-inline: 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* Header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px clamp(16px, 3vw, 28px); padding-block: 20px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; text-decoration: none; white-space: nowrap; margin-right: auto; }
/* Sotto i 520px il menu va su una seconda riga: marchio e lingua restano in alto */
@media (max-width: 519px) { .nav { order: 1; width: 100%; } }
.lang { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .85rem; font-weight: 600; text-decoration: none; transition: color .2s ease, border-color .2s ease; }
.lang:hover { color: var(--ink); border-color: var(--ink); }
.flag { width: 21px; height: 14px; flex: none; border-radius: 3px; box-shadow: 0 0 0 1px var(--line); }
.nav { display: flex; gap: clamp(12px, 3vw, 28px); font-size: clamp(.875rem, 2.4vw, .95rem); white-space: nowrap; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--ink); }

/* Hero */
.hero { padding-block: clamp(3.5rem, 11vw, 7.5rem) clamp(3rem, 8vw, 5.5rem); }
/* Bagliore con i colori dei tre progetti, dietro header e hero senza stacchi */
body::before {
  content: "";
  position: absolute; top: -240px; left: 0; right: 0; height: 1100px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 45% at 18% 30%, color-mix(in srgb, var(--bw) 28%, transparent), transparent 70%),
    radial-gradient(32% 40% at 62% 18%, color-mix(in srgb, var(--pz) 20%, transparent), transparent 70%),
    radial-gradient(36% 45% at 88% 62%, color-mix(in srgb, var(--st) 24%, transparent), transparent 70%);
  filter: blur(40px);
}
.eyebrow { display: inline-flex; align-items: baseline; gap: 10px; font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bw); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bw) 20%, transparent); }
.hero h1 { font-size: clamp(3.2rem, 12vw, 7.75rem); letter-spacing: -.025em; line-height: .95; margin-block: 18px 26px; }
.lead { font-size: clamp(1.15rem, 2.3vw, 1.45rem); line-height: 1.5; max-width: 40ch; color: var(--muted); }
.lead strong { color: var(--ink); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 34px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 22px; border-radius: 999px; font-weight: 600; font-size: 1rem; text-decoration: none; border: 1px solid var(--line); background: var(--surface); transition: transform .2s ease, border-color .2s ease; }
.btn:hover { transform: translateY(-2px); border-color: var(--ink); }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.socials { display: flex; gap: 8px; margin-left: 4px; }
.socials a { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); transition: color .2s ease, border-color .2s ease; }
.socials a:hover { color: var(--ink); border-color: var(--ink); }

.stats { display: grid; gap: 1px; margin-top: clamp(3rem, 8vw, 5rem); background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stats div { background: var(--surface); padding: 22px 24px; }
.stats strong { display: block; font-family: var(--serif); font-size: 2.2rem; line-height: 1; }
.stats span { font-size: .95rem; color: var(--muted); }

/* Sections */
section { padding-block: clamp(3.5rem, 9vw, 6rem); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 32px; margin-bottom: 32px; }
.section-head h2, .about h2, .contact h2 { font-size: clamp(2.1rem, 5vw, 3.2rem); letter-spacing: -.015em; }
.section-head p { color: var(--muted); max-width: 44ch; }

/* Project cards */
.projects { display: grid; gap: 20px; }
@media (min-width: 760px) { .projects { grid-template-columns: 1fr 1fr; } }
.project {
  display: flex; flex-direction: column; gap: 16px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 9%, var(--surface)), var(--surface) 55%);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.project:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); box-shadow: 0 18px 40px -24px color-mix(in srgb, var(--c) 60%, transparent); }
.project--featured { grid-column: 1 / -1; }
.project__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: .85rem; }
.project__label { padding: 4px 12px; border-radius: 999px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.project__domain { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }
.project h3 { font-size: clamp(2rem, 4.5vw, 2.75rem); letter-spacing: -.015em; }
.project--featured h3 { font-size: clamp(2.5rem, 6vw, 3.75rem); }
.project__tagline { font-size: 1.15rem; font-weight: 600; color: var(--c); margin-top: -6px; }
.project__text { display: grid; gap: 14px; }
.project__body { display: grid; gap: 28px; }
@media (min-width: 860px) { .project__body { grid-template-columns: 1.4fr 1fr; gap: 48px; } }
.features { display: grid; gap: 10px; align-content: start; }
.features li { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.features .icon { color: var(--c); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; color: var(--muted); background: var(--surface); }
.note { font-size: .92rem; color: var(--muted); padding-left: 14px; border-left: 3px solid var(--c); }
.project__challenge { font-size: .95rem; color: var(--muted); }
.project__challenge strong { color: var(--ink); font-weight: 600; }
.project__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-top: auto; padding-top: 8px; }
.project__cta { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--c); text-decoration: none; }
.project__cta:hover { text-decoration: underline; text-underline-offset: 4px; }
.project__cta .icon { transition: transform .25s ease; }
.project__cta:hover .icon { transform: translate(3px, -3px); }
.project__social { display: flex; flex-wrap: wrap; gap: 8px; }
.project__social a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; text-decoration: none; color: var(--muted); background: var(--surface); }
.project__social a:hover { color: var(--ink); border-color: var(--ink); }

/* About */
.about-grid { display: grid; gap: 24px 64px; }
@media (min-width: 860px) { .about-grid { grid-template-columns: 1fr 1.6fr; } }
.about .copy { display: grid; gap: 16px; font-size: 1.1rem; }
.about .chips { margin-top: 8px; }

/* Contact */
.contact { border-top: 1px solid var(--line); }
.contact .intro { color: var(--muted); max-width: 46ch; margin-top: 14px; font-size: 1.1rem; }
.links { display: grid; gap: 12px; margin-top: 32px; }
/* L'email occupa due colonne: l'indirizzo non va a capo e le cinque voci riempiono le righe */
@media (min-width: 600px) { .links { grid-template-columns: repeat(2, 1fr); } .links li:first-child { grid-column: span 2; } }
@media (min-width: 1000px) { .links { grid-template-columns: repeat(3, 1fr); } }
.links a { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-decoration: none; transition: border-color .2s ease, transform .2s ease; }
.links a:hover { border-color: var(--ink); transform: translateY(-2px); }
.links .icon { width: 24px; height: 24px; color: var(--muted); }
.links span { display: grid; line-height: 1.3; min-width: 0; }
.links b { font-weight: 600; }
.links small { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.links .arrow { margin-left: auto; width: 18px; height: 18px; }

footer { border-top: 1px solid var(--line); padding-block: 28px 40px; font-size: .9rem; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; }
footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  body::before { animation: drift 18s ease-in-out infinite alternate; }
  @supports (animation-timeline: view()) {
    .reveal { animation: reveal linear both; animation-timeline: view(); animation-range: entry 0% entry 35%; }
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
/* Il bagliore si sposta verso sinistra: oltre il bordo destro creerebbe lo scroll orizzontale,
   oltre quello sinistro no. Con scale(1.04) e -4% il bordo destro resta al 98% della pagina. */
@keyframes drift { to { transform: translate3d(-4%, 6%, 0) scale(1.04); } }
@keyframes reveal { from { opacity: 0; transform: translateY(28px); } }
