/* =========================================
   KISSBOOK HOME - MAIN STYLES
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Uncial+Antiqua&display=swap');

/* --- CONTAINER --- */
#kbh-home-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0f172a;
    background: radial-gradient(circle at center, rgba(26, 26, 46, 0.6) 0%, rgba(15, 15, 30, 0.9) 100%),
        url('../img/kbg-bouc-magique-bg.png') no-repeat center center;
    background-size: cover;
    background-attachment: fixed;
    z-index: 99999;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    pointer-events: none;
    /* Allow clicks to pass through background */
}

/* --- TOP BAR --- */
#kbh-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(56, 189, 248, 0.3);
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 2147483647 !important;
    /* Force On Top */
    pointer-events: auto;
    /* Capture clicks */
    height: 50px;
    box-sizing: border-box;
}

#kbh-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#kbh-bar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cinzel Decorative', cursive;
    font-size: 1.1rem;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    white-space: nowrap;
}

#kbh-brand {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 1.1rem;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

#kbh-controls {
    display: flex;
    gap: 10px;
}

.kbh-btn {
    background: #334155;
    border: none;
    color: #e2e8f0;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.kbh-btn:hover {
    background: #475569;
    transform: translateY(-2px);
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* --- CAROUSEL SCENE --- */
#kbh-carousel-scene {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    perspective: 2000px;
    position: relative;
    /* Background handled by wrapper */
}

/* Magic Particles */
#kbh-carousel-scene::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(0, 243, 255, 0.4), transparent),
        radial-gradient(3px 3px at 60% 70%, rgba(255, 0, 255, 0.3), transparent),
        radial-gradient(2px 2px at 40% 10%, rgba(0, 102, 255, 0.4), transparent),
        radial-gradient(1px 1px at 80% 50%, rgba(255, 255, 255, 0.6), transparent);
    background-size: 300px 300px;
    animation: kbhFloatParticles 15s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes kbhFloatParticles {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(-150px, -150px) rotate(5deg);
    }
}

/* Carousel Container */
.kbh-carousel {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: translateY(10vh);
    /* Slightly lower to center books visually, using vh to scale */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Book Elements */
.kbh-carousel-book {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 15.75vh;
    /* Half of 31.5vh */
    height: 22.5vh;
    /* Half of 45vh */
    max-width: 50vw;
    /* Tighter constraint */
    transform-style: preserve-3d;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    opacity: 0;
    pointer-events: auto;
    z-index: 1;
}

.kbh-carousel-book:hover {
    transform: translateY(-10px) scale(1.02);
    filter: brightness(1.2) !important;
}

/* Positions */
.kbh-carousel-book.pos-center {
    transform: translateX(0) translateZ(200px) scale(1.1);
    z-index: 100;
    opacity: 1;
    filter: brightness(1.1) drop-shadow(0 20px 50px rgba(0, 0, 0, 0.8));
    pointer-events: auto;
}

.kbh-carousel-book.pos-left-1 {
    transform: translateX(-450px) translateZ(50px) scale(0.9) rotateY(15deg);
    z-index: 50;
    opacity: 0.9;
    filter: brightness(0.6);
    pointer-events: auto;
}

.kbh-carousel-book.pos-left-2 {
    transform: translateX(-650px) translateZ(-100px) scale(0.8) rotateY(25deg);
    z-index: 20;
    opacity: 0.7;
    filter: brightness(0.4) blur(1px);
    pointer-events: auto;
}

.kbh-carousel-book.pos-right-1 {
    transform: translateX(450px) translateZ(50px) scale(0.9) rotateY(-15deg);
    z-index: 50;
    opacity: 0.9;
    filter: brightness(0.6);
    pointer-events: auto;
}

.kbh-carousel-book.pos-right-2 {
    transform: translateX(650px) translateZ(-100px) scale(0.8) rotateY(-25deg);
    z-index: 20;
    opacity: 0.7;
    filter: brightness(0.4) blur(1px);
    pointer-events: auto;
}

/* 3D Book Spine Construction */
.kbh-book-cover {
    width: 100%;
    height: 100%;
    background-size: 100% 100% !important;
    background-position: center !important;
    border-radius: 5px 15px 15px 5px;
    box-shadow: inset 10px 0 20px rgba(0, 0, 0, 0.5), 5px 5px 15px rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

/* Active Book Glow */
.kbh-carousel-book.pos-center .kbh-book-cover {
    box-shadow:
        inset 10px 0 20px rgba(0, 0, 0, 0.5),
        0 20px 80px rgba(0, 0, 0, 0.9),
        0 0 40px rgba(255, 215, 0, 0.3);
    /* Gold Glow */
    border: 1px solid rgba(255, 215, 0, 0.5);
    animation: kbhPulseGlow 3s ease-in-out infinite;
}

@keyframes kbhPulseGlow {

    0%,
    100% {
        box-shadow: inset 10px 0 20px rgba(0, 0, 0, 0.5), 0 20px 80px rgba(0, 0, 0, 0.9), 0 0 40px rgba(255, 215, 0, 0.3);
    }

    50% {
        box-shadow: inset 10px 0 20px rgba(0, 0, 0, 0.5), 0 20px 80px rgba(0, 0, 0, 0.9), 0 0 60px rgba(255, 215, 0, 0.6);
    }
}

/* Carousel Controls */
.kbh-carousel-controls {
    position: absolute;
    bottom: 50px;
    display: flex;
    gap: 30px;
    z-index: 1000;
}

.kbh-nav-btn {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.5rem;
    padding: 10px 30px;
    background: linear-gradient(135deg, #8b4513 0%, #3e2723 100%);
    color: #ffd700;
    border: 2px solid #d4af37;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 0 #5d4037, 0 6px 20px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.kbh-nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 0 #5d4037, 0 10px 25px rgba(0, 0, 0, 0.6);
}

.kbh-nav-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #5d4037;
}

.kbh-nav-btn.open-btn {
    background: linear-gradient(135deg, #d35400 0%, #a04000 100%);
    font-size: 1.8rem;
    padding: 15px 50px;
    animation: kbhPulseBtn 2s infinite;
}

@keyframes kbhPulseBtn {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* --- CONTENT CONTAINER (Hidden by default) --- */
#kbh-content-stage {
    position: fixed;
    top: 60px;
    /* Below topbar */
    left: 0;
    width: 100vw;
    height: calc(100vh - 60px);
    z-index: 100;
    display: none;
    /* Shown when book is opened */
}

/* Utilities */
.hidden {
    display: none !important;
}

/* 3D Visual Root Container */
#kbg-visual-root {
    position: fixed;
    top: 60px;
    /* Below topbar */
    left: 0;
    width: 100vw;
    height: calc(100vh - 60px);
    z-index: 100;
}

#kbg-visual-root:not(.hidden) {
    display: block;
}

/* Transition Animation Class */
.kbh-opening .kbh-carousel-book.pos-center {
    transform: scale(5) translateZ(1000px);
    opacity: 0;
    transition: all 1.2s ease-in;
}

.kbh-opening .kbh-carousel-book:not(.pos-center) {
    opacity: 0;
    transform: scale(0);
    transition: all 0.5s ease-out;
}

/* Hide inner/nested headers when loaded inside KBH */
#kbh-content-stage #kbg-topbar,
#kbh-content-stage .kbg-header,
#kbh-content-stage #wpadminbar,
#kbh-content-stage .site-header,
#kbh-content-stage header {
    display: none !important;
}

/* Ensure content fills height */
#kbh-content-stage>div {
    height: 100% !important;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */

@media screen and (max-width: 1024px) {

    /* Tablet / Small Laptop */
    /* Book sizes handled by VH units now */
}

@media screen and (max-width: 768px) {
    /* Mobile / Tablet Portrait */

    /* Top Bar Compact */
    #kbh-topbar {
        height: 50px;
        padding: 5px 10px;
    }

    #kbh-brand,
    #kbh-center-title,
    #kbh-bar-center {
        font-size: 1rem !important;
    }

    /* Hide center title on very small screens or make tiny */
    #kbh-bar-center {
        display: none;
    }

    .kbh-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Adjust Content Stage */
    #kbg-visual-root,
    #kbh-content-stage {
        top: 50px;
        height: calc(100vh - 50px);
    }
}

@media screen and (max-width: 480px) {

    /* Small Phone */

    /* Stack controls or hide less important ones? */
    #kbh-controls {
        gap: 5px;
    }

    .kbh-btn {
        padding: 5px;
        font-size: 0.75rem;
    }
}

/* =========================================
   FIREFOX SPECIFIC OVERRIDES
   ========================================= */
@-moz-document url-prefix() {

    /* Raise Carousel (monte un peu) */
    .kbh-carousel,
    .kbg-carousel {
        transform: translateY(5vh) !important;
        /* Up from 10vh */
    }

    /* Smaller Navigation Buttons in Firefox */
    .kbh-nav-btn {
        font-size: 1rem !important;
        padding: 6px 15px !important;
        min-width: unset !important;
    }

    .kbh-nav-btn.open-btn {
        font-size: 1.2rem !important;
        padding: 8px 25px !important;
        min-width: unset !important;
    }
}