/* Déclaration locale des polices */
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 300;
    src: url('../fonts/space-grotesk-v22-latin-300.woff2') format('woff2');
}
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 500;
    src: url('../fonts/space-grotesk-v22-latin-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/space-grotesk-v22-latin-700.woff2') format('woff2');
}

@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 300;
    src: url('../fonts/rajdhani-v17-latin-300.woff2') format('woff2');
}
@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 500;
    src: url('../fonts/rajdhani-v17-latin-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/rajdhani-v17-latin-700.woff2') format('woff2');
}

:root {
    /* Dark Theme (Default) */
    --bg-grad-1: #020024;
    --bg-grad-2: #1a0b2e;
    --bg-grad-3: #16213e;
    --bg-grad-4: #2d1b0e;
    --glass-bg: rgba(8, 8, 16, 0.60);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #e0e0e0;
    --text-dim: #ccc;
    --accent-primary: #00f3ff;
    --accent-secondary: #bc13fe;
    --panel-header-bg: rgba(0,0,0,0.4);
    --panel-footer-bg: rgba(0,0,0,0.6);
    --scanline-opacity: 0.1;
    --dot-color: #22c55e;
}

[data-theme="light"] {
    /* Light Theme (Zen Garden) */
    --bg-grad-1: #fdfbf7;
    --bg-grad-2: #e6e9f0;
    --bg-grad-3: #eacda3;
    --bg-grad-4: #d6ae7b;
    --glass-bg: rgba(255, 255, 255, 0.40);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-main: #2c3e50;
    --text-dim: #333;
    --accent-primary: #2980b9;
    --accent-secondary: #27ae60;
    --panel-header-bg: rgba(255,255,255,0.3);
    --panel-footer-bg: rgba(255,255,255,0.5);
    --scanline-opacity: 0.02;
    --dot-color: #16a34a;
}

body {
    background: linear-gradient(-45deg, var(--bg-grad-1), var(--bg-grad-2), var(--bg-grad-3), var(--bg-grad-4));
    background-size: 400% 400%;
    animation: deep-waves 30s ease infinite;
    color: var(--text-main);
    
    /* Ajoute de l'espace en haut pour éviter l'encoche */
    padding-top: env(safe-area-inset-top);
    /* Ajoute de l'espace en bas (pour la barre de geste iPhone/Android) */
    padding-bottom: env(safe-area-inset-bottom);    font-family: 'Rajdhani', sans-serif;
    
    overflow: hidden;
    height: 100dvh;
    margin: 0;
    user-select: none;
    transition: color 0.5s ease;
}

@keyframes deep-waves {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.scanlines {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.1));
    background-size: 100% 4px; pointer-events: none; z-index: 10;
    opacity: var(--scanline-opacity);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-scroll::-webkit-scrollbar { width: 3px; }
.custom-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); }
.custom-scroll::-webkit-scrollbar-thumb { background: var(--accent-secondary); border-radius: 2px; }

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 12px; width: 12px; border-radius: 50%;
    background: var(--accent-primary); cursor: pointer; margin-top: -4px;
    box-shadow: 0 0 5px var(--accent-primary); transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.3); }
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px; cursor: pointer; background: rgba(128,128,128,0.2); border-radius: 2px;
}

/* Assure-toi que cette règle existe bien et ressemble à ça */
.visualizer-canvas, #mainCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1; /* Derrière l'UI */
  pointer-events: none; /* Laisse passer les clics vers le body ou les boutons */
}

.ui-layer {
    position: relative; z-index: 20; height: 100%;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 1rem; pointer-events: none; transition: opacity 0.8s ease;
}

.interactive { pointer-events: auto; }

.btn-neon {
    background: rgba(0,0,0,0.2); border: 1px solid var(--accent-primary); color: var(--accent-primary);
    text-transform: uppercase; letter-spacing: 2px; transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
    backdrop-filter: blur(10px);
}
.btn-neon:hover {
    background: var(--accent-primary); color: var(--bg-grad-1); box-shadow: 0 0 30px var(--accent-primary);
}

.btn-icon {
    background: rgba(128,128,128,0.2); border: 1px solid rgba(128,128,128,0.3); color: var(--text-main);
    padding: 8px; border-radius: 8px; transition: all 0.2s; cursor: pointer;
    backdrop-filter: blur(5px);
}
.btn-icon:hover { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

#tracksContainer {
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    max-height: 50dvh; opacity: 1;
}

.collapsed #tracksContainer { max-height: 0; opacity: 0; overflow: hidden; padding: 0; }
.collapsed .panel-footer { display: none; }

.track-label {
    font-family: 'Space Grotesk', sans-serif; font-size: 0.65rem; letter-spacing: 0.05em; color: var(--text-dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-weight: 500;
}

.section-title {
    font-family: 'Rajdhani', sans-serif; font-size: 0.75rem; font-weight: 700; color: var(--accent-secondary);
    margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.15em;
    border-bottom: 1px solid rgba(128,128,128, 0.3); padding-bottom: 4px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.ui-hidden { opacity: 0; pointer-events: none; }

.green-dot {
    display: inline-block; width: 10px; height: 10px; background-color: var(--dot-color);
    border-radius: 50%; margin-right: 8px; box-shadow: 0 0 8px var(--dot-color);
}
.logo-text {
    font-family: 'Space Grotesk', monospace; font-weight: 700; letter-spacing: 0.1em;
    color: #7b8599; font-size: 0.9rem;
    transition: color 0.3s;
}
.logo-text:hover { color: var(--accent-primary); }

.footer-link {
    color: var(--accent-primary); text-decoration: none; border-bottom: 1px solid transparent; transition: border 0.3s;
}
.footer-link:hover { border-bottom: 1px solid var(--accent-primary); }

/* --- Style du Logo --- */
.app-logo {
    width: 64px; /* Taille par défaut */
    height: auto;
    border-radius: 12px; /* Léger arrondi si l'image est carrée */
    /* Lueur dynamique basée sur la couleur du thème actuel */
    filter: drop-shadow(0 0 5px var(--accent-primary)); 
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

/* Animation au survol */
.app-logo:hover {
    transform: scale(1.1) rotate(5deg);
    filter: drop-shadow(0 0 15px var(--accent-primary));
}

/* Ajustement pour mobile pour ne pas prendre trop de place */
@media (max-width: 640px) {
    .app-logo {
        width: 48px;
        border-radius: 8px;
    }
}

@keyframes btn-breathe {
  0%   { box-shadow: 0 0 0px rgba(59,130,246,0.0); transform: translateY(0); }
  50%  { box-shadow: 0 0 16px rgba(59,130,246,0.9); transform: translateY(-1px); }
  100% { box-shadow: 0 0 0px rgba(59,130,246,0.0); transform: translateY(0); }
}

.btn-breathing {
  animation: btn-breathe 2.5s ease-in-out infinite;
}

/* ========================================= */
/* Boutons de presets adaptés aux deux thèmes */
/* ========================================= */

/* --- Base (Sombre par défaut) --- */
.preset-btn {
  background: rgba(15, 23, 42, 0.6);
  color: #a7f3d0;
  border-color: rgba(52, 211, 153, 0.6);
  transition: all 0.3s ease;
}

/* Hover (Sombre) */
.preset-btn:not(.preset-selected):hover {
  background: rgba(16, 185, 129, 0.25);
}

/* --- Base (Clair) --- */
[data-theme="light"] .preset-btn {
  background: rgba(255, 255, 255, 0.8);
  color: #14532d;
  border-color: rgba(16, 185, 129, 0.6);
}

/* Hover (Clair) */
[data-theme="light"] .preset-btn:not(.preset-selected):hover {
  background: rgba(209, 250, 229, 1);
}

/* ========================================= */
/* État sélectionné commun aux deux thèmes    */
/* ========================================= */

/* En combinant les 2 classes, on passe à un poids de 20 qui bat Tailwind */

/* Sélectionné (Sombre) */
.preset-btn.preset-selected {
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.9);
  transform: translateY(-1px);
  background: rgba(16, 185, 129, 0.45); 
  color: #ffffff; 
}

/* Sélectionné (Clair) */
[data-theme="light"] .preset-btn.preset-selected {
  background: rgba(167, 243, 208, 1); 
  color: #064e3b;
  box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.9);
}

/* --- Boutons Settings (LoFi) - État Sélectionné --- */
.settings-selected {
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.9);
  transform: translateY(-1px);
}

/* Sombre : fond bleu profond, texte blanc */
.settings-selected {
  background: rgba(59, 130, 246, 0.4);
  color: #eff6ff; 
}

/* Clair : fond bleu très clair, texte bleu foncé */
[data-theme="light"] .settings-selected {
  background: rgba(191, 219, 254, 1); /* bg-blue-200 */
  color: #1e3a8a;
}
/* L'overlay de mise en veille (Noir absolu) */
#sleep-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000000; /* Noir pur ! */
  opacity: 0;
  pointer-events: none; /* Ne bloque rien quand il est invisible */
  transition: opacity 2s ease-in-out; /* Assombrissement très fluide */
  z-index: 99999; /* Au-dessus de la UI (20) et de tout le reste */
}

/* État actif : on affiche le noir et on capte le premier clic */
#sleep-overlay.active {
  opacity: 1; /* Opacité 100% = noir total. Tu peux mettre 0.95 si tu veux deviner un peu le fond */
  pointer-events: auto; /* Devient cliquable pour capter le réveil ! */
  cursor: pointer;
}