/* AI24 v1.8.0 — compatibility for third-party tables and tables of contents.
 * Scope: public website only; not WordPress admin or third-party ad/iframe content.
 * Light mode is deliberately unchanged except for restoring native TablePress
 * table layout, which legacy article styling previously forced to display:block.
 * Dark colors follow html[data-a24-theme="dark"] (the site's real toggle).
 */

/* Let TablePress and its sorting/responsive scripts work with a native table.
 * The legacy article CSS targets all tables with display:block, which can
 * interfere with TablePress and DataTables column sizing. */
body .page-prose table.tablepress,
body.single-post .a24-article-content table.tablepress {
  display:table;
  width:100% !important;
  max-width:100% !important;
  border-collapse:collapse;
  table-layout:auto;
  overflow:visible;
}
body .page-prose :is(.dt-container,.dataTables_wrapper,.tablepress-scroll-wrapper,.tablepress-responsive-scroll),
body.single-post .a24-article-content :is(.dt-container,.dataTables_wrapper,.tablepress-scroll-wrapper,.tablepress-responsive-scroll) {
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}
body .page-prose :is(.dt-scroll-body,.dataTables_scrollBody,.tablepress-scroll-wrapper,.tablepress-responsive-scroll),
body.single-post .a24-article-content :is(.dt-scroll-body,.dataTables_scrollBody,.tablepress-scroll-wrapper,.tablepress-responsive-scroll) {
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
@media(max-width:640px){
  body .page-prose table.tablepress :is(th,td),
  body.single-post .a24-article-content table.tablepress :is(th,td){
    white-space:normal;
    overflow-wrap:anywhere;
    padding:9px 7px;
    font-size:13px;
  }
}

/* TablePress 2.x CSS variables: these are the documented TablePress controls.
 * !important is confined to its own variables to prevail over a per-table
 * style injected by the plugin, which may be loaded after the theme. */
html[data-a24-theme="dark"] table.tablepress {
  --head-bg-color:#293c59 !important;
  --head-text-color:#f4f7ff !important;
  --head-active-bg-color:#384f77 !important;
  --head-active-text-color:#ffffff !important;
  --odd-bg-color:#1b273c !important;
  --odd-text-color:#e7eefe !important;
  --even-bg-color:#233249 !important;
  --even-text-color:#e7eefe !important;
  --hover-bg-color:#324663 !important;
  --hover-text-color:#ffffff !important;
  --border-color:#41516d !important;
  background-color:#1b273c !important;
  color:#e7eefe !important;
  border-color:#41516d !important;
}
/* Older TablePress versions and user-supplied white/translucent row styles. */
html[data-a24-theme="dark"] table.tablepress :is(thead,tfoot) > tr > :is(th,td) {
  background-color:#293c59 !important;
  color:#f4f7ff !important;
  border-color:#485c78 !important;
}
html[data-a24-theme="dark"] table.tablepress tbody > tr:nth-child(odd) > :is(td,th) {
  background-color:#1b273c !important;
  color:#e7eefe !important;
  border-color:#41516d !important;
}
html[data-a24-theme="dark"] table.tablepress tbody > tr:nth-child(even) > :is(td,th) {
  background-color:#233249 !important;
  color:#e7eefe !important;
  border-color:#41516d !important;
}
html[data-a24-theme="dark"] table.tablepress tbody > tr:hover > :is(td,th) {
  background-color:#324663 !important;
  color:#ffffff !important;
}
html[data-a24-theme="dark"] table.tablepress :is(a,a:visited){color:#c1ceff !important;}
html[data-a24-theme="dark"] table.tablepress :is(caption,.tablepress-table-name){color:#f3f7ff !important;}
html[data-a24-theme="dark"] :is(.tablepress-table-name,.tablepress-table-description){color:#e1e9f9;}

/* TablePress 2.x DataTables and older DataTables controls / summaries. */
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper){
  color:#e7eefe !important;
  background-color:transparent;
}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(
  .dt-info,.dataTables_info,.dt-length,.dataTables_length,
  .dt-search,.dataTables_filter,.dt-paging,.dataTables_paginate,
  .dt-empty,.dataTables_empty, label, caption
){color:#e7eefe !important;}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(
  input[type="search"],input[type="text"],select
){
  background-color:#162238 !important;
  border:1px solid #4c5d7a !important;
  color:#f4f7ff !important;
  color-scheme:dark;
}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(input,select):focus-visible{
  outline:2px solid #aebaff;
  outline-offset:2px;
}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(
  .dt-paging-button,.paginate_button
){background:#263751 !important;border:1px solid #485a78 !important;color:#e7eefe !important;}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(
  .dt-paging-button.current,.paginate_button.current,
  .dt-paging-button:hover,.paginate_button:hover
){background:#40537a !important;border-color:#6476a1 !important;color:#fff !important;}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(
  .dt-paging-button.disabled,.paginate_button.disabled
){opacity:.55;}
html[data-a24-theme="dark"] :is(.dt-container,.dataTables_wrapper) :is(
  .dt-scroll-head,.dt-scroll-foot,.dataTables_scrollHead,.dataTables_scrollFoot
){background:#293c59;color:#f4f7ff;}

/* Tables stored in older blog posts without the TablePress plugin. */
html[data-a24-theme="dark"] .page-prose table:not(.tablepress){
  background:#1b273c;
  color:#e7eefe;
  border-color:#41516d;
}
html[data-a24-theme="dark"] .page-prose table:not(.tablepress) :is(thead,tfoot) > tr > :is(th,td){
  background:#293c59 !important;
  color:#f4f7ff !important;
  border-color:#485c78;
}
html[data-a24-theme="dark"] .page-prose table:not(.tablepress) tbody > tr:nth-child(odd) > :is(td,th){
  background:#1b273c;
  color:#e7eefe;
  border-color:#41516d;
}
html[data-a24-theme="dark"] .page-prose table:not(.tablepress) tbody > tr:nth-child(even) > :is(td,th){
  background:#233249;
  color:#e7eefe;
  border-color:#41516d;
}

/* Easy Table of Contents (old and recent versions), LuckyWP TOC, and
 * common legacy TOC blocks. Do not recolor unrelated page content. */
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc .lwptoc_i,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
){
  background-color:#1c2a40 !important;
  background-image:none !important;
  color:#e6edfc !important;
  border:1px solid #42536d !important;
  box-shadow:none;
  max-width:100%;
  min-width:0;
  box-sizing:border-box;
}
/* Heading strip that previously stayed white with invisible text. */
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
) :is(
  .ez-toc-title-container,.ez-toc-title,.ez-toc-heading,
  .lwptoc_header,.lwptoc_title,.toc_title,.toc-header,
  .toc-header-title,.toc-title,h2.toc-title
){
  background-color:#293b59 !important;
  color:#f5f8ff !important;
  border-color:#455873 !important;
  text-shadow:none !important;
}
/* On some plugin versions the heading is an inline p or an H2. */
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
) :is(h2,h3,h4,strong,b,.ez-toc-title,.lwptoc_title,.toc_title){
  color:#f5f8ff !important;
}
/* TOC entries, counters, nested links and visited state. */
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
) :is(ul,ol,li,span,p){color:#e5ecfa !important;}
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
) a,
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
) a:visited{
  color:#c1ceff !important;
  text-decoration-color:#91a1f0;
}
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,#toc_container,.table-of-contents,
  .wp-block-rank-math-toc-block,.wp-block-yoast-seo-table-of-contents,.wp-block-table-of-contents
) a:is(:hover,:focus-visible){color:#f7f9ff !important;}
/* Expand / collapse controls, preserving plugin JS and aria/state behavior. */
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,.table-of-contents
) :is(button,.ez-toc-toggle,.ez-toc-btn,.ez-toc-title-toggle a,.lwptoc_toggle a,.toc_toggle a){
  background-color:#304665 !important;
  color:#f4f7ff !important;
  border-color:#607291 !important;
}
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,.table-of-contents
) :is(svg,svg path,svg circle,svg rect){stroke:currentColor;}
html[data-a24-theme="dark"] :is(
  #ez-toc-container,[id^="ez-toc-container"],.ez-toc-container,
  .lwptoc,.toc_container,.table-of-contents
) :is(input[type="checkbox"],input[type="radio"]){accent-color:#b4c3ff;}
