/* Bible Cross-Reference Visualizer Styles */

/* CRITICAL: Prevent white flash on ANY element */
html {
    background: var(--bg-dark) !important; /* Use theme background color */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gold: #FFD700;
    --primary-cyan: #00CED1;
    --primary-purple: #9370DB;
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --text-light: #eee;
    --text-muted: #aaa;
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
}

/* Theme: Professional (default dark blue) */
[data-theme="professional"] {
    --primary-gold: #4682B4;
    --primary-cyan: #B0C4DE;
    --primary-purple: #3CB371;
    --accent-green: #3CB371;
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --text-light: #f0f0f0;
}

/* Theme: Vibrant (dark background, neon colors) */
[data-theme="vibrant"] {
    --primary-gold: #FFD700;
    --primary-cyan: #00FFFF;
    --primary-purple: #FF00FF;
    --accent-green: #00FF41;
    --bg-dark: #0a0a0a;
    --bg-medium: #1a1a1a;
    --bg-light: #2a2a2a;
    --text-light: #FFFFFF;
}

/* Theme: Matrix (black/green) */
[data-theme="matrix"] {
    --primary-gold: #00FF41;
    --primary-cyan: #009628;
    --primary-purple: #00FF7F;
    --accent-green: #32CD32;
    --bg-dark: #000000;
    --bg-medium: #001a00;
    --bg-light: #003300;
    --text-light: #00FF41;
}

/* Theme: Sunset (warm colors) */
[data-theme="sunset"] {
    --primary-gold: #FF7F50;
    --primary-cyan: #FFA500;
    --primary-purple: #DC143C;
    --accent-green: #FF8C00;
    --bg-dark: #1a0a00;
    --bg-medium: #2d1810;
    --bg-light: #3d2416;
    --text-light: #FFD4A3;
}

/* Theme: Royal (purple) */
[data-theme="royal"] {
    --primary-gold: #8A2BE2;
    --primary-cyan: #9370DB;
    --primary-purple: #483D8B;
    --accent-green: #483D8B;
    --bg-dark: #0f0820;
    --bg-medium: #1a0f30;
    --bg-light: #2a1840;
    --text-light: #E8D5FF;
}

/* Theme: Ocean (blue/teal) */
[data-theme="ocean"] {
    --primary-gold: #00BFFF;
    --primary-cyan: #40E0D0;
    --primary-purple: #20B2AA;
    --accent-green: #20B2AA;
    --bg-dark: #001a1f;
    --bg-medium: #00293d;
    --bg-light: #003d5c;
    --text-light: #B3E5FC;
}

/* Theme: Black & Gold */
[data-theme="blackgold"] {
    --primary-gold: #FFD700;
    --primary-cyan: #FFA500;
    --primary-purple: #FF8C00;
    --accent-green: #FFD700;
    --bg-dark: #000000;
    --bg-medium: #0a0a0a;
    --bg-light: #1a1a1a;
    --viz-bg: #000000; /* Pure black for visualizations */
    --text-light: #FFD700;
    --text-dark: #000000;
}

/* Theme: Light/White */
[data-theme="light"] {
    --primary-gold: #D4AF37; /* Darker gold for visibility */
    --primary-cyan: #1E90FF; /* Darker cyan */
    --primary-purple: #9370DB;
    --accent-green: #228B22;
    --bg-dark: #FFFFFF;
    --bg-medium: #F5F5F5;
    --bg-light: #E8E8E8;
    --viz-bg: #FFFFFF; /* White for visualizations */
    --text-light: #333333; /* Dark text on white */
    --text-dark: #FFFFFF;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 100%) !important;
    background-color: var(--bg-dark) !important; /* Fallback - uses theme color */
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px;
    background: transparent !important; /* Never show white background */
}

/* Header - More compact */
header {
    text-align: center;
    padding: 5px 0; /* Reduced from 8px */
    background: linear-gradient(90deg, var(--primary-gold) 0%, var(--primary-cyan) 100%);
    border-radius: 5px; /* Reduced from 8px */
    margin-bottom: 8px; /* Reduced from 10px */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1000; /* CRITICAL: Stay above SVG visualizations */
}

header h1 {
    font-size: 1.5em;
    font-weight: bold;
    background: linear-gradient(90deg, var(--bg-dark), var(--bg-medium));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.subtitle {
    color: var(--bg-dark);
    font-size: 0.9em;
    font-weight: 500;
}

/* Navigation Tabs - Menu Bar Style */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: nowrap; /* Keep all tabs on one line */
    overflow-x: auto; /* Horizontal scroll if needed */
    overflow-y: hidden;
    position: relative;
    z-index: 1000; /* CRITICAL: Stay above SVG visualizations */
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-gold) var(--bg-dark);
}

.tab-btn {
    padding: 6px 12px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap; /* Don't wrap text inside buttons */
    flex-shrink: 0; /* Don't compress buttons */
}

.tab-btn:hover {
    background: var(--primary-cyan);
    color: var(--bg-dark);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: var(--primary-gold);
    color: var(--bg-dark);
    border-color: var(--primary-cyan);
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    background: transparent;
    padding: 5px 0;
    border-radius: 0;
    margin-bottom: 10px;
    position: relative;
    z-index: 1000; /* CRITICAL: Stay above SVG visualizations */
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.control-group label {
    color: var(--text-muted);
    font-weight: 500;
}

.control-group select,
.control-group input[type="range"] {
    padding: 4px 8px;
    background: var(--bg-medium);
    border: 1px solid var(--primary-cyan);
    border-radius: 5px;
    color: var(--text-light);
    font-size: 0.95em;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--primary-gold);
}

#min-value {
    background: var(--primary-cyan);
    color: var(--bg-dark);
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.btn {
    padding: 10px 20px;
    background: var(--bg-medium);
    border: 1px solid var(--primary-cyan);
    border-radius: 5px;
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    background: var(--primary-cyan);
    color: var(--bg-dark);
    transform: scale(1.05);
}

.btn-primary {
    background: var(--primary-gold);
    color: var(--bg-dark);
    border-color: var(--primary-gold);
}

.btn-primary:hover {
    background: var(--primary-cyan);
    border-color: var(--primary-cyan);
}

.btn-theme {
    background: linear-gradient(90deg, var(--primary-gold), var(--primary-cyan), var(--primary-purple));
    color: white;
    border-color: var(--primary-gold);
    font-weight: bold;
}

.btn-theme:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.5);
}

/* Visualization Container */
.viz-container {
    position: relative;
    background: transparent !important; /* NEVER white */
    background-color: transparent !important;
    border-radius: 0;
    overflow: visible !important; /* Allow arcs to extend beyond container */
    padding: 20px 10px;  /* Add padding back for proper spacing */
    min-height: 850px;  /* Ensure minimum height for visualizations */
    margin-bottom: 10px;
    box-shadow: none;
    z-index: 1; /* BELOW navigation and controls */
}

.viz-panel {
    display: none;
    overflow: visible !important; /* Prevent arc clipping */
    background: transparent !important; /* NEVER white */
    /* Removed min-height - let content determine height */
}

.viz-panel.active {
    display: block;
    overflow: visible !important; /* Prevent arc clipping */
    background: transparent !important; /* NEVER white */
    /* Removed min-height - let content determine height */
}

.viz-info {
    display: none; /* Hide the info boxes completely */
}

/* SVG Styles */
svg {
    width: 100%;
    /* Removed min-height constraint that was squishing visualizations */
    background: transparent;
    border-radius: 0;
    margin: 0;
    padding: 0;
    overflow: visible !important; /* Ensure arcs don't get clipped */
}

/* Tooltip */
.tooltip {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.95);
    color: var(--text-light);
    border: 2px solid var(--primary-gold);
    border-radius: 8px;
    pointer-events: none;
    transition: none !important; /* Remove transition for instant positioning */
    font-size: 0.9em;
    max-width: 300px;
    z-index: 10000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    display: none;
    will-change: transform; /* GPU acceleration */
}

.tooltip.show {
    opacity: 1;
}

.tooltip strong {
    color: var(--primary-gold);
}

/* Info Panel */
.info-panel {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.info-panel h3 {
    color: var(--primary-cyan);
    margin-bottom: 15px;
}

#detail-content {
    color: var(--text-muted);
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid var(--primary-gold);
}

.stat-card h4 {
    color: var(--primary-cyan);
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--primary-gold);
    margin: 10px 0;
}

.stat-list {
    list-style: none;
    padding: 0;
}

.stat-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-medium);
    display: flex;
    justify-content: space-between;
}

.stat-list li:last-child {
    border-bottom: none;
}

.stat-list .book-name {
    color: var(--text-light);
}

.stat-list .count {
    color: var(--primary-cyan);
    font-weight: bold;
}

/* Arc-specific styles */
.arc-line {
    fill: none;
    stroke-width: 1.5;
    opacity: 0.6;
    transition: none !important;
    pointer-events: stroke;
    cursor: pointer;
    will-change: opacity;
    transform: translateZ(0);
}

/* Chapter markers */
.chapter-node rect {
    transition: none !important;
    pointer-events: all;
}

.chapter-bar {
    transition: none !important;
    will-change: height, width, x, y, opacity;
    transform: translateZ(0);
}

.arc-line:hover {
    opacity: 1;
    stroke-width: 3;
}

.arc-line.highlight {
    opacity: 1 !important;
}

.arc-line.fade {
    opacity: 0.02 !important;
}

.arc-line.ot-ot {
    stroke: var(--accent-green);
}

.arc-line.nt-nt {
    stroke: var(--primary-cyan);
}

.arc-line.cross-testament {
    stroke: var(--primary-purple);
}

.chapter-node {
    cursor: pointer;
}

.chapter-node:hover {
    transform: scale(1.2);
}

/* Network Graph styles */
.node {
    cursor: pointer;
    stroke: var(--bg-dark);
    stroke-width: 2;
}

.node.ot {
    fill: var(--accent-green);
}

.node.nt {
    fill: var(--primary-cyan);
}

.link {
    stroke: var(--text-muted);
    stroke-opacity: 0.4;
}

.link.highlighted {
    stroke: var(--primary-gold);
    stroke-opacity: 0.8;
    stroke-width: 3;
}

/* Heatmap cells */
.heatmap-cell {
    cursor: pointer;
    transition: stroke-width 0.2s;
}

.heatmap-cell:hover {
    stroke: var(--primary-gold);
    stroke-width: 3;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    border-top: 1px solid var(--bg-light);
    margin-top: 30px;
}

footer a {
    color: var(--primary-cyan);
    text-decoration: none;
}

footer a:hover {
    color: var(--primary-gold);
    text-decoration: underline;
}

/* Loading Animation */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    font-size: 1.5em;
    color: var(--primary-gold);
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Global touch improvements */
    * {
        -webkit-tap-highlight-color: rgba(255, 215, 0, 0.3); /* Gold tap highlight */
    }

    /* Prevent text selection during touch interactions */
    svg, canvas {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    /* Smooth momentum scrolling on iOS */
    body, .tabs, .controls {
        -webkit-overflow-scrolling: touch;
    }

    /* Header */
    header h1 {
        font-size: 1.5em;
        gap: 6px;
    }

    header h1 img {
        width: 20px;
        height: 20px;
    }

    .subtitle {
        font-size: 0.7em;
    }

    /* Navigation Tabs - Touch-friendly */
    .tabs {
        justify-content: flex-start;
        gap: 8px;
        padding: 8px 0;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
    }

    .tab-btn {
        padding: 12px 16px; /* Increased for 44px min touch target */
        min-height: 44px;
        min-width: 44px; /* WCAG touch target minimum */
        font-size: 0.85em;
        flex-shrink: 0;
        touch-action: manipulation; /* Disable double-tap zoom */
    }

    /* Controls - Touch-friendly */
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .control-group {
        justify-content: space-between;
        min-height: 44px; /* Touch target */
    }

    .control-group label {
        font-size: 0.9em;
    }

    .control-group select,
    .control-group input[type="range"] {
        padding: 8px 12px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 44px;
        touch-action: manipulation; /* Disable double-tap zoom */
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9em;
        min-height: 44px;
        min-width: 44px;
        width: 100%;
        touch-action: manipulation; /* Disable double-tap zoom */
    }

    /* Visualizations - Responsive sizing */
    .viz-container {
        padding: 10px 5px;
        touch-action: pan-y pinch-zoom; /* Allow vertical scroll and pinch zoom */
    }

    svg {
        max-width: 100%;
        height: auto;
        touch-action: pan-x pan-y pinch-zoom; /* Allow all gestures on SVGs */
    }

    /* Reduce fixed heights for mobile */
    #arc-svg,
    #radial-svg,
    #network-svg,
    #chord-svg,
    #heatmap-svg,
    #sunburst-svg,
    #people-svg {
        min-height: 400px;
        max-height: 600px;
        touch-action: none; /* Let D3/visualization handle all touches */
    }

    #timeline-svg {
        min-height: 300px;
        max-height: 500px;
        touch-action: none; /* Let D3 zoom handle all touches */
    }

    /* Geographic map */
    #geomap-container {
        height: 400px !important;
        min-height: 400px;
        touch-action: none; /* Let Leaflet handle all touches */
    }

    /* Leaflet controls - larger for touch */
    .leaflet-control-zoom a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 22px !important;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Search */
    .search-box {
        flex-direction: column;
    }

    #search-input {
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom */
        min-height: 44px;
        touch-action: manipulation; /* Disable double-tap zoom */
    }

    /* Watermark - Smaller on mobile */
    .watermark {
        bottom: 10px;
        right: 10px;
        padding: 8px 16px;
        font-size: 0.85em;
    }

    .watermark img {
        width: 16px;
        height: 16px;
    }

    /* Theme toggle - ensure accessible */
    .floating-theme-toggle {
        width: 44px;
        height: 44px;
        top: 10px;
        right: 10px;
        touch-action: manipulation; /* Disable double-tap zoom */
    }

    /* Tooltip - optimized for touch */
    .tooltip {
        max-width: 90vw; /* Don't overflow screen on mobile */
        font-size: 0.85em;
        padding: 10px 14px;
    }

    /* Footer text smaller */
    footer {
        font-size: 0.8em;
        padding: 15px 10px;
    }

    /* Improve tap targets for links */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        touch-action: manipulation;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-cyan);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-gold);
}

/* Radial Arc styles */
.radial-arc {
    fill: none;
    transition: none !important;
    pointer-events: stroke;
    cursor: pointer;
}

/* Search styles */
.search-container {
    padding: 20px;
}

.search-container h2 {
    color: var(--primary-gold);
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#search-input {
    flex: 1;
    padding: 10px;
    background: var(--bg-medium);
    border: 1px solid var(--primary-cyan);
    border-radius: 5px;
    color: var(--text-light);
    font-size: 14px;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-gold);
}

.search-no-results,
.search-error {
    padding: 20px;
    background: var(--bg-light);
    border-radius: 8px;
    color: var(--text-muted);
}

.search-chapter-results,
.search-book-results {
    background: var(--bg-light);
    border-radius: 8px;
    padding: 20px;
}

.search-chapter-results h3,
.search-book-results h3 {
    color: var(--primary-gold);
    margin-bottom: 10px;
}

.search-info {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.connections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.connection-column h4 {
    color: var(--primary-cyan);
    margin-bottom: 10px;
}

.connection-list {
    list-style: none;
    padding: 0;
}

.connection-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid var(--bg-medium);
}

.conn-chapter {
    color: var(--text-light);
}

.conn-weight {
    color: var(--primary-gold);
    font-size: 12px;
}

.book-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-muted);
    font-size: 12px;
}

.stat-value {
    color: var(--primary-gold);
    font-size: 20px;
    font-weight: bold;
}

.book-connection-list {
    list-style: none;
    padding: 0;
}

.book-connection-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-medium);
}

.book-name {
    font-weight: bold;
    margin-right: 10px;
}

.book-stats {
    color: var(--text-muted);
    font-size: 12px;
}

/* Enhanced Statistics styles */
.stats-section {
    margin-bottom: 30px;
}

.section-title {
    color: var(--primary-gold);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--bg-light), var(--bg-medium));
    border: 2px solid var(--primary-gold);
}

.top-books-list {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 15px;
}

.book-rank-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: var(--bg-medium);
    border-radius: 5px;
    border-left: 3px solid var(--primary-gold);
}

.book-rank-item .rank {
    color: var(--primary-gold);
    font-weight: bold;
    margin-right: 15px;
    font-size: 1.2em;
}

.book-rank-item .book-name {
    flex: 1;
    color: var(--text-light);
    font-weight: 500;
}

.book-rank-item .connection-count {
    color: var(--primary-cyan);
    font-size: 0.9em;
}

/* Chapter indicator instant hover - optimized for 1189 chapters */
.chapter-indicator {
    will-change: stroke-width, opacity;
    pointer-events: all;
    transition: none !important;
}

/* Pure CSS hover for instant feedback */
.chapter-indicator:hover {
    stroke-width: 3 !important;
    opacity: 1 !important;
}

/* Chord Diagram - Clean and simple */
#chord-viz {
    background: transparent;
    min-height: 1000px;
    position: relative;
    z-index: 1;
}

#chord-svg {
    background: transparent;
    display: block;
}

/* Smooth ribbon rendering */
#chord-svg .ribbons path {
    shape-rendering: geometricPrecision;
}

#chord-svg .groups path {
    shape-rendering: geometricPrecision;
}

/* Geographic Map - Proper spacing from controls */
#geomap-viz {
    padding-top: 30px; /* Space between controls and map */
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

#geomap-svg {
    display: block;
    margin-top: 10px; /* Additional buffer */
}

/* Heatmap optimizations */
.heatmap-cell {
    transition: none !important;
    will-change: opacity;
    pointer-events: all;
}

.row-label, .col-label {
    transition: none !important;
    will-change: font-weight, fill;
}

/* Search result clickable items */
.connection-list li:hover {
    background: rgba(0, 206, 209, 0.1);
    border-left: 3px solid var(--primary-cyan);
    padding-left: 7px;
}

/* ===== REDESIGNED STATS PAGE ===== */

/* Stats container with better spacing */
#stats-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Hero stats at top - large and prominent */
.stats-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 50px;
}

.hero-stat-card {
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    padding: 35px 30px;
    border-radius: 15px;
    border: 2px solid var(--primary-gold);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.15);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(255, 215, 0, 0.25);
}

.hero-stat-card h3 {
    color: var(--primary-cyan);
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    font-weight: 600;
}

.hero-stat-value {
    font-size: 3.5em;
    font-weight: bold;
    color: var(--primary-gold);
    line-height: 1;
    margin: 15px 0;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
}

.hero-stat-label {
    color: #888;
    font-size: 0.9em;
    margin-top: 10px;
}

/* Section containers with clear separation */
.stats-section {
    margin-bottom: 50px;
    padding: 30px;
    background: rgba(26, 26, 46, 0.4);
    border-radius: 15px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.section-title {
    color: var(--primary-gold);
    font-size: 1.8em;
    margin-bottom: 25px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 15px;
}

/* Improved stat grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-light);
    padding: 25px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-gold);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(0, 206, 209, 0.03) 100%);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateX(5px);
    border-left-width: 6px;
    box-shadow: 0 5px 15px rgba(0, 206, 209, 0.2);
}

.stat-card h4 {
    color: var(--primary-cyan);
    margin-bottom: 12px;
    font-size: 1em;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 2.2em;
    font-weight: bold;
    color: var(--primary-gold);
    margin: 12px 0;
    line-height: 1.2;
}

.stat-card small {
    color: #888;
    font-size: 0.85em;
    display: block;
    margin-top: 8px;
}

/* Highlighted cards */
.stat-card.highlight {
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-medium) 100%);
    border: 2px solid var(--primary-gold);
    border-left-width: 6px;
}

/* Wide grid for top books */
.stats-grid-wide {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}

/* Top books list styling */
.top-books-list {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 20px;
}

.book-rank-item {
    display: flex;
    align-items: center;
    padding: 15px;
    margin: 8px 0;
    background: var(--bg-medium);
    border-radius: 8px;
    border-left: 4px solid var(--primary-gold);
    transition: all 0.2s ease;
}

.book-rank-item:hover {
    transform: translateX(5px);
    background: rgba(0, 206, 209, 0.1);
    border-left-width: 6px;
}

.book-rank-item .rank {
    color: var(--primary-gold);
    font-weight: bold;
    margin-right: 20px;
    font-size: 1.3em;
    min-width: 40px;
}

.book-rank-item .book-name {
    flex: 1;
    color: var(--text-light);
    font-weight: 600;
    font-size: 1.05em;
}

.book-rank-item .connection-count {
    color: var(--primary-cyan);
    font-size: 0.95em;
    font-weight: 500;
}

/* Stat lists styling */
.stat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stat-list li {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}

.stat-list li:hover {
    background: rgba(0, 206, 209, 0.05);
}

.stat-list li:last-child {
    border-bottom: none;
}

.stat-list .rank {
    color: var(--primary-gold);
    font-weight: bold;
    margin-right: 12px;
    min-width: 30px;
}

.stat-list .book-name {
    flex: 1;
    color: var(--text-light);
    font-weight: 500;
}

.stat-list .count {
    color: var(--primary-cyan);
    font-weight: 600;
}

/* Stats footer */
.stats-footer {
    text-align: center;
    margin-top: 50px;
    padding: 30px;
    border-top: 2px solid rgba(255, 215, 0, 0.2);
    color: #888;
}

.stats-footer strong {
    color: var(--primary-gold);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .stats-hero {
        grid-template-columns: 1fr;
    }

    .hero-stat-value {
        font-size: 2.5em;
    }

    .stats-grid,
    .stats-grid-wide {
        grid-template-columns: 1fr;
    }

    .stats-section {
        padding: 20px 15px;
    }

    .section-title {
        font-size: 1.4em;
    }
}

/* Floating Theme Toggle (Moon Icon) - Minimalist Design */
.floating-theme-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(26, 26, 46, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0.8;
}

.floating-theme-toggle:hover {
    opacity: 1;
    background: rgba(26, 26, 46, 0.9);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
    transform: translateY(-2px);
}

.floating-theme-toggle:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.floating-theme-toggle .theme-icon {
    color: var(--primary-gold);
    transition: all 0.2s ease;
}

.floating-theme-toggle:hover .theme-icon {
    color: var(--primary-cyan);
    filter: drop-shadow(0 0 4px rgba(0, 206, 209, 0.6));
}

/* Compact Stats Page */
.stats-compact {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.summary-item {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-gold);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.summary-value {
    color: var(--primary-gold);
    font-size: 1.5rem;
    font-weight: bold;
}

.stats-row {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.stats-row h3 {
    color: var(--primary-cyan);
    font-size: 1.1rem;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 8px;
}

.testament-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bar-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-label {
    color: var(--text-light);
    font-size: 0.9rem;
    min-width: 80px;
}

.bar-container {
    flex: 1;
    height: 20px;
    background: var(--bg-dark);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.bar-value {
    color: var(--primary-gold);
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: right;
}

.top-books-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.book-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-medium);
    border-radius: 5px;
    transition: background 0.2s ease;
}

.book-item:hover {
    background: rgba(0, 206, 209, 0.1);
}

.book-rank {
    color: var(--primary-gold);
    font-weight: bold;
    font-size: 1.1rem;
    min-width: 25px;
}

.book-title {
    flex: 1;
    color: var(--text-light);
    font-weight: 500;
}

.book-count {
    color: var(--primary-cyan);
    font-size: 0.9rem;
}

.insights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.insight-card {
    background: var(--bg-medium);
    padding: 15px;
    border-radius: 5px;
    border-left: 3px solid var(--primary-cyan);
}

.insight-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.insight-value {
    color: var(--primary-gold);
    font-size: 1.3rem;
    font-weight: bold;
    margin: 5px 0;
}

.insight-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.stats-credit {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 215, 0, 0.1);
}

@media (max-width: 768px) {
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .insights-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================
   Word Explorer Styles
   ============================ */

.word-explorer-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.word-search-box {
    background: var(--bg-medium);
    border: 2px solid var(--primary-gold);
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
}

.word-search-box h2 {
    color: var(--primary-gold);
    margin-bottom: 10px;
    font-size: 2em;
}

.word-search-box .subtitle {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.search-input-group {
    display: flex;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

.word-search-input {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    background: var(--bg-dark);
    color: var(--text-light);
    border: 2px solid var(--primary-cyan);
    border-radius: 8px;
    outline: none;
}

.word-search-input:focus {
    border-color: var(--primary-gold);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.search-button {
    padding: 12px 30px;
    font-size: 16px;
    background: var(--primary-gold);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.search-button:hover {
    background: var(--primary-cyan);
    transform: scale(1.05);
}

.word-results-container {
    min-height: 400px;
}

.popular-words {
    text-align: center;
    padding: 20px;
}

.popular-words h3 {
    color: var(--primary-cyan);
    margin-bottom: 20px;
}

.word-suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.suggestion-word {
    padding: 12px 20px;
    background: var(--bg-medium);
    color: var(--primary-gold);
    border: 2px solid var(--primary-gold);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.suggestion-word:hover {
    background: var(--primary-gold);
    color: var(--bg-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.4);
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.no-results h3 {
    color: var(--accent-red);
    margin-bottom: 10px;
}

.search-summary {
    background: var(--bg-medium);
    border-left: 4px solid var(--primary-gold);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.search-summary h3 {
    color: var(--text-light);
    margin-bottom: 10px;
}

.search-term {
    color: var(--primary-gold);
    font-weight: bold;
}

.result-count {
    color: var(--primary-cyan);
    font-size: 1.1em;
    font-weight: bold;
}

.results-tabs-container {
    margin-bottom: 20px;
}

.results-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--bg-medium);
    padding-bottom: 10px;
}

.results-tabs .tab-button {
    padding: 12px 24px;
    background: var(--bg-medium);
    color: var(--text-muted);
    border: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.results-tabs .tab-button:hover {
    color: var(--primary-cyan);
    border-color: var(--primary-cyan);
}

.results-tabs .tab-button.active {
    background: var(--bg-light);
    color: var(--primary-gold);
    border-color: var(--primary-gold);
}

.tab-content-container {
    background: var(--bg-medium);
    border-radius: 0 8px 8px 8px;
    padding: 30px;
    min-height: 500px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h4 {
    color: var(--primary-cyan);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.tab-content svg {
    display: block;
    margin: 20px auto;
}

.distribution-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--bg-light);
    padding: 15px 30px;
    border-radius: 8px;
    border: 2px solid var(--primary-gold);
    color: var(--text-light);
    font-size: 1.1em;
}

.stat-box strong {
    color: var(--primary-gold);
}

.concordance-controls {
    margin-bottom: 20px;
    text-align: right;
}

.download-button {
    padding: 10px 20px;
    background: var(--accent-green);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.download-button:hover {
    background: var(--primary-gold);
    transform: scale(1.05);
}

.concordance-list {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.concordance-verse {
    background: var(--bg-light);
    border-left: 4px solid var(--primary-cyan);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.concordance-verse:hover {
    border-left-color: var(--primary-gold);
    background: var(--bg-dark);
}

.verse-reference {
    color: var(--primary-gold);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.verse-text {
    color: var(--text-light);
    line-height: 1.6;
}

.verse-text mark {
    background: var(--primary-gold);
    color: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.load-more-button {
    display: block;
    margin: 20px auto;
    padding: 12px 30px;
    background: var(--primary-cyan);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.load-more-button:hover {
    background: var(--primary-gold);
    transform: scale(1.05);
}

/* Scrollbar styling for concordance list */
.concordance-list::-webkit-scrollbar {
    width: 10px;
}

.concordance-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 5px;
}

.concordance-list::-webkit-scrollbar-thumb {
    background: var(--primary-gold);
    border-radius: 5px;
}

.concordance-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-cyan);
}

.error-message {
    text-align: center;
    padding: 40px;
    background: var(--bg-medium);
    border: 2px solid var(--accent-red);
    border-radius: 10px;
    margin: 20px;
}

.error-message h3 {
    color: var(--accent-red);
    margin-bottom: 10px;
}

.error-message p {
    color: var(--text-muted);
}

/* ============================
   Bible Dictionary Modal
   ============================ */

.dictionary-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.dictionary-modal.active {
    display: flex;
}

.dictionary-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.dictionary-modal-content {
    position: relative;
    background: var(--bg-dark);
    border: 3px solid var(--primary-gold);
    border-radius: 15px;
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.dictionary-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid var(--primary-gold);
    background: var(--bg-medium);
    border-radius: 12px 12px 0 0;
}

.dictionary-modal-header h2 {
    color: var(--primary-gold);
    margin: 0;
    font-size: 1.8em;
}

.dictionary-modal-close {
    background: transparent;
    border: 2px solid var(--primary-cyan);
    color: var(--primary-cyan);
    font-size: 2em;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0;
}

.dictionary-modal-close:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
    transform: rotate(90deg);
}

.dictionary-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    color: var(--text-light);
    line-height: 1.8;
}

.dictionary-modal-body::-webkit-scrollbar {
    width: 12px;
}

.dictionary-modal-body::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 6px;
}

.dictionary-modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-gold);
    border-radius: 6px;
}

.dictionary-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-cyan);
}

.dictionary-entry {
    font-size: 1.1em;
}

.dictionary-entry p {
    margin-bottom: 15px;
}

.dictionary-entry h3, .dictionary-entry h4 {
    color: var(--primary-cyan);
    margin-top: 20px;
    margin-bottom: 10px;
}

.dictionary-loading {
    text-align: center;
    padding: 40px;
    color: var(--primary-cyan);
    font-size: 1.2em;
}

.dictionary-error {
    text-align: center;
    padding: 40px;
}

.dictionary-error h3 {
    color: var(--accent-red);
    margin-bottom: 15px;
}

.dictionary-error p {
    color: var(--text-muted);
}

.dictionary-not-found {
    text-align: center;
    padding: 40px;
}

.dictionary-not-found h3 {
    color: var(--primary-cyan);
    margin-bottom: 15px;
}

.dictionary-not-found p {
    color: var(--text-muted);
    margin-bottom: 10px;
}

.dictionary-modal-footer {
    padding: 15px 30px;
    border-top: 2px solid var(--bg-medium);
    text-align: center;
    background: var(--bg-medium);
    border-radius: 0 0 12px 12px;
}

.dictionary-modal-footer small {
    color: var(--text-muted);
    font-size: 0.9em;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .dictionary-modal-content {
        max-width: 95%;
        max-height: 90vh;
    }

    .dictionary-modal-header {
        padding: 15px 20px;
    }

    .dictionary-modal-header h2 {
        font-size: 1.4em;
    }

    .dictionary-modal-close {
        width: 40px;
        height: 40px;
        font-size: 1.5em;
    }

    .dictionary-modal-body {
        padding: 20px;
        font-size: 0.95em;
    }
}

/* Clickable dictionary links in tooltips/visualizations */
.dict-link {
    color: var(--primary-gold);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: all 0.2s ease;
}

.dict-link:hover {
    color: var(--primary-cyan);
    text-shadow: 0 0 5px rgba(0, 206, 209, 0.5);
}
