/* ==========================================================================
   Bottega Filippi - main.css (v2, tema scuro virale)
   Design tokens e copy: design/BRIEF.md. Contratto DOM: docs/ARCHITECTURE.md.
   Mobile-first, breakpoint 640 / 1024. Nessun framework, nessun CDN.
   ========================================================================== */

/* --- Font ----------------------------------------------------------------- */

@font-face {
  font-family: "Archivo Black";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/archivoblack-400.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-weight: 300 700;
  font-display: swap;
  src: url("/fonts/spacegrotesk-var.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;
}

/* --- Design tokens (BRIEF.md sezione 2, theme lock scuro) ------------------ */

:root {
  /* Colore ---------------------------------------------------------------- */
  --bg:            #0B0C0E;  /* fondo pagina, quasi nero (mai #000)          */
  --surface:       #14161A;  /* card, pannelli wizard, input                 */
  --surface-2:     #1B1E24;  /* hover card, drop zone attiva, kbd            */
  --ink:           #F4F5F7;  /* testo primario (mai bianco puro)             */
  --ink-soft:      #A7ADB8;  /* testo secondario, helper, caption            */
  --accent:        #3EE0FF;  /* ciano laser: CTA, prezzi, link, stati attivi */
  --accent-deep:   #18B6D4;  /* pressed, bordi attivi, link visitati         */
  --accent-wash:   rgba(62, 224, 255, 0.08);  /* fondo radio selezionato, righe attive */
  --border:        #23272E;  /* hairline standard 1px                        */
  --border-strong: #3B424D;  /* bordi input, radio non selezionato           */
  --ok:            #4ADE80;  /* conferme                                     */
  --err:           #FF6B62;  /* errori (testo + bordo campo)                 */

  /* Tipografia -------------------------------------------------------------*/
  --font-display: "Archivo Black", "Arial Black", sans-serif;
  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --fs-display: clamp(3rem, 1.8rem + 7.5vw, 7.5rem);       /* H1 hero, enorme  */
  --fs-h2:      clamp(2rem, 1.35rem + 3.2vw, 3.5rem);      /* titoli sezione   */
  --fs-h3:      clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);  /* card, step       */
  --fs-lead:    clamp(1.125rem, 1.05rem + 0.5vw, 1.375rem);/* sottotitoli      */
  --fs-body:    clamp(1rem, 0.97rem + 0.2vw, 1.125rem);    /* paragrafi        */
  --fs-small:   0.875rem;                                   /* helper, label    */
  --fs-micro:   0.8125rem;                                  /* note legali      */

  --lh-display: 0.95;
  --lh-heading: 1.05;
  --lh-body:    1.55;

  /* Spazio ------------------------------------------------------------------*/
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.5rem;
  --space-6:  2rem;
  --space-7:  3rem;
  --space-8:  4rem;
  --section-y: clamp(3.5rem, 2rem + 5vw, 6rem);

  /* Forma --------------------------------------------------------------------*/
  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 12px;

  /* Ombre e glow ---------------------------------------------------------------*/
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --glow-accent: 0 0 24px rgba(62, 224, 255, 0.16);

  /* Focus ------------------------------------------------------------------------*/
  --focus-ring: 2px solid var(--accent);

  /* Motion -------------------------------------------------------------------------*/
  --dur-fast:   150ms;
  --dur-base:   200ms;
  --dur-slow:   250ms;
  --ease-out:   cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout --------------------------------------------------------------------------*/
  --container-max: 72rem;
  --container-pad: clamp(1rem, 4vw, 2rem);
  --prose-max: 40rem;

  /* Estensioni locali (non nel BRIEF: solo supporto tecnico) --------------------------*/
  --range-track: #737C89; /* >=3:1 su --surface (WCAG 1.4.11 non-text) */
  --border-input: #6B7480; /* >=3:1 su --surface (WCAG 1.4.11): campi checkout e radio card non selezionate, unico confine visivo su fondo --surface */
}

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

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1, h2, h3, h4, p, ul, ol, figure, blockquote, fieldset {
  margin: 0;
  padding: 0;
}

ul, ol { list-style: none; }

[hidden] { display: none !important; }

::selection {
  background: rgba(62, 224, 255, 0.28);
  color: var(--ink);
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.icon { flex-shrink: 0; }

.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container-narrow { max-width: 52rem; }

.section { padding-block: var(--section-y); }

.section-head { margin-bottom: var(--space-7); }

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-h2);
  line-height: var(--lh-heading);
  letter-spacing: -0.01em;
}

.section-head .lead { margin-top: var(--space-4); }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: var(--prose-max);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.text-link:hover,
.text-link:focus-visible {
  color: var(--accent-deep);
  text-decoration-color: currentColor;
}

/* --- Skip link --------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100%;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-m);
}

.skip-link:focus { top: var(--space-4); }

#scroll-sentinel {
  position: absolute;
  top: 0;
  height: 1px;
  width: 1px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:active { transform: scale(0.98); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* CTA primaria: fondo ciano, testo scuro. Glow SOLO su hover (BRIEF). */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover:not(:disabled),
.btn-primary:focus-visible {
  background: var(--accent-deep);
  box-shadow: var(--glow-accent);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--ink-soft);
  background: var(--surface-2);
}

.btn-small {
  min-height: 44px;
  padding: 0.55rem 1rem;
  font-size: var(--fs-small);
}

.btn-wide { width: 100%; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  /* fallback opaco: senza backdrop-filter il testo sottostante trasparirebbe */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--dur-base) var(--ease-out);
}

@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .site-header {
    background: rgba(11, 12, 14, 0.88);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

.site-header.is-scrolled { box-shadow: var(--shadow-2); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 64px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 2rem);
}

.site-nav > a:not(.btn) {
  display: none;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 5px;
  transition: text-decoration-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.site-nav > a:not(.btn):hover,
.site-nav > a:not(.btn):focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

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

.hero {
  padding-block: clamp(3rem, 2rem + 5vw, 6rem) clamp(3rem, 2rem + 5vw, 6rem);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  max-width: 14ch;
}

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

.hero-grid {
  display: grid;
  gap: var(--space-6);
  align-items: center;
  margin-top: var(--space-6);
}

.hero-copy .lead { max-width: 34rem; }

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  margin-top: var(--space-6);
}

.hero-media img {
  border-radius: var(--radius-l);
  border: 1px solid var(--border);
}

/* --- Tre mosse --------------------------------------------------------------- */

.steps {
  counter-reset: step;
  display: grid;
  gap: var(--space-5);
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
}

/* Il numero è solo grafico (BRIEF 4.3): grande, in Archivo Black. */
.steps li::before {
  content: counter(step);
  display: block;
  font-family: var(--font-display);
  font-size: 2.5rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: var(--space-4);
}

.steps h3 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  margin-bottom: var(--space-2);
}

.steps p { color: var(--ink-soft); }

/* --- Editor: sezione e wizard ------------------------------------------------------ */

.noscript-note {
  max-width: var(--prose-max);
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
}

/* Card scura con bordo luminoso sottile (gradient border via mask). */
.wizard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: clamp(1.25rem, 1rem + 2.5vw, 2.5rem);
}

.wizard::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    160deg,
    rgba(62, 224, 255, 0.35),
    rgba(62, 224, 255, 0.04) 30%,
    rgba(62, 224, 255, 0.04) 70%,
    rgba(62, 224, 255, 0.18)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Indicatore step 1-4 */

.wizard-steps {
  counter-reset: wstep;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-7);
}

.wizard-steps li {
  counter-increment: wstep;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}

.wizard-steps li:not(:last-child) { flex: 1 1 auto; }

.wizard-steps li::before {
  content: counter(wstep);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  font-size: var(--fs-micro);
  font-weight: 700;
  line-height: 1;
  transition: background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}

.wizard-steps li:not(:last-child)::after {
  content: "";
  flex: 1 1 1rem;
  min-width: 0.75rem;
  height: 1px;
  background: var(--border);
  margin-inline: var(--space-2);
}

/* Step attivo */
#editor[data-step="1"] .wizard-steps li:nth-child(1),
#editor[data-step="2"] .wizard-steps li:nth-child(2),
#editor[data-step="3"] .wizard-steps li:nth-child(3),
#editor[data-step="4"] .wizard-steps li:nth-child(4) {
  color: var(--ink);
}

#editor[data-step="1"] .wizard-steps li:nth-child(1)::before,
#editor[data-step="2"] .wizard-steps li:nth-child(2)::before,
#editor[data-step="3"] .wizard-steps li:nth-child(3)::before,
#editor[data-step="4"] .wizard-steps li:nth-child(4)::before {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
}

/* Step completati */
#editor[data-step="2"] .wizard-steps li:nth-child(-n+1)::before,
#editor[data-step="3"] .wizard-steps li:nth-child(-n+2)::before,
#editor[data-step="4"] .wizard-steps li:nth-child(-n+3)::before {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

@media (max-width: 39.99rem) {
  .wizard-steps li span { display: none; }
  #editor[data-step="1"] .wizard-steps li:nth-child(1) span,
  #editor[data-step="2"] .wizard-steps li:nth-child(2) span,
  #editor[data-step="3"] .wizard-steps li:nth-child(3) span,
  #editor[data-step="4"] .wizard-steps li:nth-child(4) span {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Pannelli: visibile solo quello attivo, entra morbido ed esce secco */

.wizard-panel { display: none; }

#editor[data-step="1"] #step-upload,
#editor[data-step="2"] #step-crop,
#editor[data-step="3"] #step-preview,
#editor[data-step="4"] #step-checkout {
  display: block;
  animation: panel-in var(--dur-slow) var(--ease-out) both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  margin-bottom: var(--space-3);
}

.panel-hint {
  color: var(--ink-soft);
  max-width: var(--prose-max);
  margin-bottom: var(--space-6);
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-7);
}

.wizard-nav .btn-step-next,
.wizard-nav button[type="submit"] { margin-left: auto; }

/* --- Step 1: upload ------------------------------------------------------------------ */

#upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 220px;
  margin-top: var(--space-5);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-l);
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}

#upload-drop:hover,
#upload-drop:focus-visible,
#upload-drop.is-dragover {
  border-color: var(--accent);
  background: var(--surface-2);
}

#upload-drop .icon {
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.upload-main {
  font-size: var(--fs-lead);
  font-weight: 700;
}

.upload-sub {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

.upload-hint {
  margin-top: var(--space-3);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

#upload-error {
  margin-top: var(--space-3);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--err);
}

#upload-error:empty { display: none; }

.upload-sample {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

/* --- Step 2: inquadratura -------------------------------------------------------------- */

.crop-layout {
  display: grid;
  gap: var(--space-6);
}

.crop-stage-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#crop-stage {
  position: relative;
  overflow: hidden;
  touch-action: none;
  border-radius: var(--radius-m);
  aspect-ratio: var(--crop-ar, 13 / 18);
  width: min(100%, 400px);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  cursor: grab;
}

#crop-stage:active { cursor: grabbing; }

.crop-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.crop-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* --- Radio formato e orientamento ------------------------------------------------------- */

.choice-group { border: 0; }

.choice-group legend {
  font-size: var(--fs-small);
  font-weight: 500;
  margin-bottom: var(--space-3);
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}

.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.choice:hover { border-color: var(--ink-soft); }

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.choice:has(input:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.choice-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.choice-title {
  font-weight: 500;
  font-size: var(--fs-body);
}

.choice-price {
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--accent);
}

.price-note {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

/* --- Slider (range) cross-browser --------------------------------------------------------- */

.field-range label {
  display: block;
  font-size: var(--fs-small);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--range-track);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-fast) var(--ease-out);
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--range-track);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-1);
}

/* Outline sull'input, non sul thumb: Safari non disegna outline sugli
   pseudo-elementi del range e il focus diventerebbe invisibile. */
input[type="range"]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-s);
}

/* --- Step 3: anteprima 3D ----------------------------------------------------------------------- */

.preview-layout {
  display: grid;
  gap: var(--space-6);
}

/* La scena three.js ha già il suo sfondo: qui solo cornice sottile
   luminosa + glow (ammesso SOLO qui e sulla CTA primaria, BRIEF). */
#scene-mount {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 280px;
  border-radius: var(--radius-l);
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--glow-accent);
}

#scene-mount::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 1;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    160deg,
    rgba(62, 224, 255, 0.5),
    rgba(62, 224, 255, 0.08) 35%,
    rgba(62, 224, 255, 0.08) 65%,
    rgba(62, 224, 255, 0.3)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

#scene-mount canvas { display: block; }

/* Con il fallback 2D il mount si adatta al contenuto: niente cornice
   doppia né canvas tagliata dall'aspect-ratio fisso. */
#scene-mount.has-2d-fallback {
  aspect-ratio: auto;
  min-height: 0;
  overflow: visible;
  background: none;
  border: 0;
  box-shadow: none;
}

#scene-mount.has-2d-fallback::before { content: none; }

.preview-2d-note {
  margin-bottom: var(--space-4);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  max-width: var(--prose-max);
}

/* Cornice per il fallback 2D senza WebGL (usata da app.js) */
.plexi-frame {
  position: relative;
  padding: clamp(1rem, 4vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  box-shadow: var(--glow-accent);
}

.plexi-frame canvas,
.plexi-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-s);
  box-shadow: 0 18px 30px -18px rgba(0, 0, 0, 0.7);
}

.preview-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Blocco prezzo: lastra e spedizione SEMPRE voci separate + totale. */
.price-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.price-row-label { color: var(--ink-soft); }

.price-row-value { font-weight: 700; }

#price-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.price-total {
  margin-top: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.price-total .price-row-label {
  color: var(--ink);
  font-weight: 500;
}

.price-total .price-row-value {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
}

/* --- Step 4: checkout --------------------------------------------------------------------------- */

.checkout-layout {
  display: grid;
  gap: var(--space-7);
  align-items: start;
}

.field { margin-bottom: var(--space-4); }

.field label {
  display: block;
  font-size: var(--fs-small);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-s);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:hover,
.field textarea:hover { border-color: var(--ink-soft); }

.field input:focus-visible,
.field textarea:focus-visible {
  border-color: var(--accent);
  outline: var(--focus-ring);
  outline-offset: 0;
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field input.is-invalid,
.field textarea.is-invalid {
  border-color: var(--err);
}

.field-help {
  margin-top: var(--space-1);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

.field-error {
  margin-top: var(--space-1);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--err);
}

.field-error:empty { display: none; }

.input-uppercase { text-transform: uppercase; }

.form-row {
  display: grid;
  gap: 0 var(--space-4);
}

.privacy-note {
  margin-top: var(--space-2);
  font-size: var(--fs-micro);
  color: var(--ink-soft);
}

#order-summary {
  padding: var(--space-5);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
}

#order-summary h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-h3);
  margin-bottom: var(--space-4);
}

.summary-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-variant-numeric: tabular-nums;
}

.summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--ink-soft);
  font-size: var(--fs-small);
}

.summary-price {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.summary-total {
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-weight: 500;
  font-size: var(--fs-body);
  color: var(--ink);
}

.summary-total .summary-price {
  font-size: 1.375rem;
  line-height: 1;
  color: var(--accent);
}

.summary-note {
  margin-top: var(--space-4);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

#order-feedback {
  margin-top: var(--space-6);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface-2);
}

#order-feedback:empty { display: none; }

#order-feedback.success {
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--ok);
}

#order-feedback.error {
  background: rgba(255, 107, 98, 0.08);
  border-color: rgba(255, 107, 98, 0.4);
  color: var(--err);
}

#order-feedback strong,
.order-feedback-title { font-weight: 700; }

/* --- Stati di caricamento -------------------------------------------------------------------------- */

.is-loading {
  position: relative;
  pointer-events: none;
}

.is-loading > * { opacity: 0.45; }

.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: linear-gradient(
    100deg,
    rgba(62, 224, 255, 0) 30%,
    rgba(62, 224, 255, 0.12) 50%,
    rgba(62, 224, 255, 0) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton {
  background: var(--surface-2);
  border-radius: var(--radius-s);
  background-image: linear-gradient(
    100deg,
    rgba(244, 245, 247, 0) 30%,
    rgba(244, 245, 247, 0.08) 50%,
    rgba(244, 245, 247, 0) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* --- Il prodotto (griglia asimmetrica: 1 voce grande + 3 compatte) ------------------------------------ */

.product-grid {
  display: grid;
  gap: var(--space-6);
}

.product-main {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-l);
  border: 1px solid var(--border);
  background: var(--surface);
}

.product-main img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.product-main-copy { padding: var(--space-5) var(--space-6) var(--space-6); }

.product-main h3 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  margin-bottom: var(--space-2);
}

.product-main p { color: var(--ink-soft); }

.product-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.product-item h3 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: var(--lh-heading);
  margin-bottom: var(--space-2);
}

.product-item p {
  color: var(--ink-soft);
  font-size: var(--fs-small);
  line-height: 1.6;
}

/* --- Fascia anteprima (al posto delle recensioni) ------------------------------------------------------ */

.anteprima {
  background: var(--surface);
  border-block: 1px solid var(--border);
}

.anteprima-grid {
  display: grid;
  gap: var(--space-7);
  align-items: center;
}

.anteprima-copy .lead {
  margin-top: var(--space-4);
  margin-bottom: var(--space-6);
}

.anteprima-visual {
  display: flex;
  justify-content: center;
  padding: var(--space-5);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
}

.anteprima-visual svg {
  width: 100%;
  max-width: 480px;
  height: auto;
}

/* --- FAQ ---------------------------------------------------------------------------------------------------- */

.faq-list .faq-item { border-top: 1px solid var(--border); }

.faq-list .faq-item:last-child { border-bottom: 1px solid var(--border); }

.faq-list summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 44px;
  padding-block: var(--space-4);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.faq-list summary::-webkit-details-marker { display: none; }

.faq-list summary:hover { color: var(--accent); }

.faq-list summary .icon {
  color: var(--ink-soft);
  transition: transform var(--dur-base) var(--ease-out);
}

.faq-list details[open] summary .icon { transform: rotate(45deg); }

.faq-body {
  overflow: hidden;
  min-height: 0;
  padding-bottom: var(--space-5);
  max-width: var(--prose-max);
  color: var(--ink-soft);
}

/* Apertura animata col pattern grid-template-rows 0fr -> 1fr (BRIEF 5)
   sui browser con ::details-content; altrove un fade breve. */
@supports selector(details::details-content) {
  .faq-item::details-content {
    display: grid;
    grid-template-rows: 0fr;
    transition:
      grid-template-rows var(--dur-base) var(--ease-out),
      content-visibility var(--dur-base) allow-discrete;
  }

  .faq-item[open]::details-content { grid-template-rows: 1fr; }
}

@supports not (selector(details::details-content)) {
  .faq-list details[open] .faq-body {
    animation: faq-in var(--dur-base) var(--ease-out);
  }
}

@keyframes faq-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

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

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-8) var(--space-6);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.site-footer .wordmark { font-size: 1.125rem; }

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-micro);
  color: var(--ink-soft);
}

.footer-meta a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color var(--dur-fast) var(--ease-out);
}

.footer-meta a:hover,
.footer-meta a:focus-visible { text-decoration-color: currentColor; }

/* --- Reveal on scroll (una volta sola, stagger 60ms, max 3 fratelli) ------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  html.js-reveal [data-reveal] {
    opacity: 0;
    transform: translateY(10px);
    transition:
      opacity var(--dur-slow) var(--ease-out),
      transform var(--dur-slow) var(--ease-out);
  }

  html.js-reveal [data-reveal].reveal {
    opacity: 1;
    transform: none;
  }

  html.js-reveal [data-reveal]:nth-child(2) { transition-delay: 60ms; }
  html.js-reveal [data-reveal]:nth-child(n+3) { transition-delay: 120ms; }
}

/* --- Reduced motion ---------------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html { scroll-behavior: auto; }
}

/* --- Breakpoint 640 ------------------------------------------------------------------------------------------------ */

@media (min-width: 40rem) {
  .site-nav > a:not(.btn) { display: inline-flex; }

  .header-inner { min-height: 72px; }

  .steps { grid-template-columns: repeat(3, 1fr); }

  .crop-layout {
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: var(--space-7);
  }

  .form-row { grid-template-columns: 2fr 1fr 1fr; }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
  }

  .product-main { grid-column: 1 / -1; }
}

/* --- Breakpoint 1024 ---------------------------------------------------------------------------------------------- */

@media (min-width: 64rem) {
  .hero-grid {
    grid-template-columns: 5fr 6fr;
    gap: var(--space-8);
  }

  .product-grid { grid-template-columns: repeat(3, 1fr); }

  .product-main {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 3fr 2fr;
    align-items: center;
  }

  .product-main img { height: 100%; }

  .product-main-copy { padding: var(--space-7); }

  .preview-layout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: var(--space-7);
    align-items: start;
  }

  #scene-mount { aspect-ratio: 4 / 3; }

  .checkout-layout { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

  #order-summary {
    position: sticky;
    top: 6rem;
  }

  .anteprima-grid { grid-template-columns: 6fr 5fr; }
}

/* Ancore: il header sticky non deve coprire i titoli di sezione */
[id] { scroll-margin-top: 5rem; }
