/* Flexible NTHA content blocks: keep existing front-end geometry while allowing native Gutenberg inner blocks. */
.ntha-flex-copy > *:first-child { margin-top: 0; }
.ntha-flex-copy > *:last-child { margin-bottom: 0; }
.ntha-flex-copy p { line-height: 1.65; }
.ntha-flex-copy ul,
.ntha-flex-copy ol { padding-left: 1.4rem; margin: 0 0 15px; }
.ntha-flex-copy li { margin: .45rem 0; line-height: 1.55; }
.ntha-flex-copy h2 { font-size: clamp(1.55rem,2.2vw,2.15rem); line-height: 1.2; margin: 0 0 16px; color: #151b2d; }
.editor-styles-wrapper .ntha-flex-copy .block-editor-inner-blocks,
.editor-styles-wrapper .ntha-flex-copy .block-editor-block-list__layout { width: 100%; }


/* NTHA v3.29: tables inside flexible content objects */
.ntha-flex-copy .wp-block-table {
    margin: 1rem 0;
    overflow-x: auto;
}

.ntha-flex-copy .wp-block-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.ntha-flex-copy .wp-block-table th,
.ntha-flex-copy .wp-block-table td {
    border: 1px solid #d9dde3;
    padding: 0.65rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.ntha-flex-copy .wp-block-table th {
    font-weight: 700;
    background: #f3f4f6;
}

.ntha-flex-copy .wp-block-table tbody tr:nth-child(even) td {
    background: #fafafa;
}

/* NTHA v3.30: explicit Table inserter for flexible object content. */
.ntha-flex-quick-insert {
    margin-top: 12px;
}
.editor-styles-wrapper .ntha-flex-quick-insert .components-button {
    min-height: 36px;
}

/* NTHA v3.31: keep the Table action visible at the top of flexible copy areas. */
.editor-styles-wrapper .ntha-flex-quick-insert {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 12px;
}
.editor-styles-wrapper .ntha-flex-quick-insert .components-button {
    min-height: 38px;
    font-weight: 600;
}


/* NTHA v3.36: centred image above full-width content/table object. */
.ntha-centred-table-object {
    max-width: 1120px;
    margin: 54px auto;
    padding: 0 24px;
}

.ntha-centred-table-image {
    width: min(560px, 100%);
    margin: 0 auto 30px;
    text-align: center;
}

.ntha-centred-table-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 440px;
    object-fit: contain;
    border-radius: 0;
    margin: 0 auto;
}

.ntha-centred-table-copy {
    width: 100%;
}

.editor-styles-wrapper .ntha-centred-table-image .ntha-editor-image-picker {
    width: 100%;
}

.editor-styles-wrapper .ntha-centred-table-image .ntha-editor-image-picker img {
    width: 100%;
    height: auto;
    max-height: 440px;
    object-fit: contain;
}

@media (max-width: 900px) {
    .ntha-centred-table-object {
        margin: 42px auto;
    }

    .ntha-centred-table-image {
        margin-bottom: 24px;
    }
}


/* NTHA v3.41: multi-row document download table. */
.ntha-download-table-object {
    max-width: 1120px;
    margin: 28px auto 54px;
    padding: 0 24px;
}
.ntha-download-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
.ntha-download-table td {
    padding: 14px 16px;
    border: 1px solid #d9dde3;
    vertical-align: middle;
}
.ntha-download-table tbody tr:nth-child(even) td {
    background: #fafafa;
}
.ntha-download-table-label {
    font-weight: 600;
}
.ntha-download-table-action {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}
.ntha-download-table-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    padding: 8px 14px;
    border-radius: 4px;
    background: #e01d2d;
    color: #fff !important;
    font-weight: 700;
    text-decoration: none !important;
}
.ntha-download-table-button:hover,
.ntha-download-table-button:focus {
    background: #c91624;
    color: #fff !important;
}
.editor-styles-wrapper .ntha-download-table-editor {
    display: grid;
    gap: 14px;
}
.editor-styles-wrapper .ntha-download-table-editor-row {
    padding: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
}
.editor-styles-wrapper .ntha-download-table-editor-main {
    display: grid;
    grid-template-columns: minmax(260px,1fr) minmax(320px,1.2fr);
    gap: 16px;
    align-items: end;
}
.editor-styles-wrapper .ntha-download-table-editor-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}
@media (max-width: 760px) {
    .editor-styles-wrapper .ntha-download-table-editor-main {
        grid-template-columns: 1fr;
    }
    .ntha-download-table td {
        padding: 12px;
    }
}


/* NTHA v3.42: inline downloads inside flexible text content. */
.ntha-flex-copy .wp-block-file {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 16px 0;
}
.ntha-flex-copy .wp-block-file > a:not(.wp-block-file__button) {
    font-weight: 600;
    color: #151B2D;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ntha-flex-copy .wp-block-file .wp-block-file__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 4px;
    background: #E51B36;
    color: #fff !important;
    font-weight: 700;
    text-decoration: none !important;
}
.ntha-flex-copy .wp-block-file .wp-block-file__button:hover,
.ntha-flex-copy .wp-block-file .wp-block-file__button:focus {
    background: #C91624;
    color: #fff !important;
}
.editor-styles-wrapper .ntha-flex-copy .wp-block-file {
    padding: 10px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
}


/* v3.43 inline formatting for flexible text content. */
.ntha-inline-underline { text-decoration: underline; text-underline-offset: 0.12em; }
.ntha-inline-highlight { background: #fff2a8; color: inherit; padding: 0 .08em; }
a.ntha-inline-download { text-decoration: underline; text-underline-offset: .12em; font-weight: 600; }
a.ntha-inline-download::after { content: ' \2193'; font-size: .9em; }


/* NTHA v3.44: standalone best-fit table object. */
.ntha-bestfit-table-object {
    max-width: 1120px;
    margin: 44px auto;
    padding: 0 24px;
}
.ntha-bestfit-table-title {
    margin: 0 0 18px;
    color: #151B2D;
    font-size: clamp(1.65rem, 2.3vw, 2.15rem);
    line-height: 1.2;
    white-space: pre-line;
}
.ntha-bestfit-table-title.ntha-title-width-narrow { max-width: 560px; }
.ntha-bestfit-table-title.ntha-title-width-medium { max-width: 760px; }
.ntha-bestfit-table-title.ntha-title-width-wide { max-width: 960px; }
.ntha-bestfit-table-title.ntha-title-width-full { width: 100%; max-width: none; }
.ntha-bestfit-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ntha-bestfit-table {
    width: auto;
    max-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    border-spacing: 0;
    background: #fff;
}
.ntha-bestfit-table th,
.ntha-bestfit-table td {
    width: auto;
    padding: 10px 14px;
    border: 1px solid #D7DBE1;
    vertical-align: top;
    text-align: left;
}
.ntha-bestfit-table th {
    background: #F1F2F4;
    color: #151B2D;
    font-weight: 700;
}
.ntha-bestfit-table tbody tr:nth-child(even) td {
    background: #F8F8F8;
}
.editor-styles-wrapper .ntha-bestfit-table-object {
    max-width: 1120px;
    padding: 18px;
    border: 1px solid #D1D5DB;
    background: #fff;
}
.editor-styles-wrapper .ntha-bestfit-table-editor-scroll {
    max-width: 100%;
    overflow-x: auto;
    margin-top: 12px;
}
.editor-styles-wrapper .ntha-bestfit-table-editor {
    width: auto;
    max-width: none;
    table-layout: auto;
}
.editor-styles-wrapper .ntha-bestfit-table-editor th,
.editor-styles-wrapper .ntha-bestfit-table-editor td {
    min-width: 150px;
    padding: 8px;
}
.editor-styles-wrapper .ntha-bestfit-table-editor th .components-base-control,
.editor-styles-wrapper .ntha-bestfit-table-editor td .components-base-control {
    margin-bottom: 0;
}
.editor-styles-wrapper .ntha-bestfit-table-editor .ntha-bestfit-row-actions {
    min-width: 110px;
    background: #fff;
    border: 0;
}
.editor-styles-wrapper .ntha-bestfit-remove-col {
    display: block;
    margin-top: 4px;
    font-size: 12px;
}
.editor-styles-wrapper .ntha-bestfit-table-controls {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}
.editor-styles-wrapper .ntha-bestfit-table-help {
    margin: 10px 0 0;
    color: #6B7280;
    font-size: 12px;
}
@media (max-width: 640px) {
    .ntha-bestfit-table-object { padding: 0 18px; }
}


/* NTHA Table v3.46: per-cell link/download actions. */
.ntha-bestfit-table a.ntha-bestfit-cell-link,
.ntha-bestfit-table a.ntha-bestfit-cell-download {
    color: #E51B2A;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
}
.ntha-bestfit-table a.ntha-bestfit-cell-link:hover,
.ntha-bestfit-table a.ntha-bestfit-cell-download:hover {
    text-decoration-thickness: 2px;
}
.editor-styles-wrapper .ntha-bestfit-rich-cell .components-base-control {
    margin-bottom: 6px !important;
}
.editor-styles-wrapper .ntha-bestfit-rich-cell .ntha-editor-file-picker {
    min-width: 220px;
}


/* NTHA v3.47.0: corner-image flexible objects.
   The image floats so normal block content wraps beside it and then naturally
   returns to full width below the image.
   v3.54.36 fixes the float selector so only the nested image floats; the parent
   section carries the same side class for block identity and must not float. */
.ntha-cnr-image-object {
    max-width: 1120px;
    margin: 44px auto;
    padding: 0 24px;
}
.ntha-cnr-copy::after {
    content: "";
    display: table;
    clear: both;
}
.ntha-cnr-image {
    margin-bottom: 18px;
}
.ntha-cnr-image.ntha-cnr-image-left {
    float: left;
    margin-right: 30px;
}
.ntha-cnr-image.ntha-cnr-image-right {
    float: right;
    margin-left: 30px;
}
.ntha-cnr-width-small .ntha-cnr-image { width: min(220px, 34%); }
.ntha-cnr-width-medium .ntha-cnr-image { width: min(320px, 38%); }
.ntha-cnr-width-large .ntha-cnr-image { width: min(420px, 44%); }
.ntha-cnr-image img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
}
.ntha-cnr-copy > .wp-block-heading:first-of-type,
.ntha-cnr-copy > p:first-of-type {
    margin-top: 0;
}
.editor-styles-wrapper .ntha-cnr-image .ntha-editor-image-picker {
    width: 100%;
}
.editor-styles-wrapper .ntha-cnr-image .ntha-editor-image-picker img {
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: contain;
}
.editor-styles-wrapper .ntha-cnr-quick-insert {
    flex-wrap: wrap;
}
@media (max-width: 700px) {
    .ntha-cnr-image.ntha-cnr-image-left,
    .ntha-cnr-image.ntha-cnr-image-right {
        float: none;
        width: min(420px, 100%) !important;
        margin: 0 auto 22px;
    }
    .ntha-cnr-image-object {
        padding: 0 18px;
        margin: 34px auto;
    }
}



/* v3.54.39: keep CNR editor image controls above Gutenberg's editable
   InnerBlocks layer. The image picker is editor-only and deliberately sits
   outside the InnerBlocks copy container so Replace image receives the click. */
.editor-styles-wrapper .ntha-cnr-image-object > .ntha-cnr-editor-float {
    position: relative;
    z-index: 20;
}
.editor-styles-wrapper .ntha-cnr-editor-image-picker {
    position: relative;
    z-index: 21;
    pointer-events: auto !important;
    user-select: none;
}
.editor-styles-wrapper .ntha-cnr-editor-image-picker .components-button {
    position: relative;
    z-index: 22;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* NTHA v3.49.0: full NTHA table beside an image. */
.ntha-full-table-image-object {
    max-width: 1120px;
    margin: 44px auto;
    padding: 0 24px;
}
.ntha-full-table-image-grid {
    display: grid;
    gap: 28px;
    grid-template-rows: auto auto;
    align-items: start;
}
.ntha-full-table-image-object.ntha-image-width-30 .ntha-full-table-image-grid { grid-template-columns: 30fr 70fr; }
.ntha-full-table-image-object.ntha-image-width-35 .ntha-full-table-image-grid { grid-template-columns: 35fr 65fr; }
.ntha-full-table-image-object.ntha-image-width-40 .ntha-full-table-image-grid { grid-template-columns: 40fr 60fr; }
.ntha-full-table-image-object.ntha-image-width-50 .ntha-full-table-image-grid { grid-template-columns: 1fr 1fr; }
.ntha-full-table-image-right.ntha-image-width-30 .ntha-full-table-image-grid { grid-template-columns: 70fr 30fr; }
.ntha-full-table-image-right.ntha-image-width-35 .ntha-full-table-image-grid { grid-template-columns: 65fr 35fr; }
.ntha-full-table-image-right.ntha-image-width-40 .ntha-full-table-image-grid { grid-template-columns: 60fr 40fr; }
.ntha-full-table-image-right.ntha-image-width-50 .ntha-full-table-image-grid { grid-template-columns: 1fr 1fr; }

/* Flatten the table wrapper so the image can align to the table body only,
   excluding the table title. */
.ntha-full-table-image-table { display: contents; }
.ntha-full-table-image-table .ntha-bestfit-table-object { display: contents; }
.ntha-full-table-image-table .ntha-bestfit-table-title { margin-top: 0; }
.ntha-full-table-image-left .ntha-full-table-image-table .ntha-bestfit-table-title { grid-column: 2; grid-row: 1; }
.ntha-full-table-image-left .ntha-full-table-image-table .ntha-bestfit-table-scroll { grid-column: 2; grid-row: 2; }
.ntha-full-table-image-left .ntha-full-table-image-media { grid-column: 1; grid-row: 2; }
.ntha-full-table-image-right .ntha-full-table-image-table .ntha-bestfit-table-title { grid-column: 1; grid-row: 1; }
.ntha-full-table-image-right .ntha-full-table-image-table .ntha-bestfit-table-scroll { grid-column: 1; grid-row: 2; }
.ntha-full-table-image-right .ntha-full-table-image-media { grid-column: 2; grid-row: 2; }

.ntha-full-table-image-media {
    min-width: 0;
    min-height: 0;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ntha-full-table-image-media img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    border-radius: 0;
}
.ntha-full-table-image-table .ntha-bestfit-table-scroll { width: 100%; }
.ntha-full-table-image-table .ntha-bestfit-table { width: 100%; }

/* Keep the Gutenberg editor structure stable while previewing the same no-stretch image behaviour. */
.editor-styles-wrapper .ntha-full-table-image-object {
    max-width: 1120px;
    padding: 18px;
    border: 1px solid #d1d5db;
    background: #fff;
}
.editor-styles-wrapper .ntha-full-table-image-table,
.editor-styles-wrapper .ntha-full-table-image-table .ntha-bestfit-table-object {
    display: block;
}
.editor-styles-wrapper .ntha-full-table-image-media .ntha-editor-image-picker {
    width: 100%;
}
.editor-styles-wrapper .ntha-full-table-image-media .ntha-editor-image-picker img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    border-radius: 0;
    margin: 0 auto;
}
.editor-styles-wrapper .ntha-full-table-image-table .ntha-bestfit-table-object {
    border: 0;
    padding: 0;
}
@media (max-width: 820px) {
    .ntha-full-table-image-object .ntha-full-table-image-grid,
    .ntha-full-table-image-right.ntha-image-width-30 .ntha-full-table-image-grid,
    .ntha-full-table-image-right.ntha-image-width-35 .ntha-full-table-image-grid,
    .ntha-full-table-image-right.ntha-image-width-40 .ntha-full-table-image-grid,
    .ntha-full-table-image-right.ntha-image-width-50 .ntha-full-table-image-grid {
        grid-template-columns: 1fr;
    }
    .ntha-full-table-image-table,
    .ntha-full-table-image-table .ntha-bestfit-table-object { display: block; }
    .ntha-full-table-image-media,
    .ntha-full-table-image-left .ntha-full-table-image-media,
    .ntha-full-table-image-right .ntha-full-table-image-media {
        grid-column: 1;
        grid-row: auto;
        order: -1;
        min-height: 0;
    }
    .ntha-full-table-image-media img {
        width: auto;
        max-width: 100%;
        height: auto;
        max-height: 420px;
        object-fit: contain;
    }
}

/* v3.54.9 - Global NTHA content image treatment.
   Standard content images use the same 12px rounded corners site-wide.
   Tile sizing/cropping remains controlled by the tile styles; this rule does
   not alter image dimensions or force equal heights. */
.ntha-service-hero .ntha-hero-image img,
.ntha-content-object .ntha-object-image img,
.ntha-centred-table-image img,
.ntha-cnr-image img,
.ntha-full-table-image-media img {
    border-radius: 12px !important;
}

/* v3.54.8 - Trades We Offer page-only equal-height table image test.
   Both Full Table Image photos use the same display height and crop cleanly
   with object-fit: cover. Other pages retain their natural image sizing. */
@media (min-width: 761px) {
    body.ntha-trades-we-offer .ntha-full-table-image-media img {
        width: 100%;
        height: 300px;
        max-width: 100%;
        object-fit: cover;
        object-position: center;
    }
}

@media (max-width: 760px) {
    body.ntha-trades-we-offer .ntha-full-table-image-media img {
        width: auto;
        height: auto;
        max-width: 100%;
        object-fit: contain;
    }
}
