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

/* Bianco e nero pieni. Un solo carattere: Jost (800 per i titoli, 500 per i testi). */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #1c1c1c;
  --font: "Jost", "Century Gothic", "Segoe UI", "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Roboto", "Noto Sans", Arial, sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

#gl-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
}

/* Stessa posizione del logo WebGL: centro orizzontale esatto, 39% dall'alto (38% in verticale) */
.fallback-logo {
  position: fixed;
  left: 50%;
  top: 39%;
  transform: translate(-50%, -50%);
  width: calc(min(100vw, 100vh) * 0.43);
  height: calc(min(100vw, 100vh) * 0.43);
  z-index: 2;
  display: none;
  pointer-events: none;
  color: #000;
}

@media (orientation: portrait) {
  .fallback-logo {
    top: 38%;
    width: 64vw;
    height: 64vw;
  }
}

html.no-webgl .fallback-logo,
html.reduced-motion .fallback-logo {
  display: block;
}

html.no-webgl #gl-canvas,
html.reduced-motion #gl-canvas {
  display: none;
}

.fallback-logo svg {
  width: 72%;
  height: 72%;
  margin: 14%;
  display: block;
}

.ui-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(18px, 2.8vw, 34px) clamp(20px, 3.6vw, 48px);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.lang-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  pointer-events: auto;
}

.lang-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 7px 9px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}

.lang-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.lang-btn:focus-visible,
.contact-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.lang-btn[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

/* Testo sotto il monogramma: non lo copre mai */
.center-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding-bottom: clamp(10px, 2.6vh, 28px);
}

.copy-block {
  width: 100%;
  max-width: 1180px;
}

/* ---------- Riscrittura robotica delle scritte (vedi rewrite.js) ---------- */
/* Prima che lo script parta le scritte sono nascoste; se non parte, dopo 4 secondi ricompaiono da sole. */
html.rw-pending [data-rw] {
  visibility: hidden;
  animation: rw-failsafe 0s linear 4s forwards;
}

@keyframes rw-failsafe {
  to {
    visibility: visible;
  }
}

[data-rw].rw-wait {
  visibility: hidden;
}

.rw {
  position: relative;
  display: block;
}

/* Il testo vero resta al suo posto (trasparente) e tiene lo spazio definitivo */
.rw.is-rw .rw-real {
  color: transparent;
}

/* Strato decorativo: stesse righe del testo finale, mai un a capo in più */
.rw-fx {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.rw.is-rw .rw-fx {
  display: flex;
}

.rw-line {
  display: block;
  white-space: pre;
}

.wordmark .rw-fx,
.contact-link .rw-fx {
  align-items: flex-start;
}

.right-meta .rw-fx {
  align-items: flex-end;
}

.eyebrow {
  margin-bottom: clamp(8px, 1.5vh, 14px);
  line-height: 1;
}

.eyebrow > span {
  display: inline-block;
  background: var(--fg);
  color: var(--bg);
  padding: 6px 10px 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.headline {
  font-size: clamp(27px, min(4.7vw, 7.6vh), 70px);
  font-weight: 800;
  letter-spacing: -0.022em;
  line-height: 0.95;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: break-word;
  margin-bottom: clamp(8px, 1.5vh, 14px);
}

.subcopy {
  font-size: clamp(13px, 1.2vw, 15.5px);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.4;
  color: var(--muted);
  text-wrap: balance;
}

/* Footer */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.contact-link {
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 2px solid var(--fg);
  padding-bottom: 2px;
}

.right-meta {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Pallino: la freccia di sistema si nasconde solo mentre il pallino è visibile */
.cm-dot {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cm-dot.is-on {
  opacity: 1;
}

html.has-dot,
html.has-dot * {
  cursor: none !important;
}

@media (max-width: 760px) {
  .ui-layer {
    padding: 16px 16px 18px;
  }
  .top-bar {
    flex-direction: column;
    gap: 10px;
  }
  .wordmark {
    font-size: 20.5px;
  }
  .headline {
    font-size: clamp(25px, min(8.2vw, 4.6vh), 44px);
  }
  /* Su telefono: email e firma centrate, una sotto l'altra */
  .bottom-bar {
    flex-direction: column;
    justify-content: center;
    gap: 10px;
  }
  .right-meta {
    font-size: 11px;
    letter-spacing: 0.1em;
  }
  .wordmark .rw-fx,
  .contact-link .rw-fx,
  .right-meta .rw-fx {
    align-items: center;
  }
}
