/* --- RESET E IMPOSTAZIONI BASE --- */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body {
  background-color: #365b55; 
  color: #f0f0f0;           
  font-family: 'Roboto Mono', monospace; 
  overflow: hidden;       
  width: 100%;
  height: 100vh;
}

body::-webkit-scrollbar { 
  width: 0; 
}

body.force-hide #interactionHint {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease;
}

/* Classe per mostrare le sezioni tramite JavaScript */
.section-visible {
  display: flex !important;
}

/* --- UI ELEMENTS (Skip, Hint) --- */
#skipBtn {
  position: fixed;
  bottom: 40px;
  right: 40px;
  background: transparent;
  border: none;
  color: #fff;
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0; 
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#skipBtn.visible { 
  opacity: 1; 
  pointer-events: auto; 
}

#skipBtn:hover { 
  transform: translateX(5px); 
}

.arrow-icon { 
  font-size: 1.4rem; 
}

#interactionHint {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none; 
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 9998;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: pulse 2s infinite;
  text-align: center;
  width: 100%;
}

#interactionHint.visible { 
  opacity: 1; 
}

@keyframes pulse { 
  0%, 100% { opacity: 0.4; } 
  50% { opacity: 1; } 
}

/* =========================================
   HERO SECTION (Logo & Animazioni)
========================================= */

#heroSection {
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center; 
  align-items: center;     
  overflow: hidden;
  text-align: center;
  background-color: #365b55; 
  cursor: pointer; 
  transition: opacity 0.8s ease-out;
}

#heroSection.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* --- NUOVO LOGO COMPOSTO --- */
.logo-composition {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1); 
  z-index: 10; 
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px; 
  width: 600px;
  height: auto;
  pointer-events: none;
}

/* --- KEYFRAMES --- */

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes elementFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- RIGA 1: FOOD --- */
.logo-row-food {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  opacity: 0; /* Parte invisibile */
  animation: slideInLeft 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.2s;
}

.letter-f { height: 140px; width: auto; }
.letters-od { height: 140px; width: auto; }

/* --- La Mela (Applica appleEntrance) --- */
.apple-icon {
  height: 150px;
  width: auto;
  margin-bottom: -5px;
  
  opacity: 0;
  
  /* Animazione: POP & RUOTA */
  animation: appleEntrance 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards 0.4s;
}

@keyframes appleEntrance {
  0% { opacity: 0; transform: scale(0) rotate(-45deg); }
  60% { transform: scale(1.1) rotate(10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* --- RIGA 2: WASTE */
.logo-row-waste {
  opacity: 0; /* Parte invisibile */
  animation: slideInRight 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.4s;
}

.word-waste {
  height: 140px;
  width: auto;
  margin-top: -10px;
}

/* --- RIGA 3: SOTTOTITOLO */
.logo-row-subtitle {
  opacity: 0;
  animation: elementFadeIn 1.5s ease forwards 1s;
}

.subtitle-img {
  height: 40px;
  width: auto;
  margin-top: 15px;
}

/* --- LA MOSCA --- */
.fly-element {
  position: absolute;
  width: 350px;
  height: auto;
  top: -40px;   
  right: -130px; 
  z-index: 20;
  pointer-events: none;

  /* Opacità base: 1 */
  opacity: 1; 
  animation: 
    flyAppearOnly 0.5s ease-out 0.5s both, 
    flyFloat 3.5s ease-in-out 0.5s infinite alternate;
}

@keyframes flyFloat {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(15px, -20px) rotate(10deg); }
}

@keyframes flyAppearOnly {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- ISTRUZIONE CLICK --- */
.click-instruction {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Roboto Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  z-index: 100;
  pointer-events: none;
  animation: pulseText 2s infinite;
}

@keyframes pulseText {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* --- ILLUSTRAZIONE COMPLETA (Cestino e Sacchi) --- */
.illustration-wrapper {
  position: absolute;
  bottom: 30px;   
  left: 50px;     
  width: 450px;   
  height: 300px;
  z-index: 5; 
  pointer-events: none; 
}

.bin-animated {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 200px;
  z-index: 1;
  opacity: 0;
  animation: binLand 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards 0.5s;
}

@keyframes binLand {
  0% { opacity: 0; transform: translateX(-50%) translateY(-200px) rotate(-10deg); }
  60% { opacity: 1; transform: translateX(-50%) translateY(0) rotate(0deg); }
  75% { transform: translateX(-50%) translateY(-10px) rotate(-3deg); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) rotate(0deg); }
}

.sacco {
  position: absolute;
  width: 180px;
  top: -600px;
  opacity: 0;
  pointer-events: none;
}

.sacco-left {
  left: 0;
  z-index: 2; 
  animation: dropFixLeft 0.6s ease-out forwards 0.9s; 
}

.sacco-right {
  right: 0;
  z-index: 0; 
  animation: dropFixRight 0.6s ease-out forwards 1.1s; 
}

@keyframes dropFixLeft {
  0% { top: -600px; opacity: 0; transform: rotate(0deg); }
  100% { top: 50px; opacity: 1; transform: rotate(-15deg); }
}

@keyframes dropFixRight {
  0% { top: -600px; opacity: 0; transform: rotate(0deg); }
  100% { top: 60px; opacity: 1; transform: rotate(10deg); }
}

/* =========================================
   SEZIONI SUCCESSIVE
========================================= */

/* --- INTRO SECTION --- */
#introSection {
  display: none; 
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  text-align: center;
}

/* Quando visibile */
#introSection.section-visible {
  display: flex;
  animation: fadeInSection 1s ease-out;
}

.typewriter-container {
  max-width: 800px;
  font-size: 1.4rem;
  line-height: 1.8;
  min-height: 150px; 
}

.cursor {
  display: inline-block;
  width: 10px;
  height: 1.4em;
  background-color: #fff;
  margin-left: 5px;
  animation: blink 0.9s infinite;
  vertical-align: text-bottom;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* --- TIMELINE SECTION --- */
#timelineSection {
  display: none; 
  min-height: 100vh;
  padding: 100px 20px 100px 20px;
  justify-content: center;
  opacity: 0.3; 
  transition: opacity 0.8s;
}

#timelineSection.active { 
  opacity: 1; 
}

.timeline-wrapper {
  display: flex;
  width: 100%;
  max-width: 950px;
  position: relative;
}

.graphics-column { 
  width: 60px; 
  position: relative; 
  flex-shrink: 0; 
}

.vertical-line {
  position: absolute;
  left: 50%;
  top: 15px;
  width: 2px;
  background-color: #fff;
  transform: translateX(-50%);
  height: 0; 
  transition: height 0.5s ease-out;
}

.dot {
  position: absolute;
  left: 50%;
  width: 20px;
  height: 20px;
  background-color: #fff;
  border-radius: 50%;
  transform: translateX(-50%) scale(0);
  transition: transform 0.3s;
  z-index: 2;
}

.dot.show { 
  transform: translateX(-50%) scale(1); 
}

.text-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 60px;
  padding-bottom: 50px;
}

.text-block {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s, transform 0.5s;
  font-size: 1.3rem;
  line-height: 1.6;
}

.text-block.show { 
  opacity: 1; 
  transform: translateY(0); 
}

.text-block strong { 
  font-weight: 700; 
  color: #fff; 
}

@keyframes lineBlink {
  0%   { opacity: 1; }
  50%  { opacity: 0.3; }
  100% { opacity: 1; }
}

.vertical-line.blinking {
  animation: lineBlink 1s ease-in-out infinite;
}

.line-segment {
  position: absolute;
  left: 50%;
  width: 2px;
  height: 22px;
  background-color: #fff;
  transform: translateX(-50%);
  opacity: 1;
  z-index: 1;
}

.line-segment.blinking {
  animation: lineBlink 1s ease-in-out infinite;
}

/* --- OUTRO SECTION --- */
#outroSection {
  display: none; 
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  opacity: 0;
  transition: opacity 1s ease;
}

#outroSection.visible { 
  opacity: 1; 
}

.outro-container {
  max-width: 800px;
  text-align: center;
}

.outro-text {
  font-size: 1.3rem;
  line-height: 1.8;
  margin-bottom: 60px;
  color: #f0f0f0;
}

.outro-text p { 
  margin-bottom: 30px; 
}

.explore-data-btn {
  display: table; 
  background-color: #f0f0f0;
  color: #365b55;
  padding: 18px 40px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-align: center;
  margin: 0 auto; 
}

.explore-data-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

/* --- TUTORIAL SECTION --- */

#tutorialSection {
  display: none;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  padding: 40px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#tutorialSection.visible {
  display: flex;
  opacity: 1;
}

.tutorial-container {
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding-bottom: 120px;
}

.tutorial-header {
  max-width: 700px;
  margin: 0 auto 80px;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.tutorial-header.hidden {
  opacity: 0;
  transform: translateY(-40px);
  pointer-events: none;
}

.tutorial-header h2 {
  font-size: 2rem;
  margin-bottom: 20px;
}

.tutorial-header p {
  font-size: 1.2rem;
  line-height: 1.6;
}

.tutorial-header.hidden {
  margin-bottom: 0;
}

.tutorial-steps {
  list-style: none;
  font-size: 1.2rem;
  line-height: 1.8;
  margin: 0;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-steps li {
  display: none;
  opacity: 0;
  transform: translateY(0);
  transition: opacity 0.6s ease;
  text-align: left;
}

.tutorial-steps li.active-step {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.tutorial-screenshot {
  display: block;
  max-width: 90%;
  margin: 30px auto 0;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

.explore-data-btn.secondary {
  background-color: transparent;
  color: #f0f0f0;
  border: 2px solid #f0f0f0;
  margin-top: 30px;
}

button, a, .nav-btn, .explore-data-btn {
  cursor: pointer;
}

.tutorial-nav {
  display: flex;
  gap: 40px;
  margin: 40px 0 20px;
}

.nav-btn {
  background: transparent;
  border: 2px solid #fff;
  color: #fff;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.5rem;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-btn:hover {
  transform: scale(1.1);
}

.nav-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

#tutorialSection #finishTutorialBtn {
  position: relative;
  top: 2.5rem;
}

/* --- TUTORIAL PROGRESS --- */
.tutorial-progress {
  position: sticky;
  top: 30px;
  margin-bottom: 60px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tutorial-step-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.tutorial-progress-line {
  width: 100%;
  max-width: 300px;
  height: 2px;
  background-color: rgba(255,255,255,0.2);
  position: relative;
  overflow: hidden;
  margin: 0;
}

.tutorial-progress-fill {
  height: 100%;
  width: 0%;
  background-color: #fff;
  transition: width 0.4s ease;
}

.tutorial-hint {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  letter-spacing: 2px;
  opacity: 0.6;
  text-transform: uppercase;
  animation: pulse 2s infinite;
  pointer-events: none;
  z-index: 9998;
}

#tutorialSection:not(.visible) .tutorial-hint {
  display: none;
}

/* =========================================
   MEDIA QUERIES (Responsive)
========================================= */

@media (max-width: 1024px) {
    .illustration-wrapper { width: 350px; height: 250px; left: 30px; }
    .bin-animated { width: 150px; }
    .sacco { width: 140px; }
}

@media (max-width: 768px) {
  /* Logo Mobile */
  .logo-composition { 
    width: 100%; 
    transform: translate(-50%, -50%) scale(0.45); 
  }
  .fly-element { right: -20px; top: -40px; }
  .click-instruction { bottom: 20px; font-size: 0.7rem; }
  
  /* Illustrazione Mobile */
  .illustration-wrapper { 
    width: 300px; height: 200px;
    left: 50%; transform: translateX(-50%); bottom: 20px;
  }
  .bin-animated { width: 130px; }
  .sacco { width: 120px; }
  
  /* Testi */
  .typewriter-container, .text-block, .outro-text { font-size: 1rem; }
  #skipBtn { bottom: 20px; right: 20px; font-size: 1rem; }
}

@media (min-width: 1366px) {
  .tutorial-container {
    padding-bottom: 40px; 
  }

  .tutorial-header {
    margin: 0 auto 30px; 
  }

  .tutorial-screenshot {
    max-height: 250px;
    object-fit: contain;
    margin: 20px auto 0; 
  }

  #tutorialSection #finishTutorialBtn {
    position: relative;
    top: 0; 
    margin-top: 20px;
  }
}