/* Base layout and navigation states */
.nav-scrolled {
  height: 4rem;
  transition: all 0.3s ease-in-out;
}
.nav-default {
  height: 8rem;
  transition: all 0.3s ease-in-out;
}
.logo-text { display: none; }
.nav-scrolled .logo-img { display: none; }
.nav-scrolled .logo-text { display: block; }

html {
  scroll-behavior: smooth;
  height: 100%;
  overflow: hidden;
}
body {
  height: 100vh;
  overflow: hidden;
}

.page-container {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
}

section,
.hero-section {
  scroll-snap-align: start;
  scroll-snap-stop: normal;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 8rem;
}

/* Appear effect */
.fade-up { opacity: 0; transition: opacity 0.5s ease-in-out; }
.fade-up.appear { opacity: 1; }

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Typewriter effect */
.typewriter {
  overflow: hidden;
  border-right: .15em solid white;
  white-space: nowrap;
  margin: 0 auto;
  width: 0;
  animation:
    typing 3.5s steps(40, end) forwards,
    blink-caret .75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}
@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: white; }
}
.typewriter.second { animation-delay: 3.5s; }

/* Mobile menu toggle and nav menu */
.menu-toggle { display: none; }

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
    position: fixed;
    right: 1rem;
    top: 1.5rem;
    z-index: 60;
    cursor: pointer;
    padding: 0.5rem;
  }
  .menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: white;
    margin: 5px 0;
    transition: all 0.3s ease;
  }
  .menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
  .menu-toggle.active span:nth-child(2) { opacity: 0; }
  .menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(7px, -6px); }

  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    height: 100vh;
    width: 100%;
    background-color: rgba(39, 39, 42, 0.98);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: right 0.3s ease;
    z-index: 55;
  }
  .nav-menu.active { right: 0; }
  .nav-menu li {
    margin: 1.5rem 0;
    width: 100%;
    text-align: center;
  }

  /* Typography and spacing tweaks on mobile */
  .text-4xl { font-size: 1.5rem; line-height: 2rem; }
  .container { padding-left: 1rem; padding-right: 1rem; height: auto; min-height: 100%; }
  section,
  .hero-section { scroll-snap-align: none; scroll-snap-stop: normal; min-height: 100vh; height: auto; padding-top: 4rem; padding-bottom: 2rem; }
  #contatti { height: auto; min-height: 100vh; overflow-y: visible; }
  .typewriter { font-size: 1.25rem; line-height: 1.75rem; width: 100% !important; white-space: normal; border-right: none; }
  .nav-default { height: 4rem; padding: 0.5rem; }
  .nav-default .logo-img { height: 3rem; }

  /* Utility overrides for smaller screens */
  .px-8 { padding-left: 1rem; padding-right: 1rem; }
  .grid { grid-template-columns: 1fr !important; }
  .mb-12 { margin-bottom: 2rem; }
  .p-9 { padding: 1rem; }
  .mt-12 { margin-top: 2rem; }
  .gap-8 { gap: 1rem; }
  .gap-6 { gap: 1rem; }
  .p-6 { padding: 1rem; }
  .space-y-6 > * + * { margin-top: 1rem; }
  #author { margin-top: 1rem; font-size: 1.5rem; }
  .hero-section .absolute { padding: 1rem; }
  .fade-up { transform: translateY(0); }
  .page-container { scroll-snap-type: none; }
  .social-icons-container { margin-bottom: 4rem; }

  /* Fix per il typewriter su mobile */
  @keyframes typing { from { width: 0; } to { width: 100%; } }
}

/* Support page specific mobile tweaks */
@media (max-width: 640px) {
  #voiceflow-supporto {
    min-height: 320px !important;
    padding: 0.5rem !important;
  }
  .container { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
  h2 { font-size: 1.5rem !important; margin-bottom: 1rem !important; }
  .flex.mb-6 { margin-bottom: 1rem !important; }
  a[href="index.html"] { font-size: 1rem !important; padding: 0.5rem 1rem !important; }
}