/* ==========================================================================
   Stuff Curious — Moops v2
   Patch v4: Content tables (Gutenberg .wp-block-table + bare <table>)
   Depends on tokens defined in style.css (:root)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Content column width
   -------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  .post-content,
  .entry-content,
  .page-content {
    max-width: 760px;
  }
}

/* --------------------------------------------------------------------------
   1. Wrapper — card shell, clipped corners, horizontal scroll on small screens
   -------------------------------------------------------------------------- */

.wp-block-table,
.post-content > table,
.entry-content > table {
  margin: 2.5rem 0;
}

.wp-block-table {
  overflow-x: auto;                       /* also clips the border-radius */
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card, #1a1a26);
  border: 1px solid var(--border-color, #2e2b45);
  border-radius: var(--radius, 1rem);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  scrollbar-color: var(--accent-purple, #8b5df6) var(--bg-raised, #252535);
  scrollbar-width: thin;
}

.wp-block-table::-webkit-scrollbar { height: 8px; }
.wp-block-table::-webkit-scrollbar-track { background: var(--bg-raised, #252535); }
.wp-block-table::-webkit-scrollbar-thumb {
  background: var(--accent-purple, #8b5df6);
  border-radius: var(--radius-pill, 9999px);
}

/* Optional: let a table break out of the 700px single-post column */
.wp-block-table.is-wide {
  width: calc(100% + 8rem);
  max-width: 100vw;
  margin-inline: -4rem;
}

/* --------------------------------------------------------------------------
   2. Table base
   -------------------------------------------------------------------------- */

.wp-block-table table,
.post-content table,
.entry-content table {
  width: 100%;
  min-width: 0;                            /* no forced scroll on desktop */
  border-collapse: separate;               /* keeps the rounded corners intact */
  border-spacing: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary, #ccc7e8);
  font-variant-numeric: tabular-nums;      /* prices/percentages line up */
}

.wp-block-table table.has-fixed-layout { table-layout: fixed; }

/* With fixed layout, give the label column room and split the rest evenly */
.wp-block-table table.has-fixed-layout th:first-child { width: 34%; }

/* --------------------------------------------------------------------------
   3. Head — the theme's 3px purple underline, scaled down to 2px
   -------------------------------------------------------------------------- */

.wp-block-table th,
.post-content table th,
.entry-content table th {
  background: var(--bg-raised, #252535);
  color: var(--text-primary, #f0eeff);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.08em;
  line-height: 1.35;
  text-transform: uppercase;
  text-align: left;
  vertical-align: bottom;
  padding: 1.05rem 1.35rem;
  border-bottom: 2px solid var(--accent-purple, #8b5df6);
  white-space: normal;                     /* headers wrap instead of scrolling */
  overflow-wrap: break-word;
  hyphens: none;
}

/* First row of <tbody> used as a header row (Gutenberg does this by default) */
.wp-block-table tbody tr:first-child th { border-top: 0; }

/* --------------------------------------------------------------------------
   4. Body cells
   -------------------------------------------------------------------------- */

.wp-block-table td,
.post-content table td,
.entry-content table td {
  padding: 1.05rem 1.35rem;
  border-bottom: 1px solid var(--border-light, #2a2740);
  vertical-align: top;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.wp-block-table tbody tr:last-child td,
.post-content table tbody tr:last-child td,
.entry-content table tbody tr:last-child td {
  border-bottom: 0;
}

/* Row label column reads as the anchor of each row */
.wp-block-table td:first-child,
.post-content table td:first-child,
.entry-content table td:first-child {
  color: var(--text-primary, #f0eeff);
  font-weight: 500;
}

/* Zebra banding, kept faint so the purple hover still reads */
.wp-block-table tbody tr:nth-child(even) td,
.post-content table tbody tr:nth-child(even) td,
.entry-content table tbody tr:nth-child(even) td {
  background: rgba(139, 93, 246, 0.035);
}

/* Row hover — purple wash + accent rail on the leading cell */
.wp-block-table tbody tr:hover td,
.post-content table tbody tr:hover td,
.entry-content table tbody tr:hover td {
  background: rgba(139, 93, 246, 0.10);
  color: var(--text-primary, #f0eeff);
}

.wp-block-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 0 var(--accent-purple, #8b5df6);
}

/* Emphasis inside cells */
.wp-block-table td strong,
.post-content table td strong,
.entry-content table td strong {
  color: var(--text-primary, #f0eeff);
  font-weight: 600;
}

/* Parenthetical date ranges sit back a step */
.wp-block-table td small,
.wp-block-table td .cell-note {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-faint, #5a5478);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.wp-block-table td a,
.post-content table td a,
.entry-content table td a {
  color: var(--accent-purple, #8b5df6);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 93, 246, 0.4);
}

.wp-block-table td a:hover {
  color: var(--accent-purple-dark, #6b3fd4);
  border-bottom-color: var(--accent-purple-dark, #6b3fd4);
}

.wp-block-table td code {
  background: var(--bg-raised, #252535);
  border-radius: var(--radius-sm, 0.5rem);
  padding: 0.15rem 0.4rem;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.85em;
}

/* --------------------------------------------------------------------------
   5. Utility classes — add to the <table> element in the block editor
      (Block settings → Advanced → Additional CSS class)
   -------------------------------------------------------------------------- */

/* Right-align every column but the first: for price / percentage tables */
.wp-block-table.is-numeric th:not(:first-child),
.wp-block-table.is-numeric td:not(:first-child) {
  text-align: right;
}

/* Highlight a single figure: wrap the value in <span class="figure-up"> etc. */
.wp-block-table .figure-up    { color: #8affc1; font-weight: 600; }
.wp-block-table .figure-down  { color: var(--accent-coral, #ff6b6b); font-weight: 600; }
.wp-block-table .figure-flat  { color: var(--text-faint, #5a5478); font-weight: 600; }
.wp-block-table .figure-key   { color: var(--accent-amber, #f7c94e); font-weight: 600; }

/* Square badge treatment, faithful to the theme's tag style */
.wp-block-table .cell-badge {
  display: inline-block;
  background: var(--accent-purple, #8b5df6);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 0;
}

/* Call out a summary row: add class "is-total" to the <tr> */
.wp-block-table tr.is-total td {
  background: rgba(139, 93, 246, 0.14);
  color: var(--text-primary, #f0eeff);
  font-weight: 600;
  border-top: 1px solid var(--accent-purple, #8b5df6);
}

/* --------------------------------------------------------------------------
   6. Core block style variations
   -------------------------------------------------------------------------- */

.wp-block-table.is-style-stripes {
  background: var(--bg-card, #1a1a26);
  border: 1px solid var(--border-color, #2e2b45);
}

.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
  background-color: transparent;
}

.wp-block-table figcaption,
.wp-block-table + figcaption {
  padding: 0.9rem 1.35rem;
  background: var(--bg-surface, #1e1e2a);
  border-top: 1px solid var(--border-light, #2a2740);
  color: var(--text-faint, #5a5478);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: left;
}

/* --------------------------------------------------------------------------
   7. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 782px) {
  .wp-block-table.is-wide {
    width: 100%;
    margin-inline: 0;
  }

  .wp-block-table table {
    font-size: 0.88rem;
    min-width: 30rem;                      /* scroll only on small screens */
  }

  .wp-block-table th,
  .wp-block-table td {
    padding: 0.85rem 1rem;
  }

  .wp-block-table th { font-size: 0.66rem; }

  .wp-block-table table.has-fixed-layout th:first-child { width: 38%; }

  .sc-chart { padding: 1.15rem 1.15rem 1rem; }
  .sc-chart__title { font-size: 1.25rem; }

  /* Scroll affordance on the trailing edge */
  .wp-block-table {
    background-image: linear-gradient(
      to left,
      rgba(139, 93, 246, 0.12),
      rgba(139, 93, 246, 0) 2.5rem
    );
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-attachment: local;
  }
}

/* --------------------------------------------------------------------------
   8. Accessibility + print
   -------------------------------------------------------------------------- */

.wp-block-table:focus-visible {
  outline: 2px solid var(--accent-purple, #8b5df6);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .wp-block-table td { transition: none; }
}

@media print {
  .wp-block-table {
    background: #fff;
    border-color: #999;
    box-shadow: none;
    overflow: visible;
  }
  .wp-block-table th {
    background: #eee;
    color: #000;
    border-bottom-color: #333;
  }
  .wp-block-table td,
  .wp-block-table td:first-child {
    color: #000;
    background: #fff;
  }
}

/* --------------------------------------------------------------------------
   9. Footnotes — core block (.wp-block-footnotes) + manual (.sc-footnotes)
   -------------------------------------------------------------------------- */

/* 9a. Inline reference marker */
sup.fn a,
.sc-fnref {
  display: inline-block;
  min-width: 1.05em;
  margin: 0 0.12em;
  padding: 0 0.25em;
  background: rgba(139, 93, 246, 0.16);
  color: var(--accent-purple, #8b5df6);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.68em;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  border: 0;
  border-radius: 0;                        /* square, per the theme's badge rule */
  transition: background-color 0.16s ease, color 0.16s ease;
}

sup.fn a:hover,
sup.fn a:focus-visible,
.sc-fnref:hover {
  background: var(--accent-purple, #8b5df6);
  color: #fff;
}

/* 9b. The list itself.
   NOTE: `.post-content ol` in style.css is (0,1,1) and the core footnotes block
   IS the <ol>, so these selectors must match or beat that specificity. */
.post-content ol.wp-block-footnotes,
.entry-content ol.wp-block-footnotes,
.page-content ol.wp-block-footnotes,
.post-content .sc-footnotes,
.entry-content .sc-footnotes,
.page-content .sc-footnotes,
ol.wp-block-footnotes,
.sc-footnotes {
  margin: 3.5rem 0 0 0;                    /* kills the inherited 1.5rem indent */
  padding: 1.75rem 0 0 0;
  border-top: 1px solid var(--border-color, #2e2b45);
  list-style: none;
  counter-reset: sc-fn;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--text-secondary, #ccc7e8);
}

/* Inner <ol> of the manual wrapper — same specificity problem */
.post-content .sc-footnotes ol,
.entry-content .sc-footnotes ol,
.page-content .sc-footnotes ol,
.sc-footnotes ol {
  margin: 0;
  padding: 0;
  border-top: 0;
  list-style: none;
  counter-reset: sc-fn;
}

/* Eyebrow label. Delete this rule if you'd rather add your own heading. */
.wp-block-footnotes::before,
.sc-footnotes::before {
  content: "Notes & Sources";
  display: block;
  margin-bottom: 1.25rem;
  color: var(--text-faint, #5a5478);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* 9c. Each note — square counter badge in the gutter */
.post-content ol.wp-block-footnotes li,
.entry-content ol.wp-block-footnotes li,
.page-content ol.wp-block-footnotes li,
.post-content .sc-footnotes li,
.entry-content .sc-footnotes li,
.page-content .sc-footnotes li,
ol.wp-block-footnotes li,
.sc-footnotes li {
  position: relative;
  margin: 0 0 0.9rem 0;
  padding: 0.35rem 0.75rem 0.35rem 2.75rem;
  border-radius: var(--radius-sm, 0.5rem);
  list-style: none;
}

.post-content ol.wp-block-footnotes li::before,
.entry-content ol.wp-block-footnotes li::before,
.post-content .sc-footnotes li::before,
.entry-content .sc-footnotes li::before,
.wp-block-footnotes li::before,
.sc-footnotes li::before {
  counter-increment: sc-fn;
  content: counter(sc-fn);
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 1.55rem;
  height: 1.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised, #252535);
  border: 1px solid var(--border-color, #2e2b45);
  border-bottom: 2px solid var(--accent-purple, #8b5df6);
  color: var(--accent-purple, #8b5df6);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 0;
}

.wp-block-footnotes li a,
.sc-footnotes li a {
  color: var(--accent-purple, #8b5df6);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 93, 246, 0.35);
  overflow-wrap: anywhere;                 /* long URLs won't blow out the column */
}

.wp-block-footnotes li a:hover,
.sc-footnotes li a:hover {
  color: var(--accent-purple-dark, #6b3fd4);
  border-bottom-color: var(--accent-purple-dark, #6b3fd4);
}

/* 9d. Back-link arrow rendered by the core block */
.wp-block-footnotes li a[href^="#"][aria-label*="footnote" i] {
  margin-left: 0.4rem;
  color: var(--text-faint, #5a5478);
  border-bottom: 0;
  font-size: 0.9em;
}

.wp-block-footnotes li a[href^="#"][aria-label*="footnote" i]:hover {
  color: var(--accent-purple, #8b5df6);
}

/* 9e. Jump target — brief purple flash so the reader finds the note */
.wp-block-footnotes li:target,
.sc-footnotes li:target {
  background: rgba(139, 93, 246, 0.12);
  box-shadow: inset 3px 0 0 0 var(--accent-purple, #8b5df6);
  animation: sc-fn-flash 2.4s ease-out 1;
}

@keyframes sc-fn-flash {
  0%   { background: rgba(139, 93, 246, 0.30); }
  100% { background: rgba(139, 93, 246, 0.12); }
}

/* --------------------------------------------------------------------------
   10. Chart container ([sc_chart] shortcode)
   -------------------------------------------------------------------------- */

.sc-chart {
  margin: 2.5rem 0;
  padding: 1.5rem 1.5rem 1.25rem;
  background: var(--bg-card, #1a1a26);
  border: 1px solid var(--border-color, #2e2b45);
  border-radius: var(--radius, 1rem);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.sc-chart__title {
  margin: 0 0 0.3rem;
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--text-primary, #f0eeff);
}

.sc-chart__subtitle {
  margin: 0 0 1.25rem;
  color: var(--text-faint, #5a5478);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sc-chart__canvas-wrap {
  position: relative;
  width: 100%;
}

.sc-chart canvas { display: block; }

.sc-chart__source {
  margin: 1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-light, #2a2740);
  color: var(--text-faint, #5a5478);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.sc-chart__source a {
  color: var(--text-faint, #5a5478);
  border-bottom: 1px solid var(--border-color, #2e2b45);
  text-decoration: none;
}

.sc-chart__source a:hover {
  color: var(--accent-purple, #8b5df6);
  border-bottom-color: var(--accent-purple, #8b5df6);
}

/* --------------------------------------------------------------------------
   11. Footnote + chart accessibility and print
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .wp-block-footnotes li:target,
  .sc-footnotes li:target { animation: none; }
}

@media print {
  .wp-block-footnotes,
  .sc-footnotes { color: #000; border-top-color: #999; }
  .wp-block-footnotes li::before,
  .sc-footnotes li::before { color: #000; background: #eee; border-color: #999; }
  .sc-chart { background: #fff; border-color: #999; box-shadow: none; }
  .sc-chart__title { color: #000; }
}

/* --------------------------------------------------------------------------
   12. Tables with a real <thead>
   Core's table block styles (wp-includes/blocks/table/style.css) apply
   `thead { border-bottom: 3px solid }` and `td, th { border: 1px solid }`
   with no color, so both resolve to currentColor — a near-white keyline.
   Neutralize them and reassert the purple underline.
   -------------------------------------------------------------------------- */

.wp-block-table thead,
.wp-block-table tfoot,
.post-content .wp-block-table thead,
.entry-content .wp-block-table thead,
.post-content .wp-block-table tfoot,
.entry-content .wp-block-table tfoot {
  border: 0;
}

.wp-block-table th,
.wp-block-table td,
.post-content .wp-block-table th,
.post-content .wp-block-table td,
.entry-content .wp-block-table th,
.entry-content .wp-block-table td {
  border-top: 0;
  border-left: 0;
  border-right: 0;
}

.wp-block-table thead th,
.post-content .wp-block-table thead th,
.entry-content .wp-block-table thead th {
  border-bottom: 2px solid var(--accent-purple, #8b5df6);
}

/* Restore the row divider that the reset above strips from the first body row */
.wp-block-table thead + tbody tr:first-child td {
  border-top: 0;
}

/* --------------------------------------------------------------------------
   13. Featured image + captions
   Pairs with template-parts/featured-image.php
   -------------------------------------------------------------------------- */

.post-hero {
   margin-left: auto;
   margin-right: auto;
}

.post-hero__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius, 1rem);
}

/* Caption on the featured image */
.post-hero__caption {
  margin-top: 0.75rem;
  color: var(--text-faint, #847ea4);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-align: left;
}

/* Inline image captions — same treatment, so credits read consistently */
.wp-block-image figcaption,
.post-content figure figcaption,
.entry-content figure figcaption {
  margin-top: 0.6rem;
  color: var(--text-faint, #847ea4);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-align: left;
}

.post-hero__caption a,
.wp-block-image figcaption a,
.post-content figure figcaption a,
.entry-content figure figcaption a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(146, 103, 247, 0.4);
  text-underline-offset: 0.15em;
}

.post-hero__caption a:hover,
.wp-block-image figcaption a:hover,
.post-content figure figcaption a:hover {
  color: var(--accent-purple, #9267f7);
  text-decoration-color: currentColor;
}

/* The table block's own figcaption keeps its bordered-panel treatment from
   section 6 — this rule stops the generic caption styles above from touching it. */
.wp-block-table figcaption {
  margin-top: 0;
}

/* Logged-in editor notice for a missing alt attribute */
.post-hero__notice {
  margin: -1.75rem 0 2.5rem;
  padding: 0.6rem 0.9rem;
  background: rgba(247, 201, 78, 0.10);
  border-left: 3px solid var(--accent-amber, #f7c94e);
  color: var(--accent-amber, #f7c94e);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.post-hero__notice a { color: inherit; }

@media (max-width: 782px) {
  .post-hero { margin-bottom: 0; }
  .post-hero__image { border-radius: var(--radius-sm, 0.5rem); }
}

@media print {
  .post-hero__notice { display: none; }
  .post-hero__caption,
  .wp-block-image figcaption { color: #333; }
}
/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.pagination {
  margin: 3.5rem 0 1rem;
}

.pagination .page-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination .page-numbers li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination .page-numbers li::marker {
  content: "";
}

/* Individual links and the current-page span */
.pagination li > .page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.75rem;
  background: var(--bg-card, #1a1a26);
  border: 1px solid var(--border-color, #2e2b45);
  border-radius: var(--radius-sm, 0.5rem);
  color: var(--text-secondary, #ccc7e8);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.pagination li > a.page-numbers:hover {
  background: var(--bg-raised, #252535);
  border-color: var(--accent-purple, #9267f7);
  color: var(--text-primary, #f0eeff);
}

.pagination li > .page-numbers.current {
  background: var(--accent-purple-solid, #7c4ef0);
  border-color: var(--accent-purple-solid, #7c4ef0);
  color: #fff;
  cursor: default;
}

.pagination li > .page-numbers.dots {
  min-width: auto;
  padding: 0 0.35rem;
  background: none;
  border: 0;
  color: var(--text-faint, #847ea4);
}

@media (max-width: 782px) {
  .pagination { margin: 2.5rem 0 0.5rem; }
  .pagination .page-numbers { gap: 0.4rem; }
  .pagination li > .page-numbers {
    min-width: 40px;
    min-height: 40px;
    padding: 0 0.55rem;
    font-size: 0.8rem;
  }
}
