@import url("https://fonts.googleapis.com/css2?family=Cinzel+Decorative&family=Forum&family=Funnel+Sans:ital,wght@0,800;1,800&family=Metamorphous&display=swap");

:root {
  --main-color: rgba(44, 121, 162, 0.7);
  --edge-color: rgba(44, 121, 162, 1);
}

html,
body {
  touch-action: manipulation;
  height: 100dvh;
  margin: 0;
  padding: 0;
  font-family: "Metamorphous", serif;
  font-weight: 400;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(255, 255, 255, 0.7) 5%,
    rgba(255, 254, 212, 0.7) 10%,
    rgba(255, 254, 212, 0.7) 15%,
    var(--main-color) 70%,
    var(--edge-color) 100%
  );
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 100% 100%;
  color: #242424;
  overflow: hidden;
  text-align: center;
}

h1 {
  font-family: "Metamorphous", serif;
  font-size: 64px;
  font-weight: 400;
  margin: 20px 0;
  color: white;
  text-shadow: 0 0 30px white;
  z-index: 10;
}

/* Zone principale */
.app-container {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 20px 0 calc(30px + env(safe-area-inset-bottom));
}

/* Texte central */
.response-text,
#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  font-family: "Forum", serif;
  font-weight: 400;
  font-size: clamp(20px, 4vw, 28px);
  line-height: 1.4;
  padding: 0 20px;

  width: auto; /* ✅ évite le débordement */
  text-align: center;
  word-break: break-word;
  box-sizing: border-box;
  z-index: 10; /* ou un chiffre supérieur à celui du canvas */
}

.response-text::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 90%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.8) 30%,
    rgba(255, 255, 255, 0) 70%
  );
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
  filter: blur(4px);
  pointer-events: none;
}

.response-text:empty::before {
  display: none;
}

/* Boutons + micro centrés en bas */
#bottom-controls {
  position: fixed; /* ✅ toujours visible en bas */
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(30px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  padding: 0px 20px;
  box-sizing: border-box;
  z-index: 10;
}

/* Conteneur global */
.grid-buttons-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

/* Grille 2x2 */
.buttons-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Boutons */
.filter-btn {
  padding: 10px 20px;
  height: 100%;
  min-width: 140px;
  width: 100%;
  font-size: 1rem;
  border: 2px solid #242424;
  border-radius: 40px;
  background-color: transparent;
  color: #2c2c2c;
  font-family: "Montserrat", sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.filter-btn.active {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Micro centré */
.grid-buttons-wrapper .mic-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: white;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.grid-buttons-wrapper .mic-icon {
  font-size: 24px;
  color: black;
}

.mic-button.recording {
  background-color: rgba(255, 0, 0, 0.8);
}

.mic-button.recording .mic-icon {
  color: white;
}

.mic-waves {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s;
}

.mic-waves.active {
  opacity: 1;
  animation: wave 1.5s infinite;
}

@keyframes wave {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(255, 255, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

/* Bouton musique */
.music-button {
  position: fixed;
  top: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  padding: 10px 15px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
  z-index: 1000; /* 🔥 plus haut que ton canvas */
  pointer-events: auto; /* au cas où */
}

/* Spécifique au bouton musique */
#music-toggle {
  right: 15px;
}

/* Spécifique au bouton voix */
#tts-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  padding: 10px 15px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
  z-index: 1000;
  pointer-events: auto;
}

#tts-toggle:hover {
  background: rgba(255, 255, 255, 0.4);
}

.music-button:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Sketch canvas */
canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: -1;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.right-btn {
  border-radius: 140px 0px 160px 0px;
}

.left-btn {
  border-radius: 0px 140px 0px 160px;
}

/* Cas spécifique mobile */
@media screen and (max-width: 768px) {
  .response-text,
  #loading {
    max-width: 90vw;
  }
}
