/* King James Version Bible Pages - Refined & Readable */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Georgia", serif;
    line-height: 1.85;
    color: #3d2817;
    background: #fef9e7;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header Navigation */
#topheading {
    background: rgba(254, 249, 231, 0.98);
    padding: 1rem;
    margin: -2rem -1.5rem 1.5rem -1.5rem;
    border-bottom: 1px solid #e8d5b7;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #991b1b;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#topheading .nav-prev,
#topheading .nav-next {
    flex: 0 0 auto;
    min-width: 60px;
}

#topheading .nav-title {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    font-size: 1rem;
    line-height: 1.3;
}

#topheading a {
    color: #991b1b;
    text-decoration: none;
    padding: 0.625rem 1rem;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    background: #fff;
    border: 2px solid #e8d5b7;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#topheading a:hover {
    background: #fef5e7;
    border-color: #ea580c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(234, 88, 12, 0.2);
}

#topheading a:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Version Heading */
.vheading {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 2.5rem;
    color: #991b1b;
    letter-spacing: -0.02em;
}

.vheading a {
    color: #991b1b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.vheading a:hover {
    color: #ea580c;
    text-decoration: underline;
}

/* Home link styles */
.home-link-top {
    color: #991b1b;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: #fff;
    border: 2px solid #e8d5b7;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    flex: 0 0 auto;
    white-space: nowrap;
}

.home-link-top:hover {
    background: #fef5e7;
    border-color: #ea580c;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(234, 88, 12, 0.2);
}

.home-link-title {
    color: #991b1b;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 1 1 auto;
    text-align: center;
    min-width: 0;
}

.home-link-title:hover {
    color: #ea580c;
    text-decoration: underline;
}

.home-link-version {
    color: #991b1b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.home-link-version:hover {
    color: #ea580c;
    text-decoration: underline;
}

/* Table of Contents */
.toc-container {
    background: #fefaf0;
    padding: 2.5rem;
    border: 1px solid #e8d5b7;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.testament-section {
    margin-bottom: 3.5rem;
}

.testament-section:last-child {
    margin-bottom: 0;
}

.testament-title {
    font-size: 2rem;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ea580c;
    letter-spacing: -0.02em;
}

.book-group {
    margin-bottom: 2.5rem;
}

.book-group:last-child {
    margin-bottom: 0;
}

.book-group-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #c2410c;
    margin-bottom: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.book-link {
    display: block;
    padding: 1rem 1.25rem;
    background: #fefaf0;
    border: 1px solid #e8d5b7;
    border-left: 4px solid #ea580c;
    color: #3d2817;
    text-decoration: none;
    text-align: center;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.book-link:hover {
    background: #fef5e7;
    border-left-color: #991b1b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153,27,27,0.12);
    color: #991b1b;
    border-color: #d4c4a8;
}

.home-link-container {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2.5rem;
    border-top: 1px solid #e5e7eb;
}

.home-link {
    color: #991b1b;
    text-decoration: none;
    padding: 0.875rem 2rem;
    background: #fefaf0;
    border: 1px solid #e8d5b7;
    border-left: 4px solid #ea580c;
    border-radius: 6px;
    display: inline-block;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.home-link:hover {
    background: #fef5e7;
    border-left-color: #991b1b;
    color: #991b1b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153,27,27,0.12);
    border-color: #d4c4a8;
}

/* Legacy table of contents support */
.calibre3,
body > div > div:last-child {
    background: #fefaf0;
    padding: 2.5rem;
    border: 1px solid #e8d5b7;
    line-height: 1.85;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.calibre4,
body > div > div:last-child span {
    display: block;
}

.calibre4 a,
body > div > div:last-child span a {
    color: #3d2817;
    text-decoration: none;
    margin-right: 1rem;
    display: inline-block;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
    border-radius: 4px;
    font-weight: 500;
}

.calibre4 a:hover,
body > div > div:last-child span a:hover {
    background: #fef5e7;
    color: #991b1b;
}

/* Chapter Navigation */
.cross {
    text-align: center;
    margin: 2rem 0;
    padding: 1.25rem;
    background: #fefaf0;
    border: 1px solid #e8d5b7;
    border-radius: 8px;
    position: relative;
}

.cross a {
    color: #c2410c;
    text-decoration: none;
    margin: 0 0.375rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
    display: inline-block;
}

.cross a:hover {
    color: #991b1b;
    background: #fef5e7;
}

.cross strong {
    color: #991b1b;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
    background: #fef5e7;
    border-radius: 6px;
    display: inline-block;
}

/* Headings */
.hdg {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2.5rem 0 1.25rem 0;
    color: #991b1b;
    text-align: center;
    letter-spacing: -0.01em;
}

/* Verse Text */
.reg {
    margin: 1.25rem 0;
    padding: 0.75rem 0;
    text-align: justify;
    color: #3d2817;
    font-size: 1.05rem;
    line-height: 1.9;
}

.reftext {
    font-weight: 600;
    color: #c2410c;
    margin-right: 0.5rem;
}

/* Italics */
i,
i.calibre6 {
    font-style: italic;
    color: #5c4a37;
}

/* Home Link */
a[href*="index.html"] {
    color: #991b1b;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    background: #fefaf0;
    border: 1px solid #e8d5b7;
    border-left: 4px solid #ea580c;
    border-radius: 6px;
    display: inline-block;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

a[href*="index.html"]:hover {
    background: #fef5e7;
    border-left-color: #991b1b;
    color: #991b1b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153,27,27,0.12);
    border-color: #d4c4a8;
}

/* Center paragraphs and links at the end */
p:last-of-type,
body > div > p {
    text-align: center;
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid #e8d5b7;
}

/* Floating Mobile Navigation */
.mobile-nav {
    display: none;
}

/* Responsive - Mobile optimized */
@media (max-width: 768px) {
    body {
        padding: 0.75rem;
        font-size: 16px;
        line-height: 1.8;
        padding-bottom: 100px; /* Space for floating nav */
    }
    
    #topheading {
        margin: -0.75rem -0.75rem 1rem -0.75rem;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }
    
    #topheading .nav-title {
        font-size: 0.95rem;
        padding: 0 0.5rem;
    }
    
    #topheading a {
        padding: 0.75rem 1rem;
        min-height: 50px;
        min-width: 50px;
        display: inline-flex;
        align-items: center;
        font-size: 1.1rem;
        font-weight: 700;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Modern Floating Navigation */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(254, 249, 231, 0.98);
        border-top: 1px solid #e8d5b7;
        padding: 0.75rem;
        z-index: 200;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        backdrop-filter: blur(15px);
        justify-content: space-around;
        gap: 0.5rem;
    }
    
    .mobile-nav-btn {
        flex: 1;
        padding: 0.875rem 0.5rem;
        background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
        color: #fff;
        text-decoration: none;
        border-radius: 14px;
        font-weight: 700;
        font-size: 0.95rem;
        text-align: center;
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
        transition: all 0.2s ease;
        border: none;
    }
    
    .mobile-nav-btn:active {
        transform: scale(0.96);
        box-shadow: 0 2px 6px rgba(234, 88, 12, 0.4);
    }
    
    .mobile-nav-btn.secondary {
        background: #fff;
        color: #991b1b;
        border: 2px solid #e8d5b7;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    
    .mobile-nav-btn.secondary:active {
        background: #fef5e7;
        border-color: #ea580c;
    }
    
    .vheading {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .toc-container {
        padding: 1.5rem 1rem;
    }
    
    .testament-title {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
    }
    
    .book-group-title {
        font-size: 1.15rem;
        margin-bottom: 0.75rem;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }
    
    .book-link {
        padding: 1.25rem 1rem;
        font-size: 1rem;
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
    }
    
    .book-link:active {
        transform: scale(0.95);
    }
    
    .cross {
        padding: 1rem 0.5rem;
        margin: 1rem 0;
        font-size: 0.85rem;
        top: 60px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #e8d5b7 transparent;
    }
    
    .cross::-webkit-scrollbar {
        height: 6px;
    }
    
    .cross::-webkit-scrollbar-thumb {
        background: #e8d5b7;
        border-radius: 3px;
    }
    
    .cross a {
        padding: 0.75rem 1.25rem;
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin: 0.25rem;
        font-size: 0.95rem;
        font-weight: 600;
        flex-shrink: 0;
        background: #fff;
        border: 2px solid #e8d5b7;
        border-radius: 8px;
        transition: all 0.2s ease;
    }
    
    .cross a:active {
        background: #fef5e7;
        border-color: #ea580c;
        transform: scale(0.95);
    }
    
    .cross strong {
        min-height: 44px;
        min-width: 44px;
        font-size: 0.95rem;
        flex-shrink: 0;
        background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
        color: #fff;
        padding: 0.75rem 1.25rem;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
    }
    
    .hdg {
        font-size: 1.15rem;
        margin: 1.25rem 0 0.75rem 0;
    }
    
    .reg {
        font-size: 1rem;
        line-height: 1.85;
        margin-bottom: 1rem;
        padding: 0.5rem 0;
    }
    
    .reftext {
        font-size: 1rem;
        margin-right: 0.375rem;
    }
    
    .calibre3,
    body > div > div:last-child {
        padding: 1.5rem 1rem;
    }
    
    .calibre4 a,
    body > div > div:last-child span a {
        margin: 0.25rem;
        padding: 0.5rem 0.625rem;
        min-height: 36px;
        min-width: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .home-link-container {
        padding: 1.5rem 1rem;
    }
    
    .home-link {
        padding: 0.875rem 1.25rem;
        min-height: 44px;
        font-size: 0.95rem;
        margin: 0.5rem 0.25rem;
        display: inline-block;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.5rem;
        font-size: 15px;
        padding-bottom: 100px;
    }
    
    #topheading {
        margin: -0.5rem -0.5rem 0.75rem -0.5rem;
        padding: 0.625rem 0.375rem;
        font-size: 0.85rem;
    }
    
    #topheading .nav-title {
        font-size: 0.9rem;
        padding: 0 0.25rem;
    }
    
    #topheading a {
        padding: 0.75rem 0.875rem;
        min-height: 52px;
        min-width: 52px;
        font-size: 1.15rem;
    }
    
    .mobile-nav {
        padding: 0.875rem 0.5rem;
    }
    
    .mobile-nav-btn {
        padding: 0.875rem 0.5rem;
        font-size: 0.95rem;
        min-height: 60px;
    }
    
    .vheading {
        font-size: 1rem;
    }
    
    .toc-container {
        padding: 1.25rem 0.75rem;
    }
    
    .testament-title {
        font-size: 1.35rem;
    }
    
    .book-group-title {
        font-size: 1.05rem;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }
    
    .book-link {
        padding: 1rem 0.875rem;
        font-size: 0.95rem;
        min-height: 52px;
        font-weight: 600;
    }
    
    .book-link:active {
        transform: scale(0.95);
    }
    
    .reg {
        font-size: 0.95rem;
    }
    
    .reftext {
        font-size: 0.95rem;
    }
    
    .hdg {
        font-size: 1.05rem;
    }
    
    .home-link {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        width: calc(100% - 0.5rem);
        margin: 0.5rem 0.25rem;
        text-align: center;
    }
}

@media (max-width: 360px) {
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .book-link {
        width: 100%;
    }
}
