/* ==========================================================================
   Tokens
   Forma: media e superfici 14px, controlli piccoli (pulsanti, tag) a pillola.
   Colore: un solo accento (arancione) usato ovunque. Tema chiaro/scuro automatico.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("assets/fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist";
  src: url("assets/fonts/geist-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f5f6f6;
  --surface: #e9ecec;
  --text: #16181a;
  --muted: #565d62;
  --line: #d6dbdc;
  --accent: #c2410c;
  --on-accent: #ffffff;

  --radius: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --max: 1280px;
  --nav-h: 64px;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1213;
    --surface: #181c1d;
    --text: #eceff0;
    --muted: #98a2a7;
    --line: #262c2e;
    --accent: #fb923c;
    --on-accent: #1c0a02;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-feature-settings: "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--accent);
}

::selection { background: var(--accent); color: var(--on-accent); }

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p, figure { margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: absolute; left: var(--gutter); top: -4rem;
  background: var(--accent); color: var(--on-accent);
  padding: .5rem 1rem; border-radius: 999px; z-index: 30;
}
.skip:focus { top: .75rem; }

/* Icone Phosphor come maschera: ereditano il colore del testo */
.icon {
  display: inline-block;
  width: 1.15em; height: 1.15em;
  background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat;
          mask: var(--i) center / contain no-repeat;
  flex: none;
}
.icon--arrow    { --i: url("assets/icons/arrow-up-right.svg"); }
.icon--github   { --i: url("assets/icons/github-logo.svg"); }
.icon--linkedin { --i: url("assets/icons/linkedin-logo.svg"); }
.icon--pdf      { --i: url("assets/icons/file-pdf.svg"); }

/* ==========================================================================
   Navigazione (una riga, 64px)
   ========================================================================== */

.nav {
  position: sticky; top: 0; z-index: 20;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding-inline: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav__brand { font-weight: 600; letter-spacing: -0.01em; }
.nav__links { display: flex; gap: clamp(1rem, 3vw, 2rem); font-size: .9375rem; color: var(--muted); }
.nav__links a { padding: .25rem 0; transition: color 150ms ease; }
@media (pointer: coarse) { .nav__links a { display: inline-flex; align-items: center; min-height: 44px; } }
@media (hover: hover) { .nav__links a:hover { color: var(--text); } }

@media (max-width: 560px) {
  .nav__links { gap: .9rem; font-size: .875rem; }
  .nav__links a:nth-child(3) { display: none; }
}

/* ==========================================================================
   Pulsanti
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 48px; padding-inline: 1.5rem;
  border-radius: 999px;
  font-weight: 500; font-size: 1rem; white-space: nowrap;
  border: 1px solid transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--ghost { border-color: var(--line); color: var(--text); }
@media (hover: hover) {
  .btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
  .btn--ghost:hover { border-color: var(--text); }
}

/* ==========================================================================
   Segnaposto immagini (spariscono da soli quando metti la foto)
   ========================================================================== */

.ph {
  position: relative; overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
}
.ph img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; }
.ph.ph--empty img { display: none; }
.ph.ph--empty::after {
  content: attr(data-label);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: .9375rem;
}

/* ==========================================================================
   Hero (asimmetrico: testo a sinistra, ritratto a destra)
   ========================================================================== */

.hero {
  max-width: var(--max); margin-inline: auto;
  padding: 3rem var(--gutter) 4rem;
  min-height: calc(100dvh - var(--nav-h));
  display: grid; grid-template-columns: 7fr 5fr; gap: clamp(2rem, 6vw, 6rem);
  align-items: center;
}
.hero__title {
  font-size: clamp(2.5rem, 5.4vw, 4.75rem);
  line-height: 1.02; letter-spacing: -0.035em; font-weight: 600;
  text-wrap: balance; max-width: 15ch;
}
.hero__title em { font-style: normal; color: var(--accent); }
.hero__sub {
  margin-top: 1.75rem; max-width: 38ch;
  font-size: 1.1875rem; color: var(--muted); text-wrap: pretty;
}
.hero__cta { margin-top: 2.25rem; display: flex; flex-wrap: wrap; gap: .75rem; }
.hero__media { aspect-ratio: 4 / 5; width: 100%; max-width: 460px; justify-self: end; }

.hero--no-photo { grid-template-columns: 1fr; align-items: end; }
.hero--no-photo .hero__media { display: none; }
.hero--no-photo .hero__title { font-size: clamp(2.75rem, 7.2vw, 6rem); max-width: 17ch; }
.hero--no-photo .hero__sub { font-size: 1.3125rem; max-width: 40ch; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: 2rem; }
  .hero__media { order: -1; max-width: 100%; aspect-ratio: 4 / 3; justify-self: stretch; }
  .hero--no-photo .hero__title { font-size: clamp(2.5rem, 11vw, 3.5rem); }
  .hero__title { max-width: 18ch; }
}

/* ==========================================================================
   Sezioni: ritmo comune
   ========================================================================== */

.work, .path, .about, .contact {
  max-width: var(--max); margin-inline: auto;
  padding: clamp(4rem, 9vw, 8rem) var(--gutter) 0;
}
.h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  letter-spacing: -0.03em; line-height: 1.1; font-weight: 600;
  margin-bottom: clamp(1.75rem, 3vw, 2.75rem);
}

/* ==========================================================================
   Campo di nodi dietro all'hero (message passing, disegnato da main.js)
   Maschera: sfuma in alto e in basso e resta piu' lieve dietro al testo.
   ========================================================================== */

.hero-wrap { position: relative; overflow: hidden; }
.hero-wrap .hero { position: relative; z-index: 1; }
.hero-field {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20%, #000 78%, transparent 100%),
                      linear-gradient(90deg, rgba(0,0,0,.38) 0%, rgba(0,0,0,.38) 40%, #000 66%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to bottom, transparent 0, #000 20%, #000 78%, transparent 100%),
                      linear-gradient(90deg, rgba(0,0,0,.38) 0%, rgba(0,0,0,.38) 40%, #000 66%);
          mask-composite: intersect;
}
@media (max-width: 860px) {
  .hero-field {
    opacity: .55;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%);
            mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%);
  }
}

/* ==========================================================================
   Progetti (blocchi tipografici: nessuna immagine necessaria)
   Il primo e' pieno d'accento, gli altri su superficie neutra.
   ========================================================================== */

.proj__link {
  display: flex; flex-direction: column; height: 100%;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border-radius: var(--radius);
  transition: transform 200ms var(--ease-out), background-color 200ms ease;
}
.proj--soft .proj__link { background: var(--surface); }
.proj--lead .proj__link { background: var(--accent); color: var(--on-accent); }

.proj__cols { display: grid; grid-template-columns: 5fr 7fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: end; }
.proj__text { align-self: end; }
.proj__fig { border-radius: 10px; overflow: hidden; background: #fff; }
.proj__fig img { display: block; width: 100%; height: auto; }
@media (max-width: 860px) { .proj__cols { grid-template-columns: 1fr; } .proj__top { padding-bottom: 1.5rem; } }
a.proj__link:active { transform: scale(0.99); }

.proj__top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: auto; padding-bottom: 2.5rem;
  font-size: .9375rem; color: var(--muted);
}
.proj--lead .proj__top { color: inherit; opacity: .85; }
.proj__top .icon { width: 1.5rem; height: 1.5rem; transition: transform 200ms var(--ease-out); }

.proj__title {
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  letter-spacing: -0.025em; line-height: 1.12; font-weight: 600;
  max-width: 22ch; text-wrap: balance;
}
.proj--soft .proj__title { font-size: clamp(1.25rem, 2vw, 1.625rem); max-width: 24ch; }
.proj__desc { margin-top: .75rem; max-width: 52ch; text-wrap: pretty; color: var(--muted); }
.proj--lead .proj__desc { color: inherit; opacity: .9; }

.tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.tags li {
  font-size: .8125rem; line-height: 1;
  padding: .45rem .75rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.proj--soft .tags li { border-color: color-mix(in srgb, var(--muted) 35%, transparent); }
.proj--lead .tags li { border-color: color-mix(in srgb, var(--on-accent) 45%, transparent); color: inherit; }

@media (hover: hover) {
  a.proj__link:hover .icon--arrow { transform: translate(3px, -3px); }
  .proj--lead a.proj__link:hover { background: color-mix(in srgb, var(--accent) 92%, var(--text)); }
  .proj--soft a.proj__link:hover { background: color-mix(in srgb, var(--surface) 80%, var(--accent) 20%); }
}

.work__pair {
  margin-top: clamp(1rem, 2vw, 1.5rem);
  display: grid; grid-template-columns: 7fr 5fr;
  gap: clamp(1rem, 2vw, 1.5rem);
}
.proj--soft .proj__link { min-height: 16rem; }

@media (max-width: 760px) {
  .work__pair { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Percorso (date a sinistra, contenuto a destra)
   ========================================================================== */

.path__row {
  display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: 1.5rem;
  padding-block: 1.75rem; border-top: 1px solid var(--line);
}
.path__row:last-child { border-bottom: 1px solid var(--line); }
.path__when { color: var(--muted); font-variant-numeric: tabular-nums; }
.path__what h3 { font-size: 1.25rem; letter-spacing: -0.015em; line-height: 1.3; font-weight: 600; }
.path__what p { margin-top: .35rem; color: var(--muted); max-width: 60ch; text-wrap: pretty; }

@media (max-width: 640px) {
  .path__row { grid-template-columns: 1fr; gap: .35rem; }
}

/* ==========================================================================
   Chi sono (una frase grande, poi le competenze)
   ========================================================================== */

.about__lead {
  font-size: clamp(1.5rem, 3.1vw, 2.5rem);
  line-height: 1.25; letter-spacing: -0.025em; font-weight: 500;
  max-width: 28em; text-wrap: pretty;
}
.skills { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 2.25rem; }
.skills li {
  padding: .6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--line); font-size: .9375rem;
}

.about__grid {
  display: grid; grid-template-columns: minmax(240px, 380px) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem); align-items: start;
}
.about__photo { border-radius: var(--radius); overflow: hidden; background: var(--surface); aspect-ratio: 4 / 5; }
.about__photo img { width: 100%; height: 100%; object-fit: cover; }
.about__text .h2 { margin-bottom: clamp(1.25rem, 2.5vw, 2rem); }
.about__text .about__body { margin-top: clamp(1.5rem, 3vw, 2.25rem); }
@media (max-width: 760px) {
  .about__grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .about__text { display: contents; }
  .about__text .h2 { order: 1; margin-bottom: 0; }
  .about__photo { order: 2; max-width: 380px; }
  .about__lead { order: 3; }
  .about__text .about__body { order: 4; margin-top: 0; }
}
.about__body {
  display: grid; gap: 1.25rem;
  max-width: 68ch; color: var(--muted); text-wrap: pretty;
}
.about__cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem);
  margin-top: clamp(3rem, 6vw, 5rem);
}
.h3 { font-size: 1.125rem; letter-spacing: -0.015em; font-weight: 600; margin-bottom: .9rem; }
.about__cols .skills { margin-top: 0; margin-bottom: 2.25rem; }
.plain { color: var(--muted); max-width: 46ch; }
ul.plain { display: grid; gap: .6rem; }
@media (max-width: 760px) { .about__cols { grid-template-columns: 1fr; } }

/* ==========================================================================
   Contatti
   ========================================================================== */

.contact { padding-bottom: clamp(4rem, 9vw, 7rem); }
.contact__title {
  font-size: clamp(3rem, 9vw, 7rem);
  letter-spacing: -0.04em; line-height: 1; font-weight: 600;
}
.contact__mail {
  display: inline-block; margin-top: 1.75rem;
  font-size: clamp(1.25rem, 3vw, 2rem); letter-spacing: -0.02em;
  color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .25em;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: text-decoration-color 160ms ease;
  overflow-wrap: anywhere;
}
@media (hover: hover) { .contact__mail:hover { text-decoration-color: var(--accent); } }

.contact__links { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2.25rem; }
.contact__links a {
  display: inline-flex; align-items: center; gap: .5rem;
  height: 44px; padding-inline: 1.1rem; border-radius: 999px;
  border: 1px solid var(--line);
  transition: transform 160ms var(--ease-out), border-color 160ms ease;
}
.contact__links a:active { transform: scale(0.97); }
@media (hover: hover) { .contact__links a:hover { border-color: var(--text); } }

/* ==========================================================================
   Footer
   ========================================================================== */

.foot {
  max-width: var(--max); margin-inline: auto;
  padding: 1.5rem var(--gutter) 2.5rem;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 1rem;
  color: var(--muted); font-size: .9375rem;
}
@media (hover: hover) { .foot a:hover { color: var(--text); } }

/* ==========================================================================
   Movimento
   Entrata dell'hero (una sola volta) e comparsa dei blocchi allo scroll:
   servono a dare sequenza alla lettura. Tutto disattivato con "riduci movimento".
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  .hero__title, .hero__sub, .hero__cta, .hero__media {
    animation: rise 700ms var(--ease-out) both;
  }
  .hero__sub   { animation-delay: 80ms; }
  .hero__cta   { animation-delay: 160ms; }
  .hero__media { animation-delay: 120ms; }

  .js .reveal {
    opacity: 0; transform: translateY(20px);
    transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
  }
  .js .reveal.is-in { opacity: 1; transform: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .proj__media img { transition: none; }
}
