/* Minecraft Font */
@font-face {
    font-family: 'Minecraft';
    src: url('../fonts/minecraft-font/MinecraftRegular-Bmg3.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Minecraft';
    src: url('../fonts/minecraft-font/MinecraftBold-nMK1.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Minecraft';
    src: url('../fonts/minecraft-font/MinecraftItalic-R8Mo.otf') format('opentype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Minecraft';
    src: url('../fonts/minecraft-font/MinecraftBoldItalic-1y1e.otf') format('opentype');
    font-weight: bold;
    font-style: italic;
}

/* Bouton audio en haut à gauche */
.audio-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #8b6914, #6b5010);
    border: 2px solid #f4e4c1;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 105, 20, 0.4);
}

.audio-btn:hover {
    background: linear-gradient(145deg, #a07e1a, #8b6914);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(139, 105, 20, 0.6);
}

.audio-btn:active {
    transform: scale(0.95);
}

.audio-icon {
    width: 28px;
    height: 28px;
    color: #f4e4c1;
    filter: drop-shadow(0 0 3px rgba(244, 228, 193, 0.5));
}

/* Animation des ondes sonores */
.wave {
    opacity: 1;
    transition: opacity 0.3s ease;
    animation: pulse 1.5s ease-in-out infinite;
}

.wave-1 {
    animation-delay: 0s;
}

.wave-2 {
    animation-delay: 0.2s;
}

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

/* Croix mute cachée par défaut */
.mute-x {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* État muted */
.audio-btn.muted .wave {
    opacity: 0;
}

.audio-btn.muted .mute-x {
    opacity: 1;
}

.audio-btn.muted {
    background: linear-gradient(145deg, #5f4a38, #4a3828);
    border-color: #9d8b7a;
}

.audio-btn.muted .audio-icon {
    color: #9d8b7a;
}

/* Loader captivant */
#loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 5, 6, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease;
}

#loader-container.fade-out {
    opacity: 0;
}

.loader-content {
    text-align: center;
    position: relative;
}

/* Livre magique animé */
.magic-book {
    width: 120px;
    height: 160px;
    position: relative;
    margin: 0 auto 30px;
    perspective: 1000px;
}

.book-cover {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #8b6914, #6b5010);
    border: 3px solid #f4e4c1;
    border-radius: 8px;
    position: relative;
    transform-style: preserve-3d;
    animation: bookFloat 3s ease-in-out infinite, bookGlow 2s ease-in-out infinite;
    box-shadow:
        0 0 20px rgba(139, 105, 20, 0.5),
        inset 0 0 30px rgba(244, 228, 193, 0.1);
}

.book-cover::before {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: #f4e4c1;
    text-shadow: 0 0 10px rgba(244, 228, 193, 0.8);
}

.book-pages {
    position: absolute;
    right: -5px;
    top: 10px;
    width: 8px;
    height: 140px;
    background: linear-gradient(90deg,
        #f4e4c1 0%,
        #e8d8b3 50%,
        #f4e4c1 100%);
    border-radius: 0 4px 4px 0;
    animation: pagesFlip 1.5s ease-in-out infinite;
}

.magic-glow {
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: radial-gradient(circle, rgba(244, 228, 193, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes bookFloat {
    0%, 100% { transform: translateY(0px) rotateY(0deg); }
    50% { transform: translateY(-20px) rotateY(5deg); }
}

@keyframes bookGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 105, 20, 0.5), inset 0 0 30px rgba(244, 228, 193, 0.1); }
    50% { box-shadow: 0 0 40px rgba(139, 105, 20, 0.8), inset 0 0 50px rgba(244, 228, 193, 0.2); }
}

@keyframes pagesFlip {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.95); }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Titre du loader */
.loader-title {
    font-family: 'Minecraft', serif;
    font-size: 32px;
    color: #f4e4c1;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(244, 228, 193, 0.5);
    animation: titlePulse 2s ease-in-out infinite;
}

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

#loader-text {
    font-family: 'Georgia', serif;
    font-size: 16px;
    color: #c4b59d;
    margin-bottom: 25px;
    animation: textFade 1.5s ease-in-out infinite;
}

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

/* Barre de progression */
.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

.progress-bar {
    width: 300px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #8b6914;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6b5010, #8b6914, #a07e1a);
    border-radius: 8px;
    transition: width 0.3s ease;
    position: relative;
    box-shadow: 0 0 10px rgba(139, 105, 20, 0.8);
}

.progress-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(244, 228, 193, 0.6),
        transparent);
    animation: progressShine 2s linear infinite;
}

@keyframes progressShine {
    0% { left: -100%; }
    100% { left: 200%; }
}

#loader-percent {
    font-family: 'Minecraft', monospace;
    font-size: 20px;
    color: #f4e4c1;
    min-width: 50px;
    text-align: left;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(244, 228, 193, 0.5);
}

/* Runes flottantes */
.floating-runes {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    pointer-events: none;
}

.rune {
    position: absolute;
    font-size: 24px;
    color: #8b6914;
    opacity: 0.3;
    animation: runeFloat 4s ease-in-out infinite;
}

.rune:nth-child(1) {
    top: 10%;
    left: 20%;
    animation-delay: 0s;
}

.rune:nth-child(2) {
    top: 20%;
    right: 15%;
    animation-delay: 0.5s;
}

.rune:nth-child(3) {
    bottom: 15%;
    left: 15%;
    animation-delay: 1s;
}

.rune:nth-child(4) {
    bottom: 25%;
    right: 20%;
    animation-delay: 1.5s;
}

.rune:nth-child(5) {
    top: 50%;
    left: 5%;
    animation-delay: 2s;
}

.rune:nth-child(6) {
    top: 45%;
    right: 10%;
    animation-delay: 2.5s;
}

@keyframes runeFloat {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
        opacity: 0.6;
    }
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Georgia', serif;
    overflow: hidden;
    position: relative;
    color: #f4e4c1;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../images/background.png') no-repeat center center fixed;
    background-size: cover;
    z-index: -1;
}

/* Conteneur de la scène 3D */
#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#grimoire-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Vignettage pour faire ressortir le centre */
#scene-container::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Instructions - masquées */
#instructions {
    display: none;
}

/* Overlay UI pour afficher le contenu */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

#ui-overlay.hidden {
    display: none;
}

#page-content {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: 80vh;
    padding: 50px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

#page-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../images/book_start.png') no-repeat center center;
    background-size: contain;
    z-index: -1;
}

#page-content.page-turning::before {
    background: url('../images/book.gif') no-repeat center center;
    background-size: contain;
}

#page-content.page-turning-reverse::before {
    background: url('../images/book.gif') no-repeat center center;
    background-size: contain;
    transform: scaleX(-1);
}

/* Contenu du livre - Deux colonnes */
.book-wrapper {
    display: flex;
    gap: 30px;
    width: 70%;
    height: 70%;
    flex: 1;
    padding: 30px 40px;
    margin-left: 40px;
}

.book-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-family: 'Minecraft', monospace;
    color: #2b1810;
    overflow-y: auto;
    padding: 15px;
    font-size: 12px;
}

.left-page {
    text-align: left;
    margin-right: 80px;
}

.right-page {
    text-align: left;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    margin-left: -120px;
}

#left-content h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #1a0f08;
}

#left-content p {
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 8px;
}

#right-content {
    width: 95%;
    max-width: 95%;
    height: 100%;
    padding-left: 0px;
    padding-right: 0px;
}

#right-content p {
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 8px;
}

/* Boutons */
.btn-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #8b6914;
    border: none;
    color: #f4e4c1;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close:hover {
    background: #a07e1a;
    transform: rotate(90deg);
}

.navigation {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
}

.btn-nav {
    flex: 1;
    padding: 15px 30px;
    background: linear-gradient(145deg, #8b6914, #6b5010);
    border: 2px solid #f4e4c1;
    color: #f4e4c1;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.btn-nav:hover {
    background: linear-gradient(145deg, #a07e1a, #8b6914);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(139, 105, 20, 0.5);
}

.btn-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar personnalisée */
#page-content::-webkit-scrollbar {
    width: 10px;
}

#page-content::-webkit-scrollbar-track {
    background: #1a0f08;
    border-radius: 10px;
}

#page-content::-webkit-scrollbar-thumb {
    background: #8b6914;
    border-radius: 10px;
}

#page-content::-webkit-scrollbar-thumb:hover {
    background: #a07e1a;
}

/* Responsive */
@media (max-width: 768px) {
    #page-content {
        padding: 30px 20px;
        max-width: 95%;
    }

    #page-title {
        font-size: 24px;
    }

    #page-text {
        font-size: 16px;
    }

    #instructions {
        bottom: 20px;
        padding: 15px 25px;
    }

    #instructions p {
        font-size: 14px;
    }
}
