/* --- Reset e base tipografia --- */
*,
*::before,
*::after {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
}

html {
  background-color: var(--bg);
}

:root {
  --bg: #05070b;
  --bg-soft: #0a0f1a;
  --panel: rgba(255, 255, 255, 0.06);
  --text: #e6f1ff;
  --muted: #9fb3c8;
  --brand: #00f5ff;
  --brand-2: #7b5cff;
  --accent: #00ffa3;
  --danger: #ff3b81;
  --glow: 0 0 24px rgba(0, 245, 255, .35), 0 0 48px rgba(123, 92, 255, .25);
  --radius: 18px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --border: rgba(255, 255, 255, .12);
  --border-soft: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --border-hover: rgba(255, 255, 255, .22);
}

:root[data-theme='light'] {
  --bg: #f5f7fb;
  --bg-soft: #f0f3fa;
  --panel: rgba(0, 0, 0, 0.04);
  --text: #0a0f1a;
  --muted: #3b4b5e;
  --shadow: 0 8px 20px rgba(0, 0, 0, .08);
  --border: rgba(0, 0, 0, .12);
  --border-soft: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .16);
  --border-hover: rgba(0, 0, 0, .22);
  --accent: #008556;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, "Segoe UI Variable", "SF Pro Text", "SF Pro Display", Arial, "Noto Sans", sans-serif;
  background: radial-gradient(60% 60% at 60% 0%, rgba(0, 245, 255, 0.15), transparent 60%),
    radial-gradient(50% 50% at 10% 30%, rgba(123, 92, 255, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* --- Background grid animata --- */
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .3;
  background:
    linear-gradient(transparent 0 49%, rgba(0, 245, 255, .35) 50%, transparent 51%) 0 0/ 100% 38px,
    linear-gradient(90deg, transparent 0 49%, rgba(123, 92, 255, .35) 50%, transparent 51%) 0 0/ 38px 100%;
  mask: radial-gradient(circle at 50% 10%, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, .7) 55%, rgba(0, 0, 0, 0) 75%);
  animation: drift 20s linear infinite;
}

:root[data-theme='light'] .grid-bg {
  opacity: 1;
  background:
    linear-gradient(transparent 0 49%, rgba(0, 0, 0, .1) 50%, transparent 51%) 0 0/ 100% 38px,
    linear-gradient(90deg, transparent 0 49%, rgba(0, 0, 0, .08) 50%, transparent 51%) 0 0/ 38px 100%;
}

@keyframes drift {
  to {
    transform: translateY(38px);
  }
}

/* --- Animazione pulsazione badge --- */
@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(0, 245, 255, .4);
    opacity: 1
  }

  50% {
    box-shadow: 0 0 0 6px rgba(0, 245, 255, 0);
    opacity: .7
  }
}

@keyframes spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* --- Layout --- */
.container {
  width: min(1120px, 92%);
  margin-inline: auto;
}

header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(10, 15, 26, .75), rgba(10, 15, 26, .35));
  border-bottom: 1px solid var(--border-soft);
  z-index: 50;
}

:root[data-theme='light'] header {
  background: linear-gradient(180deg, rgba(245, 247, 251, .75), rgba(245, 247, 251, .35));
}

.nav {
  display: flex;
  align-items: center;
  padding: 14px 0;
}

.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--glow);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand span {
  font-weight: 700;
  letter-spacing: .2px
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 16px;
  font-weight: 600
}

.nav-links a:hover {
  color: var(--text)
}

.theme-toggle {
  margin-left: 24px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, border-color .2s ease
}

.theme-toggle:hover {
  background: var(--panel);
  border-color: var(--border-hover)
}

.theme-toggle svg {
  width: 20px;
  height: 20px
}

.theme-toggle .sun {
  display: none
}

[data-theme='light'] .theme-toggle .sun {
  display: block
}

[data-theme='light'] .theme-toggle .moon {
  display: none
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  margin-left: 12px;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, border-color .2s ease
}

.nav-toggle:hover {
  background: var(--panel);
  border-color: var(--border-hover)
}

.nav-toggle svg {
  width: 20px;
  height: 20px
}

@media (max-width: 768px) {
  .nav { position: relative; }
  .nav-links {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-soft);
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-left: 0;
    display: none;
  }

  .nav-links.open { display: flex; }

  .nav-links a { margin: 8px 0; }

  .theme-toggle { margin-left: auto; }

  .nav-toggle { display: flex; }
}

/* --- Pulsanti --- */
.btn {
  --ring: rgba(0, 245, 255, .35);
  --bg-btn: linear-gradient(135deg, rgba(0, 245, 255, .15), rgba(123, 92, 255, .15));
  border: 1px solid var(--border);
  background: var(--bg-btn);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 14px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 0 0 var(--ring), var(--shadow);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
  position: relative;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px var(--ring), var(--shadow);
  border-color: var(--border-hover);
}

.btn.primary {
  background: linear-gradient(135deg, rgba(0, 245, 255, .35), rgba(0, 255, 163, .35));
  border-color: rgba(0, 245, 255, .6)
}

.btn.loading {
  pointer-events: none;
  cursor: wait;
  color: transparent;
}

.btn.loading svg {
  opacity: 0;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid var(--border-hover);
  border-top-color: var(--brand);
  border-left-color: var(--accent);
  border-right-color: transparent;
  animation: spin .75s linear infinite;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(0, 245, 255, .25);
}

@media (prefers-reduced-motion: reduce) {
  .btn.loading::after {
    animation-duration: 1.4s;
  }
}

/* --- Hero --- */
.hero {
  padding: 88px 0 40px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 32px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 56px);
  line-height: 1.05;
  margin: 0 0 14px;
  letter-spacing: .3px;
}

.hero .kicker {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: 12px;
  display: inline-block;
  margin-bottom: 12px
}

.hero p {
  color: var(--muted);
  font-size: clamp(16px, 1.6vw, 20px);
  margin: 0 0 22px
}

.hero .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow)
}

.hero .actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap
}

.stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center
}

.stat strong {
  font-size: 26px
}

/* --- Cards e sezioni --- */
section {
  padding: 40px 0
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px
}

.section-title .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--glow)
}

.cards {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px
}

.card {
  grid-column: span 6;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s ease, border-color .2s ease
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 245, 255, .55)
}

.card h3 {
  margin: 0 0 8px
}

.card p {
  margin: 0;
  color: var(--muted)
}

.badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0, 245, 255, .15), rgba(123, 92, 255, .15));
  border: 1px solid rgba(0, 245, 255, .35);
  color: #bffcff;
  font-weight: 800;
  animation: pulse 3s infinite
}

.meta {
  color: #9fb3c8;
  font-size: 14px
}

/* --- Come posso aiutarti --- */
#servizi .cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

#servizi .card {
  text-align: center;
  grid-column: auto;
}

#servizi .card:hover {
  transform: none;
  border-color: var(--border);
}

#servizi .service-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

[data-theme='light'] .badge {
  background: linear-gradient(135deg, rgba(0, 245, 255, .25), rgba(123, 92, 255, .25));
  border-color: rgba(0, 245, 255, .45);
  color: #006b75
}

[data-theme='light'] .meta {
  color: #54687d;
}

/* --- Timeline esperienza --- */
.timeline {
  position: relative;
  padding-left: 24px
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(var(--brand), transparent)
}

.t-item {
  position: relative;
  margin: 16px 0;
  padding-left: 12px
}

.t-item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 6px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--brand);
  background: var(--bg);
  border-radius: 50%
}

.t-item h4 {
  margin: 0 0 4px;
  cursor: pointer;
}

.exp-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 4s ease;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin: 14px 0 28px;
}

.tag-cloud .tag {
  display: inline-block;
  font-weight: 700;
  color: #b9d1ff;
}

.tag-cloud .size-5 { font-size: 3.6rem; }
.tag-cloud .size-4 { font-size: 3rem; }
.tag-cloud .size-3 { font-size: 2.4rem; }
.tag-cloud .size-2 { font-size: 1.8rem; }
.tag-cloud .size-1 { font-size: 1.2rem; }

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border-soft);
  padding: 24px 0 48px;
  color: var(--muted)
}

/* --- Responsive --- */
@media (max-width: 920px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 64px
  }

  .cards .card {
    grid-column: span 12
  }

  #servizi .card {
    grid-column: auto;
  }
}

/* --- Accessibilità visiva focus --- */
:focus {
  outline: none
}

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
  border-radius: 12px
}

/* --- Effetti extra --- */
.glow {
  box-shadow: var(--glow)
}

.gradient-text {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace
}

#typewriter {
  min-height: 1.2em
}

/* --- Utility classes --- */
.card>header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px
}

.card-links {
  margin-top: 12px;
  display: flex;
  gap: 14px;
}

.flex-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap
}

.panel hr {
  border-color: var(--border-soft)
}

ul.meta {
  margin: 0;
  padding-left: 18px
}

.input-field {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  margin: 6px 0 12px
}

.input-field:-webkit-autofill,
.input-field:-webkit-autofill:hover,
.input-field:-webkit-autofill:focus,
textarea.input-field:-webkit-autofill,
textarea.input-field:-webkit-autofill:hover,
textarea.input-field:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--panel) inset;
  box-shadow: 0 0 0 1000px var(--panel) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border-color: var(--border-strong);
  transition: background-color 0s, color 0s;
}

/* --- Sezione contatti finale --- */
.contact-cta {
  padding: 80px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.contact-cta h2 {
  margin: 0 0 16px;
}

.contact-cta p {
  max-width: 620px;
  margin: 0 auto 24px;
  color: var(--muted);
}

.contact-actions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  width: 100%;
}

.contact-form {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.contact-form textarea {
  min-height: 120px;
  resize: vertical;
}

/* Fuochi d'artificio mostrati al successo dell'invio */
.contact-cta > :not(.fireworks-layer) {
  position: relative;
  z-index: 2;
}

.fireworks-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
  opacity: 0;
  transition: opacity .35s ease;
}

.fireworks-layer.active {
  opacity: 1;
}

.fireworks-layer .firework {
  position: absolute;
  inset: 0;
}

.fireworks-layer .spark {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--spark-size, 10px);
  height: var(--spark-size, 10px);
  border-radius: 999px;
  background: radial-gradient(circle at center,
      hsla(var(--spark-hue, var(--base-hue, 190)), 100%, 72%, 1) 0%,
      hsla(var(--spark-hue, var(--base-hue, 190)), 100%, 68%, .65) 45%,
      transparent 100%);
  filter: drop-shadow(0 0 14px hsla(var(--spark-hue, var(--base-hue, 190)), 100%, 72%, .9))
    drop-shadow(0 0 26px hsla(var(--spark-hue, var(--base-hue, 190)), 100%, 58%, .65));
  mix-blend-mode: screen;
  opacity: 0;
  transform: translate(var(--origin-x, 0), var(--origin-y, 0)) scale(.45);
  animation: firework-burst 3s cubic-bezier(.16, .85, .36, 1) forwards;
  animation-delay: var(--delay, 0s);
  will-change: transform, opacity;
}

.fireworks-layer .spark::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  opacity: .85;
  filter: blur(9px);
}

@keyframes firework-burst {
  0% {
    opacity: 0;
    transform: translate(var(--origin-x, 0), var(--origin-y, 0)) scale(.45);
  }

  15% {
    opacity: 1;
  }

  45% {
    opacity: 1;
    transform: translate(calc(var(--origin-x, 0) + var(--dx, 0) * .6), calc(var(--origin-y, 0) + var(--dy, 0) * .6)) scale(1.1);
  }

  75% {
    opacity: .85;
    transform: translate(calc(var(--origin-x, 0) + var(--dx, 0) * .9), calc(var(--origin-y, 0) + var(--dy, 0) * .9)) scale(.9);
  }

  100% {
    opacity: 0;
    transform: translate(calc(var(--origin-x, 0) + var(--dx, 0)), calc(var(--origin-y, 0) + var(--dy, 0))) scale(.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fireworks-layer {
    display: none;
  }
}

/* Success message card shown after contact form submission */
.success-card {
  max-width: 620px;
  margin: 42px auto 36px;
  padding: 44px 52px;
  text-align: center;
  display: grid;
  gap: 18px;
  justify-items: center;
  cursor: default;
}

.success-card .badge {
  margin: 0;
}

.success-card h3 {
  margin: 0;
  font-size: clamp(1.6rem, 1.15rem + 1vw, 1.9rem);
}

.success-card p {
  margin: 0;
  color: var(--muted);
}

.success-card:hover {
  transform: none;
  border-color: var(--border);
}

@media (max-width: 600px) {
  .success-card {
    padding: 32px 24px;
    margin: 32px auto 28px;
    gap: 16px;
  }
}

.badge.success {
  background: linear-gradient(135deg, rgba(0, 255, 163, .15), rgba(0, 255, 163, .15));
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme='light'] .badge.success {
  background: linear-gradient(135deg, rgba(0, 255, 163, .25), rgba(0, 255, 163, .25));
}