/* ==========================================================================
   EMANUELE GRECO — design system condiviso
   Palette e tipografia dal brief 1.0: bianco #FFFFFF, nero #131313,
   pallino azzurro #47AFFF, Helvetica Neue Medium (testo) / Bold (titoli, UI).
   ========================================================================== */

:root {
  --white: #ffffff;
  --ink: #131313;
  --blue: #47afff;
  --focus: #0b6ccc;           /* anello di focus: azzurro scurito, 5:1 sul bianco */
  --paper: #f4f4f4;           /* grigio dei riquadri del brief */
  --line: rgba(19, 19, 19, 0.14);
  --line-strong: rgba(19, 19, 19, 0.32);
  --muted: rgba(19, 19, 19, 0.62);   /* ≥ 4.5:1 sul bianco */
  --faint: rgba(19, 19, 19, 0.2);
  --danger: #c4302b;

  /* Cielo del minigioco */
  --sky: #cdeeff;
  --sky-deep: #9fd8fb;
  --sky-line: #4ea3cf;

  --font: "Helvetica Neue", "HelveticaNeue", "Neue Haas Grotesk Text Pro", Helvetica, Arial, sans-serif;
  --w-medium: 500;
  --w-bold: 700;

  --gutter: clamp(16px, 3.2vw, 40px);
  --header-h: 64px;
  --read: 760px;              /* colonna di lettura 720–800 px */

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: light;
}

@media (max-width: 760px) {
  :root { --header-h: 56px; }
}

/* ---------- reset essenziale ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-weight: var(--w-medium);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, video, svg, canvas { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: var(--w-bold); line-height: 1.05; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--blue); color: var(--white); }
[hidden] { display: none !important; }

/* View Transitions fra le pagine (miglioramento progressivo) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: eg-vt-out 0.32s var(--ease-in-out) both; }
::view-transition-new(root) { animation: eg-vt-in 0.42s var(--ease-out) both; }
@keyframes eg-vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes eg-vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- accessibilità ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: 12px; z-index: 1000;
  padding: 10px 16px;
  background: var(--ink); color: var(--white);
  font-weight: var(--w-bold); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 999px;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: none; }

/* ---------- lingua: blocchi IT / EN ---------- */
html[lang="it"] [data-lang="en"],
html[lang="en"] [data-lang="it"] { display: none !important; }

/* ---------- tipografia di sistema ---------- */
.label {
  font-weight: var(--w-bold);
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.label--muted { color: var(--muted); }
.caption {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.45;
}
.num { font-variant-numeric: tabular-nums; }

/* ---------- pallino azzurro identificativo ---------- */
.dot {
  display: inline-block;
  width: 0.5em; height: 0.5em;
  min-width: 7px; min-height: 7px;
  border-radius: 50%;
  background: var(--blue);
  vertical-align: middle;
  flex: none;
}

/* ==========================================================================
   HEADER (renderizzato da core.js)
   ========================================================================== */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--header-h);
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: saturate(1.2) blur(20px);
  backdrop-filter: saturate(1.2) blur(20px);
  box-shadow: 0 1px 0 var(--line);
  transition: background 0.45s var(--ease-out), color 0.45s var(--ease-out), box-shadow 0.45s;
}
/* sopra il video: testo bianco su velatura, nessuna barra */
.site-header.is-overlay {
  color: var(--white);
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
.site-header.is-overlay::before {
  content: "";
  position: absolute; inset: 0 0 -40px 0;
  z-index: -1;
  background: linear-gradient(rgba(19, 19, 19, 0.42), rgba(19, 19, 19, 0));
  pointer-events: none;
}
.site-header.is-overlay :focus-visible { outline-color: var(--white); }
.site-header a, .site-header button {
  font-weight: var(--w-bold);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
}
.site-header__home {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px;
}
.site-header__slot { width: 56px; height: 1px; }  /* spazio riservato all'avatar */
.site-header__home, .site-header__nav { white-space: nowrap; }
@media (max-width: 380px) {
  .site-header__slot { width: 44px; }
  .site-header a, .site-header button { letter-spacing: 0.06em; }
}
.site-header__nav {
  justify-self: end;
  display: flex; align-items: center; gap: clamp(14px, 2vw, 30px);
}
.site-header__nav ol { display: flex; gap: clamp(14px, 2vw, 30px); }
.nav-link {
  position: relative;
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 10px 0;
}
.nav-link__n { opacity: 0.68; font-size: 10px; }
.nav-link::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 4px;
  height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.45s var(--ease-out);
}
.nav-link:hover::after,
.nav-link[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

.lang-switch { display: inline-flex; align-items: center; gap: 2px; }
.lang-switch button { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 44px; padding: 0 4px; opacity: 0.62; transition: opacity 0.2s; }
.lang-switch button[aria-pressed="true"] { opacity: 1; }
.lang-switch button:hover { opacity: 1; }
.lang-switch span { opacity: 0.62; }

.menu-toggle { display: none; min-height: 44px; min-width: 44px; align-items: center; justify-content: flex-end; }

@media (max-width: 1080px) {
  .site-header__nav ol, .site-header__nav .lang-switch { display: none; }
  .menu-toggle { display: inline-flex; }
}

/* ---------- menu mobile ---------- */
.menu {
  position: fixed; inset: 0; z-index: 200;
  background: var(--white);
  display: flex; flex-direction: column;
  padding: 0 var(--gutter) calc(24px + env(safe-area-inset-bottom));
  visibility: hidden;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.6s var(--ease-in-out), visibility 0s 0.6s;
}
.menu.is-open {
  visibility: visible;
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.6s var(--ease-in-out), visibility 0s;
}
.menu__bar {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
}
.menu__bar a, .menu__bar button {
  font-weight: var(--w-bold); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
}
.menu__list { margin-top: auto; display: grid; gap: 6px; }
.menu__list a {
  display: flex; align-items: baseline; gap: 14px;
  font-weight: var(--w-bold);
  font-size: clamp(40px, 12vw, 64px);
  line-height: 1;
  letter-spacing: -0.035em;
  padding: 6px 0;
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.5s var(--ease-out), transform 0.7s var(--ease-out);
}
.menu__list a .nav-link__n { font-size: 12px; letter-spacing: 0.08em; opacity: 0.68; transform: translateY(-1.6em); display: inline-block; }
.menu { outline: none; }
.menu.is-open .menu__list a { opacity: 1; transform: none; }
.menu.is-open .menu__list li:nth-child(2) a { transition-delay: 0.05s; }
.menu.is-open .menu__list li:nth-child(3) a { transition-delay: 0.1s; }
.menu.is-open .menu__list li:nth-child(4) a { transition-delay: 0.15s; }
.menu.is-open .menu__list li:nth-child(5) a { transition-delay: 0.2s; }
.menu__foot {
  margin-top: 40px; padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.menu__foot .lang-switch button { font-weight: var(--w-bold); font-size: 13px; letter-spacing: 0.1em; }
.menu__scribble { right: -40px; top: 90px; width: min(260px, 62vw); }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  position: relative;
  padding: clamp(64px, 10vw, 140px) var(--gutter) calc(20px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.site-footer__row {
  display: flex; flex-wrap: wrap; gap: 12px 28px;
  justify-content: space-between; align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.site-footer__row .label { font-size: 10.5px; }
.site-footer__links { display: flex; gap: 0 22px; flex-wrap: wrap; }
.site-footer__links a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer__links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.site-footer__base { display: grid; justify-items: start; margin-top: 18px; }
.site-footer__baseline { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 20px; }
.site-footer__base .label { font-size: 10.5px; }
.site-footer__cta { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; }
.site-footer__cta .dot { width: 7px; height: 7px; min-width: 7px; min-height: 7px; }
.site-footer__cta:hover span:last-child, .site-footer__mail:hover { text-decoration: underline; text-underline-offset: 3px; }
.site-footer__lang .lang-switch button:first-child { justify-content: flex-start; padding-left: 0; min-width: 24px; }
.site-footer__mail { display: inline-flex; align-items: center; min-height: 44px; text-transform: none; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.site-footer__mark {
  display: block;
  font-weight: var(--w-bold);
  font-size: 13.4vw;
  line-height: 0.78;
  letter-spacing: -0.055em;
  white-space: nowrap;
  margin: 0 0 clamp(20px, 3vw, 36px) -0.04em;
  user-select: none;
}
.site-footer--minimal { padding-top: 96px; }

/* ==========================================================================
   SCARABOCCHI (generati da core.js — originali, nello stile della reference)
   ========================================================================== */
.scribble {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
  color: var(--ink);
}
.scribble path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.has-scribbles { position: relative; isolation: isolate; overflow-x: clip; }
.has-scribbles > :not(.scribble) { position: relative; z-index: 1; }

/* ==========================================================================
   COMPONENTI
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px;
  padding: 0 34px;
  border-radius: 999px;
  background: var(--ink); color: var(--white);
  font-weight: var(--w-bold);
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  transition: transform 0.35s var(--ease-out), background 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.btn--block { width: 100%; }

.link-u { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* campi testo: linea editoriale */
.field { position: relative; display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; padding: 18px 0 14px; border-bottom: 1px solid var(--line-strong); transition: border-color 0.25s; }
.field:focus-within { border-color: var(--ink); }
.field__n { font-size: 11px; font-weight: var(--w-bold); color: var(--muted); padding-top: 3px; letter-spacing: 0.04em; }
.field__label { display: block; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%;
  border: 0; outline: 0; background: transparent;
  padding: 6px 0 2px;
  font-size: 18px;
  font-weight: var(--w-medium);
  resize: none;
  border-radius: 0;
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field__error { grid-column: 2; font-size: 13px; color: var(--danger); margin-top: 6px; min-height: 0; }
.field.is-invalid { border-color: var(--danger); }

/* finestre di dialogo */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(19, 19, 19, 0.28);
  display: grid; place-items: center;
  padding: 16px;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s;
}
.sheet-backdrop.is-open { opacity: 1; visibility: visible; transition: opacity 0.3s; }
.sheet {
  width: min(460px, 100%);
  max-height: calc(100svh - 32px);
  overflow: auto;
  background: var(--white);
  border-radius: 22px;
  padding: 28px 24px 24px;
  box-shadow: 0 30px 80px -20px rgba(19, 19, 19, 0.35);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.45s var(--ease-out);
}
.sheet-backdrop.is-open .sheet { transform: none; }
@media (max-width: 560px) {
  .sheet-backdrop { place-items: end center; padding: 0; }
  .sheet { width: 100%; border-radius: 22px 22px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateY(100%); }
}

/* toast */
.toast-host {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 400;
  transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--white);
  padding: 12px 18px; border-radius: 999px;
  font-size: 13px; font-weight: var(--w-bold);
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.45);
  animation: eg-toast 3.6s var(--ease-out) both;
}
@keyframes eg-toast {
  0% { opacity: 0; transform: translateY(14px) scale(0.96); }
  8%, 86% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* rivelazioni allo scroll */
[data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity 0.9s var(--ease-out), transform 1.1s var(--ease-out); }
[data-reveal].is-in { opacity: 1; transform: none; }
.no-js [data-reveal] { opacity: 1; transform: none; }

/* cursore-pallino (solo puntatori fini) */
.cursor-dot {
  position: fixed; left: 0; top: 0; z-index: 900;
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--blue);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, width 0.35s var(--ease-out), height 0.35s var(--ease-out), margin 0.35s var(--ease-out);
}
.cursor-dot.is-on { opacity: 1; }
.cursor-dot.is-link { width: 34px; height: 34px; margin: -17px 0 0 -17px; opacity: 0.35; }

/* etichetta di anteprima: catalogo e pagamenti dimostrativi */
.preview-flag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10px; font-weight: var(--w-bold); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}

/* ==========================================================================
   RIDUZIONE MOVIMENTO
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  .cursor-dot { display: none; }
}
