/* F²Labs — Tutto quadra. */

@font-face {
  font-family: "Mona Sans";
  src: url("../fonts/mona-sans.woff2") format("woff2");
  font-weight: 200 900;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Michroma";
  src: url("../fonts/michroma.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Martian Mono";
  src: url("../fonts/martian-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #111111;
  --paper: #f2f2ee;
  --paper-2: #b8b8b0;
  --paper-3: #8e8e86;
  --line: rgb(242 242 238 / 0.13);
  --accent: #c6f432;
  --olive: #3e4d0e;
  /* allagamento finale: sul lime, testi e tessere passano a nero e oliva */
  --flood-fg: #111111;
  --flood-accent: #3e4d0e;

  --sans: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* i titoli: Michroma, squadrato, sulla scia di Eurostile */
  --display: "Michroma", "Eurostile", "Mona Sans", ui-sans-serif, sans-serif;

  --gutter: clamp(20px, 4.2vw, 64px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);

  color-scheme: dark;
}

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

html {
  background: var(--ink);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  font-stretch: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

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

a {
  color: inherit;
}

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

/* ---------- Campo e atmosfera */

.field {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 45%, transparent 52%, rgb(11 11 12 / 0.72) 100%);
}

main,
.foot {
  position: relative;
  z-index: 2;
}

/* grana sottile su tutto, come una pellicola */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Tipografia */

.mono {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 450;
  font-stretch: 87%;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-3);
  margin: 0;
}

.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 7.9vw, 9.8rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.h2 {
  margin: 0 0 30px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.75rem, 3.7vw, 4rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 31em;
  font-size: clamp(1.05rem, 1.25vw, 1.3rem);
  line-height: 1.55;
  color: var(--paper-2);
  text-wrap: pretty;
}

.lede + .lede {
  margin-top: 18px;
}

.lede-strong {
  color: var(--paper);
  font-weight: 520;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 30px;
}

.eyebrow::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  background: var(--accent);
}

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

.top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: calc(22px + env(safe-area-inset-top, 0px)) var(--gutter) 22px;
}

.top::before {
  content: "";
  position: absolute;
  inset: 0 0 -48px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgb(11 11 12 / 0.9) 30%, transparent);
  opacity: 0;
  transition: opacity 0.6s;
}

.top.is-scrolled::before {
  opacity: 1;
}

.brand {
  display: inline-flex;
  align-items: flex-start;
  color: var(--paper);
  text-decoration: none;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand-exp {
  margin: 0.2em 0.03em 0 0.04em;
  font-size: 0.5em;
  color: var(--accent);
  letter-spacing: 0;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 28px;
}

.clock {
  font-variant-numeric: tabular-nums;
}

html:not(.js) .clock,
html:not(.js) .hud {
  display: none;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 12px 17px 12px 15px;
  border: 1px solid rgb(236 235 230 / 0.24);
  background: rgb(11 11 12 / 0.35);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  font-stretch: 87%;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background 0.35s, color 0.35s, border-color 0.35s, translate 0.5s var(--ease-out);
}

.btn:hover {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

/* il gesto del marchio: un quadrato storto che si raddrizza */
.btn-sq,
.cue-sq {
  flex: none;
  width: 7px;
  height: 7px;
  background: var(--accent);
  rotate: 45deg;
  transition: rotate 0.6s var(--ease-out);
}

.btn:hover .btn-sq,
.btn:focus-visible .btn-sq {
  rotate: 0deg;
}

.btn-quiet {
  border-color: var(--line);
  background: transparent;
}

/* ---------- HUD */

.hud {
  position: fixed;
  inset: auto var(--gutter) calc(22px + env(safe-area-inset-bottom, 0px)) var(--gutter);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: difference;
  transition: opacity 0.8s;
}

.is-ready .hud {
  opacity: 1;
}

.hud.is-hidden {
  opacity: 0;
}

.hud-chapter {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-num,
.hud-order-val {
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.hud-bar {
  position: relative;
  width: 96px;
  height: 1px;
  background: var(--line);
}

.hud-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}

.hud-order-val {
  display: inline-block;
  min-width: 3ch;
}

/* ---------- Capitoli */

.chapter {
  position: relative;
  min-height: 118vh;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  align-items: center;
  padding: 16vh var(--gutter);
}

.chapter-body {
  grid-column: 1 / span 5;
}

.chapter[data-text="right"] .chapter-body {
  grid-column: 8 / span 5;
}

/* Hero */

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 120px var(--gutter) 92px;
}

.hero-title {
  --strike-y: 0.55em;
  font-size: clamp(2.2rem, 7.9vw, 9.8rem);
}

.nw {
  white-space: nowrap;
}

/* "caos" si cancella mentre il visitatore mette ordine */
.strike {
  position: relative;
  display: inline-block;
}

.strike::after {
  content: "";
  position: absolute;
  left: -0.04em;
  right: -0.04em;
  top: var(--strike-y, 0.5em);
  height: 0.06em;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(var(--strike, 0));
  transition: transform 0.35s var(--ease-out);
  pointer-events: none;
}

.js .strike .wi {
  transition:
    translate 1.15s var(--ease-out) calc(var(--i, 0) * 70ms),
    color 0.9s var(--ease-out);
}

.strike.is-done .wi {
  color: var(--paper-3);
}

.hero-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-top: 44px;
}

.hero .lede {
  max-width: 27em;
}

.cue {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
  color: var(--paper-2);
  text-decoration: none;
  transition: color 0.3s;
}

.cue:hover {
  color: var(--paper);
}

.cue-sq {
  animation: square-up 2.8s var(--ease-io) infinite;
}

@keyframes square-up {
  0%, 18% { rotate: 45deg; translate: 0 -3px; }
  50%, 82% { rotate: 0deg; translate: 0 3px; }
  100% { rotate: 45deg; translate: 0 -3px; }
}

/* Tutto quadra: le lettere partono distanziate e si serrano mentre il quadrato si forma */

.quadra-title {
  --q: 1;
  margin-bottom: 36px;
  font-size: clamp(2.4rem, 6.8vw, 8.4rem);
  line-height: 1.02;
  letter-spacing: calc(0.18em - 0.215em * var(--q));
}

/* F × F = F² */

.formula {
  font-size: clamp(2.2rem, 5.4vw, 6rem);
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.formula .op {
  color: var(--paper-3);
}

.formula .exp {
  display: inline-block;
  margin-left: 0.03em;
  font-size: 0.5em;
  vertical-align: 0.82em;
  color: var(--accent);
  font-weight: 700;
}

/* Contatti */

.contact {
  min-height: 100vh;
  align-items: center;
}

.contact-body {
  grid-column: 1 / -1;
}

.contact-title {
  margin-bottom: 40px;
  font-size: clamp(2.2rem, 9.4vw, 11.5rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px 36px;
  margin-top: 56px;
}

.mail {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  color: var(--paper);
  text-decoration: none;
  font-size: clamp(1.7rem, 4.2vw, 4.25rem);
  font-weight: 330;
  font-stretch: 110%;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.mail::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.1em;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0.14);
  transition: transform 0.8s var(--ease-out);
}

.mail:hover::after,
.mail:focus-visible::after {
  transform: scaleX(1);
}

.mail-arrow {
  width: 0.62em;
  height: 0.62em;
  color: var(--accent);
  transition: translate 0.6s var(--ease-out);
}

.mail:hover .mail-arrow {
  translate: 0.12em -0.12em;
}

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 40px;
  padding: 34px var(--gutter) 38px;
  border-top: 1px solid var(--line);
  background: linear-gradient(to bottom, rgb(11 11 12 / 0.4), var(--ink));
}

.brand-sm {
  font-size: 16px;
}

/* ---------- Rivelazioni (solo con JavaScript attivo) */

.js [data-reveal] {
  opacity: 0;
  translate: 0 22px;
  transition:
    opacity 1.1s var(--ease-out) calc(var(--d, 0) * 90ms),
    translate 1.1s var(--ease-out) calc(var(--d, 0) * 90ms);
}

.js .is-in [data-reveal] {
  opacity: 1;
  translate: 0 0;
}

.w {
  display: inline-block;
  overflow: clip;
  vertical-align: top;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}

.wi {
  display: inline-block;
}

.js .wi {
  translate: 0 108%;
  transition: translate 1.15s var(--ease-out) calc(var(--i, 0) * 70ms);
}

.js .is-in .wi {
  translate: 0 0;
}

.js .top {
  opacity: 0;
  translate: 0 -10px;
  transition: opacity 1s var(--ease-out) 0.2s, translate 1s var(--ease-out) 0.2s;
}

.js.is-ready .top {
  opacity: 1;
  translate: 0 0;
}

/* ---------- Allagamento finale: verso i contatti lo schermo diventa lime */

.veil,
.hud,
.top::before,
.top .brand,
.top .clock,
.top .btn,
.top .btn-sq,
.brand-exp,
.contact,
.contact .lede,
.contact .mono,
.contact .eyebrow::before,
.mail,
.mail::after,
.mail-arrow,
.btn-quiet,
.foot,
.foot .mono,
.foot .brand {
  transition:
    color 0.6s var(--ease-out),
    background-color 0.6s var(--ease-out),
    border-color 0.6s var(--ease-out),
    opacity 0.6s var(--ease-out);
}

.is-flood .veil,
.is-flood .hud {
  opacity: 0;
}

.is-flood .top::before {
  background: linear-gradient(to bottom, rgb(198 244 50 / 0.92) 30%, transparent);
}

.is-flood .top .brand,
.is-flood .foot .brand,
.is-flood .contact,
.is-flood .mail,
.is-flood .mail-arrow {
  color: var(--ink);
}

.is-flood .brand-exp {
  color: var(--olive);
}

.is-flood .contact .lede,
.is-flood .contact .mono,
.is-flood .foot .mono,
.is-flood .top .clock {
  color: var(--olive);
}

.is-flood .contact .eyebrow::before,
.is-flood .btn-sq,
.is-flood .mail::after {
  background: var(--ink);
}

.is-flood .btn {
  color: var(--ink);
  border-color: rgb(17 17 17 / 0.35);
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.is-flood .btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--accent);
}

.is-flood .foot {
  border-top-color: rgb(17 17 17 / 0.16);
  background: none;
}

.is-flood ::selection {
  background: var(--ink);
  color: var(--accent);
}

/* ---------- Mobile e tablet */

@media (max-width: 899px) {
  .top {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: 16px;
  }

  .clock,
  .hud {
    display: none;
  }

  .chapter {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100vh;
    min-height: 100svh;
    padding: 50svh var(--gutter) 9svh;
  }

  .chapter-body,
  .chapter[data-text="right"] .chapter-body {
    grid-column: auto;
  }

  .hero {
    padding: 110px var(--gutter) 40px;
  }

  .hero-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 28px;
    margin-top: 30px;
  }

  .eyebrow {
    margin-bottom: 22px;
  }

  .h2 {
    margin-bottom: 22px;
  }

  .quadra-title {
    margin-bottom: 26px;
  }

  .contact {
    justify-content: center;
    padding-top: 22svh;
  }

  .contact-actions {
    margin-top: 40px;
  }

  .foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js [data-reveal],
  .js .wi,
  .js .top {
    translate: none;
    transition-property: opacity;
    transition-duration: 0.6s;
  }

  .cue-sq {
    animation: none;
  }
}
