/**
 * Candid Dragon — rating standard layout CSS
 * ------------------------------------------------------------
 * Purpose: keep every rating label fully visible on desktop and
 * mobile (no clipped headings, chips, bars, stake/lean cells,
 * legend rows, or source / scorecard / stated tables).
 *
 * Status: NOT LIVE. Hand this to Master to add after a backup.
 * Suggested home: theme Additional CSS, or a child-theme file
 * enqueued after americana.css. This file is self-contained and
 * does not need to be inlined in each post.
 *
 * Scope: every selector below is limited to rating components
 * (.cdp-*, .cd-label*, .cd-ratings, .cd-stated, .cd-emoji,
 * .cd-labels, .cd-label-key, .cd-hbar*, #big-question, #ratings,
 * #sources-stake, #legend, #scorecard + table, and
 * figure.wp-block-table:has(.cd-stated / .cd-label)).
 * It does not restyle the header, nav, masthead scalebar, or
 * ordinary article prose.
 *
 * Open item (do not resolve here):
 *   The middle lean label is still undecided: "Factual" vs "Center".
 *   The preview currently shows "⏺️ Factual" in copy and uses
 *   .cd-label--lean-f / .cdp-lean for that cell. This stylesheet
 *   does not choose a word and does not restyle one option over
 *   the other. See the placeholder hook at the bottom of this file.
 *
 * No external fonts or other dependencies. System / theme font
 * stacks only. Overflow:hidden is never applied to labels.
 * No fixed heights on label text.
 */

/* =================================================================
   1. Shared resets for rating components
   ================================================================= */

.cdp-card,
.cdp-scroll,
.cdp-table,
.cdp-legend,
.cdp-toc,
.cdp-answer,
.cdp-h,
.cdp-note,
.cdp-banner,
.cdp-bar,
.cdp-lean,
.cdp-stake,
.cdp-nowrap,
.cdp-tx,
.cdp-cl,
.cd-ratings,
.cd-labels,
.cd-label,
.cd-stated,
.cd-emoji,
.cd-label-key,
.body .cd-hbars,
.body .cd-hbar__top,
figure.wp-block-table:has(.cd-stated),
figure.wp-block-table:has(.cd-label),
#scorecard + figure.wp-block-table {
  box-sizing: border-box;
  max-width: 100%;
  overflow: visible;
  height: auto;
}

.cdp-card *,
.cdp-legend *,
.cdp-toc *,
.cd-ratings *,
.cd-labels *,
.cd-label-key *,
figure.wp-block-table:has(.cd-stated) *,
figure.wp-block-table:has(.cd-label) *,
#scorecard + figure.wp-block-table * {
  box-sizing: border-box;
}

.cdp-card,
#big-question,
#ratings,
#sources-stake,
#legend {
  max-width: 100%;
  height: auto;
  overflow: visible;
}

/* =================================================================
   2. Rating cards (top card, glance grid, source table, key)
   ================================================================= */

.cdp-card {
  border: 1px solid #c9bfa8;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  background: #fffdf7;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.cdp-h {
  font-weight: 700;
  font-size: 1.05em;
  line-height: 1.35;
  margin: 0 0 8px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.cdp-h small {
  display: inline;
  font-weight: 500;
  white-space: normal;
}

.cdp-note,
.cdp-banner {
  overflow-wrap: break-word;
  word-wrap: break-word;
  overflow: visible;
  height: auto;
}

.cdp-note {
  font-size: 0.9em;
  line-height: 1.45;
  margin: 6px 0;
}

.cdp-banner {
  background: #f3eee4;
  border-left: 4px solid #8a6d3b;
  padding: 8px 12px;
  font-size: 0.9em;
  margin: 0 0 12px;
}

.cdp-answer,
.cdp-big .cdp-answer {
  font-size: 1.25em;
  font-weight: 700;
  line-height: 1.35;
  margin: 4px 0;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  height: auto;
}

/* =================================================================
   3. Five-step confidence bars
   Glyphs stay on one line (nowrap is for the bar only, not labels).
   On a narrow card the bar drops below the verdict word.
   ================================================================= */

.cdp-bar {
  display: inline-block;
  font-family: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: visible;
  height: auto;
  max-width: 100%;
  vertical-align: baseline;
  line-height: 1;
}

.cdp-answer .cdp-bar,
.cd-ratings .cdp-bar,
.cdp-h .cdp-bar {
  margin-left: 0.35em;
}

@media (max-width: 600px) {
  .cdp-answer .cdp-bar,
  .cdp-legend .cdp-bar,
  .cd-ratings .cdp-bar {
    display: block;
    margin: 0.25em 0 0.15em;
  }

  .cdp-big .cdp-answer {
    font-size: 1.1em;
  }

  .cdp-card {
    padding: 12px;
  }
}

/* =================================================================
   4. Inline emoji ratings, stated line, lean chips
   Override theme nowrap / min-width so chips wrap instead of clip.
   ================================================================= */

.cd-ratings,
.cd-labels,
.cd-stated {
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  height: auto;
  max-width: 100%;
}

.cd-labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.cd-label,
.cd-labels .cd-label,
.cd-ratings .cd-label,
.cd-label-key .cd-label,
td .cd-label,
.cd-stated + br + .cd-label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: auto;
  min-height: 0;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  box-sizing: border-box;
}

.cd-emoji {
  flex: none;
  letter-spacing: 0;
  text-transform: none;
  overflow: visible;
}

.cd-stated {
  display: inline;
}

.cd-label-key li {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}

.cd-label-key li .cd-label {
  flex: none;
  min-width: 0;
  margin-right: 0;
}

@media (max-width: 600px) {
  .cd-label-key li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* =================================================================
   5. Rating and source tables
   Wider than the column: scroll inside .cdp-scroll, never clip.
   Under 600px: stack into cards (source tables already carry
   data-l= attributes; the glance grid is labelled by column).
   ================================================================= */

.cdp-scroll {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.cdp-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92em;
  table-layout: auto;
  height: auto;
}

.cdp-table th,
.cdp-table td {
  border-bottom: 1px solid #e3dccb;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  height: auto;
  hyphens: manual;
}

.cdp-table th {
  font-weight: 700;
  white-space: normal;
}

/* Keep the short verdict on one line when there is room; the
   wrapper scrolls if the row cannot shrink any further. */
.cdp-nowrap {
  white-space: nowrap;
}

.cdp-lean,
.cdp-stake {
  white-space: normal;
  overflow-wrap: break-word;
  word-wrap: break-word;
  overflow: visible;
  height: auto;
}

.cdp-lean {
  min-width: 7em;
}

@media (min-width: 601px) {
  /* Glance grid (3 columns) can stay a table on tablet and desktop. */
  .cdp-scroll > .cdp-table:not(.cdp-src) {
    min-width: 32rem;
  }
}

/* The source ledger has five columns (Source, What they say, Lean,
   Stake, Record). The article column is only ~680px even at a 1280
   viewport, so a table always clips the last column. Stack it at
   every width. */
.cdp-card .cdp-scroll:has(> .cdp-src),
.cdp-card .cdp-scroll:has(> .cdp-table.cdp-src) {
  overflow-x: visible;
}

.cdp-src,
.cdp-scroll > .cdp-table.cdp-src {
  min-width: 0 !important;
}

.cdp-src thead {
  display: none;
}

.cdp-src,
.cdp-src tbody,
.cdp-src tr,
.cdp-src td {
  display: block;
  width: auto;
  max-width: 100%;
}

.cdp-src tr {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  margin: 0 0 10px;
  padding: 8px 10px;
}

.cdp-src td {
  border: 0;
  padding: 3px 0;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
}

.cdp-src td[data-l]:not(:first-child)::before {
  content: attr(data-l) ": ";
  display: block;
  font-weight: 700;
  margin: 0 0 0.1em;
}

@media (max-width: 600px) {
  /* Beat the preview's in-post <style> (.cdp-nowrap { white-space: nowrap })
     and stop .cdp-scroll from clipping stacked card text. */
  .cdp-card .cdp-scroll {
    overflow-x: visible;
  }

  .cdp-src,
  .cdp-scroll > .cdp-table:not(.cdp-src) {
    min-width: 0;
  }

  .cdp-card .cdp-nowrap,
  .cdp-scroll .cdp-nowrap,
  .cdp-table td.cdp-nowrap,
  #ratings .cdp-table td {
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }

  .cdp-scroll .cdp-table thead {
    display: none;
  }

  .cdp-scroll .cdp-table,
  .cdp-scroll .cdp-table tbody,
  .cdp-scroll .cdp-table tr,
  .cdp-scroll .cdp-table td {
    display: block;
    width: auto;
    max-width: 100%;
  }

  .cdp-scroll .cdp-table tr {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin: 0 0 10px;
    padding: 8px 10px;
  }

  .cdp-scroll .cdp-table td {
    border: 0;
    padding: 3px 0;
  }

  /* Put the field name on its own line so the value never runs off. */
  .cdp-src td[data-l]:not(:first-child)::before,
  #ratings .cdp-table td::before {
    display: block;
    font-weight: 700;
    margin: 0 0 0.1em;
  }

  /* Source table: labels come from data-l on each cell. */
  .cdp-src td[data-l]:not(:first-child)::before {
    content: attr(data-l) ": ";
  }

  /* Glance grid (Claim / Our rating / Confidence). */
  #ratings .cdp-table td:nth-child(1)::before {
    content: "Claim";
  }

  #ratings .cdp-table td:nth-child(2)::before {
    content: "Our rating of the claim";
  }

  #ratings .cdp-table td:nth-child(3)::before {
    content: "Confidence";
  }

  #ratings .cdp-table td:nth-child(3) .cdp-bar {
    display: inline-block;
    margin: 0.15em 0 0;
  }
}

/* =================================================================
   6. WordPress tables that carry ratings
   (Then / Later / Stated timeline, Accountability scorecard)
   Scroll sideways above 600px; stack into cards below.
   ================================================================= */

figure.wp-block-table:has(.cd-stated),
figure.wp-block-table:has(.cd-label),
#scorecard + figure.wp-block-table {
  display: block;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

figure.wp-block-table:has(.cd-stated) table,
figure.wp-block-table:has(.cd-label) table,
#scorecard + figure.wp-block-table table {
  width: 100%;
  height: auto;
  table-layout: auto;
  overflow: visible;
}

figure.wp-block-table:has(.cd-stated) th,
figure.wp-block-table:has(.cd-stated) td,
figure.wp-block-table:has(.cd-label) th,
figure.wp-block-table:has(.cd-label) td,
#scorecard + figure.wp-block-table th,
#scorecard + figure.wp-block-table td {
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  height: auto;
  vertical-align: top;
}

@media (min-width: 601px) {
  figure.wp-block-table:has(.cd-stated) table,
  figure.wp-block-table:has(.cd-label) table,
  #scorecard + figure.wp-block-table table {
    min-width: 36rem;
  }
}

@media (max-width: 600px) {
  figure.wp-block-table:has(.cd-stated) table,
  figure.wp-block-table:has(.cd-label) table,
  #scorecard + figure.wp-block-table table {
    min-width: 0;
  }

  figure.wp-block-table:has(.cd-stated) thead,
  figure.wp-block-table:has(.cd-label) thead,
  #scorecard + figure.wp-block-table thead {
    display: none;
  }

  figure.wp-block-table:has(.cd-stated) table,
  figure.wp-block-table:has(.cd-stated) tbody,
  figure.wp-block-table:has(.cd-stated) tr,
  figure.wp-block-table:has(.cd-stated) td,
  figure.wp-block-table:has(.cd-label) table,
  figure.wp-block-table:has(.cd-label) tbody,
  figure.wp-block-table:has(.cd-label) tr,
  figure.wp-block-table:has(.cd-label) td,
  #scorecard + figure.wp-block-table table,
  #scorecard + figure.wp-block-table tbody,
  #scorecard + figure.wp-block-table tr,
  #scorecard + figure.wp-block-table td {
    display: block;
    width: auto;
    max-width: 100%;
  }

  figure.wp-block-table:has(.cd-stated) tr,
  figure.wp-block-table:has(.cd-label) tr,
  #scorecard + figure.wp-block-table tr {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin: 0 0 10px;
    padding: 8px 10px;
  }

  figure.wp-block-table:has(.cd-stated) td,
  figure.wp-block-table:has(.cd-label) td,
  #scorecard + figure.wp-block-table td {
    border: 0;
    padding: 3px 0;
    white-space: normal;
    overflow: visible;
  }

  figure.wp-block-table:has(.cd-stated) td::before,
  figure.wp-block-table:has(.cd-label) td::before,
  #scorecard + figure.wp-block-table td::before {
    display: block;
    font-weight: 700;
    margin: 0 0 0.1em;
  }

  /* Then / Later / Stated timeline */
  figure.wp-block-table:has(.cd-stated) td:nth-child(1)::before {
    content: "Then";
  }

  figure.wp-block-table:has(.cd-stated) td:nth-child(2)::before {
    content: "Later";
  }

  figure.wp-block-table:has(.cd-stated) td:nth-child(3)::before {
    content: "Stated / our rating";
  }

  /* Accountability scorecard (no .cd-stated inside) */
  #scorecard + figure.wp-block-table td:nth-child(1)::before {
    content: "Who";
  }

  #scorecard + figure.wp-block-table td:nth-child(2)::before {
    content: "What they got right";
  }

  #scorecard + figure.wp-block-table td:nth-child(3)::before {
    content: "What they got wrong";
  }
}

/* =================================================================
   7. Rating key and icon index
   ================================================================= */

.cdp-legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 24px;
  font-size: 0.92em;
  overflow: visible;
}

.cdp-legend > * {
  min-width: 0;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  height: auto;
  padding: 2px 0;
  line-height: 1.4;
}

@media (min-width: 720px) {
  .cdp-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cdp-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 1;
  column-gap: 24px;
}

@media (min-width: 720px) {
  .cdp-toc ol {
    columns: 2;
  }
}

.cdp-toc li {
  break-inside: avoid;
  padding: 5px 0;
  border-bottom: 1px dotted #e3dccb;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
  min-width: 0;
  overflow: visible;
  overflow-wrap: break-word;
}

.cdp-toc a {
  text-decoration: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.cdp-ic {
  width: 1.4em;
  text-align: center;
  flex: none;
}

.cdp-tx,
.cdp-cl {
  min-width: 0;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  height: auto;
}

.cdp-cl {
  font-size: 0.85em;
  color: #555;
}

/* =================================================================
   8. Horizontal bar charts (theme .cd-hbar*)
   The fill track may clip the bar itself; labels must not clip.
   ================================================================= */

.body .cd-hbars,
.body .cd-hbar__top {
  overflow: visible;
  max-width: 100%;
  min-width: 0;
}

.body .cd-hbar__top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 12px;
}

.body .cd-hbar__amt {
  flex: none;
  overflow: visible;
  white-space: nowrap;
}

.body .cd-hbar__track {
  /* Clip only the fill, never a label. */
  overflow: hidden;
}

/* =================================================================
   9. Middle lean label — Center
   Chris chose "Center" (Master chat, Dec 1, 2026, 8:30 AM CT).
   Wording lives in post content, not this stylesheet. Existing
   chip class is .cd-label--lean-f; .cd-label--lean-center is an
   optional alias for new markup. Layout rules already apply to
   .cdp-lean and .cd-label--lean*.
   ================================================================= */

.cd-label--lean-f,
.cd-label--lean-center,
.cdp-lean,
.cd-label--lean-middle {
  /* Layout only. Wording is a content decision, not a CSS one. */
  overflow: visible;
  white-space: normal;
  overflow-wrap: break-word;
}

/* =================================================================
   10. Print and reduced-motion
   ================================================================= */

@media print {
  .cdp-scroll,
  figure.wp-block-table:has(.cd-stated),
  figure.wp-block-table:has(.cd-label),
  #scorecard + figure.wp-block-table {
    overflow: visible;
  }

  .cdp-scroll > .cdp-table,
  .cdp-src,
  figure.wp-block-table:has(.cd-stated) table,
  figure.wp-block-table:has(.cd-label) table,
  #scorecard + figure.wp-block-table table {
    min-width: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cdp-scroll,
  figure.wp-block-table:has(.cd-stated),
  figure.wp-block-table:has(.cd-label),
  #scorecard + figure.wp-block-table {
    scroll-behavior: auto;
  }
}
