/* JetBrains Mono ospitato in proprio: servito dalla CDN di Google, il solo
   caricamento della pagina spedirebbe l'IP del visitatore a un terzo, e
   l'informativa promette che questo non accade. I due sottoinsiemi sono quelli
   che il sito usa davvero; gli altri (cirillico, greco, vietnamita) non sono
   stati scaricati. I percorsi sono relativi a questo file, non alla pagina. */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/jetbrainsmono-latin.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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/jetbrainsmono-latin.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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/fonts/jetbrainsmono-latin-ext.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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../assets/fonts/jetbrainsmono-latin-ext.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;
}

:root {
  --ink: #0A0A0B;
  --surface: #131316;
  --rule: #24242A;
  --text: #E9E9E6;
  --mute: #8A8A92;
  --emph: #FFFFFF;

  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;

  --phi: 1.618;
  --col: 1080px;
  /* Il minimo del clamp morde solo sotto i ~480px, quindi stringe i margini
     laterali sul telefono senza toccare il desktop. */
  --pad: clamp(0.9rem, 4.5vw, 4rem);
  --gap-v: clamp(6rem, 12vh, 10rem);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  /* Senza uno sfondo esplicito qui, quello del body si propaga al canvas del
     viewport e non verrebbe invertito dal filtro. */
  background: var(--ink);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Invert colors: feature solo telefono. */
.invert-toggle {
  display: none;
}
html::-webkit-scrollbar {
  width: 0;
  height: 0;
}

body[data-lang="it"] .lang-en,
body[data-lang="en"] .lang-it {
  display: none;
}

body {
  background: var(--ink);
  color: var(--text);
  overflow-x: hidden;
  font-family: var(--mono);
  font-weight: 400;
  line-height: var(--phi);
  text-transform: lowercase;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 var(--pad);
}

a {
  color: inherit;
  text-decoration: none;
}

.waveform {
  display: block;
  width: 100%;
  color: #e9e9e6;
}

.waveform.primary {
  height: clamp(80px, 12vh, 130px);
  margin: clamp(1.25rem, 3.5vh, 2rem) 0 0.5rem;
}

.waveform.mini {
  width: 2.2rem;
  height: 1.1rem;
}

.manifesto {
  margin-top: clamp(5rem, 10vh, 8.5rem);
}

.evidence {
  margin-top: var(--gap-v);
}

.site-footer {
  margin-top: var(--gap-v);
}

:focus-visible {
  outline: 2px solid var(--emph);
  outline-offset: 3px;
}

/* Brand — top-left, small, strikethrough */
.site-header {
  padding-top: clamp(1.5rem, 4vh, 2.5rem);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.lang-toggle button {
  background: none;
  border: none;
  color: var(--mute);
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  transition: color 120ms ease;
}

.lang-toggle button:hover,
.lang-toggle button.active {
  color: var(--text);
}

.lang-toggle .sep {
  color: var(--mute);
  opacity: 0.4;
  font-size: 0.75rem;
}

.brand {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: lowercase;
  color: var(--text);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* Hero */
.hero {
  position: relative;
  padding-top: clamp(0.75rem, 3vh, 2rem);
}

.hero .eyebrow {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  text-align: left;
  color: var(--mute);
  margin: 0 0 calc(3rem * var(--phi));
}

.hero .hero-line {
  position: relative;
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(0.6rem, 1.4vw, 0.95rem);
  letter-spacing: 0.35em;
  line-height: 1.4;
  color: var(--text);
  margin: 0;
  overflow: hidden;
  min-height: clamp(80px, 12vh, 130px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hero .hero-line .waveform.primary {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}

.hero .hero-line span {
  position: relative;
  z-index: 1;
}

body[data-lang="it"] .hero-line .lang-it,
body[data-lang="en"] .hero-line .lang-en {
  display: block;
  white-space: nowrap;
}

/* Sotto i ~700px il tracking largo non ci sta piu' nella riga: senza questo
   l'overflow:hidden dell'hero taglia il testo ai lati invece di mandarlo a capo. */
@media (max-width: 700px) {
  .hero .hero-line {
    letter-spacing: 0.22em;
  }
  body[data-lang="it"] .hero-line .lang-it,
  body[data-lang="en"] .hero-line .lang-en {
    white-space: normal;
  }
}

/* Index */
nav[aria-label="Index"] {
  padding-top: clamp(1.5rem, 4vh, 3rem);
}

.index {
  list-style: none;
  margin: clamp(5rem, 9vh, 7rem) 0 0;
  padding: 0;
}

.index-row {
  display: grid;
  grid-template-columns: 2.4rem 6.5rem 1fr auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 0.6rem;
  margin: 0 -0.6rem;
  font-family: var(--mono);
  transition: background 120ms ease-out;
}

.index-row:hover,
.index-row:focus-visible {
  background: var(--surface);
}

.index-label {
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
}

.index-desc {
  font-size: 0.82rem;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.index-meta {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--mute);
  text-align: right;
  white-space: nowrap;
}

.index-meta.relate {
  color: var(--text);
}

#tools .index-label,
#tools .index-meta.relate,
#tools .waveform.mini {
  color: #00A9A0;
  animation: relate-glow 12s linear infinite;
}

#tools.index-row {
  position: relative;
  z-index: 0;
  background: var(--surface);
  grid-template-columns: 4rem 4.9rem 1fr auto;
  transition: none;
}

/* Cycling hover fill lives on a pseudo-element so it never touches the row's
   own load-stagger animation — that conflict was what made the banner vanish. */
#tools.index-row::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  background: #00A9A0;
}

#tools.index-row:hover::before,
#tools.index-row:focus-visible::before {
  opacity: 1;
  /* negative delay starts the cycle at its 50% keyframe (#3DA39B) so the
     first color seen on hover is turquoise. */
  animation: relate-glow-bg 12s linear -6s infinite;
}

#tools .index-label {
  font-weight: 700;
}

/* Senza descrizione la riga ha un figlio in meno: fisso la colonna del meta
   per tenerlo allineato a quello delle altre voci. */
#tools .index-meta.relate {
  grid-column: 4;
}

#tools .waveform.mini {
  width: 100%;
}

#tools.index-row:hover .index-label,
#tools.index-row:hover .index-meta.relate,
#tools.index-row:hover .waveform.mini,
#tools.index-row:focus-visible .index-label,
#tools.index-row:focus-visible .index-meta.relate,
#tools.index-row:focus-visible .waveform.mini {
  color: var(--emph);
  animation: none;
}

@keyframes relate-glow {
  0%, 100% { color: #00A9A0; }
  50% { color: #3DA39B; }
}

@keyframes relate-glow-bg {
  0%, 100% { background-color: #00A9A0; }
  50% { background-color: #3DA39B; }
}

@media (prefers-reduced-motion: reduce) {
  #tools .index-label,
  #tools .index-meta.relate,
  #tools .waveform.mini,
  #tools.index-row:hover::before,
  #tools.index-row:focus-visible::before,
  .now:not(.next) .now-tag {
    animation: none;
  }
}

/* Page-load stagger */
@media (prefers-reduced-motion: no-preference) {
  .index-row {
    opacity: 0;
    transform: translateY(8px);
    animation: rowin 400ms ease forwards;
  }
  .index li:nth-child(1) .index-row { animation-delay: 60ms; }
  .index li:nth-child(2) .index-row { animation-delay: 120ms; }
  .index li:nth-child(3) .index-row { animation-delay: 180ms; }
  .index li:nth-child(4) .index-row { animation-delay: 240ms; }
  .index li:nth-child(5) .index-row { animation-delay: 300ms; }
}

@keyframes rowin {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Manifesto */
.manifesto {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.95rem;
  line-height: var(--phi);
  max-width: 68ch;
  color: var(--text);
}

.manifesto p {
  margin: 0 0 calc(1rem * var(--phi));
}

.manifesto p:last-child {
  margin-bottom: 0;
}

/* A capo forzato solo su telefono: un blocco vuoto in flusso inline spezza la
   riga senza lasciare spazi parassiti quando e' spento. */
.br-mobile { display: none; }
.sep-desk { display: inline; }

/* Evidence — awards by year */
.evidence {
  margin-bottom: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  line-height: 1.9;
  color: var(--mute);
  text-transform: none;
}

.ev-row {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.9rem;
  padding: 0.6rem 0;
}

.ev-year {
  color: var(--text);
  letter-spacing: 0.08em;
}

.ev-items {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.ev-items span {
  color: var(--mute);
}

.ev-items a {
  color: var(--text);
  transition: color 120ms ease;
}

.ev-items a:hover {
  color: var(--emph);
}

@media (max-width: 600px) {
  .ev-row {
    grid-template-columns: 3rem 1fr;
    gap: 0.6rem;
  }
}

/* Now banner */
.now {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  margin-top: var(--gap-v);
}

.now-dot {
  color: var(--text);
  font-size: 0.6rem;
  line-height: 1;
  align-self: center;
}

.now-tag {
  color: var(--text);
  text-transform: lowercase;
  letter-spacing: 0.08em;
  min-width: 3em;
}

.now:not(.next) .now-tag {
  color: #00A9A0;
  font-weight: 700;
  animation: relate-glow 12s linear infinite;
}

.cap {
  text-transform: none;
}

.now.next {
  margin-top: clamp(0.6rem, 1.5vh, 1rem);
}

.now-body {
  color: var(--mute);
}

.now-link {
  text-decoration: none;
}

.now-link:hover .now-body {
  color: var(--text);
}

.now-body a {
  color: var(--text);
  white-space: nowrap;
  transition: color 120ms ease;
}

.now-body a:hover {
  color: var(--emph);
}

.cantico {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.now-cta {
  color: var(--text);
  margin-left: auto;
  transition: color 120ms ease;
}

.now-cta:hover {
  color: var(--emph);
}

/* Footer */
.site-footer {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.9;
  color: var(--mute);
  padding-bottom: clamp(3rem, 8vh, 6rem);
}

.site-footer a {
  color: var(--mute);
  transition: color 120ms ease;
}

.site-footer a:hover {
  color: var(--text);
}

.footer-nav {
  display: flex;
  gap: 0.4rem 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-nav a {
  font-size: 0.72rem;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
}

.footer-nav + .foot-links {
  margin-top: 0.75rem;
}

.foot-vat {
  color: var(--mute);
}

.foot-legal {
  margin-top: 0.75rem;
  color: var(--mute);
  text-align: justify;
  text-align-last: justify;
}

.site-footer .foot-fine {
  font-size: 0.7rem;
  color: var(--mute);
  margin-top: 1.25rem;
}

/* Mobile index collapse */
@media (max-width: 600px) {
  /* --gap-v e' il respiro tra manifesto, banner, premi e footer: tarato su una
     colonna da 1080px, su 375px diventa un buco. */
  :root {
    --gap-v: clamp(4.5rem, 11vh, 7rem);
  }
  /* Misurato in vh e non in rem: la prima schermata deve fermarsi all'indice,
     e dove finisce la piega lo decide l'altezza dello schermo, non il corpo. */
  .manifesto {
    margin-top: clamp(7rem, 22vh, 12rem);
    text-align: justify;
    text-align-last: justify;
  }
  .br-mobile { display: block; }
  /* Con l'a capo lo slash resterebbe appeso a fine riga. */
  .sep-desk { display: none; }
  /* Sul telefono il sito resta in inglese: al posto di it/en c'e' il bottone
     che inverte i colori. */
  .lang-toggle {
    display: none;
  }
  .invert-toggle {
    display: block;
    padding: 0;
    border: none;
    background: none;
    color: var(--mute);
    font: inherit;
    cursor: pointer;
    /* Il cerchio ha piu' massa visiva del testo del brand: centrato sulla
       box sembra basso, un paio di pixel in su lo rimettono in asse. */
    transform: translateY(-2px);
  }
  .invert-toggle span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.6rem;
    line-height: 1;
  }
  .invert-toggle[aria-pressed="true"] {
    color: var(--text);
  }

  /* Il filtro sul body ribalta tutto; le foto lo annullano con un secondo
     invert, mentre i canvas restano invertiti perche' sono tratto, non
     immagine, e devono seguire il testo. */
  html.inverted {
    background: #F5F5F5;
  }
  html.inverted body {
    filter: invert(1);
  }
  html.inverted img,
  html.inverted video {
    filter: invert(1);
  }

  /* Stacco dal fondo uguale a quello dell'header dalla cima. */
  .site-footer {
    padding-bottom: 1rem;
  }
  body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
  }
  body > main {
    flex: 1 0 auto;
  }

  /* Su telefono lo stacco sopra l'indice vale piu' di mezzo schermo: le voci
     arrivavano sotto la piega. */
  .site-header {
    padding-top: 1rem;
  }
  /* Sul telefono l'occhiello scende sotto il claim e ne diventa il sottotitolo. */
  .hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* La fascia della sinusoide passa dall'h1 all'hero: cosi' claim e
       sottotitolo ci stanno dentro tutti e due, uno attaccato all'altro. */
    min-height: clamp(130px, 24vh, 190px);
    /* Il canvas e' absolute con inset:0, quindi si aggancia al padding box: da
       quando il containing block e' l'hero, il padding-top non lo sposta piu'.
       Lo stacco sopra la sinusoide va messo come margine, e vale esattamente il
       padding-top della .page-hero delle altre pagine. */
    margin-top: calc(clamp(0.5rem, 2vh, 1rem) + 1.25rem * var(--phi));
    padding-top: 0;
    --claim-fs: clamp(0.82rem, 3.8vw, 1.1rem);
    --claim-chars: 29;
  }
  body[data-lang="it"] .hero {
    --claim-chars: 31;
  }
  /* La larghezza del sottotitolo e' quella del claim, calcolata invece che
     misurata: il font e' monospace, justify.js toglie gli spazi e ogni carattere
     occupa 0.6em di avanzamento piu' 0.14em di tracking. Cosi' la prima e
     l'ultima lettera cadono sotto la r di research e la n di composition.
     text-align-last serve perche' l'occhiello e' una riga sola: senza, e'
     l'ultima riga e resterebbe allineata a sinistra. */
  .hero .eyebrow {
    order: 2;
    position: relative;
    z-index: 1;
    width: min(100%, calc(var(--claim-fs) * 0.74 * var(--claim-chars)));
    margin: 0.55rem auto 0;
    text-align: justify;
    text-align-last: justify;
  }
  /* L'occhiello italiano e' di nove caratteri piu' lungo e su quella larghezza
     andrebbe a capo. */
  body[data-lang="it"] .hero .eyebrow {
    font-size: 0.62rem;
  }

  /* La sinusoide sfonda il padding del .wrap e arriva ai bordi dello schermo.
     Serve overflow:visible perche' l'hero altrimenti riclippa il canvas. */
  .hero .hero-line {
    overflow: visible;
    /* Statico apposta: senza containing block qui, il canvas si aggancia
       all'hero e la fascia copre anche il sottotitolo. */
    position: static;
    min-height: 0;
    font-size: var(--claim-fs);
    letter-spacing: 0.14em;
  }
  .hero .hero-line .waveform.primary {
    left: 50%;
    right: auto;
    width: 100vw;
    max-width: none;
    transform: translateX(-50%);
  }

  nav[aria-label="Index"] {
    padding-top: 1.5rem;
  }
  .index {
    margin-top: clamp(7.5rem, 18vh, 11rem);
  }

  /* Le descrizioni non entrano nella riga senza essere troncate: su telefono
     resta solo il titolo con il trattino a fine riga. */
  .index-row {
    grid-template-columns: 2rem 1fr auto;
    gap: 0.6rem;
  }
  .index-desc {
    display: none;
  }
  .index-meta {
    justify-self: end;
  }
  #tools.index-row {
    grid-template-columns: 3.2rem 1fr auto;
  }
  /* Senza la desc l'auto-placement basta: la colonna fissa qui sballerebbe. */
  #tools .index-meta.relate {
    grid-column: auto;
  }
  /* La banda del banner sfonda il padding del .wrap e arriva ai bordi dello
     schermo; il padding la ricompensa cosi' il testo resta in colonna. */
  .index-row {
    margin: 0 calc(var(--pad) * -1);
    padding: 0.5rem var(--pad) 0.75rem;
  }
  .index-label { font-size: 0.76rem; }
  .index-meta { font-size: 0.7rem; }
  .now-cta {
    margin-left: 0;
    flex-basis: 100%;
  }
  /* Ogni riga del footer sta su un rigo solo: il corpo scala con la viewport
     ed e' dimensionato sulla stringa piu' lunga della riga, che e' sempre
     quella italiana. */
  .site-footer {
    font-size: clamp(0.42rem, 2vw, 0.72rem);
  }
  .footer-nav {
    flex-wrap: nowrap;
    gap: 0.3rem;
  }
  .footer-nav a {
    font-size: clamp(0.42rem, 2.05vw, 0.72rem);
    white-space: nowrap;
  }
  /* Giustificata da bordo a bordo. Con white-space:nowrap la giustificazione
     tipografica non ha appigli, quindi la distribuzione la fa il flex. */
  .foot-legal {
    font-size: clamp(0.4rem, 1.9vw, 0.72rem);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.25rem;
    white-space: nowrap;
  }
}
