/* Rich Text and Stream Field Content Styling for Bootstrap 5 */
/* This CSS ensures Wagtail rich text and stream field content looks great with Bootstrap 5 */

/* ========================================
   Rich Text Container Styling
   ======================================== */

.content-body,
.rich-text,
[class*="richtext"] {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 1.7;
    color: #1a1a1a; /* Darker color for better accessibility (WCAG AAA) */
}

/* Lead text styling for intro paragraphs */
.content-body.lead {
    font-size: 1.25rem;
    font-weight: 300;
}

/* ========================================
   Typography - Headings (Override theme variables)
   ======================================== */

/* Force light theme heading colors - override any theme variables */
.content-body h1,
.rich-text h1,
.content-body h2,
.rich-text h2,
.content-body h3,
.rich-text h3,
.content-body h4,
.rich-text h4,
.content-body h5,
.rich-text h5,
.content-body h6,
.rich-text h6 {
    color: #1a1a1a !important; /* Force dark text on light background */
}

.content-body h1,
.rich-text h1 {
    font-size: 2.5rem;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    border-bottom: 3px solid #0d6efd;
    padding-bottom: 0.75rem;
}

.content-body h2,
.rich-text h2 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1.25rem;
    font-weight: 700;
    position: relative;
    padding-left: 1rem;
}

.content-body h2:before,
.rich-text h2:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 100%;
    background-color: #0d6efd;
}

.content-body h3,
.rich-text h3 {
    font-size: 1.75rem;
    margin-top: 1.75rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.content-body h4,
.rich-text h4 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.875rem;
    font-weight: 600;
}

.content-body h5,
.rich-text h5 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.content-body h6,
.rich-text h6 {
    font-size: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* First heading should have no top margin */
.content-body > h1:first-child,
.content-body > h2:first-child,
.content-body > h3:first-child,
.content-body > h4:first-child,
.content-body > h5:first-child,
.content-body > h6:first-child {
    margin-top: 0;
}

/* ========================================
   Typography - Paragraphs
   ======================================== */

.content-body p,
.rich-text p {
    margin-bottom: 1.25rem;
    line-height: 1.8; /* Increased line height for better readability */
    font-size: 1.0625rem;
    color: #1a1a1a; /* Ensure paragraphs have good contrast */
}

.content-body p:last-child,
.rich-text p:last-child {
    margin-bottom: 0;
}

/* ========================================
   Typography - Lists
   ======================================== */

.content-body ul,
.content-body ol,
.rich-text ul,
.rich-text ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.content-body ul li,
.content-body ol li,
.rich-text ul li,
.rich-text ol li {
    margin-bottom: 0.5rem;
    line-height: 1.8; /* Better line height for readability */
    color: #1a1a1a; /* Ensure list items have good contrast */
}

/* Custom bullet points for unordered lists */
.content-body ul,
.rich-text ul {
    list-style: none;
    padding-left: 0;
}

.content-body ul li,
.rich-text ul li {
    position: relative;
    padding-left: 2rem;
}

.content-body ul li:before,
.rich-text ul li:before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0.6rem;
    width: 8px;
    height: 8px;
    background-color: #0056b3; /* Darker blue for better visibility */
    border-radius: 50%;
}

/* Nested lists */
.content-body ul ul,
.content-body ol ul,
.rich-text ul ul,
.rich-text ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.content-body ul ul li:before,
.rich-text ul ul li:before {
    background-color: transparent;
    border: 2px solid #0d6efd;
}

/* Ordered lists */
.content-body ol,
.rich-text ol {
    counter-reset: item;
    list-style: none;
    padding-left: 0;
}

.content-body ol li,
.rich-text ol li {
    counter-increment: item;
    position: relative;
    padding-left: 2.5rem;
}

.content-body ol li:before,
.rich-text ol li:before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 0;
    background-color: #0056b3; /* Darker blue for better contrast */
    color: white;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700; /* Bolder for better readability */
    font-size: 0.875rem;
}

/* ========================================
   Typography - Blockquotes
   ======================================== */

.content-body blockquote,
.rich-text blockquote {
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: #f1f3f5; /* Slightly darker background */
    border-left: 5px solid #0d6efd;
    font-style: italic;
    position: relative;
    font-size: 1.125rem;
    color: #1a1a1a; /* Ensure blockquotes have good contrast */
}

.content-body blockquote:before,
.rich-text blockquote:before {
    content: '\201C';
    font-size: 4rem;
    position: absolute;
    top: -0.5rem;
    left: 1rem;
    color: #0d6efd;
    opacity: 0.3;
    font-family: Georgia, serif;
}

.content-body blockquote p:last-child,
.rich-text blockquote p:last-child {
    margin-bottom: 0;
}

/* ========================================
   Typography - Links
   ======================================== */

.content-body a,
.rich-text a {
    color: #0056b3; /* Darker blue for better contrast on white background */
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: all 0.3s ease;
    font-weight: 500; /* Slightly bolder for better readability */
}

.content-body a:hover,
.rich-text a:hover {
    color: #003d82; /* Even darker on hover */
    text-decoration: underline; /* Keep underline on hover for accessibility */
}

/* ========================================
   Typography - Code
   ======================================== */

.content-body code,
.rich-text code {
    background-color: #f1f3f5; /* Slightly darker background */
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: #c2185b; /* Darker pink for better contrast (WCAG AA) */
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-weight: 500; /* Slightly bolder */
}

.content-body pre,
.rich-text pre {
    background-color: #212529;
    color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.content-body pre code,
.rich-text pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

/* ========================================
   Typography - Tables
   ======================================== */

.content-body table,
.rich-text table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    background-color: transparent;
}

.content-body table thead,
.rich-text table thead {
    background-color: #212529;
    color: white;
}

.content-body table th,
.content-body table td,
.rich-text table th,
.rich-text table td {
    padding: 0.75rem;
    vertical-align: top;
    border-top: 1px solid #dee2e6;
}

.content-body table thead th,
.rich-text table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #dee2e6;
    border-top: 0;
}

.content-body table tbody tr:hover,
.rich-text table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.075);
}

/* ========================================
   Typography - Horizontal Rules
   ======================================== */

.content-body hr,
.rich-text hr {
    margin: 3rem 0;
    border: 0;
    border-top: 3px solid #dee2e6;
    position: relative;
}

.content-body hr:after,
.rich-text hr:after {
    content: '§';
    position: absolute;
    top: -1rem;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 0 1rem;
    color: #495057; /* Darker gray for better contrast (WCAG AA compliant) */
    font-size: 1.5rem;
}

/* ========================================
   Images and Media
   ======================================== */

.content-body img,
.rich-text img {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Image alignment classes */
.content-body .richtext-image.left,
.rich-text .richtext-image.left {
    float: left;
    margin-right: 1.5rem;
    margin-bottom: 1rem;
    max-width: 50%;
}

.content-body .richtext-image.right,
.rich-text .richtext-image.right {
    float: right;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    max-width: 50%;
}

.content-body .richtext-image.full-width,
.rich-text .richtext-image.full-width {
    width: 100%;
    margin: 2rem 0;
}

/* ========================================
   Embeds
   ======================================== */

.content-body .responsive-object,
.rich-text .responsive-object {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    margin: 2rem 0;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.content-body .responsive-object iframe,
.rich-text .responsive-object iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ========================================
   Stream Field Block Styling
   ======================================== */

/* Paragraph blocks */
.block-paragraph {
    margin-bottom: 1.5rem;
}

/* Heading blocks */
.block-heading {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* Image blocks */
.block-image {
    margin: 2rem 0;
    text-align: center;
}

.block-image img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.block-image figcaption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #495057; /* Darker gray for better contrast (WCAG AA compliant) */
    font-style: italic;
}

/* Embed blocks */
.block-embed {
    margin: 2rem 0;
}

/* ========================================
   Custom Content Blocks
   ======================================== */

/* Process step blocks */
.block-process_step {
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.25rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #0d6efd;
}

.block-process_step .step-title {
    background-color: #f8f9fa;
    padding: 0.75rem 1.25rem;
    margin-bottom: 0;
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.block-process_step .step-description {
    padding: 1.25rem;
}

/* Benefit blocks */
.block-benefit {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid #b8daff;
    border-radius: 0.25rem;
    background-color: #cfe2ff;
    color: #084298;
    border-left-width: 4px;
}

.block-benefit .benefit-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.block-benefit .benefit-description {
    margin-bottom: 0;
}

/* ========================================
   Utility Classes
   ======================================== */

/* Clear floats */
.content-body::after,
.rich-text::after {
    content: "";
    display: table;
    clear: both;
}

/* Spacing utilities */
.content-body > *:first-child,
.rich-text > *:first-child {
    margin-top: 0 !important;
}

.content-body > *:last-child,
.rich-text > *:last-child {
    margin-bottom: 0 !important;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    /* Reduce heading sizes on mobile */
    .content-body h1,
    .rich-text h1 {
        font-size: 2rem;
    }
    
    .content-body h2,
    .rich-text h2 {
        font-size: 1.75rem;
    }
    
    .content-body h3,
    .rich-text h3 {
        font-size: 1.5rem;
    }
    
    /* Adjust image floats on mobile */
    .content-body .richtext-image.left,
    .content-body .richtext-image.right,
    .rich-text .richtext-image.left,
    .rich-text .richtext-image.right {
        float: none;
        margin: 1.5rem 0;
        max-width: 100%;
    }
    
    /* Reduce blockquote font size */
    .content-body blockquote,
    .rich-text blockquote {
        font-size: 1rem;
        padding: 1rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .content-body img,
    .rich-text img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    .content-body h1,
    .content-body h2,
    .content-body h3,
    .content-body h4,
    .content-body h5,
    .content-body h6,
    .rich-text h1,
    .rich-text h2,
    .rich-text h3,
    .rich-text h4,
    .rich-text h5,
    .rich-text h6 {
        page-break-after: avoid;
    }
}

/* ========================================
   Light Theme Enforcement - Override Any Dark Theme
   ======================================== */

/* Force light theme for all content regardless of theme variables */
body .content-body,
body .rich-text,
[data-theme="dark"] .content-body,
[data-theme="dark"] .rich-text {
    color: #1a1a1a !important;
    background-color: transparent !important;
}

/* Force light theme headings */
body .content-body h1,
body .content-body h2,
body .content-body h3,
body .content-body h4,
body .content-body h5,
body .content-body h6,
body .rich-text h1,
body .rich-text h2,
body .rich-text h3,
body .rich-text h4,
body .rich-text h5,
body .rich-text h6,
[data-theme="dark"] .content-body h1,
[data-theme="dark"] .content-body h2,
[data-theme="dark"] .content-body h3,
[data-theme="dark"] .content-body h4,
[data-theme="dark"] .content-body h5,
[data-theme="dark"] .content-body h6,
[data-theme="dark"] .rich-text h1,
[data-theme="dark"] .rich-text h2,
[data-theme="dark"] .rich-text h3,
[data-theme="dark"] .rich-text h4,
[data-theme="dark"] .rich-text h5,
[data-theme="dark"] .rich-text h6 {
    color: #1a1a1a !important;
}

/* Force light theme paragraphs and text */
body .content-body p,
body .rich-text p,
[data-theme="dark"] .content-body p,
[data-theme="dark"] .rich-text p {
    color: #1a1a1a !important;
}

/* Force light theme lists */
body .content-body ul li,
body .content-body ol li,
body .rich-text ul li,
body .rich-text ol li,
[data-theme="dark"] .content-body ul li,
[data-theme="dark"] .content-body ol li,
[data-theme="dark"] .rich-text ul li,
[data-theme="dark"] .rich-text ol li {
    color: #1a1a1a !important;
}

/* Force light theme blockquotes */
body .content-body blockquote,
body .rich-text blockquote,
[data-theme="dark"] .content-body blockquote,
[data-theme="dark"] .rich-text blockquote {
    background-color: #f1f3f5 !important;
    color: #1a1a1a !important;
    border-left-color: #0d6efd !important;
}

/* Force light theme code */
body .content-body code,
body .rich-text code,
[data-theme="dark"] .content-body code,
[data-theme="dark"] .rich-text code {
    background-color: #f1f3f5 !important;
    color: #c2185b !important;
}

/* Force light theme links */
body .content-body a,
body .rich-text a,
[data-theme="dark"] .content-body a,
[data-theme="dark"] .rich-text a {
    color: #0056b3 !important;
}

body .content-body a:hover,
body .rich-text a:hover,
[data-theme="dark"] .content-body a:hover,
[data-theme="dark"] .rich-text a:hover {
    color: #003d82 !important;
}