/* ==========================================================================
   stats.css — reusable "statistics article" template for TarotCards.io blog
   --------------------------------------------------------------------------
   Loaded ONLY on posts flagged _trt_stats (see tarot_enqueue_styles in
   functions.php) so it never touches other pages. All visuals are HTML + CSS
   + inline SVG — no JavaScript. Scoped under body.stats-article and the blog
   content wrapper .post-trt-content-inner; every component class is prefixed
   .stat- so it cannot collide with the theme.

   Brand tokens are lifted from the theme (style.css): Lora headings /
   Montserrat body, cream content card #EBE1CE, bronze #89621C, deep purple
   #362E7E, gold #EAC47E, cyan #26DBFF. Accent hues are darkened where needed
   for WCAG-AA contrast on the cream surface.
   ========================================================================== */

.stats-article .post-trt-content-inner {
  --stat-ink: #241d4e;        /* deep indigo — big figures / emphasis        */
  --stat-purple: #362e7e;     /* theme deep purple                            */
  --stat-violet: #6b3fc4;     /* mid violet for gradients                     */
  --stat-cyan: #1f8fb8;       /* darkened cyan (AA on cream)                  */
  --stat-gold: #b07d1f;       /* darkened gold (AA on cream)                  */
  --stat-bronze: #89621c;     /* theme heading/link bronze                    */
  --stat-cream: #ebe1ce;      /* content card bg                              */
  --stat-surface: #fbf7ef;    /* card / callout surface (lighter than cream)  */
  --stat-surface-2: #f3ead8;  /* zebra / track                                */
  --stat-line: #d9cbac;       /* hairline borders on cream                    */
  --stat-muted: #574e3a;      /* muted captions / sources (AA small text)     */
  --stat-radius: 14px;
  --stat-gap: clamp(0.9rem, 2.2vw, 1.4rem);
}

/* Keep our components readable regardless of the theme's fluid vw type. */
.stats-article .post-trt-content-inner .stat-hero,
.stats-article .post-trt-content-inner .stat-glance,
.stats-article .post-trt-content-inner .stat-bars,
.stats-article .post-trt-content-inner .stat-note,
.stats-article .post-trt-content-inner .stat-callout,
.stats-article .post-trt-content-inner .stat-table-wrap,
.stats-article .post-trt-content-inner .stat-related,
.stats-article .post-trt-content-inner .stat-sources {
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Headings — editorial treatment with a short gold underline accent
   -------------------------------------------------------------------------- */
.stats-article .post-trt-content-inner h2 {
  color: var(--stat-purple);
  font-size: clamp(1.5rem, 4.4vw, 2.15rem);
  line-height: 1.2;
  margin: 2.4em 0 0.7em;
  padding-bottom: 0.35em;
  position: relative;
}
.stats-article .post-trt-content-inner h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.4rem;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--stat-gold), #eac47e);
}
.stats-article .post-trt-content-inner h3 {
  color: var(--stat-ink);
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  line-height: 1.3;
  margin: 1.6em 0 0.4em;
}
.stats-article .post-trt-content-inner p,
.stats-article .post-trt-content-inner li {
  font-size: clamp(1rem, 1.25vw, 1.125rem);
  line-height: 1.75;
}
.stats-article .post-trt-content-inner a {
  color: var(--stat-bronze);
  text-underline-offset: 2px;
}
/* The theme auto-injects CTA blocks into the article body; keep their heading the
   theme's gold (our generic h3 colour would otherwise tie on specificity and win
   by load order, rendering it dark-on-dark). */
.stats-article .post-trt-content-inner .tarot-cta-block h3 {
  color: #f3d66b;
  font-family: "Lora", serif;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.15;
  margin: 0 0 24px;
}

/* --------------------------------------------------------------------------
   Hero — the single biggest stat as real text (fast LCP, no image)
   -------------------------------------------------------------------------- */
.stat-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  margin: 0.6rem 0 2.2rem;
  padding: clamp(1.4rem, 4vw, 2.4rem) 1.2rem;
  background:
    radial-gradient(120% 140% at 50% -20%, rgba(54, 46, 126, 0.10), transparent 60%),
    var(--stat-surface);
  border: 1px solid var(--stat-line);
  border-radius: var(--stat-radius);
}
.stat-hero-fig {
  font-family: "Lora", Georgia, serif;
  font-weight: 700;
  font-size: clamp(3.2rem, 13vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--stat-purple); /* fallback if background-clip unsupported */
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .stat-hero-fig {
    background: linear-gradient(92deg, var(--stat-purple) 10%, var(--stat-violet) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}
.stat-hero-cap {
  font-size: clamp(1.05rem, 2vw, 1.3rem) !important;
  line-height: 1.4 !important;
  max-width: 34ch;
  margin: 0 !important;
  color: var(--stat-ink);
}
.stat-hero-src {
  font-size: 0.8rem !important; /* beat the theme's 3-class .post-trt…inner p rule */
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--stat-muted);
}
/* Text-only hero (pages with no single headline number) */
.stat-hero--text {
  text-align: left;
  align-items: flex-start;
}
.stat-hero--text .stat-hero-lead {
  font-family: "Lora", Georgia, serif;
  font-size: clamp(1.25rem, 3vw, 1.7rem) !important;
  line-height: 1.4 !important;
  color: var(--stat-ink);
  margin: 0 !important;
}

/* --------------------------------------------------------------------------
   At-a-glance — responsive grid of stat cards
   -------------------------------------------------------------------------- */
.stat-glance {
  margin: 1.8rem 0;
}
.stat-glance-title {
  font-family: "Lora", Georgia, serif;
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  color: var(--stat-purple);
  margin: 0 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--stat-gap);
  list-style: none;
  margin: 0;
  padding: 0;
}
.stat-card {
  background: var(--stat-surface);
  border: 1px solid var(--stat-line);
  border-top: 3px solid var(--stat-gold);
  border-radius: var(--stat-radius);
  padding: 1.05rem 1.15rem;
  margin: 0;
  font-size: clamp(0.98rem, 1.2vw, 1.06rem);
  line-height: 1.55;
}
.stat-card strong {
  color: var(--stat-ink);
  font-weight: 700;
}
.stat-card .src,
.stat-card .stat-src {
  display: block;
  margin-top: 0.55rem;
  font-size: 0.74rem !important; /* beat the theme's 3-class li font-size rule */
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--stat-muted);
}
.stats-article .post-trt-content-inner .stat-glance-title {
  font-size: clamp(1.05rem, 2.2vw, 1.3rem) !important;
}

/* --------------------------------------------------------------------------
   CSS bar chart — accessible, real-text %, no JS. Fill width set inline.
   -------------------------------------------------------------------------- */
.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 1.8rem 0;
}
.stat-bar {
  display: grid;
  grid-template-columns: minmax(8rem, 30%) 1fr;
  align-items: center;
  gap: 0.6rem 1rem;
}
.stat-bar-label {
  font-size: clamp(0.9rem, 1.15vw, 1rem);
  color: var(--stat-ink);
}
.stat-bar-track {
  position: relative;
  height: 1.5rem;
  background: var(--stat-surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--stat-purple), var(--stat-violet));
  min-width: 2px;
}
.stat-bar-val {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  transform: translateY(-50%);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--stat-ink);
}
@media (max-width: 670px) {
  .stat-bar { grid-template-columns: 1fr; gap: 0.25rem; }
}

/* --------------------------------------------------------------------------
   Comparison table — semantic <table>, zebra rows, mobile horizontal scroll
   -------------------------------------------------------------------------- */
.stat-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.6rem 0;
  border: 1px solid var(--stat-line);
  border-radius: var(--stat-radius);
}
table.stat-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: clamp(0.9rem, 1.15vw, 1rem);
  background: var(--stat-surface);
}
table.stat-table thead th {
  background: var(--stat-purple);
  color: #f4ecd8;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  text-align: left;
  padding: 0.7rem 0.75rem;
  position: sticky;
  top: 0;
}
table.stat-table th,
table.stat-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--stat-line);
  vertical-align: top;
  text-align: left;
}
table.stat-table tbody tr:nth-child(even) { background: var(--stat-surface-2); }
table.stat-table td.pct {
  font-weight: 700;
  color: var(--stat-ink);
  white-space: nowrap;
}
/* inline mini-bar rendered under a clean % cell (decorative; % text carries meaning) */
.stat-cellbar {
  display: block;
  height: 5px;
  margin-top: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--stat-purple), var(--stat-violet));
}
.stat-flag {
  color: #9a3a2f;
  font-style: normal;
  font-weight: 600;
  font-size: 0.85em;
}

/* --------------------------------------------------------------------------
   Note / callout — honest-data caveats and pull-stats
   -------------------------------------------------------------------------- */
.stat-note,
.stat-callout {
  background: var(--stat-surface);
  border: 1px solid var(--stat-line);
  border-left: 4px solid var(--stat-gold);
  border-radius: 10px;
  padding: 1rem 1.2rem 1rem 2.9rem;
  margin: 1.6rem 0;
  font-size: clamp(0.95rem, 1.15vw, 1.02rem);
  line-height: 1.6;
  position: relative;
}
.stat-note::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 1.05rem;
  width: 1.15rem;
  height: 1.15rem;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23b07d1f'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm0 5a1.3 1.3 0 110 2.6A1.3 1.3 0 0112 7zm1.4 11h-2.8v-6.6h2.8V18z'/%3E%3C/svg%3E");
}
.stat-note strong:first-child { color: var(--stat-purple); }

/* --------------------------------------------------------------------------
   FAQ (plain HTML — no FAQPage schema)
   -------------------------------------------------------------------------- */
.stats-article .post-trt-content-inner h3.stat-q {
  padding-left: 1.4rem;
  position: relative;
}
.stats-article .post-trt-content-inner h3.stat-q::before {
  content: "?";
  position: absolute;
  left: 0;
  top: 0.05em;
  font-family: "Lora", serif;
  font-weight: 700;
  color: var(--stat-gold);
}

/* --------------------------------------------------------------------------
   About / Related guides / Sources
   -------------------------------------------------------------------------- */
ul.stat-related {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.7rem;
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}
ul.stat-related li { margin: 0; }
ul.stat-related a {
  display: block;
  background: var(--stat-surface);
  border: 1px solid var(--stat-line);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  color: var(--stat-purple);
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
ul.stat-related a:hover {
  border-color: var(--stat-gold);
  transform: translateY(-1px);
}
ol.stat-sources {
  font-size: clamp(0.85rem, 1.05vw, 0.95rem);
  line-height: 1.55;
  color: var(--stat-muted);
  padding-left: 1.3rem;
}
ol.stat-sources li {
  margin: 0.45rem 0;
  font-size: clamp(0.85rem, 1.05vw, 0.95rem) !important; /* beat theme li rule */
}
ol.stat-sources a { color: var(--stat-bronze); word-break: break-word; }

/* --------------------------------------------------------------------------
   Motion / responsive
   -------------------------------------------------------------------------- */
@media (max-width: 670px) {
  .stat-cards { grid-template-columns: 1fr; }
  .stat-hero { padding: 1.4rem 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .stat-related a { transition: none; }
}

/* --------------------------------------------------------------------------
   Table of contents — sticky LEFT sidebar (matches the card-page layout).
   The theme emits a .trt-toc-layout wrapper for stats posts (see
   generate_toc_after_content); the borderless numbered rail styling is already
   inherited from the theme's .post-trt:not(.card) .toc-trt rules. Here we only
   add the 2-column sticky layout, scoped to .stats-article.
   -------------------------------------------------------------------------- */
@media (min-width: 981px) {
  .stats-article .post-trt-content .post-trt-content-inner {
    max-width: min(92vw, 1200px);
  }
  .stats-article .trt-toc-layout {
    display: flex;
    align-items: flex-start;
    gap: 2.4rem;
  }
  .stats-article .trt-toc-layout .trt-toc-main {
    flex: 1 1 auto;
    min-width: 0;
    order: 2;
  }
  .stats-article .trt-toc-layout .toc-trt {
    order: 1;
    flex: 0 0 260px;
    width: 260px;
    max-width: 260px;
    margin: 0;
    padding: 0;
    position: sticky;
    top: 5.5rem;
    align-self: flex-start;
    max-height: calc(100vh - 7rem);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  .stats-article .trt-toc-layout .toc-trt ul {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }
  .stats-article .trt-toc-layout .toc-trt.toc-collapsed {
    max-height: none;
  }
}
/* mobile/tablet: stack — TOC centered on top (theme JS handles collapse) */
@media (max-width: 980px) {
  .stats-article .trt-toc-layout {
    display: block;
  }
  .stats-article .trt-toc-layout .toc-trt {
    position: static;
    flex: none;
    width: auto;
    max-width: 580px;
    margin: 0 auto 2.4rem;
    max-height: none;
    display: block;
  }
}

/* Future Mediavine note: this template keeps h2/p as top-level children of
   .post-trt-content-inner so in-content ad auto-insertion works. When ads are
   enabled, reserve slot height on their containers to protect CLS. No ad
   markup is emitted today (Mediavine is not installed). */
