/**
 * UK Catholic Readings API - Styles
 * Version 2.3.0
 */

/* Container */
.ukcr-api-container {
    font-family: 'Goudy Bookletter 1911', Georgia, 'Times New Roman', serif;
    max-width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Scrollable content area - THIS IS THE KEY FIX */
.ukcr-api-content {
    padding: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Ensure scroll works independently of background */
    position: relative;
    z-index: 2;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Better touch scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    /* Prevent scroll chaining to parent/window */
    overscroll-behavior: contain;
}

/* Custom scrollbar styling */
.ukcr-api-content::-webkit-scrollbar {
    width: 8px;
}

.ukcr-api-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ukcr-api-content::-webkit-scrollbar-thumb {
    background: #c41e3a;
    border-radius: 4px;
}

.ukcr-api-content::-webkit-scrollbar-thumb:hover {
    background: #a01830;
}

/* Firefox scrollbar */
.ukcr-api-content {
    scrollbar-width: thin;
    scrollbar-color: #c41e3a #f1f1f1;
}

/* Header section */
.ukcr-api-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: linear-gradient(135deg, #c41e3a 0%, #8b0000 100%);
    color: white;
}

.ukcr-api-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: normal;
}

/* Date header inside content */
.ukcr-api-date-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #c41e3a;
}

.ukcr-api-date {
    color: #c41e3a;
    margin: 0;
    font-size: 1.4em;
}

/* Individual readings */
.ukcr-api-reading {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
}

.ukcr-api-reading:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.ukcr-api-reading-title {
    color: #c41e3a;
    font-size: 1.2em;
    margin: 0 0 10px 0;
    font-weight: bold;
}

.ukcr-api-citation {
    color: #666;
    font-style: italic;
    margin: 0 0 15px 0;
    font-size: 0.95em;
}

.ukcr-api-text {
    line-height: 1.8;
    color: #333;
}

.ukcr-api-text p {
    margin: 0 0 12px 0;
}

.ukcr-api-text p:last-child {
    margin-bottom: 0;
}

/* Drop caps - missal style */
.ukcr-drop-cap {
    color: #c41e3a;
    font-size: 1.4em;
    font-weight: bold;
}

/* Psalm styling */
.ukcr-api-reading[data-type="psalm"] .ukcr-api-text {
    padding-left: 20px;
    border-left: 3px solid #c41e3a;
}

/* Gospel acclamation */
.ukcr-api-reading[data-type="acclamation"] {
    background: #fef9e7;
    padding: 15px;
    border-radius: 5px;
    margin-left: -15px;
    margin-right: -15px;
    padding-left: 15px;
    padding-right: 15px;
}

/* Gospel styling */
.ukcr-api-reading[data-type="gospel"] .ukcr-api-reading-title {
    color: #c41e3a;
}

/* Footer */
.ukcr-api-footer {
    padding: 10px 25px;
    background: #f5f5f5;
    text-align: center;
    color: #888;
    border-top: 1px solid #e0e0e0;
}

.ukcr-api-footer a {
    color: #c41e3a;
    text-decoration: none;
}

.ukcr-api-footer a:hover {
    text-decoration: underline;
}

/* Loading state */
.ukcr-api-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.ukcr-api-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #c41e3a;
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: ukcr-spin 1s linear infinite;
}

@keyframes ukcr-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state */
.ukcr-api-error {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.ukcr-api-error a {
    color: #c41e3a;
    text-decoration: none;
}

/* PDF Button */
.ukcr-pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    color: white;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.ukcr-pdf-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ukcr-pdf-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ukcr-pdf-btn.generating {
    background: rgba(255, 255, 255, 0.1);
}

/* Compact style variant */
.ukcr-api-container[data-style="compact"] .ukcr-api-content {
    padding: 15px;
}

.ukcr-api-container[data-style="compact"] .ukcr-api-reading {
    margin-bottom: 20px;
    padding-bottom: 15px;
}

.ukcr-api-container[data-style="compact"] .ukcr-api-text {
    font-size: 0.95em;
    line-height: 1.6;
}

/* Responsive - larger, easier-to-read text on phones */
@media (max-width: 600px) {
    .ukcr-api-content {
        padding: 18px 16px;
    }
    
    .ukcr-api-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    /* Title of the day */
    .ukcr-api-date {
        font-size: 1.6rem;
        line-height: 1.3;
    }
    
    .ukcr-api-reading-title {
        font-size: 1.35rem;
    }
    
    .ukcr-api-citation {
        font-size: 1.05rem;
    }
    
    /* Reading text - at least 18px whatever the theme's base size */
    .ukcr-api-text,
    .ukcr-api-container[data-style="compact"] .ukcr-api-text {
        font-size: max(18px, 1.15rem);
        line-height: 1.75;
    }
    
    .ukcr-api-text p {
        margin-bottom: 14px;
    }
    
    /* Keep the red capitals in proportion with the larger text */
    .ukcr-drop-cap {
        font-size: 1.3em;
    }
    
    .ukcr-api-reading[data-type="psalm"] .ukcr-api-text {
        padding-left: 14px;
    }
    
    .ukcr-api-footer {
        font-size: 0.95rem;
    }
}
