/* Ensure font-display swap for any web fonts to prevent layout shift */
@font-face {
    font-display: swap;
}

/* Modern Typography inspired by Stripe */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-size: 16px; /* 12pt minimum for usability */
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #fafbfc;
    /* Prevent layout shift during page load */
    min-height: 100vh;
}

/* Simplified color palette - consistent indigo theme */
:root {
    --primary-color: #4338ca;     /* Even darker indigo for WCAG AAA compliance (4.67:1 ratio on white) */
    --secondary-color: #6d28d9;   /* Darker purple variant for better contrast */
    --accent-color: #0891b2;      /* Darker cyan for better accessibility */
    --success-color: #047857;     /* Darker green for WCAG AA compliance */
    --warning-color: #b45309;     /* Darker amber for better contrast */
    --danger-color: #b91c1c;      /* Darker red for better contrast */
    --text-primary: #111827;      /* Dark gray - excellent contrast */
    --text-secondary: #374151;    /* Darker gray for better contrast (was #4b5563) */
    --text-muted: #4b5563;        /* Darker muted text for better contrast (was #6b7280) */
    --border-color: #e5e7eb;      /* Light border */
    --surface: #ffffff;           /* White surface */
    --surface-hover: #f9fafb;     /* Light hover */
}

/* Card styling with subtle shadows */
.service-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.service-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px 0 rgba(0, 0, 0, 0.1), 0 4px 6px 0 rgba(0, 0, 0, 0.05);
    border-color: var(--primary-color);
}

/* Button styling - consistent color theme */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 12px 24px;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-primary, .btn-success, .btn-info {
    background: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
    /* Ensure sufficient contrast ratio for accessibility (WCAG AA) */
    font-weight: 600;
}

.btn-primary:hover, .btn-success:hover, .btn-info:hover,
.btn-primary:focus, .btn-success:focus, .btn-info:focus {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-outline-primary, .btn-outline-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover, .btn-outline-secondary:hover,
.btn-outline-primary:focus, .btn-outline-secondary:focus {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

/* Navigation styling */
.navbar {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    /* Reserve minimum height to prevent layout shift */
    min-height: 56px;
}

.navbar-brand {
    font-weight: 600;
    color: var(--text-primary) !important;
    font-size: 1.25rem;
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 8px 16px !important;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--primary-color) !important;
    background: var(--surface-hover);
}

/* Typography improvements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

h5 {
    font-size: 1.125rem;
    font-weight: 600;
}

h6 {
    font-size: 1rem;
    font-weight: 600;
}

.display-4 {
    font-weight: 700;
    letter-spacing: -0.05em;
}

.lead {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Consistent small text - minimum 12pt (0.875rem = 14px which is acceptable for secondary text) */
.small-text {
    font-size: 0.875rem;
}

/* Ensure all text meets minimum 12pt for body text */
p, .card-text, .form-text {
    font-size: 1rem; /* 16px = 12pt */
    line-height: 1.5;
}

/* Card title and header sizing - make h2/h3 in specific contexts same size as h4/h5/h6 for visual consistency */
h2.card-title,
.card-header h2,
.card-body h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

h2.mb-2,
h2.text-muted,
h2.mb-3,
h3.mb-3 {
    font-size: 1rem;
    font-weight: 600;
}

/* Form styling */
.form-control {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--surface);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-control:hover {
    border-color: var(--primary-color);
}

/* Alert styling */
.alert {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.alert-danger {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger-color);
    border-color: rgba(220, 38, 38, 0.2);
}

.alert-dismissible .btn-close {
    filter: none;
    opacity: 0.7;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* Loading and utility styles */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

.message-content {
    background-color: var(--surface-hover);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

/* Ministry recommendation content styling */
.interest-summary {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.interest-summary strong {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1rem;
}

.interest-summary div {
    margin-top: 0.5rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.service-categories {
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.service-categories strong {
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 1rem;
}

.service-categories div {
    margin-top: 0.75rem;
    color: var(--text-primary);
    line-height: 1.5;
    padding-left: 0.5rem;
}

.service-categories div:first-of-type {
    margin-top: 0.5rem;
}

/* Footer styling */
footer {
    margin-top: auto;
    background: var(--surface) !important;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    /* Reserve minimum height to prevent layout shift */
    min-height: 80px;
}

/* Card improvements */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    background: var(--surface);
    /* Prevent layout shift by using content-visibility */
    contain: layout style paint;
}

.card-header {
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0 !important;
}

/* List group items */
.list-group-item {
    border-color: var(--border-color);
    background: var(--surface);
}

.list-group-item:hover {
    background: var(--surface-hover);
}

.list-group-item.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Spinner colors */
.spinner-border {
    color: var(--primary-color);
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: var(--primary-color) !important;
}

.text-info {
    color: var(--primary-color) !important;
}

/* Accessibility - Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Focus indicators for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Mobile-first responsive design */
@media (max-width: 576px) {
    /* Small phones */
    .container {
        padding: 0.5rem 0.75rem;
    }

    main#main-content {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
        margin-bottom: 0.5rem !important;
    }

    .lead {
        font-size: 0.9rem;
    }

    h5 {
        font-size: 1rem;
    }

    h6 {
        font-size: 0.9rem;
    }

    .service-card {
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 1rem !important;
    }

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

    .btn:not(.flex-grow-1):not(.w-100) {
        width: auto;
    }

    .fa-3x {
        font-size: 2rem !important;
    }

    .fa-2x {
        font-size: 1.5rem !important;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .nav-link {
        padding: 6px 12px !important;
        font-size: 0.9rem;
    }

    /* Reduce vertical spacing on mobile */
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .py-3 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    /* Compact form controls on mobile */
    .form-select,
    .form-control {
        font-size: 0.95rem;
        padding: 10px 12px;
    }

    textarea.form-control {
        min-height: 100px;
    }

    .form-label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .form-text {
        font-size: 0.75rem;
    }

    /* Home page mobile optimizations - ultra compact to fit all 3 cards */
    .home-header {
        margin-bottom: 0.5rem !important;
    }

    .home-header h1 {
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem !important;
        line-height: 1.3 !important;
    }

    .home-header .fas.fa-book-open {
        font-size: 1rem;
        margin-right: 0.25rem !important;
    }

    .home-header p {
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
    }

    .home-cards {
        margin-top: 0 !important;
    }

    .home-cards .service-card {
        margin-bottom: 0.5rem !important;
    }

    .home-cards .card-body {
        padding: 0.75rem 0.5rem !important;
    }

    .home-cards .card-title {
        font-size: 0.95rem !important;
        margin-bottom: 0.25rem !important;
    }

    .home-cards .card-text {
        font-size: 0.75rem !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.3;
    }

    .home-cards .mb-2 {
        margin-bottom: 0.25rem !important;
    }

    .home-cards .mb-3 {
        margin-bottom: 0.25rem !important;
    }

    .home-cards .btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.8rem !important;
    }

    .home-cards .fa-2x {
        font-size: 1.25rem !important;
    }

    .home-cards .row.g-3 {
        --bs-gutter-y: 0.5rem;
    }
}

@media (max-width: 768px) {
    /* Tablets and small laptops */
    .container {
        padding: 0 1rem;
    }

    .service-card {
        margin-bottom: 1.5rem;
    }

    .row.g-4 {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    .col-md-4 {
        margin-bottom: 1rem;
    }
}

@media (max-width: 992px) {
    /* Medium devices */
    .col-lg-8, .col-lg-10 {
        max-width: 100%;
        flex: 0 0 100%;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .service-card:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }

    .nav-link:hover {
        background: transparent;
    }
}

/* Improve form usability on mobile */
@media (max-width: 768px) {
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 14px;
    }

    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    textarea.form-control {
        min-height: 100px;
    }

    /* Compact main content padding */
    main#main-content {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* Bootstrap override for consistent colors */
.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-success {
    background-color: var(--primary-color) !important;
}

.bg-info {
    background-color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

/* Badge styling */
.badge {
    border-radius: 6px;
    font-weight: 500;
}

.badge.bg-success, .badge.bg-primary, .badge.bg-info {
    background-color: var(--primary-color) !important;
}

/* Input group styling */
.input-group .btn {
    border-color: var(--border-color);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Bible books section styling */
.book-btn {
    transition: all 0.15s ease;
    border-radius: 4px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.compact-btn {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
}

/* Form element height consistency - ensures all inputs and buttons align perfectly */
.form-select-sm,
.btn-sm,
.form-control-sm:not(textarea) {
    height: calc(1.8rem + 1rem + 2px);
    line-height: 1.8;
    padding: 0.5rem 0.75rem;
}

/* Ensure buttons don't get extra line-height issues */
.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Insights list styling */
.insight-item {
    padding-left: 0.5rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.insight-item:hover {
    border-left-color: var(--primary-color);
    background-color: var(--surface-hover);
}

.insight-item p {
    line-height: 1.6;
    color: var(--text-primary);
}

/* Insights selector mobile optimization */
@media (max-width: 768px) {
    .insights-selector .card-body,
    .ministry-form .card-body,
    .qa-form .card-body {
        padding: 0.75rem !important;
    }

    .insights-selector .row.g-2 {
        --bs-gutter-y: 0.5rem;
    }

    .insights-selector .form-label,
    .ministry-form .form-label,
    .qa-form .form-label {
        margin-bottom: 0.25rem !important;
        font-size: 0.8rem;
    }

    .insights-selector .form-select-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        height: calc(1.8rem + 1rem + 2px);
    }

    .insights-selector .btn-sm,
    .ministry-form .btn-sm,
    .qa-form .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        height: calc(1.8rem + 1rem + 2px);
    }

    .ministry-form .form-control-sm,
    .qa-form .form-control-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .ministry-form textarea.form-control-sm,
    .qa-form textarea.form-control-sm {
        min-height: 80px;
    }

    /* Compact card headers */
    .card-header {
        padding: 0.5rem 0.75rem !important;
    }

    .card-header h2 {
        font-size: 1rem !important;
    }

    /* Mobile insight items */
    .insight-item {
        padding-left: 0.4rem;
        margin-bottom: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

.testament-separator {
    border-top: 2px solid var(--border-color);
    margin: 0.5rem 0;
    padding-top: 0.5rem;
    position: relative;
}

.testament-separator::before {
    content: attr(data-testament);
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    padding: 0 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
