/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary:   #1a3a5c;
    --gold:      #c9a84c;
    --paper:     #faf8f4;
    --mist:      #eee8de;
    --shadow:    0 24px 64px rgba(15,14,13,0.22);
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'DM Sans', Arial, sans-serif;
    background: var(--mist);
}

/* ─── TOP BAR ───────────────────────────────────────────── */
.top {
    height: 60px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    border-bottom: 2px solid var(--gold);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

/* ─── MAIN LAYOUT ───────────────────────────────────────── */
.mainbook {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 60px);
    gap: 18px;
    padding: 24px 16px 64px;
}

/* ─── BOOK CONTAINER ────────────────────────────────────── */
#bookContainer {
    display: flex;
    width: 1100px;
    max-width: 90vw;
    height: 700px;
    max-height: calc(100vh - 130px);

    background: var(--paper);
    border-radius: 3px 12px 12px 3px;
    overflow: hidden;

    /* layered shadow = thick book spine illusion */
    box-shadow:
        var(--shadow),
        -5px 0 0 #d5cfc5,
        -9px 0 0 #c4bdb2;

    position: relative;
}

/* spine line */
#bookContainer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom,
        transparent,
        rgba(0,0,0,0.1) 20%,
        rgba(0,0,0,0.18) 50%,
        rgba(0,0,0,0.1) 80%,
        transparent
    );
    transform: translateX(-50%);
    z-index: 5;
    pointer-events: none;
}

/* ─── PAGES ─────────────────────────────────────────────── */
#leftPage,
#rightPage {
    width: 50%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--paper);
}

/* ─── START / END TEXT ──────────────────────────────────── */
#leftPage h2,
#rightPage h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-family: 'Playfair Display', serif;
    font-size: clamp(1rem, 2.5vw, 1.8rem);
    font-weight: 400;
    color: var(--primary);
    letter-spacing: 0.04em;
    background: var(--paper);
    padding: 24px;
    text-align: center;
}

/* ─── PAGE IMAGES ───────────────────────────────────────── */
[data-page="0"]  { background-image: url('page1.png');  }
[data-page="1"]  { background-image: url('page2.png');  }
[data-page="2"]  { background-image: url('page3.png');  }
[data-page="3"]  { background-image: url('page4.png');  }
[data-page="4"]  { background-image: url('page5.png');  }
[data-page="5"]  { background-image: url('page6.png');  }
[data-page="6"]  { background-image: url('page7.png');  }
[data-page="7"]  { background-image: url('page8.png');  }
[data-page="8"]  { background-image: url('page9.png');  }
[data-page="9"]  { background-image: url('page10.png'); }
[data-page="10"] { background-image: url('page11.png'); }
[data-page="11"] { background-image: url('page12.png'); }
[data-page="12"] { background-image: url('page13.png'); }
[data-page="13"] { background-image: url('page14.png'); }
[data-page="14"] { background-image: url('page15.png'); }
[data-page="15"] { background-image: url('page16.png'); }
[data-page="16"] { background-image: url('page17.png'); }
[data-page="17"] { background-image: url('page18.png'); }
[data-page="18"] { background-image: url('page19.png'); }
[data-page="19"] { background-image: url('page20.png'); }
[data-page="20"] { background-image: url('page21.png'); }
[data-page="21"] { background-image: url('page22.png'); }

/* ─── NAV BUTTONS ───────────────────────────────────────── */
.book-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1.5px solid rgba(26,58,92,0.2);
    background: rgba(250,248,244,0.95);
    color: var(--primary);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.book-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.08);
}
.book-btn:active { transform: scale(0.95); }

/* ─── FLOATING BUTTONS ──────────────────────────────────── */
#modeToggle,
#zoomToggle {
    position: fixed;
    bottom: 20px;
    border: 1.5px solid rgba(26,58,92,0.2);
    background: rgba(250,248,244,0.95);
    color: var(--primary);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-family: 'DM Sans', Arial, sans-serif;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}
#modeToggle { left: 20px; }
#zoomToggle { right: 20px; }

#modeToggle:hover,
#zoomToggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ─── SCROLL MODE ───────────────────────────────────────── */
/* fills almost full screen, dark bg so pages pop */
#bookContainer.scroll-mode {
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;

    /* nearly full viewport */
    width: 98vw;
    max-width: 98vw;
    height: 90vh;
    max-height: 90vh;

    padding: 28px 0;
    gap: 24px;

    background: #111;
    border-radius: 10px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

#bookContainer.scroll-mode::before { display: none; }

#bookContainer.scroll-mode::-webkit-scrollbar { width: 5px; }
#bookContainer.scroll-mode::-webkit-scrollbar-track { background: #222; }
#bookContainer.scroll-mode::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

/* each page in scroll mode */
#bookContainer.scroll-mode div {
    width: 88%;
    max-width: 860px;
    aspect-ratio: 3 / 4;
    flex-shrink: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--paper);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
}
#bookContainer.scroll-mode div:hover {
    transform: scale(1.005);
}

/* ─── ZOOM MODE ─────────────────────────────────────────── */
body.zoom .top { display: none; }
body.zoom .mainbook { height: 100vh; padding: 10px 16px 64px; }
body.zoom #bookContainer {
    width: 99vw;
    max-width: 99vw;
    height: 90vh;
    max-height: 90vh;
}

/* ─── MOBILE (≤768px) ───────────────────────────────────── */
@media (max-width: 768px) {
    .mainbook {
        gap: 10px;
        padding: 16px 10px 70px;
    }

    #leftPage { display: none; }

    #bookContainer {
        width: 95vw;
        max-width: 95vw;
        height: auto;
        aspect-ratio: 3 / 4;
        border-radius: 8px;
        box-shadow: 0 16px 40px rgba(0,0,0,0.2);
    }
    #bookContainer::before { display: none; }

    #rightPage {
        width: 100%;
        height: 100%;
    }

    .book-btn { width: 40px; height: 40px; font-size: 18px; }

    #modeToggle, #zoomToggle {
        padding: 8px 14px;
        font-size: 12px;
        bottom: 14px;
    }

    #bookContainer.scroll-mode {
        width: 100vw;
        max-width: 100vw;
        height: 88vh;
    }
    #bookContainer.scroll-mode div {
        width: 92%;
    }
}

/* ─── LANDSCAPE MOBILE ──────────────────────────────────── */
/* Book height very low — fits in landscape without overflowing */
@media (max-width: 900px) and (orientation: landscape) {
    .mainbook {
        gap: 10px;
        padding: 8px 10px 54px;
        height: calc(100vh - 60px);
    }

    #bookContainer {
        width: auto;
        max-width: 80vw;
        height: 58vh;      /* LOW height for landscape */
        max-height: 58vh;
        aspect-ratio: unset;
        border-radius: 6px;
    }
    #bookContainer::before { display: block; }

    /* show both pages in landscape */
    #leftPage  { display: block; width: 50%; height: 100%; }
    #rightPage { width: 50%; height: 100%; }

    .book-btn { width: 36px; height: 36px; font-size: 16px; }

    #modeToggle, #zoomToggle {
        padding: 6px 12px;
        font-size: 11px;
        bottom: 10px;
    }

    #bookContainer.scroll-mode {
        height: 80vh;
        max-height: 80vh;
        width: 96vw;
        max-width: 96vw;
    }
}

/* ─── SMALL PHONES ──────────────────────────────────────── */
@media (max-width: 420px) {
    .book-btn { width: 34px; height: 34px; font-size: 15px; }
    #modeToggle, #zoomToggle { padding: 7px 11px; font-size: 11px; }
}
/* Mobile pe zoom button disable + hide */
@media (max-width: 768px) {
    #zoomToggle {
        display: none;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
    }
}