/**
 * Mobile Chapter Styles - Bible Teaching Program
 * Elite Mobile Design - Centralized CSS for book chapter pages
 * Updated: January 2026
 *
 * Usage: Set CSS variables in page <head>, then link this file:
 *   <style>:root { --accent-color: #2E5090; --accent-rgb: 46, 80, 144; }</style>
 *   <link rel="stylesheet" href="/css/mobile-chapter.css">
 */

/* ===== ACCENT COLOR (Set per page via inline <style>) ===== */
/* No defaults here - each page MUST define:
   :root { --accent-color: #HEX; --accent-rgb: R, G, B; }

   Book Accent Colors:
   - Floods: #2E5090 / 46, 80, 144
   - Higher Calling: #4A7FB5 / 74, 127, 181
   - R.A. Torrey: #1C1D37 / 28, 29, 55
   - John Newton: #5B6B7C / 91, 107, 124
   - William Gurnall: #6B5344 / 107, 83, 68
   - John Bunyan: #8B4513 / 139, 69, 19
   - Martin Luther: #4A4A4A / 74, 74, 74
   - Isaac Sharp: #4A6741 / 74, 103, 65
*/

/* ===== MOBILE STYLES (max-width: 1023px) ===== */
@media (max-width: 1023px) {

    /* ===== MOBILE-ONLY ELEMENT VISIBILITY ===== */
    /* Ensure mobile-only elements are visible on mobile */
    .mobile-only {
        display: block !important;
    }

    /* Mobile breadcrumbs and title */
    .mobile-breadcrumb-wrapper,
    .mobile-chapter-title,
    #btp-mobile-header {
        display: block !important;
    }

    /* Bottom nav needs flex display */
    nav.mobile-chapter-bottom-nav {
        display: flex !important;
    }
    /* Overlay hidden until active */
    .mobile-chapter-overlay {
        display: none !important;
    }
    .mobile-chapter-overlay.active {
        display: block !important;
    }

    /* ===== HIDE SITE NAVIGATION & FOOTER ===== */
    #nav-placeholder, #nav-placeholder *,
    #mobileFooterNav, #mobileBreadcrumbBar,
    #mobileNavBottomFill, .pull-handle-area,
    .mobile-nav-bar, .top-nav,
    #footer-placeholder, #footer-placeholder *,
    footer, .footer-content,
    .mobile-fab, .fab-button, [onclick*="toggleMobileNav"] {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* ===== HIDE DESKTOP ELEMENTS ===== */
    .bg-white.border-b.border-gray-100 { display: none !important; }
    section.relative.overflow-hidden { display: none !important; }
    .lg\:col-span-1 { display: none !important; }
    .hidden.lg\:block { display: none !important; }
    .bg-parchment.rounded-xl.p-6.border-2 { display: none !important; }
    .bg-parchment.rounded-xl.p-6.border { display: none !important; }
    section.bg-ancient-ink { display: none !important; }
    section.bg-gradient-to-br { display: none !important; }
    .page-header { display: none !important; }
    .flex.items-center.justify-between.gap-4 { display: none !important; }
    main .grid > .lg\:col-span-1 { display: none !important; }
    main .grid > div:last-child:not(.lg\:col-span-2):not(.lg\:col-span-3) { display: none !important; }
    .lg\:col-span-3 > .pt-6 { display: none !important; }
    main > .text-center { display: none !important; }
    .pt-6 > a[href*="index.html"] { display: none !important; }
    .pt-6.hidden { display: none !important; }
    div[class*="pt-6"][class*="hidden"] { display: none !important; }
    article + .pt-6 { display: none !important; }
    article + div:has(a[href*="index.html"]) { display: none !important; }
    .mobile-chapter-bottom-nav a[href*="index.html"] { display: flex !important; }
    :not(.mobile-chapter-bottom-nav) > a[href*="index.html"]:has(svg) { display: none !important; }
    .lg\:col-span-3 > div.pt-6 { display: none !important; }

    /* ===== LAYOUT ===== */
    body {
        padding-bottom: 60px !important;
        background: #F9F7F2 !important;
        min-height: 100vh;
    }
    .lg\:col-span-3 { grid-column: span 4 / span 4; }
    .grid { display: block !important; }
    main.max-w-7xl { padding: 0 !important; max-width: 100% !important; display: block !important; }
    main.max-w-7xl > .grid { display: block !important; }
    main.max-w-7xl .lg\:col-span-3 { padding: 0 !important; }
    main.max-w-7xl .lg\:col-span-1 { display: none !important; }

    /* ===== ELITE BREADCRUMBS ===== */
    .mobile-breadcrumb-wrapper {
        padding: 0.75rem 1.25rem;
        background: #F9F7F2;
    }
    .mobile-breadcrumb-inner {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.8125rem;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .mobile-breadcrumb-inner::-webkit-scrollbar { display: none; }
    .mobile-breadcrumb-inner a {
        color: #9CA3AF;
        text-decoration: none;
        transition: color 0.15s;
    }
    .mobile-breadcrumb-inner a:active { color: #CBA378; }
    /* Replace arrow separators with dots */
    .mobile-breadcrumb-inner > span:not(.current) {
        font-size: 0;
        color: transparent;
    }
    .mobile-breadcrumb-inner > span:not(.current)::after {
        content: '·';
        font-size: 0.875rem;
        color: #D1D5DB;
    }
    .mobile-breadcrumb-inner .current {
        color: var(--accent-color);
        font-weight: 500;
    }

    /* ===== ELITE CHAPTER TITLE ===== */
    .mobile-chapter-title {
        display: flex;
        align-items: center;
        gap: 0.875rem;
        padding: 0 1.25rem 1rem;
        background: #F9F7F2;
    }
    .chapter-badge {
        width: 2.5rem;
        height: 2.5rem;
        background: var(--accent-color);
        color: white;
        border-radius: 0.625rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem;
        font-weight: 700;
        flex-shrink: 0;
    }
    .mobile-chapter-title h1 {
        font-family: 'Playfair Display', serif;
        font-size: 1.125rem;
        font-weight: 600;
        color: #1C1D37;
        margin: 0;
        line-height: 1.3;
    }

    /* ===== CONTENT CONTAINER ===== */
    .bg-white.rounded-2xl.shadow-sm,
    .bg-white.rounded-xl.shadow-sm {
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 1.25rem !important;
        background: #F9F7F2 !important;
    }
    .p-8, .p-8.lg\:p-12 {
        padding: 0 1.25rem 1.25rem !important;
    }

    /* ===== BOOK CONTENT TYPOGRAPHY ===== */
    .book-content, .content-area, article {
        font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
        font-size: 0.9375rem !important;
        line-height: 1.75 !important;
        color: #374151 !important;
        padding: 0 !important;
        background: transparent !important;
    }
    .book-content p, .content-area p {
        margin-bottom: 1rem !important;
        text-align: left !important;
    }
    .book-content br, .content-area br {
        display: none;
    }
    .book-content h2, .content-area h2 {
        font-family: 'Playfair Display', serif !important;
        font-size: 1.25rem !important;
        font-weight: 600 !important;
        color: #1C1D37 !important;
        margin: 1.5rem 0 0.75rem 0 !important;
    }
    .book-content h3, .content-area h3 {
        font-family: 'Playfair Display', serif !important;
        font-size: 1.0625rem !important;
        font-weight: 600 !important;
        color: #1C1D37 !important;
        margin: 1.25rem 0 0.5rem 0 !important;
    }
    .book-content b, .book-content strong {
        font-weight: 600;
        color: #1C1D37;
    }
    .book-content i, .book-content em {
        font-style: italic;
    }
    .book-content blockquote, .content-area blockquote {
        border-left: 3px solid var(--accent-color) !important;
        margin: 1rem 0 !important;
        padding: 0.875rem 1rem !important;
        background: white !important;
        font-style: italic !important;
        color: #4b5563 !important;
        border-radius: 0 !important;
    }

    /* ===== ELITE BOTTOM NAVIGATION ===== */
    .mobile-chapter-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: white;
        border-top: 1px solid rgba(0,0,0,0.06);
        display: flex;
        z-index: 9999;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    }
    .mobile-chapter-bottom-nav a,
    .mobile-chapter-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        font-family: 'Inter', system-ui, sans-serif;
        font-size: 0.6875rem;
        font-weight: 500;
        color: #6b7280;
        background: transparent;
        border: none;
        text-decoration: none;
        cursor: pointer;
        transition: color 0.15s;
    }
    /* Ensure icon always on top, text below */
    .mobile-chapter-bottom-nav a svg,
    .mobile-chapter-bottom-nav button svg {
        order: -1;
    }
    .mobile-chapter-bottom-nav a:active,
    .mobile-chapter-bottom-nav button:active {
        color: var(--accent-color);
        background: rgba(var(--accent-rgb), 0.08);
    }
    .mobile-chapter-bottom-nav svg {
        width: 20px;
        height: 20px;
        stroke: currentColor;
    }

    /* ===== ELITE OVERLAY ===== */
    .mobile-chapter-overlay {
        position: fixed;
        inset: 0;
        background: rgba(28, 29, 55, 0.5);
        z-index: 10000;
        display: none;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .mobile-chapter-overlay.active { display: block; }

    /* ===== ELITE DRAWER (Slides from RIGHT) ===== */
    .mobile-chapter-drawer {
        display: block;
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100%;
        background: #F9F7F2;
        z-index: 10001;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: -8px 0 32px rgba(28, 29, 55, 0.2);
    }
    .mobile-chapter-drawer.active { right: 0; }

    /* Drawer Header - Premium Book-Branded */
    .drawer-header {
        background: var(--accent-color) !important;
        background-image: linear-gradient(
            135deg,
            rgba(255,255,255,0.15) 0%,
            rgba(255,255,255,0) 50%,
            rgba(0,0,0,0.1) 100%
        ) !important;
        padding: 1.25rem;
        position: relative;
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,0.12),
            0 6px 20px rgba(var(--accent-rgb), 0.35);
    }
    .drawer-header-content {
        display: flex;
        gap: 1rem;
        align-items: flex-start;
    }
    /* Book Cover Thumbnail */
    .drawer-book-cover {
        width: 56px;
        height: 72px;
        border-radius: 6px;
        object-fit: cover;
        box-shadow:
            0 4px 12px rgba(0,0,0,0.25),
            0 2px 4px rgba(0,0,0,0.15);
        border: 2px solid rgba(255,255,255,0.2);
        flex-shrink: 0;
    }
    /* Book Icon (fallback when no cover) */
    .drawer-book-icon {
        width: 56px;
        height: 72px;
        border-radius: 6px;
        background: rgba(255,255,255,0.15);
        border: 2px solid rgba(255,255,255,0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.75rem;
        color: rgba(255,255,255,0.9);
        flex-shrink: 0;
        box-shadow:
            0 4px 12px rgba(0,0,0,0.2),
            inset 0 1px 0 rgba(255,255,255,0.1);
    }
    .drawer-title-area {
        flex: 1;
        padding-top: 0.25rem;
    }
    .drawer-label {
        font-size: 0.5625rem;
        text-transform: uppercase;
        letter-spacing: 0.15em;
        color: rgba(255,255,255,0.65);
        margin-bottom: 0.25rem;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    .drawer-title {
        font-family: 'Playfair Display', serif;
        font-weight: 600;
        font-size: 1.125rem;
        color: white;
        line-height: 1.25;
        text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    .drawer-subtitle {
        font-size: 0.75rem;
        color: rgba(255,255,255,0.8);
        margin-top: 0.25rem;
        font-style: italic;
        line-height: 1.3;
    }
    .drawer-author {
        font-size: 0.6875rem;
        color: rgba(255,255,255,0.6);
        margin-top: 0.375rem;
        font-style: italic;
    }
    .drawer-close {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        width: 2rem;
        height: 2rem;
        background: rgba(0,0,0,0.15);
        border: 1px solid rgba(255,255,255,0.1);
        border-radius: 50%;
        color: rgba(255,255,255,0.8);
        font-size: 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s ease;
        backdrop-filter: blur(4px);
    }
    .drawer-close:active {
        background: rgba(0,0,0,0.25);
        transform: scale(0.92);
    }

    /* Drawer Nav Section */
    .drawer-nav-section {
        padding: 0.875rem 1.25rem;
        background: white;
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }
    .drawer-nav-links {
        display: flex;
        gap: 0.5rem;
    }
    .drawer-nav-links a {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.625rem 0.75rem;
        background: #1C1D37;
        border: none;
        color: white;
        text-align: center;
        border-radius: 0.5rem;
        font-size: 0.6875rem;
        font-weight: 600;
        text-decoration: none;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        transition: all 0.15s ease;
    }
    .drawer-nav-links a:first-child {
        background: #1C1D37;
    }
    .drawer-nav-links a:last-child {
        background: #CBA378;
        color: #1C1D37;
    }
    .drawer-nav-links a:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    /* Drawer Content */
    .drawer-content {
        padding: 1rem 1.25rem 2rem;
    }
    .drawer-section-label {
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: #9CA3AF;
        margin-bottom: 0.75rem;
        font-weight: 600;
    }

    /* Elite Chapter Links - Compact single-line layout */
    .chapter-link {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center;
        gap: 0.625rem;
        padding: 0.75rem 1rem;
        margin-bottom: 0.375rem;
        background: white;
        border-radius: 0.625rem;
        box-shadow: 0 1px 6px -2px rgba(28, 29, 55, 0.08);
        text-decoration: none;
        transition: all 0.15s ease;
    }
    .chapter-link:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(28, 29, 55, 0.1);
    }

    /* Current Chapter - Highlighted with Book Accent */
    .chapter-link.current {
        background: var(--accent-color) !important;
        box-shadow: 0 3px 12px -3px rgba(var(--accent-rgb), 0.4);
    }
    .chapter-link.current .chapter-number {
        color: white !important;
        opacity: 0.9;
    }
    .chapter-link.current .chapter-title {
        color: white;
    }
    .chapter-link.current .chapter-arrow {
        color: rgba(255,255,255,0.7);
    }

    /* Chapter Number Badge - Compact */
    .chapter-number {
        font-family: 'Playfair Display', serif;
        font-size: 1rem;
        font-weight: 600;
        color: var(--accent-color);
        width: 1.75rem;
        flex-shrink: 0;
        text-align: center;
    }

    /* Chapter Title - Single line with ellipsis */
    .chapter-title {
        flex: 1;
        min-width: 0;
        font-family: 'Inter', system-ui, sans-serif;
        font-size: 0.8125rem;
        font-weight: 500;
        color: #1C1D37;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Chapter Arrow - Smaller */
    .chapter-arrow {
        width: 16px;
        height: 16px;
        color: #9CA3AF;
        flex-shrink: 0;
    }

    /* Resource/PDF Badge - Elegant inline styling */
    .chapter-number[style*="background"] {
        background: var(--accent-color) !important;
        color: white !important;
        font-size: 0.5625rem !important;
        padding: 0.1875rem 0.5rem !important;
        border-radius: 0.25rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        font-weight: 700;
        font-family: 'Inter', sans-serif;
        width: auto !important;
        min-width: auto !important;
        text-align: center;
        line-height: 1;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
}

/* ===== DESKTOP - Hide Mobile Elements ===== */
@media (min-width: 1024px) {
    .mobile-only { display: none !important; }
    .mobile-breadcrumb-wrapper, .mobile-chapter-title,
    .mobile-chapter-bottom-nav, .mobile-chapter-drawer,
    .mobile-chapter-overlay { display: none !important; }
}
