@import url('https://fonts.googleapis.com/css2?family=Gabriela&display=swap');

/* Themes */

/* 1. Sky Blue (Dark) - Default */
:root {
    /* Font Scaling Defaults */
    --font-scale: 1;
    --font-base: 16px;

    /* Theme: Sky Blue (Dark) */
    --c-bg: #1a2634;
    --c-text: #e6f1ff;
    --c-primary: #3b82f6;
    --c-secondary: #60a5fa;
    --c-accent: #0ea5e9;
    --c-panel: #243447;
    --c-border: #334155;
    --c-shadow: rgba(0, 0, 0, 0.5);
    --c-link: #60a5fa;
    --c-link-hover: #93c5fd;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;

    /* Layout */
    --max-width: 800px;
    --radius: 12px;
}

/* Base HTML Font Size Calculation */
html {
    font-size: calc(var(--font-base) * var(--font-scale));
    font-family: 'Lato', sans-serif;
    color: var(--c-text);
    background-color: var(--c-bg);
    transition: background-color 0.3s ease, color 0.3s ease;
    scroll-behavior: smooth;
}

h1,
h2,
.site-title {
    font-family: 'Gabriela', serif;
}

/* Progress Bar */
#progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    z-index: 9999;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--c-accent);
    transition: width 0.2s ease-out;
}

/* 2. Midnight (Dark) */
html.theme-midnight {
    --c-bg: #0f172a;
    --c-text: #f8fafc;
    --c-primary: #818cf8;
    --c-secondary: #a5b4fc;
    --c-accent: #6366f1;
    --c-panel: #1e293b;
    --c-border: #334155;
    --c-link: #a5b4fc;
    --c-link-hover: #c7d2fe;
}

/* 3. Forest (Dark) */
html.theme-forest {
    --c-bg: #052e16;
    --c-text: #ecfdf5;
    --c-primary: #34d399;
    --c-secondary: #6ee7b7;
    --c-accent: #10b981;
    --c-panel: #064e3b;
    --c-border: #065f46;
    --c-link: #6ee7b7;
    --c-link-hover: #a7f3d0;
}

/* 4. Slate (Dark) */
html.theme-slate {
    --c-bg: #27272a;
    --c-text: #fafafa;
    --c-primary: #a1a1aa;
    --c-secondary: #d4d4d8;
    --c-accent: #71717a;
    --c-panel: #3f3f46;
    --c-border: #52525b;
    --c-link: #e4e4e7;
    --c-link-hover: #ffffff;
}

/* 5. Paper (Light) */
html.theme-paper {
    --c-bg: #fdf6e3;
    --c-text: #2c3e50;
    --c-primary: #d35400;
    --c-secondary: #e67e22;
    --c-accent: #e67e22;
    --c-panel: #eee8d5;
    --c-border: #d4c4a8;
    --c-shadow: rgba(0, 0, 0, 0.1);
    --c-link: #d35400;
    --c-link-hover: #e67e22;
}

/* 6. Clean White (Light) */
html.theme-white {
    --c-bg: #ffffff;
    --c-text: #111827;
    --c-primary: #2563eb;
    --c-secondary: #3b82f6;
    --c-accent: #3b82f6;
    --c-panel: #f3f4f6;
    --c-border: #e5e7eb;
    --c-shadow: rgba(0, 0, 0, 0.1);
    --c-link: #2563eb;
    --c-link-hover: #1d4ed8;
}

/* 7. Sepia (Light) */
html.theme-sepia {
    --c-bg: #f4ecd8;
    --c-text: #433422;
    --c-primary: #8b5a2b;
    --c-secondary: #a67c52;
    --c-accent: #a67c52;
    --c-panel: #e6dcc5;
    --c-border: #d7c9a8;
    --c-shadow: rgba(67, 52, 34, 0.1);
    --c-link: #8b5a2b;
    --c-link-hover: #5c3a17;
}

/* 8. Lavender (Light) */
html.theme-lavender {
    --c-bg: #f3e8ff;
    --c-text: #4c1d95;
    --c-primary: #7c3aed;
    --c-secondary: #8b5cf6;
    --c-accent: #8b5cf6;
    --c-panel: #ede9fe;
    --c-border: #ddd6fe;
    --c-shadow: rgba(76, 29, 149, 0.1);
    --c-link: #7c3aed;
    --c-link-hover: #6d28d9;
}

/* Emphasize Text for Bible Verses */
em,
.bible-text {
    font-style: italic;
    opacity: 0.9;
}

/* Layout Containers */
.main-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-sm);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header-banner {
    text-align: center;
    margin-bottom: var(--spacing-sm);
}

.header-banner img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px var(--c-shadow);
}

/* Header */
.site-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    background-color: var(--c-panel);
    padding: var(--spacing-md);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    box-shadow: 0 4px 6px var(--c-shadow);
}

.site-title {
    margin: 0 0 var(--spacing-xs) 0;
    display: inline-block;
    vertical-align: middle;
}

.header-controls {
    display: inline-block;
    margin-left: var(--spacing-sm);
    vertical-align: middle;
}

.site-subtitle {
    margin: 0;
    font-size: 1rem;
    color: var(--c-secondary);
    font-weight: normal;
    font-style: italic;
    font-family: 'Lato', sans-serif;
}

/* Form Elements - Ensure they use Lato */
button,
input,
select,
textarea {
    font-family: 'Lato', sans-serif;
}

/* Buttons */
.control-btn {
    background: var(--c-primary);
    color: var(--c-bg);
    /* Use bg color for text contrast */
    border: none;
    padding: 0.5rem 0.8rem;
    font-size: 1.5rem;
    /* Increased from 1.2rem */
    font-weight: bold;
    /* Bolded as requested */
    border-radius: var(--radius);
    cursor: pointer;
    margin-left: 2px;
    margin-right: 2px;
    transition: transform 0.1s ease, background 0.2s ease;
    box-shadow: 0 2px 4px var(--c-shadow);
    display: inline-block;
}

.control-btn:hover {
    filter: brightness(1.1);
    color: var(--c-bg);
    /* Ensure text stays distinct from background */
    text-decoration: none;
}

.control-btn:active {
    transform: translateY(2px);
}

/* Navigation */
/* 
   The .site-nav class styles the main navigation container.
   It uses a subtle 3D shadow effect to lift it off the page.
   This structural CSS supports the layout generated dynamically in Navigation.php.
*/
.site-nav {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm);
    background-color: var(--c-panel);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    /* 3D Effect Shadow */
    box-shadow: 0 8px 16px var(--c-shadow), 0 2px 4px var(--c-shadow);
}

.nav-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 3rem;
    /* Increased gap to clear separate Navigation from Tools */
}

.nav-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.nav-select-wrapper {
    /* Refactored for better scaling with font-size changes */
    flex: 1;
    /* Allow it to grow */
    min-width: 200px;
    max-width: 100%;
    /* Was fixed 300px, causing overlap */
}

/* Groupings within nav-right */
.nav-controls,
.nav-downloads {
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-btn {
    background-color: var(--c-secondary);
    color: var(--c-bg);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-weight: bold;
    text-decoration: none;
    transition: transform 0.1s;
    white-space: nowrap;
    /* Prevent breaking inside button */
}

.dl-btn {
    background-color: var(--c-accent);
    /* distinct color for download links */
    padding: 0.6rem 0.8rem;
    /* slightly smaller padding? */
}

.nav-btn:hover {
    text-decoration: none;
    filter: brightness(1.2);
    /* Sligthly brighter */
    color: var(--c-bg) !important;
    /* Force text color to remain high contrast, resisting a:hover */
    transform: translateY(-2px);
    /* Lift effect */
    box-shadow: 0 4px 8px var(--c-shadow);
    /* Enhanced shadow */
}

.nav-btn:active {
    transform: translateY(2px);
}

.nav-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    background-color: var(--c-border);
}

select#chapter-select {
    padding: 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    background-color: var(--c-bg);
    color: var(--c-text);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
}

/* Content */
.chapter-content {
    background-color: var(--c-panel);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    box-shadow: 0 4px 6px var(--c-shadow);
    margin-bottom: var(--spacing-lg);
}

.chapter-content p {
    text-align: justify;
}

/* Formatting for Generated Content */
.chapter-content h2 {
    border-bottom: 2px solid var(--c-border);
    padding-bottom: 0.5rem;
}

.chapter-content h4 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    color: var(--c-secondary);
}

/* Subsection styling */
.subsection-divider {
    border-top: 1px solid var(--c-border);
    margin: var(--spacing-lg) 0;
}

.subsection-title {
    color: var(--c-secondary);
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: var(--spacing-sm);
}

blockquote {
    border-left: 4px solid var(--c-primary);
    margin: var(--spacing-md) 0;
    padding-left: var(--spacing-md);
    font-style: italic;
    color: var(--c-secondary);
}

/* Link Styling */
a {
    color: var(--c-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--c-primary);
    text-decoration: underline;
}

a.bible-link {
    font-weight: bold;
    text-decoration: none;
    border-bottom: 1px dotted var(--c-primary);
    color: var(--c-secondary);
}

a.bible-link:hover {
    border-bottom-style: solid;
    color: var(--c-primary);
}

/* Footer */
.site-footer {
    text-align: center;
    margin-top: auto;
    color: var(--c-secondary);
    font-size: 0.9rem;
}

/* Images in Chapters */
.chapter-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px var(--c-shadow);
    margin: var(--spacing-md) 0;
    display: block;
}

.chapter-image.float-left {
    float: left;
    margin-right: var(--spacing-md);
    max-width: 40%;
}

.chapter-image.float-right {
    float: right;
    margin-left: var(--spacing-md);
    max-width: 40%;
}

.clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* -------------------------------------------------------------------------- */
/*                                Embedded Images                             */
/* -------------------------------------------------------------------------- */

.book-image {
    float: right;
    width: 40%;
    max-width: 400px;
    margin: 0.5rem 0 1rem 1.5rem;
    border-radius: 16px;
    /* 3D Effect */
    box-shadow:
        1px 1px 0px #999,
        2px 2px 0px #999,
        3px 3px 0px #999,
        4px 4px 0px #999,
        5px 5px 15px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: zoom-in;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.book-image:hover {
    transform: scale(1.02) translateY(-2px);
    box-shadow:
        1px 1px 0px #999,
        2px 2px 0px #999,
        3px 3px 0px #999,
        4px 4px 0px #999,
        5px 5px 0px #999,
        6px 6px 20px rgba(0, 0, 0, 0.5);
}

/* Mobile: Clear float, full width */
@media (max-width: 700px) {
    .book-image {
        float: none;
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 1.5rem 0;
    }
}

/* -------------------------------------------------------------------------- */
/*                                Lightbox Modal                              */
/* -------------------------------------------------------------------------- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    max-width: 95%;
    max-height: 95vh;
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 2001;
    user-select: none;
}

/* Responsive */
@media (max-width: 600px) {
    .header-controls {
        display: block;
        margin: var(--spacing-sm) 0 0 0;
    }

    .nav-container {
        flex-direction: column;
    }

    .nav-left,
    .nav-right {
        width: 100%;
        justify-content: center;
    }

    .nav-btn,
    .nav-select-wrapper {
        width: 100%;
        text-align: center;
    }

    select#chapter-select {
        width: 100%;
    }

    /* Mobile Text Real Estate Optimization */
    .main-container {
        padding: 0.5rem;
        /* Reduced from 1rem */
    }

    .chapter-content {
        padding: 1rem 0.75rem;
        /* Reduced from 2rem. Slightly less horizontal padding. */
    }

    .site-header,
    .site-nav {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}