/**
 * Agrimídia post tables v1.0.0
 * Escopo: somente tabelas dentro do conteúdo público de posts.
 */

.w-post-elm.post_content {
    --lh-table-border: #d8deea;
    --lh-table-header: #172766;
    --lh-table-header-border: #344586;
    --lh-table-text: #243247;
    --lh-table-muted-row: #f6f8fc;
    --lh-table-hover-row: #eef2f9;
    --lh-table-focus: #e41e2b;
}

.w-post-elm.post_content :where(.lh-post-table-scroll, .wp-block-table),
.w-post-elm.post_content :where(div, figure, section, article):has(> table) {
    position: relative;
    max-width: 100%;
    margin-block: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--lh-table-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 22px rgb(19 36 91 / 8%);
    scrollbar-color: #7d89a8 #eef1f7;
    scrollbar-width: thin;
}

.w-post-elm.post_content:has(> table) {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.w-post-elm.post_content :where(.lh-post-table-scroll, .wp-block-table):focus-visible {
    outline: 3px solid var(--lh-table-focus);
    outline-offset: 3px;
}

.w-post-elm.post_content table {
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    margin: 1.5rem 0 !important;
    border: 1px solid var(--lh-table-border) !important;
    border-radius: 12px;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    table-layout: auto !important;
    background: #fff;
    color: var(--lh-table-text);
    font-size: clamp(14px, calc(10.5px + 0.25vw), 16px);
    line-height: 1.45;
}

.w-post-elm.post_content :where(.lh-post-table-scroll, .wp-block-table) > table {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0;
}

.w-post-elm.post_content table :where(th, td) {
    box-sizing: border-box;
    padding: clamp(10px, 0.75vw, 13px) clamp(12px, 1vw, 16px) !important;
    border: 0 !important;
    border-right: 1px solid var(--lh-table-border) !important;
    border-bottom: 1px solid var(--lh-table-border) !important;
    color: inherit;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
}

.w-post-elm.post_content table :where(th, td):last-child {
    border-right: 0 !important;
}

.w-post-elm.post_content table > :where(tbody, tfoot) > tr:last-child > :where(th, td) {
    border-bottom: 0 !important;
}

.w-post-elm.post_content table > thead > tr > :where(th, td),
.w-post-elm.post_content table:not(:has(thead)) > tbody:first-child > tr:first-child > :where(th, td) {
    border-color: var(--lh-table-header-border) !important;
    background: var(--lh-table-header) !important;
    color: #fff !important;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.w-post-elm.post_content table > thead > tr:last-child > :where(th, td) {
    border-bottom-color: var(--lh-table-header-border) !important;
}

.w-post-elm.post_content table > thead :where(strong, b, a),
.w-post-elm.post_content table:not(:has(thead)) > tbody:first-child > tr:first-child :where(strong, b, a) {
    color: inherit !important;
}

.w-post-elm.post_content table > tbody > tr:nth-child(even) > :where(th, td) {
    background: var(--lh-table-muted-row) !important;
}

.w-post-elm.post_content table > tbody > tr:hover > :where(th, td) {
    background: var(--lh-table-hover-row) !important;
}

.w-post-elm.post_content table > tbody > tr > th {
    background: #edf1f8 !important;
    font-weight: 700;
}

.w-post-elm.post_content table caption {
    padding: 0 0 0.65rem;
    color: var(--lh-table-text);
    font-size: 0.9375rem;
    font-weight: 700;
    text-align: left;
    caption-side: top;
}

.w-post-elm.post_content table :where(th, td) > :first-child {
    margin-top: 0;
}

.w-post-elm.post_content table :where(th, td) > :last-child {
    margin-bottom: 0;
}

@supports not selector(:has(*)) {
    .w-post-elm.post_content table {
        display: block;
        max-width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 767px) {
    .w-post-elm.post_content :where(.lh-post-table-scroll, .wp-block-table),
    .w-post-elm.post_content :where(div, figure, section, article):has(> table) {
        margin-block: 1.25rem;
        border-radius: 10px;
    }


    .w-post-elm.post_content table :where(th, td) {
        padding: 10px 12px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .w-post-elm.post_content :where(.lh-post-table-scroll, .wp-block-table) {
        scroll-behavior: auto;
    }
}
