/**
 * Verse Display Styles
 * Version: 1.0.0
 *
 * Styles for verse/pasuk display pages with Reader Mode support,
 * display system v3.0, kri/ktiv notation, translations, etc.
 *
 * Used by: verse/index.html, pasuk/index.html
 *
 * Dependencies: tanach-common.css must be loaded first
 */

/* ===================================================================
   Universal Text Color Inheritance
   =================================================================== */
#verse-container,
#verse-container *,
#translation-container,
#translation-container * {
    color: var(--base-text);
}

/* Preserve colored trope marks - inline styles override inherited color */
.word span[style*="color"] {
    /* Inline styles automatically override the inherited color */
}

/* ===================================================================
   Verse Container
   =================================================================== */
#verse-container {
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    max-width: 100%;
}

/* Hebrew Citation - h1 styling for Reader Mode */
#verse-container h1 {
    font-family: 'SBL Hebrew', 'Ezra SIL', serif;
    font-size: calc(24px * var(--font-size-multiplier, 1));
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 20px;
    text-align: center;
    margin-top: 0;
}

#verse-citation {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

/* Verse Content */
#verse-content {
    font-family: 'SBL Hebrew', 'Ezra SIL', serif;
    font-size: calc(28px * var(--font-size-multiplier, 1));
    line-height: 1.8;
    text-align: justify;
    direction: rtl;
    padding: 20px;
    background: var(--base-bg);
    border-radius: 5px;
    border: 1px solid var(--border-color);
    min-height: 100px;
}

/* ===================================================================
   Reader Mode Support
   =================================================================== */
.verse-plaintext-summary {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.verse-plaintext-summary p {
    margin: 0;
    padding: 0;
    font-family: 'SBL Hebrew', 'Ezra SIL', serif;
    font-size: 28px;
    line-height: 1.8;
    direction: rtl;
}

.verse-text-plain {
    display: none;
}

.verse-text-formatted {
    display: inline;
    font-family: 'SBL Hebrew', 'Ezra SIL', serif;
    font-size: calc(28px * var(--font-size-multiplier, 1));
    line-height: 1.8;
    direction: rtl;
}

/* ===================================================================
   Footnotes
   =================================================================== */
.footnoteText {
    display: none;
    color: #ff0000;
    font-size: 12pt;
}
.footnote:focus + .footnoteText { display: block; }
.close:focus .footnoteText { display: none; }

/* ===================================================================
   Multiple Verse Display
   =================================================================== */
.verses-container {
    margin-top: 10px;
}

.verse-item {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.verse-item:last-child {
    border-bottom: none;
}

.verse-number {
    font-weight: bold;
    margin-left: 5px;
    color: var(--base-text);
    opacity: 0.7;
}

.verse-text {
    margin-right: 5px;
}

/* ===================================================================
   Display System v3.0
   =================================================================== */

/* Verse display container */
.verse-display {
    font-family: 'SBL Hebrew', 'Ezra SIL', serif;
    font-size: 18pt;
    line-height: 1.8;
    direction: rtl;
}

/* Line-by-line layout */
.verse-display-line {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.verse-line {
    padding: 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.verse-line.separator-border {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 5px;
}

.verse-line.separator-space {
    margin-bottom: 20px;
}

.verse-line.highlighted {
    background-color: #ffffcc;
    color: #000000 !important;
}

:root[data-theme="dark"] .verse-line.highlighted {
    background-color: #6b6b00;
    color: #e0e0e0 !important;
}

.verse-citation {
    font-weight: bold;
    color: var(--base-text);
    opacity: 0.7;
    margin-left: 10px;
    font-size: 0.9em;
}

/* Block (paragraph) layout */
.verse-display-block {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.verse-block {
    padding: 15px;
    border-radius: 4px;
}

.verse-block.separator-border {
    border: 1px solid var(--border-color);
}

.verse-block.separator-space {
    margin-bottom: 30px;
}

.block-citation {
    font-weight: bold;
    color: var(--base-text);
    opacity: 0.7;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.block-text {
    text-align: justify;
    text-justify: inter-word;
}

.inline-verse-number {
    font-weight: bold;
    color: var(--base-text);
    opacity: 0.7;
    font-size: 0.85em;
    margin: 0 5px;
    vertical-align: super;
}

.inline-verse-number.highlighted {
    background-color: #ffffcc;
    color: #000000 !important;
    padding: 2px 4px;
    border-radius: 3px;
}

:root[data-theme="dark"] .inline-verse-number.highlighted {
    background-color: #6b6b00;
    color: #e0e0e0 !important;
}

.verse-text-inline {
    display: inline;
}

.verse-text-inline.highlighted {
    background-color: #ffffcc;
    color: #000000 !important;
}

:root[data-theme="dark"] .verse-text-inline.highlighted {
    background-color: #6b6b00;
    color: #e0e0e0 !important;
}

/* ===================================================================
   Word-level Styles
   =================================================================== */
.word {
    display: inline;
    margin: 0 2px;
}

/* Kri/Ktiv notation */
.kri-ktiv-pair {
    display: inline-block;
    white-space: nowrap;
}

sub.ktiv-notation {
    font-size: 0.85em;
    color: #666;
    vertical-align: sub;
    margin-left: 2px;
}

sup.kri-notation {
    font-size: 0.85em;
    color: #0066cc;
    vertical-align: super;
    margin-right: 2px;
}

:root[data-theme="dark"] sub.ktiv-notation {
    color: #aaa;
}

:root[data-theme="dark"] sup.kri-notation {
    color: #6699ff;
}

/* ===================================================================
   Status Messages
   =================================================================== */
.verse-limit-warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
}

:root[data-theme="dark"] .verse-limit-warning {
    background-color: #4a4000;
    border-color: #6a5a00;
    color: #ffeb3b;
}

.no-verses {
    text-align: center;
    color: var(--base-text);
    opacity: 0.6;
    font-style: italic;
    padding: 20px;
}

.error-message {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

:root[data-theme="dark"] .error-message {
    background-color: #4a0000;
    border-color: #6a0000;
    color: #ff6b6b;
}

/* ===================================================================
   Display Options Offcanvas
   =================================================================== */
#displayOptionsOffcanvas {
    background-color: var(--base-bg);
    color: var(--base-text);
}

#displayOptionsOffcanvas .offcanvas-header {
    border-bottom: 1px solid var(--border-color);
}

#displayOptionsOffcanvas h6 {
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--base-text);
}

#displayOptionsOffcanvas .form-label {
    font-weight: 500;
    margin-bottom: 5px;
}

#displayOptionsOffcanvas .form-check-label {
    margin-left: 5px;
}

#displayOptionsOffcanvas hr {
    border-color: var(--border-color);
    opacity: 0.3;
}

/* Offcanvas dark theme support */
:root[data-theme="dark"] #displayOptionsOffcanvas .btn-close {
    filter: invert(1);
}

:root[data-theme="dark"] #displayOptionsOffcanvas .form-select,
:root[data-theme="dark"] #displayOptionsOffcanvas .form-control {
    background-color: var(--secondary-bg);
    color: var(--base-text);
    border-color: var(--border-color);
}

:root[data-theme="dark"] #displayOptionsOffcanvas .btn-outline-primary {
    color: #6ea8fe;
    border-color: #6ea8fe;
}

:root[data-theme="dark"] #displayOptionsOffcanvas .btn-outline-primary:hover {
    background-color: #6ea8fe;
    color: #000;
}

:root[data-theme="dark"] #displayOptionsOffcanvas .btn-check:checked + .btn-outline-primary {
    background-color: #6ea8fe;
    border-color: #6ea8fe;
    color: #000;
}

/* Display options button styling */
#display-options-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#display-options-btn:hover {
    transform: scale(1.05);
    transition: transform 0.2s;
}

/* ===================================================================
   Trope Color Classes
   =================================================================== */
.word.trop-1 { color: #ff0000; }
.word.trop-2 { color: #00ff00; }
.word.trop-3 { color: #0000ff; }
.word.trop-4 { color: #ffff00; }
.word.trop-5 { color: #ff00ff; }
.word.trop-6 { color: #00ffff; }

:root[data-theme="dark"] .word.trop-1 { color: #ff6666; }
:root[data-theme="dark"] .word.trop-2 { color: #66ff66; }
:root[data-theme="dark"] .word.trop-3 { color: #6666ff; }
:root[data-theme="dark"] .word.trop-4 { color: #ffff66; }
:root[data-theme="dark"] .word.trop-5 { color: #ff66ff; }
:root[data-theme="dark"] .word.trop-6 { color: #66ffff; }

/* ===================================================================
   Hebrew Translation Display
   =================================================================== */
.hebrew-translation {
    font-family: 'Arial Hebrew', 'Noto Sans Hebrew', 'SBL Hebrew', sans-serif;
    font-size: 0.9em;
    direction: rtl;
    color: var(--base-text);
    opacity: 0.85;
    font-style: italic;
    margin-top: 8px;
    padding: 8px 12px;
    background-color: var(--secondary-bg);
    border-right: 3px solid var(--accent-color);
    border-radius: 4px;
    line-height: 1.6;
}

.hebrew-translation::before {
    content: "תרגום: ";
    font-weight: bold;
    opacity: 0.7;
    font-size: 0.9em;
    margin-left: 5px;
}

:root[data-theme="dark"] .hebrew-translation {
    background-color: rgba(255, 255, 255, 0.05);
    border-right-color: #6ea8fe;
}

.verse-block .hebrew-translation {
    margin-top: 12px;
}

.verse-line .hebrew-translation {
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 0.85em;
}

/* ===================================================================
   Bible Translation Display
   =================================================================== */
.translation-info {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

:root[data-theme="dark"] .translation-info {
    color: #adb5bd;
}

#translation-content {
    padding: 20px;
    background: var(--base-bg);
    border-radius: 5px;
    border: 1px solid var(--border-color);
    min-height: 60px;
}

.translation-menu {
    margin-bottom: 20px;
}

.loading-translation {
    text-align: center;
    font-style: italic;
    color: #6c757d;
    padding: 20px;
}

.error-message-translation {
    color: #dc3545;
    font-weight: bold;
    padding: 15px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

:root[data-theme="dark"] .error-message-translation {
    background-color: #4a0000;
    border-color: #6a0000;
    color: #ff6b6b;
}

h2.translation-info {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    font-weight: bold;
    margin-top: 0;
}

:root[data-theme="dark"] h2.translation-info {
    color: #adb5bd;
}

/* ===================================================================
   UI Layout
   =================================================================== */
#search-container {
    max-width: 600px;
    margin: 30px auto 40px;
}

#verse-key {
    text-align: center;
    font-size: 18px;
    direction: ltr;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 15px;
}

.section-header,
h2.section-header,
h3.section-header {
    font-size: 16px;
    font-weight: bold;
    margin-top: 30px;
    margin-bottom: 15px;
    text-align: center;
    color: var(--base-text);
    opacity: 0.8;
}

.btn-group-custom {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 20px 0 30px;
}

.btn-clipboard {
    flex: 1;
    min-width: 150px;
}

.btn-nav {
    min-width: 120px;
}

.nav-button.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--base-text);
    opacity: 0.6;
}

/* ===================================================================
   Responsive
   =================================================================== */
@media (max-width: 768px) {
    .verse-display {
        font-size: 16pt;
        line-height: 1.6;
    }

    .verse-line,
    .verse-block {
        padding: 8px;
    }

    .inline-verse-number {
        font-size: 0.8em;
    }

    #displayOptionsOffcanvas {
        width: 100% !important;
    }

    .btn-group-custom {
        flex-direction: column;
    }

    .btn-clipboard, .btn-nav {
        width: 100%;
        min-width: auto;
    }

    #search-container {
        max-width: 100%;
    }
}
