/* =====================================================
   LEC Book Reader — Leio e Cresço · Robison Sá
   v1.2.0
   ===================================================== */

:root {
    --lec-br-page-bg:     #F7F1E6;
    --lec-br-text:        #2C1A0E;
    --lec-br-font-size:   15px;
    --lec-br-line-height: 1.88;
    --lec-br-page-radius: 0px;
    --lec-br-body-font:   'Lora', Georgia, serif;
    --lec-br-heading-font:'Playfair Display', Georgia, serif;
    --lec-br-ui:          #F7F1E6;
    --lec-br-ui-rgb:      247, 241, 230;
    --lec-br-overlay-rgb: 10, 6, 3;
    --lec-br-overlay-op:  0.94;
    --lec-br-btn-bg:      #2C1A0E;
    --lec-br-btn-text:    #F7F1E6;
    --lec-br-btn-radius:  2px;
}

/* ── Isolar capitular do tema no trigger ─────────────── */
.lec-br-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 0 20px;
    margin-bottom: 28px;
    border-top: 1px solid rgba(44, 26, 14, 0.10);
    font-size: 16px;
    line-height: 1.5;
}

/* Zera qualquer capitular herdada do tema */
.lec-br-trigger .lec-br-hint-text::first-letter,
.lec-br-trigger button::first-letter,
.lec-br-trigger span::first-letter {
    font-size:      1em  !important;
    float:          none !important;
    line-height:    inherit !important;
    margin:         0 !important;
    padding:        0 !important;
    font-family:    inherit !important;
    font-weight:    inherit !important;
    color:          inherit !important;
    text-transform: none !important;
    display:        inline !important;
}

.lec-br-open {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--lec-br-btn-bg);
    color: var(--lec-br-btn-text);
    border: none;
    padding: 13px 28px;
    border-radius: var(--lec-br-btn-radius);
    font-family: 'Lora', Georgia, serif;
    font-size: 14.5px;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.22s, box-shadow 0.22s, transform 0.12s;
    box-shadow: 0 2px 14px rgba(44, 26, 14, 0.16);
    line-height: 1;
}

.lec-br-open:hover {
    background: #3E2410;
    box-shadow: 0 4px 20px rgba(44, 26, 14, 0.26);
    transform: translateY(-1px);
}

.lec-br-open:active { transform: translateY(0); }

.lec-br-open svg { flex-shrink: 0; opacity: 0.9; }

/* span em vez de p — não dispara p::first-letter do tema */
.lec-br-hint-text {
    display: block;
    font-family: 'Lora', Georgia, serif;
    font-size: 12.5px;
    font-style: italic;
    color: rgba(44, 26, 14, 0.42);
    margin: 0;
    text-align: center;
}

/* ── Overlay ─────────────────────────────────────────── */

#lec-br-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(var(--lec-br-overlay-rgb), var(--lec-br-overlay-op));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: stretch;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.28s ease;
}

#lec-br-overlay[hidden] { display: none; }
#lec-br-overlay.lec-br-visible { opacity: 1; }

#lec-br-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
    box-sizing: border-box;
}

/* ── Top Bar ─────────────────────────────────────────── */

#lec-br-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 0;
    flex-shrink: 0;
}

.lec-br-brand-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(var(--lec-br-ui-rgb), 0.38);
}

#lec-br-close {
    background: none;
    border: 1px solid rgba(var(--lec-br-ui-rgb), 0.15);
    color: rgba(var(--lec-br-ui-rgb), 0.55);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    padding: 0;
    flex-shrink: 0;
}

#lec-br-close:hover {
    background: rgba(var(--lec-br-ui-rgb), 0.10);
    color: var(--lec-br-ui);
    border-color: rgba(var(--lec-br-ui-rgb), 0.30);
}

/* ── Stage ───────────────────────────────────────────── */

#lec-br-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

/* ── Loading ─────────────────────────────────────────── */

#lec-br-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: rgba(var(--lec-br-ui-rgb), 0.45);
    font-family: 'Lora', Georgia, serif;
    font-size: 14px;
    font-style: italic;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.lec-br-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(var(--lec-br-ui-rgb), 0.12);
    border-top-color: rgba(var(--lec-br-ui-rgb), 0.50);
    border-radius: 50%;
    animation: lec-br-spin 0.75s linear infinite;
}

@keyframes lec-br-spin { to { transform: rotate(360deg); } }

/* ── Nav ─────────────────────────────────────────────── */

#lec-br-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 0 18px;
    flex-shrink: 0;
}

#lec-br-prev, #lec-br-next {
    background: none;
    border: 1px solid rgba(var(--lec-br-ui-rgb), 0.18);
    color: rgba(var(--lec-br-ui-rgb), 0.60);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    padding: 0;
}

#lec-br-prev:hover, #lec-br-next:hover {
    background: rgba(var(--lec-br-ui-rgb), 0.09);
    color: var(--lec-br-ui);
    border-color: rgba(var(--lec-br-ui-rgb), 0.35);
}

#lec-br-counter {
    font-family: 'Lora', Georgia, serif;
    font-size: 13px;
    font-style: italic;
    color: rgba(var(--lec-br-ui-rgb), 0.40);
    min-width: 72px;
    text-align: center;
}

/* ── Páginas do livro ────────────────────────────────── */
/*
   IMPORTANTE: .lec-br-page NÃO deve ter overflow:hidden
   O StPageFlip precisa de liberdade para posicionar e
   animar os elementos fora dos limites da página durante
   a dobra. O overflow é controlado só dentro da página.
*/

.lec-br-page {
    background: var(--lec-br-page-bg);
    box-sizing: border-box;
    position: relative;
    border-radius: var(--lec-br-page-radius);
    overflow: hidden;
    /* width/height/min/max definidos via JS inline */
}

.lec-br-page.lec-br-dark {
    background: var(--lec-br-cover-bg);
}

/* Camada interna que carrega o fundo (StPageFlip reescreve o style da
   página raiz, então o background precisa morar aqui). */
.lec-br-surface {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: var(--lec-br-page-radius);
}

/* Área de conteúdo — AQUI fica o overflow:hidden */
.lec-br-page-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 56px;   /* reserva espaço do rodapé */
    overflow: hidden;
    padding: 44px 40px 0;
    box-sizing: border-box;
}

.lec-br-page-foot {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    box-sizing: border-box;
}

.lec-br-pnum {
    font-family: 'Lora', Georgia, serif;
    font-size: 11px;
    font-style: italic;
    color: rgba(44, 26, 14, 0.28);
}

.lec-br-pmark {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(44, 26, 14, 0.17);
}

/* ── Capa ────────────────────────────────────────────── */

.lec-br-cover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 36px;
    box-sizing: border-box;
    overflow: hidden;
}

.lec-br-cover-brand {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--lec-br-cover-acc) 32%, transparent);
    margin-bottom: 26px;
}

.lec-br-cover-ornament {
    font-size: 12px;
    color: color-mix(in srgb, var(--lec-br-cover-acc) 22%, transparent);
    margin-bottom: 22px;
    letter-spacing: 0.5em;
}

.lec-br-cover-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(16px, 4vw, 24px);
    font-weight: 700;
    color: var(--lec-br-cover-text);
    line-height: 1.35;
    margin-bottom: 20px;
    word-break: break-word;
    overflow: hidden;
}

.lec-br-cover-rule {
    width: 30px;
    height: 1px;
    background: color-mix(in srgb, var(--lec-br-cover-acc) 20%, transparent);
    margin: 0 auto 20px;
}

.lec-br-cover-author {
    font-family: 'Lora', Georgia, serif;
    font-size: 13px;
    font-style: italic;
    color: color-mix(in srgb, var(--lec-br-cover-text) 65%, transparent);
}

/* ── Contracapa ──────────────────────────────────────── */

.lec-br-back-cover {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 32px 36px;
    box-sizing: border-box;
    overflow: hidden;
}

.lec-br-back-brand {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 10px;
    letter-spacing: 0.20em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--lec-br-cover-acc) 28%, transparent);
}

/* ── Tipografia nas páginas ──────────────────────────── */

.lec-br-text {
    font-family: var(--lec-br-body-font);
    font-size: var(--lec-br-font-size);
    line-height: var(--lec-br-line-height);
    color: var(--lec-br-text);
    word-break: break-word;
}

.lec-br-text p {
    margin: 0 0 1.05em;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.lec-br-text p:last-child { margin-bottom: 0; }

/* Capitular — só na primeira página */
.lec-br-text.lec-br-first > p:first-of-type::first-letter {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 3.3em;
    font-weight: 700;
    float: left;
    line-height: 0.78;
    margin: 5px 8px -2px 0;
    color: var(--lec-br-text);
}

.lec-br-text h2, .lec-br-text h3, .lec-br-text h4 {
    font-family: var(--lec-br-heading-font);
    color: var(--lec-br-text);
    line-height: 1.3;
    margin: 0 0 0.65em;
    font-weight: 700;
    overflow: hidden;
}

.lec-br-text h2 { font-size: 19px; }
.lec-br-text h3 { font-size: 16.5px; }
.lec-br-text h4 { font-size: 15px; }
.lec-br-text strong { font-weight: 600; }
.lec-br-text em { font-style: italic; }

.lec-br-text ul, .lec-br-text ol {
    padding-left: 20px;
    margin: 0 0 1.05em;
}

.lec-br-text li { margin-bottom: 0.35em; }

.lec-br-text blockquote {
    border-left: 2px solid rgba(44, 26, 14, 0.18);
    padding-left: 14px;
    margin: 0 0 1.05em 4px;
    font-style: italic;
    color: rgba(44, 26, 14, 0.65);
    overflow: hidden;
}

.lec-br-text a {
    color: var(--lec-br-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.68;
}

/* ── Fallback ────────────────────────────────────────── */

.lec-br-fallback {
    background: var(--lec-br-page-bg);
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 72vh;
    overflow-y: auto;
    border-radius: 2px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.35);
}

.lec-br-fallback .lec-br-page-inner {
    position: static;
    height: auto;
    min-height: 300px;
}

.lec-br-fallback .lec-br-page-foot {
    position: static;
    height: auto;
    padding: 8px 40px 24px;
}

/* ── Corner Hint ─────────────────────────────────────── */

.lec-br-corner-hint {
    position: absolute;
    bottom: 0;
    right: calc(50% - var(--lec-br-half-w, 200px));
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 52px 52px;
    border-color: transparent transparent rgba(var(--lec-br-ui-rgb), 0.15) transparent;
    pointer-events: none;
    animation: lec-br-corner 2.2s ease-in-out forwards;
    z-index: 10;
    filter: drop-shadow(-2px -2px 4px rgba(0,0,0,0.2));
}

@keyframes lec-br-corner {
    0%   { opacity: 0; transform: scale(0.3); }
    20%  { opacity: 1; transform: scale(1.1); }
    65%  { opacity: 0.9; transform: scale(1.0); }
    100% { opacity: 0; transform: scale(0.9); }
}

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 767px) {
    #lec-br-modal { padding: 0 12px; }

    .lec-br-page-inner {
        bottom: 46px;
        padding: 28px 22px 0;
    }

    .lec-br-page-foot {
        height: 46px;
        padding: 0 22px;
    }

    .lec-br-text {
        font-size: calc(var(--lec-br-font-size) - 1px);
        line-height: 1.82;
    }

    .lec-br-text.lec-br-first > p:first-of-type::first-letter {
        font-size: 3em;
    }

    .lec-br-cover { padding: 36px 24px; }
}

/* ── Reduced Motion ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .lec-br-spinner      { animation: none; }
    .lec-br-corner-hint  { animation: none; display: none; }
    #lec-br-overlay      { transition: none; }
    .lec-br-open         { transition: none; }
}
