/**
 * WordPress Gutenberg Blocks — Premium Styling
 * Element Home Solutions Theme
 *
 * Design principles:
 *   1. Content lives in a controlled, elegant container (max-width 900px)
 *   2. Typography is warm, readable, and hierarchical
 *   3. Images feel integrated, not "pasted" — shadows, radii, aspect limits
 *   4. Columns always stack cleanly; text NEVER overlaps images
 *   5. FAQ looks like a premium design element, not raw HTML
 *   6. Everything "just works" regardless of how SEO fills the page
 */

/* ========================================
   CONTENT WRAPPER — The Visual Framework
   ======================================== */

.ehs-service-content__wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

.ehs-service-content__wrapper>*:first-child {
    margin-top: 0;
}

.ehs-service-content__wrapper>*:last-child {
    margin-bottom: 0;
}

/* ========================================
   HEADINGS — Clear hierarchy, premium feel
   ======================================== */

.ehs-service-content__wrapper h1,
.ehs-service-content__wrapper h2,
.ehs-service-content__wrapper h3,
.ehs-service-content__wrapper h4,
.ehs-service-content__wrapper h5,
.ehs-service-content__wrapper h6,
.wp-block-heading,
.wp-block-post-title {
    font-family: var(--ehs-font-family-heading);
    color: var(--ehs-color-dark);
    line-height: 1.25;
}

/* H2 — Primary section dividers. Large top margin creates clear separation. */
.ehs-service-content__wrapper h2,
.wp-block-heading h2 {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 700;
    margin-top: 3.5rem;
    margin-bottom: 1.25rem;
    letter-spacing: -0.015em;
}

/* H3 — Sub-section headers */
.ehs-service-content__wrapper h3,
.wp-block-heading h3 {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

/* H4 */
.ehs-service-content__wrapper h4,
.wp-block-heading h4 {
    font-size: clamp(1.1rem, 1.5vw, 1.25rem);
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

/* H5, H6 — Accent labels */
.ehs-service-content__wrapper h5,
.ehs-service-content__wrapper h6,
.wp-block-heading h5,
.wp-block-heading h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ehs-color-primary);
}

/* ========================================
   PARAGRAPHS — Warm, readable body text
   ======================================== */

.ehs-service-content__wrapper p,
.wp-block-paragraph {
    color: #334155;
    font-size: 1.0625rem;
    line-height: 1.75;
    margin-bottom: 1.5rem;
}

/* Links */
.ehs-service-content__wrapper a:not(.wp-block-button__link):not(.ehs-portfolio-card__link) {
    color: var(--ehs-color-primary);
    text-decoration: underline;
    text-decoration-color: rgba(97, 6, 217, 0.25);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.ehs-service-content__wrapper a:not(.wp-block-button__link):not(.ehs-portfolio-card__link):hover {
    color: var(--ehs-color-primary-dark, #4c05a8);
    text-decoration-color: var(--ehs-color-primary);
}

/* Bold */
.ehs-service-content__wrapper strong {
    font-weight: 700;
    color: var(--ehs-color-dark);
}

/* Drop cap */
.wp-block-paragraph.has-drop-cap:not(:focus)::first-letter {
    font-size: 3.5em;
    font-weight: 700;
    color: var(--ehs-color-primary);
    line-height: 1;
    margin: 0.05em 0.12em 0 0;
    float: left;
}

/* ========================================
   LISTS — Elegant checkmarks, breathing room
   ======================================== */

.ehs-service-content__wrapper ul,
.ehs-service-content__wrapper ol {
    margin: 0 0 2rem 0;
    padding: 0;
    color: #334155;
}

/* Unordered — purple checkmark bullets */
.ehs-service-content__wrapper ul {
    list-style: none;
}

.ehs-service-content__wrapper ul li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.875rem;
    line-height: 1.7;
}

.ehs-service-content__wrapper ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236106d9'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* Ordered */
.ehs-service-content__wrapper ol {
    padding-left: 1.75rem;
}

.ehs-service-content__wrapper ol li {
    padding-left: 0.25rem;
    margin-bottom: 0.875rem;
    line-height: 1.7;
}

.ehs-service-content__wrapper ol li::marker {
    color: var(--ehs-color-primary);
    font-weight: 700;
}

/* ========================================
   QUOTE / BLOCKQUOTE
   ======================================== */

.wp-block-quote {
    margin: 2.5rem 0;
    padding: 1.75rem 2rem;
    background: linear-gradient(135deg, rgba(97, 6, 217, 0.03), rgba(124, 71, 244, 0.06));
    border-left: 4px solid var(--ehs-color-primary);
    border-radius: 0 var(--ehs-radius-md, 12px) var(--ehs-radius-md, 12px) 0;
}

.wp-block-quote p {
    font-size: 1.125rem;
    font-style: italic;
    color: var(--ehs-color-dark);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.wp-block-quote cite {
    display: block;
    font-size: 0.875rem;
    font-style: normal;
    font-weight: 600;
    color: var(--ehs-color-primary);
    margin-top: 0.75rem;
}

.wp-block-quote cite::before {
    content: '— ';
}

/* Pull quote */
.wp-block-pullquote {
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--ehs-gradient-cta-bright);
    border: none;
    border-radius: var(--ehs-radius-lg, 16px);
    margin: 3rem 0;
}

.wp-block-pullquote blockquote {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

.wp-block-pullquote p {
    color: white;
    font-size: 1.375rem;
    font-weight: 600;
    font-style: normal;
}

.wp-block-pullquote cite {
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   SEPARATOR
   ======================================== */

.wp-block-separator {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--ehs-color-primary), transparent);
    margin: 3rem auto;
    max-width: 80px;
}

.wp-block-separator.is-style-wide {
    max-width: 100%;
}

.wp-block-separator.is-style-dots {
    background: none;
    height: auto;
    text-align: center;
}

.wp-block-separator.is-style-dots::before {
    content: '···';
    color: var(--ehs-color-primary);
    font-size: 1.75rem;
    letter-spacing: 0.75rem;
}

.wp-block-separator.has-alpha-channel-opacity {
    opacity: 1;
}

/* ========================================
   BUTTONS
   ======================================== */

.wp-block-button {
    margin-bottom: 1rem;
}

.wp-block-button__link {
    font-family: var(--ehs-font-family-heading);
    font-weight: 600;
    padding: 14px 32px;
    border-radius: var(--ehs-radius-sm, 8px);
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    border: none;
    background: var(--ehs-gradient-cta-bright);
    color: white;
    box-shadow: var(--ehs-shadow-button);
}

.wp-block-button__link:hover {
    background: var(--ehs-gradient-cta-bright-hover);
    transform: translateY(-2px);
    box-shadow: var(--ehs-shadow-button-strong);
    color: white;
}

/* Outline button */
.wp-block-button.is-style-outline .wp-block-button__link {
    background: transparent;
    border: 2px solid var(--ehs-color-primary);
    color: var(--ehs-color-primary);
    box-shadow: none;
}

.wp-block-button.is-style-outline .wp-block-button__link:hover {
    background: var(--ehs-color-primary);
    color: white;
}

/* Buttons group */
.wp-block-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* ========================================
   IMAGES — Premium, integrated treatment
   ======================================== */

.wp-block-image {
    margin-bottom: 2rem;
    max-width: 100%;
}

.wp-block-image img {
    border-radius: var(--ehs-radius-lg, 16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
    max-width: 100%;
    height: auto;
    display: block;
}

.wp-block-image.is-style-rounded img {
    border-radius: var(--ehs-radius-pill, 9999px);
}

.wp-block-image figcaption {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: #94a3b8;
    text-align: center;
    font-style: italic;
}

/* Size variants */
.wp-block-image.size-large,
.wp-block-image.size-full {
    width: 100%;
}

/* ========================================
   GALLERY
   ======================================== */

.wp-block-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 0;
    list-style: none;
}

.wp-block-gallery .wp-block-image img {
    border-radius: var(--ehs-radius-md, 12px);
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   COLUMNS — The critical fix.
   WordPress injects dynamic classes like
   "is-vertically-aligned-center" and
   "wp-container-core-columns-is-layout-*"
   that create chaos. We override them here.
   ======================================== */

/*
 * align-items: stretch is crucial for sticky images.
 * With flex-start, the image column shrinks to the image's height
 * and sticky has no room to scroll. With stretch, both columns
 * are the same height as the tallest one, giving the image
 * column enough vertical space for sticky to work.
 * Gap set to 3rem for comfortable breathing room.
 */
.ehs-service-content__wrapper .wp-block-columns,
.ehs-service-content__wrapper .wp-block-columns.is-layout-flex,
.ehs-service-content__wrapper .wp-block-columns[class*="wp-container-core-columns"] {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 3rem !important;
    align-items: stretch !important;
    margin-bottom: 3rem;
}

/* Override WP's vertical alignment classes — stretch, not flex-start */
.ehs-service-content__wrapper .wp-block-column.is-vertically-aligned-center,
.ehs-service-content__wrapper .wp-block-column.is-vertically-aligned-bottom {
    align-self: stretch !important;
}

.ehs-service-content__wrapper .wp-block-column,
.ehs-service-content__wrapper .wp-block-column.is-layout-flow {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    word-break: break-word;
    max-width: 100%;
}

/*
 * Sticky images — the key UX trick.
 * When a column has an image paired with a tall text column,
 * the image "sticks" to the viewport so the user always sees
 * it while reading. No more white gap underneath.
 */
.ehs-service-content__wrapper .wp-block-column .wp-block-image {
    position: sticky;
    top: 100px;
    /* Below sticky header */
    margin: 0 0 1.5rem 0;
    /* Kill browser/WP default 40px side margins on <figure> */
}

.ehs-service-content__wrapper .wp-block-column .wp-block-image img {
    width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--ehs-radius-lg, 16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
}

/* ========================================
   MEDIA & TEXT
   ======================================== */

.wp-block-media-text {
    display: grid;
    grid-template-columns: 50% 1fr;
    gap: 2.5rem;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.wp-block-media-text.has-media-on-the-right {
    grid-template-columns: 1fr 50%;
}

.wp-block-media-text__media {
    margin: 0;
}

.wp-block-media-text__media img {
    width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--ehs-radius-lg, 16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
}

.wp-block-media-text__content {
    word-break: break-word;
}

/* ========================================
   LAYOUT FLOW HELPERS
   ======================================== */

.wp-block-column-is-layout-flow>* {
    margin-bottom: 1.25rem;
}

.wp-block-column-is-layout-flow>*:first-child {
    margin-top: 0;
}

.wp-block-column-is-layout-flow>*:last-child {
    margin-bottom: 0;
}

/* ========================================
   GROUP
   ======================================== */

.wp-block-group {
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: var(--ehs-radius-lg, 16px);
}

.wp-block-group.has-background {
    padding: 2.5rem;
}

.is-layout-flow>*+* {
    margin-top: 1.25rem;
}

/* ========================================
   COVER
   ======================================== */

.wp-block-cover {
    border-radius: var(--ehs-radius-lg, 16px);
    overflow: hidden;
    min-height: 400px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.wp-block-cover__inner-container {
    width: 100%;
    z-index: 1;
    color: white;
    text-align: center;
}

/* ========================================
   CODE
   ======================================== */

code {
    background: rgba(97, 6, 217, 0.06);
    color: var(--ehs-color-primary);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Courier New', monospace;
}

.wp-block-code {
    background: var(--ehs-color-dark);
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: var(--ehs-radius-md, 12px);
    overflow-x: auto;
    margin-bottom: 2rem;
}

.wp-block-code code {
    background: transparent;
    color: inherit;
    padding: 0;
}

pre.wp-block-code {
    font-family: 'Monaco', 'Courier New', monospace;
}

/* ========================================
   TABLE
   ======================================== */

.wp-block-table {
    margin-bottom: 2rem;
}

.wp-block-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--ehs-radius-md, 12px);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.wp-block-table thead {
    background: var(--ehs-gradient-cta-bright);
}

.wp-block-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: white;
    font-family: var(--ehs-font-family-heading);
}

.wp-block-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    background: white;
}

.wp-block-table tbody tr:hover td {
    background: rgba(97, 6, 217, 0.02);
}

.wp-block-table tbody tr:last-child td {
    border-bottom: none;
}

.wp-block-table.is-style-stripes tbody tr:nth-child(odd) td {
    background: #f8fafc;
}

/* ========================================
   EMBEDS
   ======================================== */

.wp-block-embed {
    margin-bottom: 2rem;
}

.wp-block-embed__wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--ehs-radius-lg, 16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
}

.wp-block-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--ehs-radius-lg, 16px);
}

/* ========================================
   SPACER
   ======================================== */

.wp-block-spacer {
    display: block;
}

/* ========================================
   ALIGNMENTS
   ======================================== */

.alignwide {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

.aligncenter {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.alignleft {
    float: left;
    margin-right: 2rem;
    margin-bottom: 1rem;
}

.alignright {
    float: right;
    margin-left: 2rem;
    margin-bottom: 1rem;
}

/* Native WP Text Alignment */
.has-text-align-left {
    text-align: left;
}

.has-text-align-center {
    text-align: center;
}

.has-text-align-right {
    text-align: right;
}

.has-text-align-justify {
    text-align: justify;
}

/* ========================================
   YOAST FAQ BLOCK — Premium accordion cards
   ======================================== */

.schema-faq.wp-block-yoast-faq-block {
    margin: 3.5rem 0;
    border-top: 1px solid #e2e8f0;
}

.schema-faq-section {
    border-bottom: 1px solid #e2e8f0;
    padding: 2rem 0;
}

.schema-faq-question {
    font-size: clamp(1.1rem, 1.5vw, 1.25rem);
    font-family: var(--ehs-font-family-heading);
    color: var(--ehs-color-dark);
    font-weight: 700;
    margin: 0 0 1rem 0;
    position: relative;
    padding-right: 2.5rem;
    line-height: 1.4;
}

.schema-faq-question::after {
    content: '';
    position: absolute;
    right: 0;
    top: 2px;
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236106d9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.45;
    transition: opacity 0.2s ease;
}

.schema-faq-section:hover .schema-faq-question::after {
    opacity: 0.8;
}

.schema-faq-answer {
    color: #475569;
    line-height: 1.75;
    margin: 0;
    font-size: 1.0625rem;
}

.schema-faq-answer p {
    margin-bottom: 0.75rem;
}

.schema-faq-answer p:last-child {
    margin-bottom: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 782px) {
    .ehs-service-content__wrapper {
        padding: 2rem 1.25rem;
    }

    /* Force columns to stack on mobile/tablet */
    .ehs-service-content__wrapper .wp-block-columns,
    .ehs-service-content__wrapper .wp-block-columns.is-layout-flex,
    .ehs-service-content__wrapper .wp-block-columns[class*="wp-container-core-columns"] {
        flex-direction: column !important;
        flex-wrap: wrap !important;
        gap: 1.5rem !important;
    }

    .ehs-service-content__wrapper .wp-block-column,
    .ehs-service-content__wrapper .wp-block-column.is-layout-flow {
        flex-basis: auto !important;
        width: 100% !important;
    }

    /* Disable sticky on mobile — columns are stacked */
    .ehs-service-content__wrapper .wp-block-column .wp-block-image {
        position: static;
    }

    .wp-block-media-text {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .wp-block-media-text.has-media-on-the-right {
        grid-template-columns: 1fr;
    }

    .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media {
        grid-row: 1;
    }

    .wp-block-group {
        padding: 1.25rem;
    }

    .wp-block-quote,
    .wp-block-pullquote {
        padding: 1.25rem;
    }

    .wp-block-cover {
        min-height: 280px;
    }

    .wp-block-buttons {
        flex-direction: column;
    }

    .wp-block-button {
        width: 100%;
    }

    .wp-block-button__link {
        display: block;
        text-align: center;
    }

    .alignleft,
    .alignright {
        float: none;
        margin: 0 auto 1rem;
        text-align: center;
    }

    .alignleft img,
    .alignright img {
        margin-left: auto;
        margin-right: auto;
    }

    .schema-faq-question {
        font-size: 1.0625rem;
        padding-right: 2rem;
    }
}