/* ------------------------------------------------------------------
   Tables in articles: the built-in Table block.

   Loads on the site wherever a table is used, and in the block editor,
   so a table looks the same while it is being typed. Colors are literal
   (not the page's CSS variables) for that reason.

   What the editor's own controls do here:
     Header section   navy label row
     Footer section   the "bottom line" row, tinted and bold
     Caption          the note strip at the foot of the card
     Styles: Stripes  alternating rows instead of hairlines
     Align: Center    a compact table, as wide as its contents, centered
     Align: Left/Right the same as Center (articles in 3.1 center aligned blocks)
     Column alignment Right for a column of numbers

   Every selector starts with :root so it outranks WordPress's own table
   rules and the article text rules, whichever order the sheets load in.
   ------------------------------------------------------------------ */

/* ---- the card ---- */
:root .wp-block-table,
:root .wp-block-table *{box-sizing:border-box}
:root .wp-block-table{
  --t-line:#E0E7F1; --t-ink:#1B2740; --t-text:#283752; --t-muted:#5B6880;
  --t-navy:#253450; --t-sky:#8FB9E8; --t-tint:rgba(46,94,151,.05); --t-foot:#EAF2FB; --t-foot-line:#CCDDF2;
  display:block;position:relative;clear:both;
  margin-top:2.2em;margin-bottom:2.2em;padding:0;
  border:1px solid var(--t-line);border-radius:14px;
  box-shadow:0 10px 30px rgba(27,39,64,.05);
  overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;
  font-family:'Montserrat',Arial,Helvetica,sans-serif;color:var(--t-text);text-align:left;
  /* White card. The edge shading only shows when the table is wider than
     the card (phones), as a cue that it scrolls sideways. */
  background:
    linear-gradient(90deg,#fff 35%,rgba(255,255,255,0)) 0 0/34px 100% no-repeat local,
    linear-gradient(270deg,#fff 35%,rgba(255,255,255,0)) 100% 0/34px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%,rgba(27,39,64,.22),rgba(27,39,64,0)) 0 0/14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%,rgba(27,39,64,.22),rgba(27,39,64,0)) 100% 0/14px 100% no-repeat scroll,
    #fff;
}

/* on the site the card sits flush with the text column (the editor keeps its own side
   margins). In an article, blocks are spaced from above only, like the rest of .oc-body. */
:root .oc-body .wp-block-table,
:root .page-body .wp-block-table{margin-left:0;margin-right:0}
:root .oc-body .wp-block-table{margin-top:36px;margin-bottom:0}
:root .oc-body .wp-block-table + *{margin-top:32px}

:root .wp-block-table table{
  width:100%;margin:0;border:0;border-collapse:separate;border-spacing:0;background:none;color:inherit;
  font-size:.95rem;line-height:1.5;font-variant-numeric:tabular-nums lining-nums;
}

/* ---- cells: hairline rows, no vertical rules ---- */
:root .wp-block-table th,
:root .wp-block-table td{
  padding:.76rem 1.05rem;border:0;border-bottom:1px solid var(--t-line);
  text-align:left;vertical-align:top;font-weight:400;word-break:normal;overflow-wrap:break-word;
}
:root .wp-block-table th:first-child,
:root .wp-block-table td:first-child{padding-left:1.35rem}
:root .wp-block-table th:last-child,
:root .wp-block-table td:last-child{padding-right:1.35rem}

/* column alignment set in the editor */
:root .wp-block-table .has-text-align-left{text-align:left}
:root .wp-block-table .has-text-align-center{text-align:center}
:root .wp-block-table .has-text-align-right{text-align:right}
/* a right-aligned cell is a figure: keep it on one line */
:root .wp-block-table tbody .has-text-align-right,
:root .wp-block-table tfoot .has-text-align-right{white-space:nowrap}

/* ---- header row: the navy band every page on the site opens with ---- */
:root .wp-block-table thead{border:0}
:root .wp-block-table thead th,
:root .wp-block-table thead td{
  padding-top:.8rem;padding-bottom:.74rem;vertical-align:bottom;
  background:var(--t-navy);color:#fff;border-bottom:2px solid var(--t-sky);
  font-size:.72rem;font-weight:700;letter-spacing:.1em;line-height:1.4;text-transform:uppercase;
}
:root .wp-block-table thead strong,
:root .wp-block-table thead a{color:inherit}

/* ---- body ---- */
:root .wp-block-table tbody td:first-child,
:root .wp-block-table tbody th:first-child{font-weight:600;color:var(--t-ink)}
:root .wp-block-table tbody tr:last-child > *{border-bottom:0}
:root .wp-block-table tbody strong{color:var(--t-ink);font-weight:700}
@media (hover:hover){
  :root .wp-block-table tbody tr:hover > *{background:var(--t-tint)}
}

/* ---- footer row: the bottom line ---- */
:root .wp-block-table tfoot{border:0}
:root .wp-block-table tfoot th,
:root .wp-block-table tfoot td{
  background:var(--t-foot);color:var(--t-ink);font-weight:700;
  border-top:1px solid var(--t-foot-line);border-bottom:0;
}

/* ---- caption: a note strip at the foot of the card ---- */
:root .wp-block-table figcaption{
  position:sticky;left:0;display:block;margin:0;padding:.72rem 1.35rem .76rem;
  background:#F6F8FC;border-top:1px solid var(--t-line);
  color:var(--t-muted);font-size:.84rem;font-style:normal;font-weight:400;line-height:1.55;text-align:left;
}

/* ---- Styles: Stripes ---- */
:root .wp-block-table.is-style-stripes{border:1px solid var(--t-line)}
:root .wp-block-table.is-style-stripes tbody tr:nth-child(odd){background:none}
:root .wp-block-table.is-style-stripes tbody tr > *{border-bottom-color:transparent}
:root .wp-block-table.is-style-stripes tbody tr:nth-child(even) > *{background:var(--t-tint)}
@media (hover:hover){
  :root .wp-block-table.is-style-stripes tbody tr:hover > *{background:rgba(46,94,151,.09)}
}

/* ---- Align: a compact table, as wide as its contents, centered ----
   Left and Right do the same as Center: 3.1 articles never float a block. */
:root .wp-block-table.aligncenter,
:root .wp-block-table.alignleft,
:root .wp-block-table.alignright{display:block;float:none;width:-moz-fit-content;width:fit-content;min-width:min(20rem,100%);max-width:100%;margin-left:auto;margin-right:auto}
:root .wp-block-table.aligncenter table,
:root .wp-block-table.alignleft table,
:root .wp-block-table.alignright table{table-layout:auto;width:100%}
/* the note wraps to the table's width instead of stretching the card */
:root .wp-block-table.aligncenter figcaption,
:root .wp-block-table.alignleft figcaption,
:root .wp-block-table.alignright figcaption{width:0;min-width:100%}

/* ---- phones: tighter cells; wide tables scroll sideways inside the card ---- */
@media (max-width:640px){
  :root .wp-block-table table{font-size:.9rem}
  :root .wp-block-table th,
  :root .wp-block-table td{padding:.66rem .75rem}
  :root .wp-block-table th:first-child,
  :root .wp-block-table td:first-child{padding-left:1rem}
  :root .wp-block-table th:last-child,
  :root .wp-block-table td:last-child{padding-right:1rem}
  :root .wp-block-table thead th,
  :root .wp-block-table thead td{font-size:.68rem;letter-spacing:.08em}
  :root .wp-block-table figcaption{padding:.66rem 1rem .7rem}
  /* Up to three columns always fit the screen. With four or more, a short
     table still fits; a wordy one keeps readable columns and scrolls
     sideways inside the card instead. */
  :root .wp-block-table table:has(tr > :nth-child(4)){table-layout:auto;width:max-content;min-width:100%;max-width:36rem}
  :root .wp-block-table table:has(tr > :nth-child(5)){max-width:44rem}
}

/* ---- a plain HTML table typed into an article gets the same look ---- */
:root .oc-body > table{
  width:100%;margin:36px 0 0;border:1px solid #E0E7F1;border-radius:14px;border-collapse:separate;border-spacing:0;
  overflow:hidden;background:#fff;box-shadow:0 10px 30px rgba(27,39,64,.05);
  font-size:.95rem;line-height:1.5;font-variant-numeric:tabular-nums lining-nums;color:#283752;
}
:root .oc-body > table th,
:root .oc-body > table td{padding:.76rem 1.05rem;border:0;border-bottom:1px solid #E0E7F1;text-align:left;vertical-align:top;font-weight:400}
:root .oc-body > table th:first-child,
:root .oc-body > table td:first-child{padding-left:1.35rem}
:root .oc-body > table th:last-child,
:root .oc-body > table td:last-child{padding-right:1.35rem}
:root .oc-body > table thead th,
:root .oc-body > table thead td{
  padding-top:.8rem;padding-bottom:.74rem;vertical-align:bottom;background:#253450;color:#fff;border-bottom:2px solid #8FB9E8;
  font-size:.72rem;font-weight:700;letter-spacing:.1em;line-height:1.4;text-transform:uppercase;
}
:root .oc-body > table tbody td:first-child{font-weight:600;color:#1B2740}
:root .oc-body > table tbody tr:last-child > *{border-bottom:0}
:root .oc-body > table tfoot th,
:root .oc-body > table tfoot td{background:#EAF2FB;color:#1B2740;font-weight:700;border-top:1px solid #CCDDF2;border-bottom:0}

/* ---- in the editor: classic themes wrap an aligned block ---- */
:root .wp-block[data-align="center"] > .wp-block-table,
:root .wp-block[data-align="left"] > .wp-block-table,
:root .wp-block[data-align="right"] > .wp-block-table{width:-moz-fit-content;width:fit-content;min-width:min(20rem,100%);max-width:100%}
:root .wp-block[data-align="center"] > .wp-block-table{float:none;margin-left:auto;margin-right:auto}
/* the older, non-framed editor collapses a left/right block's height; undo that, as nothing floats */
html :where(.wp-block)[data-align=left][data-type="core/table"],
html :where(.wp-block)[data-align=right][data-type="core/table"]{height:auto}
:root .wp-block[data-align="left"] > .wp-block-table,
:root .wp-block[data-align="right"] > .wp-block-table{float:none;margin-left:auto;margin-right:auto}
:root .wp-block[data-align="center"] > .wp-block-table table,
:root .wp-block[data-align="left"] > .wp-block-table table,
:root .wp-block[data-align="right"] > .wp-block-table table{table-layout:auto;width:100%;margin:0}
:root .wp-block[data-align="center"] > .wp-block-table figcaption,
:root .wp-block[data-align="left"] > .wp-block-table figcaption,
:root .wp-block[data-align="right"] > .wp-block-table figcaption{width:0;min-width:100%}
