/* Nekud content tables (mu-plugin). Loaded after the theme and Transmission CSS.
   Beats `.nk-tx table:not(.leaflet-container table){ display:block }`, which
   left tables content-width (often the left third) inside a nested double box. */

html body .nk-prose.nk-prose table,
html body .nk-article.nk-article table,
html body .entry-content.entry-content table,
html body .wp-block-table table,
html body .nk-tx.nk-tx table,
html body .nk-tx.nk-tx table:not(.leaflet-container table) {
  display: table;
  width: 100%;
  max-width: none;
  table-layout: auto;
  border-collapse: collapse;
  overflow: visible;
  font-size: .875em;
  line-height: 1.45;
}

html body .leaflet-container table,
html body .leaflet-pane table,
html body .leaflet-popup table {
  display: table;
  width: auto;
  max-width: none;
}

/* 2–4 column tables: earlier columns stay content-wide on one line;
   the last column takes the leftover space and is allowed to wrap. */
html body .nk-prose.nk-prose table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):not(:last-child),
html body .nk-article.nk-article table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):not(:last-child),
html body .entry-content.entry-content table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):not(:last-child),
html body .nk-tx.nk-tx table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):not(:last-child) {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
html body .nk-prose.nk-prose table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):last-child,
html body .nk-article.nk-article table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):last-child,
html body .entry-content.entry-content table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):last-child,
html body .nk-tx.nk-tx table:has(:is(thead, tbody) > tr > :last-child:nth-child(-n+3)):not(:has(> tbody > tr:only-child)) :is(th, td):last-child {
  width: auto;
  white-space: normal;
}

html body .nk-prose.nk-prose :is(th, td),
html body .nk-article.nk-article :is(th, td),
html body .entry-content.entry-content :is(th, td),
html body .wp-block-table :is(th, td),
html body .nk-tx.nk-tx :is(th, td),
html body .nk-tx.nk-tx .notes-table :is(th, td),
html body .nk-tx.nk-tx .niqqud-table :is(th, td) {
  padding: .75em 1.05em;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--nk-c-border, #b9c0cb);
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

html body .nk-prose.nk-prose :is(thead th, thead td, tr:first-child th, tbody th),
html body .nk-article.nk-article :is(thead th, thead td, tr:first-child th, tbody th),
html body .entry-content.entry-content :is(thead th, thead td, tr:first-child th, tbody th),
html body .wp-block-table :is(thead th, thead td, tr:first-child th, tbody th),
html body .nk-tx.nk-tx :is(thead th, thead td, tr:first-child th, tbody th),
html body .nk-tx.nk-tx .notes-table :is(thead th, thead td, tr:first-child th),
html body .nk-tx.nk-tx .niqqud-table :is(thead th, thead td, tr:first-child th) {
  font-family: var(--nk-f-meta-family, inherit);
  font-size: .82em;
  font-weight: 600;
  letter-spacing: .08em;
  font-variant: small-caps;
  text-transform: none;
  color: var(--nk-c-primary, #14223d);
  background: color-mix(in srgb, var(--nk-c-primary, #14223d) 9%, var(--nk-c-bg, #FBFAF5));
  border-bottom: 1px solid var(--nk-c-border, #b9c0cb);
}

html body .nk-prose.nk-prose tbody tr:nth-child(even) td,
html body .nk-article.nk-article tbody tr:nth-child(even) td,
html body .entry-content.entry-content tbody tr:nth-child(even) td,
html body .wp-block-table tbody tr:nth-child(even) td,
html body .nk-tx.nk-tx tbody tr:nth-child(even) td,
html body .nk-tx.nk-tx .notes-table tbody tr:nth-child(even) td,
html body .nk-tx.nk-tx .niqqud-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--nk-c-primary, #14223d) 3.5%, var(--nk-c-bg, #FBFAF5));
}

html body .nk-prose.nk-prose tbody tr:hover td,
html body .nk-article.nk-article tbody tr:hover td,
html body .entry-content.entry-content tbody tr:hover td,
html body .wp-block-table tbody tr:hover td,
html body .nk-tx.nk-tx tbody tr:hover td,
html body .nk-tx.nk-tx .notes-table tbody tr:hover td,
html body .nk-tx.nk-tx .notes-table tr:hover td,
html body .nk-tx.nk-tx .niqqud-table tr:hover td {
  background: color-mix(in srgb, var(--nk-c-accent, #d4a537) 14%, var(--nk-c-bg, #FBFAF5));
}

html body .nk-prose.nk-prose tr:last-child :is(td, th),
html body .nk-article.nk-article tr:last-child :is(td, th),
html body .entry-content.entry-content tr:last-child :is(td, th),
html body .nk-tx.nk-tx tr:last-child :is(td, th) {
  border-bottom: 0;
}

/* Single bordered rounded box on the outermost wrap; horizontal scroll on narrow screens. */
html body .nk-prose.nk-prose :is(.table-wrap, .nk-table-wrap, .wp-block-table, .overflow-x-auto:has(table), [data-table-scroll]),
html body .nk-article.nk-article :is(.table-wrap, .nk-table-wrap, .wp-block-table, .overflow-x-auto:has(table), [data-table-scroll]),
html body .entry-content.entry-content :is(.table-wrap, .nk-table-wrap, .wp-block-table, .overflow-x-auto:has(table), [data-table-scroll]),
html body .nk-tx.nk-tx :is(.table-wrap, .nk-table-wrap, .wp-block-table, .overflow-x-auto:has(table), [data-table-scroll]) {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-block: 1.6em;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--nk-c-accent, #d4a537) var(--nk-c-pastel-1, #eef0f3);
  border: 1px solid var(--nk-c-border, #b9c0cb);
  border-radius: calc(var(--nk-radius-media, 18px) * var(--nk-sq-k, 1));
  corner-shape: var(--nk-squircle, squircle);
  background: var(--nk-c-card-bg, #fff);
}

/* Neutralise the nested inner wrap so the box is not doubled. */
html body .nk-prose.nk-prose :is(.table-wrap, .overflow-x-auto, .wp-block-table, [data-table-scroll]) :is(.nk-table-wrap, .table-wrap),
html body .nk-article.nk-article :is(.table-wrap, .overflow-x-auto, .wp-block-table, [data-table-scroll]) :is(.nk-table-wrap, .table-wrap),
html body .entry-content.entry-content :is(.table-wrap, .overflow-x-auto, .wp-block-table, [data-table-scroll]) :is(.nk-table-wrap, .table-wrap),
html body .nk-tx.nk-tx :is(.table-wrap, .overflow-x-auto, .wp-block-table, [data-table-scroll]) :is(.nk-table-wrap, .table-wrap),
html body .nk-tx.nk-tx .table-wrap .nk-table-wrap,
html body .nk-tx.nk-tx .overflow-x-auto .nk-table-wrap {
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

html body .nk-prose.nk-prose .wp-block-table,
html body .nk-article.nk-article .wp-block-table {
  margin-inline: 0;
}


/* Key-facts / stat-strip: a one-row .nk-table with 3–6 columns
   (Muhammad Ali Pasha, The War of 1860, and any later copy of that pattern).
   Fit the measure on desktop — equal columns, wrapping, compact padding.
   Do not inherit the 2–3 column nowrap / last-column-flex rules. */
html body .nk-prose.nk-prose table.nk-table:has(> tbody > tr:only-child):has(> thead tr > :nth-child(3)):not(:has(> thead tr > :nth-child(7))),
html body .nk-article.nk-article table.nk-table:has(> tbody > tr:only-child):has(> thead tr > :nth-child(3)):not(:has(> thead tr > :nth-child(7))),
html body .entry-content.entry-content table.nk-table:has(> tbody > tr:only-child):has(> thead tr > :nth-child(3)):not(:has(> thead tr > :nth-child(7))),
html body .nk-prose.nk-prose table.nk-table.nk-facts,
html body .nk-article.nk-article table.nk-table.nk-facts,
html body .entry-content.entry-content table.nk-table.nk-facts {
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  font-size: .82em;
  line-height: 1.35;
}

html body .nk-prose.nk-prose .nk-table-wrap:has(> table.nk-table:has(> tbody > tr:only-child):has(> thead tr > :nth-child(3)):not(:has(> thead tr > :nth-child(7)))),
html body .nk-article.nk-article .nk-table-wrap:has(> table.nk-table:has(> tbody > tr:only-child):has(> thead tr > :nth-child(3)):not(:has(> thead tr > :nth-child(7)))),
html body .entry-content.entry-content .nk-table-wrap:has(> table.nk-table:has(> tbody > tr:only-child):has(> thead tr > :nth-child(3)):not(:has(> thead tr > :nth-child(7)))),
html body .nk-prose.nk-prose .nk-table-wrap:has(> table.nk-facts),
html body .nk-article.nk-article .nk-table-wrap:has(> table.nk-facts),
html body .entry-content.entry-content .nk-table-wrap:has(> table.nk-facts) {
  overflow-x: hidden;
  max-width: 100%;
}

html body .nk-prose.nk-prose table.nk-table:has(> tbody > tr:only-child) :is(th, td),
html body .nk-article.nk-article table.nk-table:has(> tbody > tr:only-child) :is(th, td),
html body .entry-content.entry-content table.nk-table:has(> tbody > tr:only-child) :is(th, td),
html body .nk-prose.nk-prose table.nk-table.nk-facts :is(th, td),
html body .nk-article.nk-article table.nk-table.nk-facts :is(th, td),
html body .entry-content.entry-content table.nk-table.nk-facts :is(th, td),
html body .nk-prose.nk-prose table.nk-table:has(> tbody > tr:only-child) :is(th, td):not(:last-child),
html body .nk-article.nk-article table.nk-table:has(> tbody > tr:only-child) :is(th, td):not(:last-child),
html body .entry-content.entry-content table.nk-table:has(> tbody > tr:only-child) :is(th, td):not(:last-child),
html body .nk-prose.nk-prose table.nk-table:has(> tbody > tr:only-child) :is(th, td):last-child,
html body .nk-article.nk-article table.nk-table:has(> tbody > tr:only-child) :is(th, td):last-child,
html body .entry-content.entry-content table.nk-table:has(> tbody > tr:only-child) :is(th, td):last-child {
  width: auto;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  padding: .4em .65em;
  vertical-align: top;
  line-height: 1.35;
}

/* Phone: stack each fact as a label/value pair. Labels come from data-label (set in the mu-plugin script). */
@media (max-width: 640px) {
  html body .nk-prose.nk-prose .nk-table-wrap:has(> table.nk-facts),
  html body .nk-article.nk-article .nk-table-wrap:has(> table.nk-facts),
  html body .entry-content.entry-content .nk-table-wrap:has(> table.nk-facts) {
    overflow: visible;
  }
  html body .nk-prose.nk-prose table.nk-table.nk-facts thead,
  html body .nk-article.nk-article table.nk-table.nk-facts thead,
  html body .entry-content.entry-content table.nk-table.nk-facts thead {
    display: none;
  }
  html body .nk-prose.nk-prose table.nk-table.nk-facts,
  html body .nk-article.nk-article table.nk-table.nk-facts,
  html body .entry-content.entry-content table.nk-table.nk-facts,
  html body .nk-prose.nk-prose table.nk-table.nk-facts tbody,
  html body .nk-article.nk-article table.nk-table.nk-facts tbody,
  html body .entry-content.entry-content table.nk-table.nk-facts tbody,
  html body .nk-prose.nk-prose table.nk-table.nk-facts tr,
  html body .nk-article.nk-article table.nk-table.nk-facts tr,
  html body .entry-content.entry-content table.nk-table.nk-facts tr {
    display: block;
    width: 100%;
    max-width: 100%;
    table-layout: auto;
  }
  html body .nk-prose.nk-prose table.nk-table.nk-facts td,
  html body .nk-article.nk-article table.nk-table.nk-facts td,
  html body .entry-content.entry-content table.nk-table.nk-facts td {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: .55em .75em .6em;
    border-bottom: 1px solid var(--nk-c-border, #b9c0cb);
  }
  html body .nk-prose.nk-prose table.nk-table.nk-facts td:last-child,
  html body .nk-article.nk-article table.nk-table.nk-facts td:last-child,
  html body .entry-content.entry-content table.nk-table.nk-facts td:last-child {
    border-bottom: 0;
  }
  html body .nk-prose.nk-prose table.nk-table.nk-facts td::before,
  html body .nk-article.nk-article table.nk-table.nk-facts td::before,
  html body .entry-content.entry-content table.nk-table.nk-facts td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .15em;
    font-family: var(--nk-f-meta-family, inherit);
    font-size: .82em;
    font-weight: 600;
    letter-spacing: .08em;
    font-variant: small-caps;
    text-transform: none;
    color: var(--nk-c-primary, #14223d);
  }
  html body .nk-prose.nk-prose table.nk-table.nk-facts td:nth-child(even),
  html body .nk-article.nk-article table.nk-table.nk-facts td:nth-child(even),
  html body .entry-content.entry-content table.nk-table.nk-facts td:nth-child(even) {
    background: color-mix(in srgb, var(--nk-c-primary, #14223d) 3.5%, var(--nk-c-bg, #FBFAF5));
  }
  /* Fallback if JS has not labelled the cells: scroll inside the rounded box. */
  html body .nk-prose.nk-prose .nk-table-wrap:has(> table.nk-table:has(> tbody > tr:only-child)):not(:has(> table.nk-facts)),
  html body .nk-article.nk-article .nk-table-wrap:has(> table.nk-table:has(> tbody > tr:only-child)):not(:has(> table.nk-facts)),
  html body .entry-content.entry-content .nk-table-wrap:has(> table.nk-table:has(> tbody > tr:only-child)):not(:has(> table.nk-facts)) {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--nk-c-accent, #d4a537) var(--nk-c-pastel-1, #eef0f3);
  }
}
