@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Lato:wght@300;400;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: 'Lato', sans-serif;
    /* Rich wooden texture background */
    background: linear-gradient(135deg, #1b1612 0%, #2e241c 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    /* Use dynamic viewport height (dvh) for mobile browsers with UI bars */
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    color: #333;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    padding: 10px 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    /* Let flex centering do its job but keep a minor safe area */
}

.book-wrapper {
    position: relative;
    width: 95vw;
    /* Almost full width */
    max-width: 450px;
    height: 100%;
    /* Take full available height of the padded app container */
    max-height: 800px;
    /* Don't grow endlessly on massive monitors */
    margin: 0;
    /* Remove auto margin that was causing weird space distribution */
}

.book {
    width: 100%;
    height: 100%;
    position: relative;
    perspective: 1500px;
    /* Strong 3D perspective */
}

/* Base style for a page */
.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    /* Textured paper color */
    background-color: #f7eed8;
    background-image: radial-gradient(#ebe0c8 10%, transparent 10%);
    background-size: 10px 10px;
    border-radius: 4px 15px 15px 4px;
    /* Right edges curved */
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.1),
        /* inner vignette */
        5px 5px 20px rgba(0, 0, 0, 0.4);
    /* drop shadow */
    transform-origin: left center;
    /* Hinge on the left */
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    transform-style: preserve-3d;
    display: flex;
    flex-direction: column;
    z-index: 1;
    /* Managed dynamically by JS */
}

/* Leather spine (binding) */
.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to right, #4a2c11, #8B5A2B 30%, #4a2c11 90%);
    border-right: 1px solid rgba(0, 0, 0, 0.5);
    border-radius: 4px 0 0 4px;
    box-shadow: inset -2px 0 5px rgba(0, 0, 0, 0.3);
    z-index: 10;
    /* Above the content */
}

/* When a page turns left */
.page.turned {
    transform: rotateY(-180deg);
}

.page-content {
    /* Offset by the binder */
    padding: 20px 15px 70px 40px;
    height: 100%;
    display: flex;
    flex-direction: column;
    backface-visibility: hidden;
    /* Hide when flipped */
    overflow-y: auto;
    /* Allow scrolling if text is too large */
    scrollbar-width: none;
    /* Firefox */
}

.page-content::-webkit-scrollbar {
    display: none;
    /* Safari and Chrome */
}

/* Cover style */
.page.cover {
    background: linear-gradient(135deg, #1f2326 0%, #111417 100%);
    color: #ffd700;
    justify-content: center;
    align-items: center;
    border: 2px solid #5a4b31;
}

.page.cover .page-content {
    padding: 20px 20px 20px 50px;
    /* Offset spine */
    justify-content: center;
    align-items: center;
    background: transparent;
    box-shadow: none;
}

.cover-title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    color: #e6b35c;
}

.cover-subtitle {
    font-family: 'Lato', sans-serif;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #a38f6d;
}

/* Menu Items inside pages */
.menu-grid {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-evenly;
}

.menu-item {
    margin-bottom: 20px;
    border-bottom: 1px dashed rgba(139, 90, 43, 0.4);
    padding-bottom: 15px;
    transition: transform 0.2s ease, background 0.2s ease;
    border-radius: 8px;
    padding: 10px;
}

.menu-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.menu-item:hover {
    transform: translateX(5px);
    background: rgba(139, 90, 43, 0.05);
    /* Slight highlight */
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.item-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.4em;
    font-weight: 700;
    color: #2c1e16;
}

.item-price {
    font-family: 'Lato', sans-serif;
    font-size: 1.3em;
    font-weight: 700;
    color: #8b3a3a;
}

.item-desc {
    font-size: 1.05em;
    color: #5c4e41;
    line-height: 1.4;
    font-style: italic;
}

.page-number {
    text-align: right;
    font-size: 0.9rem;
    color: #a38f6d;
    font-family: 'Playfair Display', serif;
    margin-top: auto;
}

/* Nav Zones inside book */
.nav-zone {
    position: absolute;
    bottom: 8px;
    /* Keep inside the book-wrapper for mobile compatibility */
    width: 60px;
    height: 60px;
    z-index: 1000;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.nav-zone.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* We place the left zone slightly past the spine */
.nav-left {
    left: 20px;
}

/* We place the right zone at the edge */
.nav-right {
    right: 5px;
}

/* Pulse animation to draw attention */
.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.3);
    /* Gold color */
    z-index: 1;
    animation: animatePulse 2s infinite ease-in-out;
}

.nav-arrow {
    position: relative;
    z-index: 2;
    font-size: 2.5rem;
    color: #8a6c2d;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    user-select: none;
}

/* Small hint: bounce arrow horizontally */
.nav-right:hover .nav-arrow {
    animation: slideRight 0.8s infinite;
}

.nav-left:hover .nav-arrow {
    animation: slideLeft 0.8s infinite;
}

@keyframes animatePulse {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.3);
        opacity: 0;
    }

    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

@keyframes slideRight {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(5px);
    }
}

@keyframes slideLeft {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-5px);
    }
}

/* Font controls */
.font-controls {
    position: absolute;
    bottom: 15px;
    /* Inside the book area, over the page-content bottom padding */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 1000;
}

.font-btn {
    background: rgba(20, 16, 12, 0.8);
    backdrop-filter: blur(5px);
    color: #d4af37;
    border: 1px solid rgba(212, 175, 55, 0.5);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
}

.font-btn:hover {
    background: rgba(40, 32, 24, 0.9);
    border-color: #d4af37;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.4);
}

.font-btn:active {
    transform: translateY(1px);
}