/* Integration styles for existing layout with new block features */

/* Ensure blocks work within existing #primary and .text_page containers */
#primary .text_page .wp-block {
    max-width: none; /* Allow blocks to use full container width */
}

/* Integration with existing layout containers */
#primary .text_page .alignwide {
    margin-left: -2rem;
    margin-right: -2rem;
    max-width: calc(100% + 4rem);
}

#primary .text_page .alignfull {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    max-width: 100vw;
    width: 100vw;
}

/* Ensure responsive embeds work within existing content areas */
#primary .text_page .responsive-embed-wrapper,
#primary .text_page .wp-block-embed .wp-block-embed__wrapper {
    margin: 1.5rem 0;
}

/* Fix for existing layout quirks */
#primary .text_page .wp-block-columns {
    margin-left: 0;
    margin-right: 0;
}

/* Ensure existing image handling doesn't conflict */
#primary .text_page .wp-block-image img {
    max-width: 100%;
    height: auto;
}

/* Override existing paragraph styles to work with block spacing */
#primary .text_page .wp-block-paragraph {
    margin-bottom: 1em;
}

/* Integration with existing clearfix classes */
#primary .text_page .wp-block-group.clearfix::after,
#primary .text_page .clearfix .wp-block::after {
    content: " ";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
    font-size: 0;
}

/* Ensure blocks respect existing responsive breakpoints */
@media (max-width: 1024px) {
    #doc .alignwide {
        margin-left: -1rem;
        margin-right: -1rem;
        max-width: calc(100% + 2rem);
    }
    
    #doc .alignfull {
        margin-left: calc(-50vw + 50%);
        margin-right: calc(-50vw + 50%);
    }
}

@media (max-width: 768px) {
    #doc .alignwide,
    #doc .alignfull {
        margin-left: -1rem;
        margin-right: -1rem;
        max-width: calc(100% + 2rem);
        width: calc(100% + 2rem);
    }
}

/* Specific fixes for your existing theme structure */
.text_page .wp-block-embed iframe {
    max-width: 100%;
}

/* Ensure existing JavaScript compatibility */
.text_page .wp-block-image.space_img img {
    /* Maintain existing space image handling - inherits from main.js */
    display: block;
}

/* Fix for gallery blocks within existing structure */
.text_page .wp-block-gallery {
    margin: 1.5rem 0;
}

.text_page .wp-block-gallery .wp-block-image {
    margin: 0;
}

/* Button styling that works with existing theme colors */
.wp-block-button .wp-block-button__link:not(.has-background) {
    background-color: #D35400;
    color: #ffffff;
}

.wp-block-button .wp-block-button__link:not(.has-background):hover {
    background-color: #B7461C;
}

/* Quote styling that matches theme */
.wp-block-quote:not(.has-background) {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-left-color: #D35400;
}

/* Cover block integration */
.wp-block-cover .wp-block-cover__inner-container {
    color: #ffffff;
}

/* Table styling to match existing theme */
.wp-block-table table {
    border-collapse: collapse;
    width: 100%;
}

.wp-block-table td,
.wp-block-table th {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
}

.wp-block-table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* List styling improvements */
.wp-block-list {
    padding-left: 1.5rem;
}

.wp-block-list li {
    list-style-type: disc;
    margin-bottom: 0.5rem;
}

/* Code block styling */
.wp-block-code {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    font-family: monospace;
    overflow-x: auto;
}

/* Preformatted text styling */
.wp-block-preformatted {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    white-space: pre-wrap;
    overflow-x: auto;
}