/* Space Grotesk (SIL Open Font License), file in /fonts/: nessuna richiesta a servizi esterni */

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/space-grotesk-latin-ext-400-normal.woff2) format('woff2');
  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;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/space-grotesk-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/space-grotesk-latin-ext-500-normal.woff2) format('woff2');
  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;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/space-grotesk-latin-500-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/space-grotesk-latin-ext-600-normal.woff2) format('woff2');
  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;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/space-grotesk-latin-600-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(fonts/space-grotesk-latin-ext-700-normal.woff2) format('woff2');
  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;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(fonts/space-grotesk-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* ---------- Base ---------- */

:root {
  --bg: #000;
  --card-from: #111c38;
  --card-to: #0a1226;
  --border: rgba(148, 163, 214, 0.18);
  --border-accent: rgba(245, 166, 35, 0.35);
  --text: #f5f6f8;
  --muted: #a3a9b8;
  --dim: #6f7687;
  --accent: #f5a623;
  --accent-strong: #ffb229;
  --accent-ink: #120b00;
  --radius: 16px;
  --container: 1120px;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Bagliore blu che vaga lentamente per lo schermo.
   Il centro del cerchio parte dall'angolo in alto a sinistra e viene spostato con translate(vw, vh). */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 80vmax;
  height: 80vmax;
  margin: -40vmax 0 0 -40vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 62, 140, 0.34), rgba(37, 62, 140, 0.12) 40%, transparent 68%);
  transform: translate(0vw, 45vh);
  animation: glow-wander 20s ease-in-out infinite;
  will-change: transform;
  pointer-events: none;
  z-index: -1;
}

/* Secondo bagliore, arancione (#fca311): stesso percorso del blu ma percorso al contrario.
   Il ritardo negativo lo fa partire a metà giro, così i due bagliori non partono dallo stesso punto. */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 70vmax;
  height: 70vmax;
  margin: -35vmax 0 0 -35vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(252, 163, 17, 0.2), rgba(252, 163, 17, 0.07) 40%, transparent 68%);
  transform: translate(75vw, 85vh);
  animation: glow-wander 20s ease-in-out -10s infinite reverse;
  will-change: transform;
  pointer-events: none;
  z-index: -1;
}

@keyframes glow-wander {
  0%,
  100% {
    transform: translate(0vw, 45vh) scale(1);
  }
  20% {
    transform: translate(35vw, 10vh) scale(1.1);
  }
  40% {
    transform: translate(90vw, 30vh) scale(0.95);
  }
  60% {
    transform: translate(75vw, 85vh) scale(1.15);
  }
  80% {
    transform: translate(20vw, 95vh) scale(1);
  }
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 16px;
}

.accent {
  color: var(--accent);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Bottoni ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.8em 1.4em;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-ghost {
  border-color: rgba(255, 255, 255, 0.75);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
}

/* ---------- Sezioni e card ---------- */

.section {
  padding-block: 48px;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.eyebrow.small {
  font-size: 0.66rem;
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 700;
}

.head-gap {
  margin-bottom: 32px;
}

.card {
  background: linear-gradient(180deg, var(--card-from), var(--card-to));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-accent {
  border-color: var(--border-accent);
}

/* ---------- Header ---------- */

.site-header {
  position: relative;
  z-index: 10;
}

/* Solo il nome, nessun menu: la pagina si legge dall'alto in basso */
.site-header .bar {
  display: flex;
  align-items: center;
  height: 64px;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

/* Lingua: ITA porta alla versione italiana, ENG a quella in /en/ */
.lang {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.lang a {
  min-width: 44px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
}

.lang a[aria-current] {
  background: var(--accent);
  color: #000;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 24px;
}

.site-footer .row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-block: 28px;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: var(--text);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Alone arancione fermo dietro l'avatar */
.hero::before {
  content: '';
  position: absolute;
  top: -260px;
  left: calc(50% - 350px);
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(245, 166, 35, 0.09), transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  background: var(--accent);
  border: 4px solid #000;
  box-shadow:
    0 0 0 3px var(--accent),
    0 0 60px 6px rgba(245, 166, 35, 0.35);
  margin-bottom: 28px;
}

/* Titolo e testo: il blocco è largo quanto la riga più lunga del titolo
   e il testo sotto prende esattamente quella larghezza, senza mai uscire */
.hero-text {
  width: fit-content;
  max-width: 100%;
}

.hero h1 {
  font-size: clamp(2.1rem, 9vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 24px;
  white-space: nowrap;
}

/* A capo fissi: tre righe su telefono e tablet (br-m), due su computer (br-d) */
.hero h1 .br-d {
  display: none;
}

.hero .lead {
  width: 0;
  min-width: 100%;
  max-width: none;
}

/* Una frase per riga, con righe di lunghezza simile: niente parole rimaste da sole in fondo */
.hero .lead span {
  display: block;
  text-wrap: balance;
}

.lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 1rem;
  margin: 0 0 28px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-bottom: 32px;
}

.socials {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.socials a {
  display: block;
  padding: 9px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 0.8rem;
}

.socials a:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ---------- Progetto ---------- */

/* Griglia dei progetti: card da 220 a 255px, al massimo quattro per riga sul computer, sempre centrate */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 255px));
  justify-content: center;
  gap: 16px;
}

.project {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
}

/* Data di uscita sotto l'etichetta del progetto */
.release {
  color: var(--muted);
  font-size: 0.75rem;
  margin: -6px 0 12px;
}

/* Il logo ha il testo scuro: sta su una targa color carta per leggersi sul fondo scuro */
.project-logo {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f6f1e7;
}

.project-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.pdesc {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0 0 14px;
  flex-grow: 1;
}

/* Card "Prossimamente": tratteggiata, senza link */
.project-soon {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;
  border: 1px dashed var(--border-accent);
  min-height: 200px;
}

.soon-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  border-radius: 50%;
  border: 1px dashed var(--accent);
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
}

.soon-title {
  margin: 6px 0 6px;
  font-weight: 600;
  font-size: 1rem;
}

.soon-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.btn-sm {
  padding: 0.6em 0.9em;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* ---------- Skill ---------- */

/* Card in fila. Senza JavaScript (o con "riduci movimento") si scorrono a mano;
   skills.js aggiunge .marquee, duplica le card e il nastro scorre da solo */
.skills {
  overflow-x: auto;
  padding-bottom: 8px;
}

.skills-track {
  display: flex;
  gap: 20px;
  width: max-content;
}

.skills.marquee {
  overflow: hidden;
  padding-bottom: 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.skills.marquee .skills-track {
  animation: skills-scroll 45s linear infinite;
}

/* Si ferma quando ci passi sopra col mouse o tieni il dito sopra */
.skills.marquee:hover .skills-track,
.skills.marquee:active .skills-track {
  animation-play-state: paused;
}

/* Sposta di un intero giro di card (metà nastro + metà dello spazio tra i due giri) */
@keyframes skills-scroll {
  to {
    transform: translateX(calc(-50% - 10px));
  }
}

.skill-card {
  flex: 0 0 280px;
  background: #0a0a0c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
}

.skill-card ul {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 16px;
}

.skill-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.level {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fff4dc, var(--accent));
}

/* ---------- Contatti ---------- */

.contact {
  display: grid;
  align-items: center;
  gap: 24px;
  padding: 24px 20px;
}

.contact-text {
  color: var(--muted);
  margin: 12px 0 0;
  font-size: 0.95rem;
}

.email-box {
  display: grid;
  justify-items: start;
  gap: 4px;
}

/* Indirizzo + icona: un unico pulsante, al clic copia l'email (vedi copy.js) */
.email-copy {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  padding: 14px 18px;
  font: inherit;
  font-size: clamp(1rem, 4.2vw, 1.25rem);
  font-weight: 600;
  color: var(--text);
  background: #05070d;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.email-copy:hover,
.email-copy.copied {
  border-color: var(--accent);
}

.email-address {
  overflow-wrap: anywhere;
  text-align: left;
}

.copy-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
}

.icon-check,
.email-copy.copied .icon-copy {
  display: none;
}

.email-copy.copied .icon-check {
  display: block;
}

.copy-hint {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--dim);
}

.copy-hint.ok {
  color: var(--accent);
}

/* ---------- Motto ---------- */

.motto {
  text-align: center;
  padding-block: 48px 56px;
}

.motto blockquote {
  margin: 0 0 14px;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  font-style: italic;
  color: var(--muted);
}

/* ---------- Pagine di esito (grazie, errore, 404) ---------- */

.status {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding-block: 48px;
}

.status .text {
  color: var(--muted);
  max-width: 560px;
  margin: 12px 0 28px;
}

/* ---------- Pagina di testo (privacy) ---------- */

.page {
  max-width: 768px;
  padding-block: 24px 56px;
  color: #d9dce3;
}

.page h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin-bottom: 8px;
  color: var(--text);
}

.page .updated {
  color: var(--dim);
  font-size: 0.85rem;
  margin: 0 0 32px;
}

.page h2 {
  font-size: 1.25rem;
  margin: 2em 0 0.5em;
  color: var(--text);
}

.page ul {
  padding-left: 1.2em;
  display: grid;
  gap: 12px;
}

.page a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Schermi più grandi ---------- */

@media (min-width: 600px) {
  .container {
    padding-inline: 24px;
  }
  .site-header .bar {
    height: 72px;
  }
  .section {
    padding-block: 72px;
  }
  .hero {
    padding-top: 16px;
    padding-bottom: 64px;
  }
  .avatar {
    width: 176px;
    height: 176px;
  }
  .lead {
    font-size: 1.05rem;
  }
  .skill-card {
    flex-basis: 320px;
  }
  .contact {
    padding: 40px;
  }
  .page {
    padding-block: 48px 72px;
  }
}

@media (min-width: 960px) {
  .hero h1 .br-m {
    display: none;
  }
  .hero h1 .br-d {
    display: initial;
  }
  /* Avatar accanto al titolo, alto quanto le sue due righe; il gruppo e il resto sotto sono centrati */
  .hero {
    --h1-size: clamp(2.6rem, 4.4vw, 3.4rem);
    display: grid;
    grid-template-columns: auto auto;
    justify-content: center;
    column-gap: 32px;
    align-items: start;
    padding-top: 32px;
  }
  .hero > * {
    grid-column: 1 / -1;
    justify-self: center;
  }
  .hero .avatar {
    grid-column: 1;
    grid-row: 1;
    /* due righe di titolo (2 × line-height 1.08) meno l'anello esterno di 3px per lato */
    width: calc(var(--h1-size) * 2.16 - 6px);
    height: calc(var(--h1-size) * 2.16 - 6px);
    margin: 0 3px;
    box-shadow:
      0 0 0 3px var(--accent),
      0 0 40px 4px rgba(245, 166, 35, 0.3);
  }
  /* Titolo e testo nella colonna a destra, allineati a sinistra */
  .hero .hero-text {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    text-align: left;
  }
  .hero h1 {
    font-size: var(--h1-size);
  }
  /* Il testo sotto il titolo è centrato; prima e ultima frase restano su una riga
     (il blocco si allarga se serve), la frase centrale va a capo nella larghezza del blocco */
  .hero .lead {
    text-align: center;
    width: auto;
    min-width: 0;
  }
  .hero .lead span:first-child,
  .hero .lead span:last-child {
    white-space: nowrap;
  }
  .hero .lead span:nth-child(2) {
    width: 0;
    min-width: 100%;
  }
  .hero .actions {
    margin-top: 4px;
  }
  /* Pulsanti e social centrati sotto il testo, non sotto tutto il gruppo con l'avatar */
  .hero .actions,
  .hero .socials {
    grid-column: 2;
  }
  .contact {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 48px 64px;
  }
}

/* Effetti al passaggio del mouse solo dove esiste un puntatore */
@media (hover: hover) {
  .btn:hover {
    transform: translateY(-1px);
  }
  .lang a:not([aria-current]):hover {
    color: var(--text);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  body::after,
  body::before {
    animation: none;
  }
  .skills.marquee .skills-track {
    animation: none;
  }
  .btn {
    transition: none;
  }
}
