/* =========================================================================
   OPUS FORME — Stili custom del sito pubblico
   Tailwind copre la maggior parte; qui solo componenti riutilizzabili,
   stato pre-animazione e micro-interazioni non comode con sole utility.
   (Lo stile dell'area admin resta in style.css, non toccato.)
   ========================================================================= */

/* -------------------------------------------------------------------------
   Palette: nero, bianco, off-white + quadricromia (ciano / magenta / giallo).
   Accento principale = magenta. Tutti i token sono CSS variable, così il
   dark mode (.dark su <html>) cambia solo questi valori in un punto solo.
   ------------------------------------------------------------------------- */
:root {
  /* Neutri (tema chiaro) */
  --bg:        #fafaf7; /* off-white dominante */
  --surface:   #ffffff; /* card, form, sezioni */
  --surface-2: #f4f3ef; /* input, sfondi tenui */
  --ink:       #15171a; /* titoli / testo forte */
  --graphite:  #3d4248; /* corpo testo */
  --mute:      #7b828a; /* testo secondario */
  --line:      #e7e6e1; /* bordi sottili */

  /* Colori di quadricromia */
  --cyan:    #00aeef;
  --magenta: #ec008c;
  --yellow:  #ffd200;

  /* Accento interattivo (magenta) */
  --accent:      var(--magenta);
  --accent-dark: #c10073; /* hover + testo accento su sfondo chiaro */
  --accent-soft: rgba(236, 0, 140, 0.10); /* fondini tenui */

  /* Header (sfondo quando "scrolled") */
  --header-bg: rgba(250, 250, 247, 0.85);

  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Tema scuro */
.dark {
  --bg:        #0d0e10; /* deve combaciare col carving di logo-dark.svg */
  --surface:   #17191c;
  --surface-2: #1f2226;
  --ink:       #f4f5f3;
  --graphite:  #c7ccd1;
  --mute:      #8a9097;
  --line:      #2a2d31;

  --accent:      var(--magenta);
  --accent-dark: #ff5fb2; /* testo accento leggibile su sfondo scuro */
  --accent-soft: rgba(236, 0, 140, 0.16);

  --header-bg: rgba(13, 14, 16, 0.85);
}

html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }

/* Selezione testo coerente col brand */
::selection { background: rgba(236, 0, 140, 0.18); }

/* Rispetta chi preferisce meno movimento: niente animazioni/transizioni. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------------
   Reveal scroll-triggered.
   Progressive enhancement: lo stato "nascosto" si applica SOLO quando JS
   (Motion One) è pronto e aggiunge .motion-ready su <html>. Se il CDN o JS
   falliscono, i contenuti restano perfettamente visibili.
   ------------------------------------------------------------------------- */
.motion-ready [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  will-change: opacity, transform;
}

/* =========================== HEADER =================================== */
#site-header.is-scrolled {
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

/* Link di navigazione desktop */
.nav-link {
  position: relative;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--graphite);
  transition: color 0.4s var(--ease-soft);
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: width 0.4s var(--ease-soft);
}
.nav-link:hover { color: var(--accent-dark); }
.nav-link:hover::after,
.nav-link.is-active::after { width: 100%; }
.nav-link.is-active { color: var(--accent-dark); }

.nav-link--cta {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 1.1rem;
}
.nav-link--cta::after { display: none; }
.nav-link--cta:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Toggle dark mode */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--graphite);
  background: transparent;
  transition: color 0.4s var(--ease-soft), border-color 0.4s var(--ease-soft), transform 0.4s var(--ease-soft);
}
.theme-toggle:hover { color: var(--accent-dark); border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle svg { width: 20px; height: 20px; }
/* Mostra luna in chiaro, sole in scuro */
.theme-ico-sun { display: none; }
.dark .theme-ico-sun { display: block; }
.dark .theme-ico-moon { display: none; }

/* Menu mobile a tutto schermo */
#mobile-menu { background: var(--bg); }
.mobile-link {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  transition: color 0.3s var(--ease-soft);
}
.mobile-link:hover { color: var(--accent-dark); }

#mobile-menu.is-open {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

/* Hamburger animato */
.hamburger { position: relative; display: block; width: 24px; height: 16px; }
.hamburger span {
  position: absolute;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.4s var(--ease-soft), opacity 0.3s var(--ease-soft), top 0.4s var(--ease-soft);
}
.hamburger span:nth-child(1) { top: 0; }
.hamburger span:nth-child(2) { top: 7px; }
.hamburger span:nth-child(3) { top: 14px; }
#menu-toggle.is-open .hamburger span:nth-child(1) { top: 7px; transform: rotate(45deg); }
#menu-toggle.is-open .hamburger span:nth-child(2) { opacity: 0; }
#menu-toggle.is-open .hamburger span:nth-child(3) { top: 7px; transform: rotate(-45deg); }

/* =========================== BOTTONI ================================= */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  padding: 0.85rem 1.6rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(236, 0, 140, 0.65);
  transition: transform 0.4s var(--ease-soft), background 0.4s var(--ease-soft), box-shadow 0.4s var(--ease-soft);
}
.btn-primary:hover {
  background: #c10073;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -10px rgba(236, 0, 140, 0.7);
}
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.85rem 1.6rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.4s var(--ease-soft), color 0.4s var(--ease-soft);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-dark); }

/* ===================== TIPOGRAFIA SEZIONI =========================== */
.section-eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent-dark);
}
.section-title {
  margin-top: 0.6rem;
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ===================== CARD (pilastri / servizi) ==================== */
.card {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  padding: 1.6rem;
  height: 100%;
  transition: transform 0.5s var(--ease-soft), box-shadow 0.5s var(--ease-soft), border-color 0.5s var(--ease-soft);
}
.card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--card-accent, var(--accent)) 45%, transparent);
  box-shadow: 0 24px 50px -28px rgba(0, 0, 0, 0.30);
}
/* L'icona usa un colore di quadricromia diverso per card (impostato da JS via --card-accent) */
.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 14%, transparent);
  color: var(--card-accent, var(--accent-dark));
  font-size: 1.3rem;
}

/* ========================== FORM ==================================== */
.field-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--surface-2);
  padding: 0.75rem 0.95rem;
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.3s var(--ease-soft), box-shadow 0.3s var(--ease-soft), background 0.3s var(--ease-soft);
}
.field-input::placeholder { color: var(--mute); }
.field-input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(236, 0, 140, 0.14);
}
.field-input.is-invalid {
  border-color: #e0586f;
  box-shadow: 0 0 0 4px rgba(224, 88, 111, 0.1);
}
.field-file {
  width: 100%;
  font-size: 0.9rem;
  color: var(--graphite);
}
.field-file::file-selector-button {
  margin-right: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface);
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.3s var(--ease-soft);
}
.field-file::file-selector-button:hover { border-color: var(--accent); }

.field-error {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #c8475c;
}

.contact-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  flex: 0 0 auto;
  border-radius: 0.9rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.contact-ico svg { width: 1.6rem; height: 1.6rem; }

/* Spinner del bottone invia */
.cf-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cf-spin 0.7s linear infinite;
}
@keyframes cf-spin { to { transform: rotate(360deg); } }

/* ==================== INDICATORE DI SCROLL ========================= */
.scroll-indicator {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 26px;
  height: 42px;
  border: 2px solid currentColor;
  border-radius: 14px;
  opacity: 0.6;
}
.scroll-dot {
  margin-top: 7px;
  width: 4px;
  height: 8px;
  border-radius: 4px;
  background: currentColor;
  animation: scroll-bob 1.8s var(--ease-soft) infinite;
}
@keyframes scroll-bob {
  0%   { transform: translateY(0); opacity: 1; }
  60%  { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ========================= GALLERY ================================= */
.gallery-item {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 1rem;
  cursor: pointer;
  background: var(--surface-2);
  break-inside: avoid; /* evita tagli tra le colonne masonry */
}
.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* "cut" dinamico: il thumbnail è un crop, il full si vede nel lightbox */
  transition: transform 0.6s var(--ease-soft), filter 0.6s var(--ease-soft);
}
.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent 55%);
  opacity: 0;
  transition: opacity 0.5s var(--ease-soft);
}
.gallery-item:hover img { transform: scale(1.05); }
.gallery-item:hover::after { opacity: 1; }
.gallery-item .gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 0.9rem 1rem;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.5s var(--ease-soft), transform 0.5s var(--ease-soft);
}
.gallery-item:hover .gallery-caption { opacity: 1; transform: translateY(0); }

/* ========================= LIGHTBOX =============================== */
#lightbox.is-open { display: flex; }
.lb-arrow {
  position: absolute;
  top: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  transition: background 0.3s var(--ease-soft);
}
.lb-arrow:hover { background: rgba(255, 255, 255, 0.22); }

.social-foot {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.3s var(--ease-soft);
}
.social-foot:hover { color: var(--accent-dark); }
.social-foot-ico { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }

/* Focus visibile per accessibilità da tastiera */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
  border-radius: 4px;
}
