/* OAKOKHO BOOKS — DYNAMIC BOOK STYLES */
/* LAST REVIEWED: 2026-09-11 */

/* DYNAMIC PAGE WRAPPER — flex column; height chain: Turn.js sets px height on .page,
   .dynamic-page inherits 100% of that, giving the flex container a definite height */
.dynamic-page {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* IMAGE AREA — grows to fill space above the text box; explicit width: 100% because
   some rendering paths skip align-items:stretch for background-only flex items */
.page-bg {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
}

/* TEXT OVERLAY — BASE — in-flow flex item sized by its own content */
.text-overlay {
    flex: 0 0 auto;
    position: relative;
    width: 100%;
    transform: none !important;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 0;
    padding: 14px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
}

/* POSITION VARIANTS */
/* bottom: flows naturally at the end of the flex column; text sits at top of the box */
.overlay-bottom {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(14px) brightness(1.3) saturate(0.7);
    -webkit-backdrop-filter: blur(14px) brightness(1.3) saturate(0.7);
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    position: relative;
    overflow: hidden;
    margin: 0 2px;
    width: calc(100% - 4px);
    transition: background 0.3s ease;
}

/* FEATHER EDGE — fades image into the solid overlay panel */
.overlay-bottom::before {
    content: '';
    position: absolute;
    top: -32px;
    left: 0;
    right: 0;
    height: 32px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, var(--overlay-alpha, 0.18)) 100%);
    pointer-events: none;
}

/* top / center / left / right: float over the image, so they escape the flex flow */
.overlay-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.overlay-center {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%) !important;
    text-align: center;
}

.overlay-left {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40% !important;
}

.overlay-right {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto !important;
    width: 40% !important;
}

/* =====================================================
   COVER PAGE (P1)
   ===================================================== */
.page-cover .overlay-text-as {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
    line-height: 1.4;
}
.page-cover .overlay-text-en {
    font-size: 1.2rem;
    text-align: center;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

/* =====================================================
   TITLE PAGE (P3)
   ===================================================== */
.page-title .overlay-text-as {
    font-size: 1.7rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    line-height: 1.4;
}
.page-title .overlay-text-en {
    font-size: 1.1rem;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* =====================================================
   BACK COVER (P12 / last page)
   ===================================================== */
.page-backcover .overlay-text-as {
    font-size: 0.95rem;
    text-align: center;
}

/* FORCE REMOVE TEXT-SHADOW FROM ALL OVERLAY TEXT (overrides page-role variants) */
.overlay-text-en,
.overlay-text-as,
.overlay-text-en *,
.overlay-text-as * {
    text-shadow: none !important;
}

/* ASSAMESE TEXT */
.overlay-text-as {
    font-family: 'Noto Serif Bengali', serif;
    font-size: var(--dyn-font-size, 1.1rem);
    color: #001845;
    margin: 0;
    line-height: 1.7;
    text-shadow: none;
}

/* ENGLISH TEXT */
.overlay-text-en {
    font-family: 'Baloo 2', sans-serif;
    font-size: var(--dyn-font-size-en, 0.9rem);
    color: #001845;
    margin: 0;
    line-height: 1.5;
    text-shadow: none;
}

.overlay-text-en.hidden {
    display: none;
}

/* TRANSLITERATION TEXT */
.overlay-text-tr {
    font-family: 'Baloo 2', sans-serif;
    font-size: var(--dyn-font-size-en, 0.9rem);
    color: #ffb3c6;
    margin: 0;
    line-height: 1.5;
    font-style: italic;
    letter-spacing: 0.02em;
}
.overlay-text-tr.hidden {
    display: none;
}

/* WORD SPANS — CLICKABLE */
.dyn-word {
    cursor: pointer;
    display: inline-block;
    border-radius: 3px;
    padding: 0 1px;
    transition: background 0.15s;
}

.dyn-word:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* DYNAMIC TOOLBAR */
.dynamic-toolbar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 20px;
    padding: 6px 14px;
}

.dynamic-toolbar button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.dynamic-toolbar button:hover,
.dynamic-toolbar button.active {
    background: rgba(79, 107, 196, 0.75);
    border-color: transparent;
}

/* FONT SIZE VARIANTS — SET VIA JS ON .magazine-container */
.magazine-container.font-small .overlay-text-as {
    --dyn-font-size: 0.85rem;
}
.magazine-container.font-small .overlay-text-en,
.magazine-container.font-small .overlay-text-tr {
    --dyn-font-size-en: 0.75rem;
}
.magazine-container.font-medium .overlay-text-as {
    --dyn-font-size: 1.1rem;
}
.magazine-container.font-medium .overlay-text-en,
.magazine-container.font-medium .overlay-text-tr {
    --dyn-font-size-en: 0.9rem;
}
.magazine-container.font-large .overlay-text-as {
    --dyn-font-size: 1.4rem;
}
.magazine-container.font-large .overlay-text-en,
.magazine-container.font-large .overlay-text-tr {
    --dyn-font-size-en: 1.15rem;
}
.magazine-container.font-xlarge .overlay-text-as {
    --dyn-font-size: 1.75rem;
}
.magazine-container.font-xlarge .overlay-text-en,
.magazine-container.font-xlarge .overlay-text-tr {
    --dyn-font-size-en: 1.4rem;
}


/* ONBOARDING MODAL */
.dyn-onboard-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dyn-onboard-modal.hidden {
    display: none;
}
.dyn-onboard-box {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.dyn-onboard-box h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 20px;
}
.dyn-onboard-box ul {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    text-align: left;
}
.dyn-onboard-box ul li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dyn-onboard-box ul li i {
    color: #667eea;
    width: 20px;
    text-align: center;
}
.btn-got-it {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-got-it:hover {
    background: #5568d3;
}

/* SPEAKER BUTTON WRAPPER — ZERO-HEIGHT FLEX NODE AT IMAGE/OVERLAY BOUNDARY */
/* Button is absolutely positioned relative to this wrapper, floating upward */
.speaker-btn-wrap {
    position: relative;
    flex: 0 0 0px;
    height: 0;
    width: calc(100% - 4px);
    margin: 0 2px;
    overflow: visible;
    z-index: 10;
    background: transparent;
}

/* SPEAKER BUTTON — ABSOLUTE, FLOATS AT IMAGE/OVERLAY BOUNDARY */
.page-speaker-btn {
    position: absolute;
    bottom: 10px;
    right: 12px;
    z-index: 30;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(102, 126, 234, 0.9);
    color: #fff;
    font-size: 1rem;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    transition: background 0.2s, transform 0.15s;
}

/* ONLY THE ACTIVE PAGE'S BUTTON IS VISIBLE */
.page-speaker-btn.visible {
    display: flex;
}

/* ACTIVE STATE — BUTTON IS CURRENTLY SPEAKING */
.page-speaker-btn.speaking {
    background: rgba(231, 76, 60, 0.9);
    transform: scale(1.1);
}

.page-speaker-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.05);
}

.page-speaker-btn.speaking:hover {
    background: rgba(192, 57, 43, 1);
}

@media (max-width: 768px) {
    /* SWITCH TO FIXED ON MOBILE — SAME CONTEXT AS PAGE-INFO */
    /* SAFE-AREA INSET FOR IPHONE HOME INDICATOR */
    .dynamic-toolbar {
        position: fixed;
        top: auto;
        bottom: calc(clamp(10px, 2vh, 18px) + env(safe-area-inset-bottom, 0px));
        left: 50%;
        transform: translateX(-50%);
        padding: clamp(4px, 1vh, 6px) clamp(8px, 2vw, 14px);
        gap: clamp(4px, 1vw, 8px);
        z-index: 10001;
    }

    /* TOOLBAR BUTTONS — SMALLER ON MOBILE */
    .dynamic-toolbar button {
        font-size: clamp(10px, 2.5vw, 12px);
        padding: clamp(3px, 0.8vw, 4px) clamp(6px, 1.5vw, 10px);
    }

    /* MATCH TOOLBAR BOTTOM — SAME SAFE-AREA OFFSET SO THEY SIT ON ONE LINE */
    .page-info {
        bottom: calc(clamp(10px, 2vh, 18px) + env(safe-area-inset-bottom, 0px));
        left: auto;
        right: clamp(10px, 3vw, 16px);
        transform: none;
        padding: clamp(6px, 1.5vw, 10px) clamp(12px, 3vw, 20px);
        font-size: clamp(0.75rem, 3vw, 1rem);
    }

}
