/* =========================================================
   NT HEBREW PRINT ENGINE V3 (PURE HEBREW EDITION)
   Unified Editorial CSS for Flowing Text & Columns
========================================================= */

@font-face {
    font-family: 'Gentium Book Plus';
    src: url('../fonts/GentiumPlus-Regular.ttf') format('truetype'); 
    font-weight: 400;
}

@font-face {
    font-family: 'Gentium Book Plus';
    src: url('../fonts/GentiumPlus-Bold.ttf') format('truetype');
    font-weight: 700;
}

@font-face {
    font-family: 'Ezra SIL';
    src: url('../font/SILEOTSR.ttf') format('truetype');
}

/* =========================================================
   RESET
========================================================= */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    padding-top: 30px; 
    width: 100%;
    background: #1e1f21; 
    overflow-x: hidden;
    font-family: 'Times New Roman', Times, serif;
}

/* =========================================================
   MÓDULO DE COMANDO (TOP NAVIGATION BAR)
========================================================= */
.top-nav-bar {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 70px;
    background-color: #f8f9fa;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 40px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
    font-family: Georgia, 'Times New Roman', Times, serif;
    direction: ltr; 
}

.top-nav-bar .nav-left, .top-nav-bar .nav-center, .top-nav-bar .nav-right {
    display: flex; align-items: center; gap: 15px;
}

.top-nav-bar .nav-center {
    font-size: 15pt; font-weight: bold; letter-spacing: 1px;
}
.top-nav-bar .edicion-text { color: #005b82; }
.top-nav-bar .book-name-text { color: #b2945d; margin-left: 5px; }

.top-nav-bar .nav-btn {
    text-decoration: none; padding: 10px 22px; border-radius: 6px;
    font-weight: bold; font-size: 11pt; cursor: pointer; border: none;
    transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center;
}
.top-nav-bar .nav-btn.disabled { background-color: #e9ecef; color: #adb5bd; cursor: not-allowed; border: 1px solid #dee2e6; }
.top-nav-bar .nav-btn.btn-blue { background-color: #005b82; color: white; }
.top-nav-bar .nav-btn.btn-blue:hover { background-color: #004563; }
.top-nav-bar .nav-btn.btn-print { background-color: #1a3c5a; color: white; font-family: Arial, sans-serif; }
.top-nav-bar .nav-btn.btn-print:hover { background-color: #11283d; }
.top-nav-bar .nav-btn.btn-red { background-color: #d10000; color: white; }
.top-nav-bar .nav-btn.btn-red:hover { background-color: #a30000; }

/* =========================================================
   LAYOUT TOGGLE (1-COL / 2-COL)
========================================================= */
.layout-toggle-container {
    display: flex; gap: 20px; align-items: center;
    background: white; padding: 5px 15px; border-radius: 30px;
    border: 1px solid #ccc; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.layout-option {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; font-family: Arial, sans-serif; font-size: 11pt; color: #333;
}
.layout-option input[type="radio"] {
    appearance: none; width: 18px; height: 18px; border: 2px solid #005b82;
    border-radius: 50%; margin: 0; outline: none; transition: 0.2s;
    position: relative; cursor: pointer;
}
.layout-option input[type="radio"]:checked { background: #005b82; border-color: #005b82; }
.layout-option input[type="radio"]:checked::after {
    content: ''; position: absolute; top: 4px; left: 4px;
    width: 6px; height: 6px; background: white; border-radius: 50%;
}

@media print {
    .top-nav-bar, .no-print, #content-source { display: none !important; }
    body { padding-top: 0 !important; background-color: white !important; }
}

/* =========================================================
   PAGE SYSTEM
========================================================= */
#pages-container {
    width: 100%; display: flex; flex-direction: column; align-items: center;
    gap: 30px; padding-top: 30px; padding-bottom: 60px;
}
.page {
    position: relative; height: 1056px !important; max-height: 1056px !important;
    padding: 44px 40px 40px 40px !important; width: 816px; min-width: 816px; max-width: 816px;
    background: white; overflow: hidden; isolation: isolate; margin: 0 auto;
    break-after: page; page-break-after: always; box-shadow: 0 0 10px rgba(0,0,0,0.15);
}
@media print { .page { margin: 0; box-shadow: none; } }

/* =========================================================
   PAGE CONTENT & COLUMN LAYOUTS
========================================================= */
.page-content {
    position: relative; width: 100%; max-width: 100%; overflow: visible;
    padding-top: 26px !important;
    direction: rtl; text-align: justify;
}

/* ONE COLUMN CONFIG */
body.layout-1-col .page-content {
    column-count: 1;
    padding-left: 20px; padding-right: 20px;
}

/* TWO COLUMN CONFIG */
body.layout-2-col .page-content {
    column-count: 2;
    column-gap: 40px;
    column-rule: 1px solid #e0e0e0;
}

/* =========================================================
   HEADER & FOOTER
========================================================= */
.page-header {
    position: absolute !important; top: 30px !important; left: 50px !important; right: 30px !important; 
    height: 30px !important; display: grid !important; grid-template-columns: 1fr auto 1fr !important;
    align-items: flex-end !important; direction: ltr !important; padding-bottom: 6px !important; 
    border-bottom: 1px solid #d9d9d9 !important; font-size: 9.5pt !important; letter-spacing: 0.4px !important;
    color: #1b1f21 !important; line-height: 1 !important; font-variant: small-caps !important; z-index: 20 !important;
}
.head-center { text-align: center !important; font-weight: bold !important; font-size: 10.5pt !important; padding: 0 15px !important; }
.head-left { text-align: left !important; justify-self: start !important; font-weight: 600 !important; color: #111212; }
.head-right { text-align: right !important; justify-self: end !important; font-weight: 600 !important; color: #111212; }
.head-verses { direction: ltr !important; unicode-bidi: bidi-override !important; }
.page-footer { display: none !important; }

/* =========================================================
   PURE HEBREW CONTINUOUS TEXT STYLES (V3 SPECIFIC)
========================================================= */
/* Asegura que cada versículo sea un bloque independiente */
.verse-row {
    display: block !important; /* Cambiado de inline a block */
    width: 100% !important;
    margin-bottom: 10px !important; /* Espacio vertical entre versículos */
    text-align: justify;
    break-inside: avoid !important; /* Evita que el versículo se corte a la mitad de una línea */
}

/* Ajuste para que el número del versículo quede integrado al inicio */
.verse-number-inline {
    display: inline-block;
    font-family: 'Times New Roman', Times, serif;
    font-size: 9.5pt;
    font-weight: bold;
    color: #cc0000; /* Puedes ponerlo rojo como en tu imagen */
    margin-left: 8px;
    direction: ltr;
}

.he-word {
    display: inline-block;
    font-family: 'Ezra SIL', serif;
    font-size: 19.5pt; /* Larger size for readability in pure text mode */
    direction: rtl;
    unicode-bidi: isolate;
    color: #000;
}

.yah-gold {
    color: #816126 !important;
    font-weight: 600;
}

/* Controles Premium en la navegación */
.premium-controls {
    display: flex;
    gap: 20px;
    margin-top: 5px;
    font-size: 10px;
    background: rgba(0,0,0,0.05);
    padding: 5px 15px;
    border-radius: 4px;
}

.control-group { display: flex; gap: 8px; }

/* Limpia y fuerza el tamaño en las palabras */
body.font-small .he-word { font-size: 14pt !important; }
body.font-medium .he-word { font-size: 17pt !important; }
body.font-large .he-word { font-size: 20pt !important; }

/* El número de versículo también debe escalar */
body.font-small .verse-number-inline { font-size: 7.5pt !important; }
body.font-medium .verse-number-inline { font-size: 9.5pt !important; }
body.font-large .verse-number-inline { font-size: 11pt !important; }

/* Escalamiento Proporcional Premium */
body.font-small .inline-chapter-title { font-size: 15pt !important; }
body.font-medium .inline-chapter-title { font-size: 18pt !important; }
body.font-large .inline-chapter-title { font-size: 21pt !important; }

body.font-small .section-title { font-size: 9pt !important; }
body.font-medium .section-title { font-size: 10pt !important; }
body.font-large .section-title { font-size: 12pt !important; }

/* Aseguramos que el motor recalcule si cambiamos el tamaño */
body.font-small { --content-height: 1100px; } /* Ajuste fino */
/* =========================================================
   TITLES
========================================================= */
.inline-chapter-title {
    text-align: right !important; font-size: 18pt !important; font-family: Georgia, 'Times New Roman', Times, serif !important;
    color: #515151 !important; margin-top: 15px !important; margin-bottom: 10px !important;
    clear: both !important; break-after: avoid !important; page-break-after: avoid !important;
}
.section-title {
    text-align: center; font-size: 10pt; margin-top: 10px; margin-bottom: 10px; color: #0e4e74; letter-spacing: 1px;
    display: block; width: 100%; font-family: 'Times New Roman', Times, serif;
}
.main-book-title-container {
    text-align: center; margin-top: 40px; margin-bottom: 50px; font-family: Georgia, 'Times New Roman', Times, serif !important;
    width: 100%; display: block; column-span: all; /* Spans across both columns if active */
}
.main-book-subtitle { font-size: 13pt; letter-spacing: 2px; color: #444; text-transform: uppercase; margin-bottom: 10px; }
.main-book-title { font-size: 38pt; font-weight: 700; letter-spacing: 4px; color: #000; text-transform: uppercase; }

/* Ghost Page overrides */
#content-source, #matrix-ghost-page {
    position: fixed !important; visibility: hidden !important; top: -100% !important; left: -100% !important;
    width: 706px; height: 0 !important; overflow: hidden !important; pointer-events: none; z-index: -9999;
}

/* =========================================================
   SCREEN PREVIEW MODE & PRINT LOCKDOWN
========================================================= */
@media screen {
    body { background-color: #525659 !important; display: flex; flex-direction: column; align-items: center; padding: 40px 0; }
    #pages-container { display: flex; flex-direction: column; align-items: center; gap: 40px; width: 100%; }
    .page {
        width: 816px !important; height: 1054px !important; min-width: 816px !important; max-width: 816px !important;
        min-height: 1054px !important; max-height: 1054px !important; padding: 44px 30px 40px 50px !important; 
        box-sizing: border-box !important; background: white !important; margin: 0 !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important; overflow: hidden !important; position: relative !important;
    }
    /* Ajuste para ambos: pantalla e impresión */
    .page-content {
        width: 736px !important;
        max-width: 736px !important;
        min-width: 736px !important;
        margin: 0 auto !important; 
        
        /* El padding-bottom aquí es el que crea el "margen invisible" */
        padding-top: 46px !important; 
        padding-bottom: 80px !important; /* <--- Esto evita que el texto bese el borde */
        padding-left: 0 !important;
        padding-right: 0 !important;
        
        position: relative !important;
        border: none !important; 
        direction: rtl !important;
    }
}

@page { size: 8.5in 11in; margin: 0 !important; }

@media print {
    html, body {
        width: auto !important; height: auto !important; margin: 0 !important; padding: 0 !important; border: 0 !important;
        background: white !important; overflow: visible !important; box-sizing: border-box !important; -webkit-print-color-adjust: exact !important;
    }
    #pages-container { display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; gap: 0 !important; overflow: hidden !important; }
    .page {
        width: 816px !important; height: 1054px !important; max-height: 1054px !important; min-height: 1054px !important;
        margin: 0 auto !important; padding: 44px 40px 40px 40px !important; box-sizing: border-box !important;
        page-break-inside: avoid !important; break-inside: avoid !important; box-shadow: none !important; overflow: hidden !important; position: relative !important;
    }
    .page + .page { page-break-before: always !important; break-before: page !important; }
    /* Ajuste para ambos: pantalla e impresión */
    .page-content {
        width: 736px !important;
        max-width: 736px !important;
        min-width: 736px !important;
        margin: 0 auto !important; 
        
        /* El padding-bottom aquí es el que crea el "margen invisible" */
        padding-top: 46px !important; 
        padding-bottom: 80px !important; /* <--- Esto evita que el texto bese el borde */
        padding-left: 0 !important;
        padding-right: 0 !important;
        
        position: relative !important;
        border: none !important; 
        direction: rtl !important;
    }
    #content-source, .no-print { display: none !important; }
}

body.print-locked .page, body.print-locked .verse-row, body.print-locked .he-word {
    break-inside: avoid !important; page-break-inside: avoid !important;
}
