/* --- DESIGN ARBRE VIVANT --- */
:root {
    --bg-deep: #050a10;
    --tree-cortex: #3e2723;
    --leaf-hope: #4cd137;   /* Vert Espoir */
    --leaf-fear: #e84118;   /* Rouge Peur */
    --leaf-curious: #9c88ff; /* Violet Curiosité */
    --leaf-tech: #00a8ff;    /* Bleu Tech */
    --energy: #00e5ff;       /* Cyan Énergie */
    --glass: rgba(10, 15, 25, 0.85);
    --border: rgba(0, 229, 255, 0.3);
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: radial-gradient(circle at center bottom, #1a2633 0%, var(--bg-deep) 80%);
    color: #ecf0f1;
    overflow-x: hidden;
    min-height: 100vh;
}

h1 {
    text-align: center;
    font-size: 2rem;
    margin-top: 20px;
    z-index: 10;
    position: relative;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

#tree-canvas {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

/* Animation de "Dessin" du SVG */
.draw-anim {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: draw 3s ease-out forwards;
}

@keyframes draw {
    to { stroke-dashoffset: 0; }
}

/* Ajustement de la taille du SVG */
.trunk-svg {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px; /* Plus large */
    height: 95vh;
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(0 0 20px rgba(0,0,0,0.5));
}

/* --- ZONES INTERACTIVES (NOEUDS) --- */
.node-zone {
    position: absolute;
    z-index: 5;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--glass);
    border: 1px solid var(--border);
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    display: flex; align-items: center; gap: 8px;
}

.node-zone:hover {
    transform: scale(1.15);
    border-color: var(--energy);
    box-shadow: 0 0 15px var(--energy);
    background: rgba(0, 229, 255, 0.1);
}

.node-zone.hot-topic {
    border-color: #e84118;
    color: #e84118;
    animation: pulse-red 2s infinite;
}
.node-zone.hot-topic:hover {
    background: rgba(232, 65, 24, 0.1);
    box-shadow: 0 0 20px #e84118;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(232, 65, 24, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(232, 65, 24, 0); }
    100% { box-shadow: 0 0 0 0 rgba(232, 65, 24, 0); }
}

.node-zone .icon { font-size: 1.2rem; }

/* Positionnement "Absolu" sur l'arbre (Ajusté pour mobile et desktop) */
/* Racines */
.root-left { bottom: 15%; left: 20%; }
.root-right { bottom: 15%; right: 20%; }

/* Tronc */
.trunk-center { bottom: 40%; left: 50%; transform: translateX(-50%); }

/* Branches */
.branch-left { bottom: 65%; left: 25%; }
.branch-right { bottom: 65%; right: 25%; }

/* Cime */
.crown-top { top: 15%; left: 50%; transform: translateX(-50%); border-color: var(--leaf-curious); }

/* --- FEUILLAGE DYNAMIQUE (CANOPÉE) --- */
#canopy {
    position: absolute;
    top: 5%;
    left: 10%;
    width: 80%;
    height: 50%;
    z-index: 4;
    pointer-events: none; /* Les feuilles individuelles auront pointer-events: auto */
}

.leaf {
    position: absolute;
    width: 30px; height: 30px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 50% 50% 0 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    transition: all 0.4s ease;
    animation: float 4s infinite ease-in-out;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.leaf:hover {
    transform: scale(1.8) rotate(15deg);
    z-index: 100;
    background: #fff;
    color: #000;
}

/* Couleurs d'émotion */
.leaf.anxious { border-color: var(--leaf-fear); color: var(--leaf-fear); }
.leaf.anxious:hover { background: var(--leaf-fear); color: #fff; }

.leaf.hopeful { border-color: var(--leaf-hope); color: var(--leaf-hope); }
.leaf.hopeful:hover { background: var(--leaf-hope); color: #fff; }

.leaf.tech { border-color: var(--leaf-tech); color: var(--leaf-tech); }
.leaf.tech:hover { background: var(--leaf-tech); color: #fff; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(5deg); }
}

/* --- ANIMATIONS SPECIALES --- */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake-anim {
    animation: shake 0.5s;
    animation-iteration-count: 1;
}

/* Zoom effect on Reader Open */
.reader-overlay.active { 
    display: flex; opacity: 1; 
    backdrop-filter: blur(8px) grayscale(50%); /* Plus immersif */
}

.node-zone.hot-topic {
    box-shadow: 0 0 15px #ff4757, inset 0 0 10px #ff4757;
    animation: pulse-red 1.5s infinite alternate;
}

@keyframes pulse-red {
    from { transform: scale(1); box-shadow: 0 0 10px #ff4757; }
    to { transform: scale(1.1); box-shadow: 0 0 25px #ff4757; }
}
.reader-modal {
    width: 90%; max-width: 600px; max-height: 80vh;
    background: #11161d; border: 1px solid var(--energy);
    padding: 30px; border-radius: 15px; overflow-y: auto;
    box-shadow: 0 0 50px rgba(0, 229, 255, 0.15);
    transform: translateY(20px); transition: transform 0.3s;
    color: #c9d1d9;
}
.reader-overlay.active { display: flex; opacity: 1; }
.reader-overlay.active .reader-modal { transform: translateY(0); }

.close-btn { float: right; cursor: pointer; font-size: 1.5rem; color: var(--energy); }
.reader-content h2 { color: var(--energy); border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-top: 0; }
.reader-content p { line-height: 1.6; }
.source-tag {
    display: inline-block; background: #21262d; padding: 4px 10px; 
    border-radius: 4px; font-size: 0.75rem; margin-top: 20px; color: #8b949e; border: 1px solid #30363d;
}

/* --- CHAT --- */
#chat-trigger {
    position: fixed; bottom: 30px; right: 30px;
    background: var(--energy); color: #000;
    padding: 15px 25px; border-radius: 30px;
    cursor: pointer; box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
    font-weight: bold; transition: transform 0.3s;
    z-index: 2000;
}
#chat-trigger:hover { transform: scale(1.05); filter: brightness(1.2); }

#chat-window {
    position: fixed; bottom: 90px; right: 30px;
    width: 350px; height: 450px;
    background: #11161d; border: 1px solid var(--energy);
    border-radius: 12px; display: none; flex-direction: column;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    z-index: 2000; overflow: hidden;
}

.chat-header {
    background: rgba(0, 229, 255, 0.1); padding: 15px; color: var(--energy); font-weight: bold;
    display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border);
}

.chat-messages {
    flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}

.message {
    padding: 10px 15px; border-radius: 10px; max-width: 80%; font-size: 0.9rem;
    word-wrap: break-word;
}
.message.bot { background: #1f2936; align-self: flex-start; color: #c9d1d9; border-left: 2px solid var(--energy); }
.message.user { background: var(--energy); align-self: flex-end; color: #000; }

.chat-input-area {
    padding: 10px; background: #0d1117; border-top: 1px solid var(--border); display: flex; gap: 10px;
}
.chat-input-area input {
    flex: 1; background: transparent; border: 1px solid #30363d; border-radius: 4px; color: #fff; outline: none; padding: 8px;
}
.chat-input-area button {
    background: var(--energy); color: #000; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-weight: bold; transition: background 0.3s;
}
.chat-input-area button:hover {
    background: #00b8cc;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .trunk-svg { width: 100%; height: 80vh; bottom: 0; }
    .node-zone { padding: 8px 12px; font-size: 0.8rem; }
    .root-left { left: 5%; bottom: 10%; }
    .root-right { right: 5%; bottom: 10%; }
    .branch-left { left: 5%; bottom: 60%; }
    .branch-right { right: 5%; bottom: 60%; }
    #chat-window { width: 90%; right: 5%; bottom: 80px; }
}
