/* Paper Theme Colors */
:root {
    --paper-bg: #f2e6d9;
    --paper-text: #352b25;
    --paper-secondary: #5c4f45;
    --paper-accent: #7d5a3c;
    --paper-card-bg: #faf6f1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f0f0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* When in presentation mode, lock body scrolling and hide all UI chrome */
body.presentation-mode {
    overflow: hidden;
    position: fixed;
    height: 100vh;
}

/* Hide all UI elements during presentation - only show lyrics */
body.presentation-mode #library-view,
body.presentation-mode #content-area {
    display: none !important;
}

/* Content Area - Full width, paper background */
#content-area {
    width: 100%;
    min-height: 100vh;
    background: var(--paper-bg);
    padding: 20px;
    box-sizing: border-box;
}

#content-area > * {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.content-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(125, 90, 60, 0.15);
}

.back-btn {
    background: none;
    border: none;
    color: var(--paper-accent);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(125, 90, 60, 0.08);
}

#content-title {
    margin: 0;
    font-family: 'Lora', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--paper-text);
}

/* Paper Card Preview - Minimal, content-focused */
.paper-card {
    margin: 0 auto 100px auto;
    max-width: 100%;
    min-height: 300px;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

.preview-content {
    padding: 24px;
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--paper-text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.preview-placeholder {
    color: var(--paper-secondary);
    font-style: italic;
    text-align: center;
    padding: 40px;
}

.preview-line {
    margin-bottom: 8px;
}

.preview-line.verse-number {
    font-family: 'Lora', Georgia, serif;
    font-weight: 600;
    color: var(--paper-accent);
    font-size: 0.95rem;
    margin-top: 20px;
    margin-bottom: 4px;
}

.preview-line.verse-text {
    margin-left: 0;
}

/* Edit Container */
.edit-container {
    margin: 0 auto 80px auto;
    max-width: 100%;
}

.edit-container textarea {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.6;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    box-sizing: border-box;
}

.edit-container textarea:focus {
    outline: none;
    border-color: #4a6da7;
    box-shadow: 0 0 0 3px rgba(74, 109, 167, 0.1);
}

/* Bottom Toolbar - Floating buttons */
.content-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 12px;
    z-index: 100;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 24px;
    background: var(--paper-card-bg);
    color: var(--paper-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(53, 43, 37, 0.15);
}

.toolbar-btn:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(53, 43, 37, 0.2);
    transform: translateY(-1px);
}

.toolbar-btn i {
    font-size: 1rem;
    color: var(--paper-secondary);
}

.toolbar-btn-primary {
    background: var(--paper-accent);
    color: white;
}

.toolbar-btn-primary:hover {
    background: #6a4a30;
}

.toolbar-btn-primary i {
    color: white;
}

.toolbar-btn.active {
    background: var(--paper-accent);
    color: white;
}

.toolbar-btn.active i {
    color: white;
}

/* Line Length Presets Menu */
.presets-menu {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px;
    z-index: 101;
    min-width: 200px;
}

.presets-menu-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    padding: 4px 8px 8px;
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
}

.preset-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    font-size: 0.95rem;
    color: #333;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.preset-option:hover {
    background: #f0f4f8;
}

.preset-option.selected {
    background: #e8f0fe;
    color: #4a6da7;
}

.preset-option i {
    width: 20px;
    color: #666;
}

.preset-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    margin-top: 8px;
}

.preset-custom label {
    font-size: 0.9rem;
    color: #666;
}

.preset-custom input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.preset-apply {
    padding: 6px 12px;
    background: #4a6da7;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.preset-apply:hover {
    background: #3a5a97;
}

/* Mobile adjustments */
@media screen and (max-width: 768px) {
    .content-toolbar {
        bottom: 16px;
        gap: 8px;
    }

    .toolbar-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .toolbar-btn span {
        display: none;
    }

    .toolbar-btn i {
        font-size: 1.1rem;
    }

    .paper-card {
        margin: 0 0 90px 0;
        max-height: calc(100vh - 160px);
    }

    .preview-content {
        padding: 16px;
        font-size: 1rem;
    }

    .presets-menu {
        left: 10px;
        right: 10px;
        transform: none;
        bottom: 80px;
    }

    #content-area {
        padding: 16px;
    }
}

.input-container {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 20px;
    max-width: 100%;
}

#lyrics-input {
    width: 300px;
    height: 100px;
    margin-bottom: 10px;
    padding: 10px;
    font-size: 1rem;
    border-radius: 5px;
    border: 1px solid #ccc;
}

#submit-lyrics {
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 5px;
    border: none;
    background-color: #333;
    color: white;
    cursor: pointer;
}

.lyrics-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 80%;
    display: none;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100vh;
    overflow: hidden;
}

.lyrics-chunk {
    font-size: 2rem;
    line-height: 1.4;
    color: #333;
    opacity: 0.2;
    transition: opacity 0.4s ease, transform 0.5s ease, top 0.5s ease;
    position: absolute;
    width: 100%;
    text-align: center;
    padding: 0 20px;
    box-sizing: border-box;
    max-height: 8rem;
    overflow: hidden;
}

.lyrics-chunk.active {
    opacity: 1;
    transform: translateY(-50%);
    font-weight: bold;
}

/* Previous and next chunks above/below the active chunk */
.lyrics-chunk.previous {
    opacity: 0.3;
    transform: translateY(-50%);
}

.lyrics-chunk.next {
    opacity: 0.3;
    transform: translateY(-50%);
}

/* Bible Card Styles */
.card-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.bible-card {
    background-color: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 300px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.bible-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.bible-icon {
    font-size: 24px;
    color: #3a5a97;
}

.bible-card-content h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.bible-card-content p {
    margin: 5px 0 0;
    color: #666;
    font-size: 14px;
}

/* Bible Selector Styles */
.bible-selector {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 300px;
    margin-top: 20px;
    display: none;
}

.bible-selector.active {
    display: block;
}

.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-container input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 0 0 5px 5px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.search-result-item {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

.chapter-selector {
    margin-top: 15px;
    display: none;
}

.chapter-selector.active {
    display: block;
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.chapter-number {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    background-color: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.chapter-number:hover {
    background-color: #e0e0e0;
}

.chapter-number.selected {
    background-color: #3a5a97;
    color: white;
}

.load-button {
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    background-color: #3a5a97;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.load-button:hover {
    background-color: #2a4a87;
}

.load-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Touch Controls and Mobile Styles */

/* Touch indicator for swipe feedback */
.touch-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.touch-indicator.fade-out {
    opacity: 0;
}

/* Ripple effect for taps */
.ripple-effect {
    position: fixed;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 9998;
    animation: ripple-animation 0.6s ease-out;
}

@keyframes ripple-animation {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Mobile-specific styles */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    /* Adjust input container for mobile */
    .input-container {
        width: 100%;
        max-width: 100%;
        padding: 15px;
        box-sizing: border-box;
    }

    #lyrics-input {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 120px;
    }

    #submit-lyrics {
        width: 100%;
        padding: 12px 20px;
        font-size: 1.1rem;
        margin-top: 10px;
    }

    .instructions {
        font-size: 14px;
    }

    .instructions ul {
        padding-left: 20px;
    }

    /* Bible card adjustments */
    .card-container {
        width: 100%;
        justify-content: center;
    }

    .bible-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .bible-selector {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Larger text for mobile in presentation mode */
    .lyrics-chunk {
        font-size: 1.5rem;
        line-height: 1.4;
        padding: 0 15px;
        max-height: 6rem;
    }

    .lyrics-chunk.active {
        font-size: 2rem;
        max-height: 8rem;
    }

    /* Ensure container fills screen on mobile */
    .lyrics-container {
        width: 100%;
    }

    /* Format controls responsive */
    #format-controls {
        flex-wrap: wrap;
    }

    #format-controls label {
        width: 100%;
        margin-bottom: 5px;
    }

    #line-length-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Chapter grid for mobile */
    .chapter-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .chapter-number {
        height: 44px; /* Larger touch target */
        font-size: 16px;
    }
}

/* Tablet-specific styles */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .lyrics-chunk {
        font-size: 2.5rem;
        line-height: 1.4;
        max-height: 10rem;
    }

    .lyrics-chunk.active {
        font-size: 3rem;
        max-height: 12rem;
    }

    .lyrics-container {
        width: 90%;
    }

    .bible-card {
        width: 350px;
    }

    .bible-selector {
        width: 350px;
    }
}

/* Prevent text selection during swipe gestures */
.lyrics-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: pan-y; /* Allow vertical scrolling but handle horizontal gestures */
}

/* Improve touch target sizes */
@media (hover: none) and (pointer: coarse) {
    /* This targets touch devices */
    .chapter-number,
    .search-result-item,
    #submit-lyrics,
    .load-button,
    .bible-card {
        min-height: 44px; /* Apple's recommended touch target size */
    }

    .search-container input,
    #book-search {
        font-size: 16px; /* Prevents automatic zoom on iOS */
    }
}

/* Visual tap zones indicator (optional, shows on long press) */
.lyrics-container::before,
.lyrics-container::after {
    content: '';
    position: fixed;
    top: 0;
    bottom: 0;
    width: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.lyrics-container::before {
    left: 0;
    background: linear-gradient(to right, rgba(74, 109, 167, 0.1), transparent);
}

.lyrics-container::after {
    right: 0;
    background: linear-gradient(to left, rgba(74, 109, 167, 0.1), transparent);
}

/* Fullscreen styles for mobile */
.lyrics-container:fullscreen,
.lyrics-container:-webkit-full-screen,
.lyrics-container:-moz-full-screen {
    background-color: #f0f0f0;
}

