html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  cursor: none;
  font-family: Helvetica, sans-serif;
  background: url("../img/etoile.jpg") no-repeat center center fixed;
  background-size: cover;
}

@keyframes bg-gradient-move {
  0% {
    background-position: top;
  }
  100% {
    background-position: bottom;
  }
}

.background-text {
  position: absolute;
  top: 0;
  left: 0;
  padding: 20px;
  z-index: 1;
  color: white;
  font-size: 24pt;
  width: 100%;
  height: 100%;
  overflow: auto;
  opacity: 1;
  /* ENLÈVE le masque dégradé animé sur le texte */
  -webkit-mask-image: none;
  mask-image: none;
  animation: none;
}

.columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 40px;
}

.cursor-image {
  position: absolute;
  width: 250px;
  height: 250px;
  pointer-events: none;
  z-index: 3;
  transform: translate(-50%, -50%);
}

.decharge {
  position: relative;
  top: -140px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100vw;
  height: 300px;
  position: absolute;
  border-radius: 90%;
  background: linear-gradient(
    to bottom,
    #f37500 0%,
    #df0707 60%,
    transparent 100%
  );
  border: none;
  z-index: 2;
  box-shadow: 0 8px 32px 0 rgba(255, 0, 0, 0.18);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.speed-label {
  position: absolute;
  color: white;
  font-size: 12px;
  font-family: monospace;
  z-index: 2;
  color: #ff2222 !important;
}

.trail {
  position: absolute;
  background-color: white;
  z-index: 1;
  pointer-events: none;
}

/* Ensure the first trail (main debris) can be interacted with */
.trail[style*="z-index: 2"] {
  pointer-events: auto;
}

.capture-data {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: auto;
  color: rgb(81, 255, 0);
  font-size: 20px;
  font-family: monospace;
  z-index: 2;
  max-height: 90%;
  overflow-y: auto;
  background: none;
  padding: 0;
}

.capture-data p {
  color: #4cff4c !important;
}

@media screen and (max-width: 768px) {
  .columns {
    grid-template-columns: 1fr;
  }

  .cursor-image {
    width: 180px;
    height: 180px;
  }

  .decharge {
    top: 0;
    height: 250px;
  }

  .decharge-text {
    margin-top: 160px;
    font-size: 18px;
  }

  .capture-data {
    font-size: 14px !important;
    max-width: 80%;
  }

  .popup-content {
    margin: 20px;
    padding: 20px;
  }

  .popup-text {
    font-size: 1rem;
  }

  .starwars-crawl {
    font-size: 20px;
    max-width: 85%;
    padding: 0 10px;
    letter-spacing: 1px;
    transform: perspective(600px) rotateX(25deg) scale(0.9);
  }

  .floating-story {
    font-size: 16px;
    max-width: 85%;
    transform: translateX(-50%) perspective(600px) rotateX(25deg) scale(0.9);
  }

  .custom-cursor {
    display: none;
  }
}

/* Touch-specific optimizations */
@media (hover: none) {
  body {
    cursor: auto;
  }

  .custom-cursor {
    display: none;
  }
}

.custom-cursor {
  position: fixed;
  width: 24px;
  height: 24px;
  pointer-events: none;
  z-index: 1000;
  mix-blend-mode: difference;
  transition: background 0.2s;
  background: none;
}

.custom-cursor::before,
.custom-cursor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: white;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.custom-cursor::before {
  width: 18px;
  height: 2px;
}

.custom-cursor::after {
  width: 2px;
  height: 18px;
}

/* Pour l'effet Star Wars, place tout le texte dans un seul conteneur */
.floating-story {
  background-color: black;
  position: absolute;
  left: 50%;
  top: 90vh;
  transform: translateX(-50%) perspective(600px) rotateX(25deg) scale(1.1);
  color: #ffe81f;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 2px 8px #000, 0 0 2px #ffe81f, 0 0 8px #ffe81f;
  background: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  pointer-events: none;
  user-select: none;
  max-width: 700px;
  z-index: 10;
  box-shadow: none;
  white-space: pre-line;
  animation: starwars-crawl 40s linear infinite;
  opacity: 1 !important;
}

@keyframes starwars-crawl {
  0% {
    top: 90vh;
    opacity: 1;
  }
  100% {
    top: -100vh;
    opacity: 1;
  }
}

.capture-data,
.capture-data p,
.capture-data strong,
.capture-data span {
  font-size: 14px !important;
}

/* Star Wars intro */
.starwars-crawl {
  color: #ffe81f;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 48px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 2px 8px #000, 0 0 2px #ffe81f, 0 0 8px #ffe81f;
  max-width: 900px;
  white-space: pre-line;
  animation: starwars-crawl 3s linear forwards;
  opacity: 1;
  transform: perspective(600px) rotateX(25deg) scale(1.1);
  padding: 0 20px;
}

@keyframes starwars-crawl {
  0% {
    transform: translateY(60vh) perspective(600px) rotateX(25deg) scale(1.1);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(-40vh) perspective(600px) rotateX(25deg) scale(1.1);
    opacity: 0;
  }
}

#starwars-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Masque tout sauf l'intro pendant l'animation */
body.intro-active > *:not(#starwars-text) {
  visibility: hidden !important;
  opacity: 0;
}

body.intro-active #starwars-text {
  visibility: visible !important;
  opacity: 1;
}

/* Phase de transition */
body.transition-phase #satellite,
body.transition-phase #decharge,
body.transition-phase #captureData,
body.transition-phase #custom-cursor {
  visibility: hidden !important;
  opacity: 0;
}

/* Les débris sont visibles pendant la transition */
body.transition-phase .trail {
  visibility: visible !important;
  opacity: 1;
}

body.transition-phase .debris-label {
  visibility: visible !important;
  opacity: 1;
}

/* Affichage normal après la transition */
body:not(.transition-phase):not(.intro-active) #satellite,
body:not(.transition-phase):not(.intro-active) #decharge,
body:not(.transition-phase):not(.intro-active) #captureData,
body:not(.transition-phase):not(.intro-active) #custom-cursor {
  visibility: visible !important;
  opacity: 1;
  transition: opacity 1s ease-in;
}

/* Styles for the satellite */
#satellite {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto !important;
  z-index: 4;
}

#satellite.dragging {
  cursor: grabbing;
}

/* Styles for the atmospheric deposit */
#decharge {
  position: fixed;
  top: -140px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100vw;
  height: 300px;
  border-radius: 90%;
  background: linear-gradient(
    to bottom,
    #f37500 0%,
    #df0707 60%,
    transparent 100%
  );
  border: none;
  z-index: 5;
  box-shadow: 0 8px 32px 0 rgba(255, 0, 0, 0.18);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.decharge-text {
  margin-top: 180px;
  font-family: monospace;
  font-size: 24px;
  color: #111;
  font-weight: bold;
  letter-spacing: 1px;
  user-select: none;
  pointer-events: none;
}

/* Styles for the capture data */
#captureData {
  position: fixed;
  top: 80px;
  left: 24px;
  right: auto;
  color: rgb(81, 255, 0);
  font-size: 20px;
  font-family: monospace;
  z-index: 4;
  max-height: 90%;
  overflow-y: auto;
  background: none;
  padding: 0;
}

/* Styles for the pause popup */
#pause-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
}

/* Règles spécifiques pour garantir que les couleurs du popup ne changent jamais */
#pause-popup .popup-content {
  background: #111 !important;
  border-radius: 18px;
  box-shadow: 0 4px 32px 0 rgba(0, 0, 0, 0.18);
  padding: 40px 30px 30px 30px;
  max-width: 700px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#pause-popup .popup-text {
  color: #4cff4c !important;
  font-family: monospace;
  font-size: 1.2rem;
  text-align: left;
  margin: 0;
  white-space: pre-line;
  filter: none !important;
}

/* Style pour le bouton de fermeture */
.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.close-button::before,
.close-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 2px;
  background-color: #4cff4c;
}

.close-button::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.close-button::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.close-button:hover::before,
.close-button:hover::after {
  background-color: #fff;
}

/* Assurer que même dans les niveaux, les couleurs restent les mêmes */
.level-5 #pause-popup .popup-text,
.level-10 #pause-popup .popup-text,
.level-15 #pause-popup .popup-text,
.level-20 #pause-popup .popup-text,
.level-25 #pause-popup .popup-text {
  color: #4cff4c !important;
  filter: none !important;
}

.level-5 #pause-popup .progress-bar,
.level-10 #pause-popup .progress-bar,
.level-15 #pause-popup .progress-bar,
.level-20 #pause-popup .progress-bar,
.level-25 #pause-popup .progress-bar {
  background-color: #4cff4c !important;
  filter: none !important;
}

@keyframes depot-blink {
  0% {
    background: linear-gradient(
      to bottom,
      #f37500 0%,
      #df0707 60%,
      transparent 100%
    );
    opacity: 1;
  }
  25% {
    background: linear-gradient(
      to bottom,
      #ffffff 0%,
      #ffffff 60%,
      transparent 100%
    );
    opacity: 0.9;
  }
  50% {
    background: linear-gradient(
      to bottom,
      #f37500 0%,
      #df0707 60%,
      transparent 100%
    );
    opacity: 1;
  }
  75% {
    background: linear-gradient(
      to bottom,
      #ffffff 0%,
      #ffffff 60%,
      transparent 100%
    );
    opacity: 0.9;
  }
  100% {
    background: linear-gradient(
      to bottom,
      #f37500 0%,
      #df0707 60%,
      transparent 100%
    );
    opacity: 1;
  }
}

#decharge.blink {
  animation: depot-blink 1s ease-in-out;
}

/* Specific adjustments for very small screens (iPhone SE, etc.) */
@media screen and (max-width: 380px) {
  .starwars-crawl {
    font-size: 18px;
    transform: perspective(600px) rotateX(25deg) scale(0.8);
  }

  .floating-story {
    font-size: 14px;
    transform: translateX(-50%) perspective(600px) rotateX(25deg) scale(0.8);
  }
}

/* Effet de clignotement global */
@keyframes site-flash {
  0% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.5);
  }
  100% {
    filter: brightness(1);
  }
}

/* Palier 5: Première variation de couleurs fluo */
.level-5 {
  filter: saturate(2) brightness(1.3) hue-rotate(-90deg);
  transition: filter 0.5s ease;
}

.level-5 .trail {
  background-color: #f0f !important;
}
.level-5 .decharge {
  background: linear-gradient(
    to bottom,
    #ff0 0%,
    #0ff 60%,
    transparent 100%
  ) !important;
}
.level-5 .capture-data {
  color: #ff0 !important;
}
.level-5 .capture-data p {
  color: #0ff !important;
}

/* Palier 10: Deuxième variation de couleurs fluo */
.level-10 {
  filter: saturate(2) brightness(1.3) hue-rotate(45deg);
  transition: filter 0.5s ease;
}

.level-10 .trail {
  background-color: #0f0 !important;
}
.level-10 .decharge {
  background: linear-gradient(
    to bottom,
    #ff0 0%,
    #f0f 60%,
    transparent 100%
  ) !important;
}
.level-10 .capture-data {
  color: #f0f !important;
}
.level-10 .capture-data p {
  color: #ff0 !important;
}

/* Palier 15: Troisième variation de couleurs fluo */
.level-15 {
  filter: saturate(2) brightness(1.3) hue-rotate(90deg);
  transition: filter 0.5s ease;
}

.level-15 .trail {
  background-color: #ff0 !important;
}
.level-15 .decharge {
  background: linear-gradient(
    to bottom,
    #f0f 0%,
    #0ff 60%,
    transparent 100%
  ) !important;
}
.level-15 .capture-data {
  color: #ff0 !important;
}
.level-15 .capture-data p {
  color: #0ff !important;
}

/* Palier 20: Quatrième variation de couleurs fluo */
.level-20 {
  filter: saturate(2) brightness(1.3) hue-rotate(180deg);
  transition: filter 0.5s ease;
}

.level-20 .trail {
  background-color: #0ff !important;
}
.level-20 .decharge {
  background: linear-gradient(
    to bottom,
    #0f0 0%,
    #f0f 60%,
    transparent 100%
  ) !important;
}
.level-20 .capture-data {
  color: #0f0 !important;
}
.level-20 .capture-data p {
  color: #f0f !important;
}

/* Palier 25: Retour à la normale */
.level-25 {
  filter: none;
  transition: filter 0.5s ease;
}

/* Animation de clignotement */
.flash-transition {
  animation: site-flash 0.5s ease 3;
}

/* Préservation des couleurs du satellite pour tous les niveaux */
.level-5 #satellite,
.level-10 #satellite,
.level-15 #satellite,
.level-20 #satellite {
  filter: hue-rotate(0deg) saturate(1) brightness(1) !important;
}

.debris-label {
  position: absolute;
  color: #ff0000;
  font-family: monospace;
  font-size: 16px;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 2px #000;
  z-index: 3;
}

.star {
  position: absolute;
  background-color: #ffffff;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

@keyframes twinkle {
  0% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

.star-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* Masque tout sauf l'intro pendant l'animation */
body.intro-active > *:not(#starwars-text) {
  visibility: hidden !important;
}

body.intro-active #starwars-text {
  visibility: visible !important;
  opacity: 1;
}

/* Phase de transition */
body.transition-phase #satellite,
body.transition-phase #decharge,
body.transition-phase #captureData,
body.transition-phase #custom-cursor {
  visibility: hidden !important;
  opacity: 0;
}

/* Les débris sont visibles pendant la transition */
body.transition-phase .trail {
  visibility: visible !important;
  opacity: 1;
}

/* Affichage normal après la transition */
body:not(.transition-phase):not(.intro-active) #satellite,
body:not(.transition-phase):not(.intro-active) #decharge,
body:not(.transition-phase):not(.intro-active) #captureData,
body:not(.transition-phase):not(.intro-active) #custom-cursor {
  visibility: visible !important;
  opacity: 1;
  transition: opacity 1s ease-in;
}

/* Styles for the satellite */
#satellite {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto !important;
  isolation: isolate; /* Isole le satellite des effets de filtre du parent */
}

#satellite.dragging {
  cursor: grabbing;
}

/* Styles for the atmospheric deposit */
#decharge {
  top: -140px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100vw;
  height: 300px;
  position: absolute;
  border-radius: 90%;
  background: linear-gradient(
    to bottom,
    #f37500 0%,
    #df0707 60%,
    transparent 100%
  );
  border: none;
  z-index: 2;
  box-shadow: 0 8px 32px 0 rgba(255, 0, 0, 0.18);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.decharge-text {
  margin-top: 180px;
  font-family: monospace;
  font-size: 24px;
  color: #111;
  font-weight: bold;
  letter-spacing: 1px;
  user-select: none;
  pointer-events: none;
}

/* Styles for the capture data */
#captureData {
  position: absolute;
  top: 80px;
  left: 24px;
  right: auto;
  color: rgb(81, 255, 0);
  font-size: 20px;
  font-family: monospace;
  z-index: 2;
  max-height: 90%;
  overflow-y: auto;
  background: none;
  padding: 0;
}

/* Styles for the pause popup */
#pause-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  isolation: isolate;
}
