/* ─── Reset & Base ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:        #04060d;
  --bg-card:   #0d1117;
  --bg-cta:    #060a14;
  --blue:      #1b5cff;
  --cyan:      #00e5ff;
  --border:    rgba(255,255,255,0.08);
  --text:      #ffffff;
  --muted:     rgba(255,255,255,0.55);
  --tag:       #00e5ff;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a  { text-decoration: none; color: inherit; }

/* ─── Navbar ─── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  height: 68px;
  transition: background 0.3s, backdrop-filter 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}

nav.scrolled {
  background: rgba(4,6,13,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-color: var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.nav-logo img { width: 32px; height: 32px; object-fit: contain; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 36px;
  list-style: none;
}
.nav-links a {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.lang-switch > span { color: var(--muted); }

.lang-btn {
  background: none;
  border: none;
  padding: 4px 2px;
  font: inherit;
  letter-spacing: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { color: var(--text); font-weight: 700; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }

/* ─── Hero ─── */
#hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 120px 48px 80px;
  overflow: hidden;
}

#hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  pointer-events: none;
  z-index: 0;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(4,6,13,0.88) 0%,
    rgba(4,6,13,0.60) 55%,
    rgba(4,6,13,0.15) 100%
  );
  pointer-events: none;
  z-index: 1;
}

.hero-content {
  position: relative;
  max-width: 680px;
  z-index: 2;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 28px;
}
.section-tag::before {
  content: '';
  display: block;
  width: 32px; height: 1px;
  background: var(--cyan);
}

h1.hero-title {
  font-size: clamp(48px, 6vw, 78px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}
h1.hero-title .accent {
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.65;
  max-width: 520px;
  margin-bottom: 44px;
}

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

.btn-dark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.btn-dark:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.16); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: transparent;
  color: var(--cyan);
  font-size: 15px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid rgba(0,229,255,0.35);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-outline:hover { background: rgba(0,229,255,0.07); border-color: rgba(0,229,255,0.6); }

.scroll-hint {
  position: absolute;
  bottom: 36px; left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: bounce 2.4s ease-in-out infinite;
}
.scroll-hint svg { opacity: 0.5; }
@keyframes bounce {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(8px); }
}

/* ─── Scrollytelling ─── */
#scrollytelling {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.scroll-panels {
  display: flex;
  flex-direction: column;
}

.scroll-panel {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 80px 64px 80px 48px;
  opacity: 0.35;
  transition: opacity 0.5s;
}
.scroll-panel.active { opacity: 1; }

.scroll-panel-inner { max-width: 520px; }

.panel-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 28px;
}
.panel-tag::before {
  content: '';
  display: block;
  width: 24px; height: 1px;
  background: var(--cyan);
}

.scroll-panel h2 {
  font-size: clamp(36px, 4.5vw, 58px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.scroll-panel p {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 440px;
}

.scroll-avatar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}

.avatar-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.avatar-img {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: 92%;
  object-fit: contain;
  object-position: bottom center;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.avatar-img.visible { opacity: 1; }

/* ─── Section: Il progetto (chi siamo) ─── */
#chi-siamo {
  padding: 120px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.about-content { max-width: 760px; }

.about-content p {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 24px;
}
.about-content p:last-child { margin-bottom: 0; }

.about-content a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: rgba(0,229,255,0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}
.about-content a:hover { text-decoration-color: var(--cyan); }

.about-contact {
  color: var(--text) !important;
  font-size: 15px;
}

/* ─── Section: Come funziona ─── */
#come-funziona {
  padding: 120px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-heading {
  margin-bottom: 64px;
}
.section-heading .section-tag { margin-bottom: 20px; }
.section-heading h2 {
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  transition: border-color 0.25s, transform 0.25s;
  opacity: 0;
  transform: translateY(24px);
}
.card.in-view {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease, border-color 0.25s, box-shadow 0.25s;
}
.card:hover {
  border-color: rgba(0,229,255,0.2);
  box-shadow: 0 0 32px rgba(0,229,255,0.06);
}

.card-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.15em;
  margin-bottom: 20px;
}

.card-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(0,229,255,0.3);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  color: var(--cyan);
}

.card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.card p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.65;
}

/* ─── Section: Servizi ─── */
#servizi {
  padding: 120px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  transition: border-color 0.25s, box-shadow 0.25s;
  opacity: 0;
  transform: translateY(24px);
}
.service-card.in-view {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease, border-color 0.25s, box-shadow 0.25s;
}
.service-card:hover {
  border-color: rgba(0,229,255,0.2);
  box-shadow: 0 0 32px rgba(0,229,255,0.06);
}

.service-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  color: var(--cyan);
}

.service-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.service-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── Section: Accessibilità ─── */
#accessibilita {
  padding: 120px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

#accessibilita .section-heading { margin-bottom: 56px; }

.features-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.feature-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  opacity: 0;
  transform: translateY(20px);
}
.feature-box.in-view {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.feature-label {
  font-size: 22px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.feature-box p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── Section: CTA ─── */
#cta {
  background: var(--bg-cta);
  padding: 120px 48px;
  text-align: center;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#cta h2 {
  font-size: clamp(32px, 4.5vw, 56px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 32px;
}

.phone-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}
.phone-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: dot-pulse 2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%,100% { box-shadow: 0 0 8px var(--cyan); }
  50%      { box-shadow: 0 0 20px var(--cyan), 0 0 40px rgba(0,229,255,0.4); }
}

.phone-num {
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.cta-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 40px;
  letter-spacing: 0.02em;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 40px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-cta:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(27,92,255,0.4);
}

/* ─── Footer ─── */
footer {
  padding: 72px 48px 0;
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 56px;
}

.footer-brand .nav-logo { margin-bottom: 16px; }
.footer-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 280px;
}

.footer-col h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer-col ul a {
  font-size: 14px;
  color: var(--muted);
  transition: color 0.2s;
}
.footer-col ul a:hover { color: var(--text); }

.footer-contact-item {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}
.footer-contact-item strong { color: var(--text); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-bottom span {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.04em;
}

/* ─── Responsive ─── */
@media (max-width: 960px) {
  nav { padding: 0 24px; }
  .nav-links { display: none; }

  #hero { padding: 100px 24px 60px; }

  #scrollytelling { grid-template-columns: 1fr; }

  .scroll-avatar {
    position: relative;
    height: 60vw;
    min-height: 280px;
    max-height: 480px;
    border-bottom: 1px solid var(--border);
  }
  .avatar-img { height: 100%; }

  .scroll-panel { min-height: auto; padding: 60px 24px; opacity: 1; }

  #chi-siamo,
  #come-funziona,
  #servizi,
  #accessibilita { padding: 80px 24px; }

  .cards-row      { grid-template-columns: 1fr; }
  .cards-grid     { grid-template-columns: 1fr; }
  .features-row   { grid-template-columns: 1fr 1fr; }

  #cta { padding: 80px 24px; }

  footer { padding: 56px 24px 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 40px; }
  .footer-desc { max-width: 100%; }
}

@media (max-width: 480px) {
  .features-row { grid-template-columns: 1fr; }
  h1.hero-title { font-size: 40px; }
  .hero-actions { flex-direction: column; align-items: flex-start; }
  .btn-dark, .btn-outline { width: 100%; justify-content: center; }
}

/* ─── Chat widget: Sofia ─── */
#chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1200;
}

#chat-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #04060d;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(0,229,255,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}
#chat-toggle:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(0,229,255,0.45); }
#chat-toggle svg { position: relative; }

#chat-toggle-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5c5c;
  border: 2px solid #04060d;
}

#chat-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  height: 520px;
  max-height: 70vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
#chat-header-info { display: flex; align-items: center; gap: 12px; }
#chat-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: contain; background: rgba(0,229,255,0.1); }
#chat-title { font-size: 15px; font-weight: 700; }
#chat-subtitle { font-size: 12px; color: var(--muted); }
#chat-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  transition: color 0.2s;
}
#chat-close:hover { color: var(--text); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.chat-bubble-sofia {
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-bubble-user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 18px 12px;
}
.chat-typing[hidden] { display: none; }
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

#chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
#chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
#chat-input:focus { outline: none; border-color: rgba(0,229,255,0.4); }
#chat-input::placeholder { color: var(--muted); }

#chat-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
}
#chat-send:hover { opacity: 0.88; }

@media (max-width: 480px) {
  #chat-widget { bottom: 16px; right: 16px; }
  #chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    max-height: none;
    right: -8px;
  }
}

/* ─── Stagger delays for card animations ─── */
.card:nth-child(2)         { transition-delay: 0.08s; }
.card:nth-child(3)         { transition-delay: 0.16s; }
.service-card:nth-child(2) { transition-delay: 0.08s; }
.service-card:nth-child(3) { transition-delay: 0.1s;  }
.service-card:nth-child(4) { transition-delay: 0.18s; }
.feature-box:nth-child(2)  { transition-delay: 0.06s; }
.feature-box:nth-child(3)  { transition-delay: 0.12s; }
.feature-box:nth-child(4)  { transition-delay: 0.18s; }
