@import url('https://fonts.googleapis.com/css2?family=Gabriela&display=swap');

/* Global Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Typography for Titles */
h1,
h2,
.site-title {
    font-family: 'Gabriela', serif;
}

/* 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;
}

/* 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 0.8rem;
    font-size: 1.2rem;
    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-flex;
    align-items: center;
    justify-content: center;
    height: 3rem;
    min-width: 3rem;
}

.js-theme-btn {
    font-size: 1.6rem;
}

.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: 0.4rem;
    /* Minimal padding */
    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: 0.2rem;
    /* Minimal gap for wrapping */
    align-content: center;
}

@media (min-width: 800px) {
    .nav-container {
        gap: 3rem;
        /* Restore large gap for wide screens */
    }
}

.nav-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin: 0;
    flex-wrap: nowrap;
    /* Fix overlap */
    justify-content: center;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin: 0;
}

.nav-select-wrapper {
    max-width: 300px;
    flex: 1;
    min-width: 200px;
    /* Ensure dropdown doesn't shrink too much */
}

/* 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;
    /* FIX: Constrain width to parent wrapper */
    width: 100%;
    max-width: 100%;
}

/* 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;
}

/* 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: 40%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px var(--c-shadow);
    margin: 0 0 var(--spacing-md) var(--spacing-md);
    display: block;
    float: right;
    clear: right;
    /* Prevent stacking weirdness */
}

/* Remove explicit float classes as we enforce right-side */


.clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* Responsive */
@media (max-width: 600px) {

    /* Maximize Mobile Space */
    .main-container {
        padding: 0.5rem;
    }

    .chapter-content {
        padding: 1rem 0.75rem;
    }

    .site-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .site-nav {
        margin-bottom: 1rem;
    }

    /* Formatting retained, padding stays minimal (0.4rem) */

    .header-controls {
        display: block;
        margin: var(--spacing-sm) 0 0 0;
    }

    /* FIX: Force left/dropdown/right to stay on one line, but allow groups to wrap */
    .nav-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .chapter-image {
        float: none;
        max-width: 100%;
        margin: 1rem auto;
        width: 100%;
    }

    /* Navigation Groups */
    /* Force the Left Arrow, Dropdown, Right Arrow to ALWAYS be one line */
    .nav-left {
        width: 100%;
        flex-wrap: nowrap;
        /* CRITICAL */
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }

    .nav-right {
        width: 100%;
        justify-content: center;
        margin-top: 0.2rem;
    }

    /* Allow buttons to take natural size, not 100% like before */
    .nav-btn {
        width: auto;
        flex-shrink: 0;
    }

    /* Allow Select to grow */
    .nav-select-wrapper {
        width: auto;
        flex: 1;
        /* Grow to fill space between arrows */
        text-align: center;
        margin: 0 0.2rem;
        min-width: 0;
    }

    select#chapter-select {
        width: 100%;
    }
}