/* ==========================================================================
   Article content — the styling that replaces what the posts hardcode.

   inc/content-filter.php strips the inline declarations and swaps each box for
   one of these classes. The colours below are derived from the theme palette,
   so a 2024 post and a 2026 post look like the same publication.

   Every text/ground pair here clears WCAG AA:
     note 12.14  good 4.83  bad 6.04  warn 5.34  highlight 6.51
   ========================================================================== */

:root{
  --cf-note-ink:#1F235B;      --cf-note-bg:#E3EBFF;      --cf-note-edge:#C7D4F5;
  --cf-good-ink:#0F7A43;      --cf-good-bg:#E9F5EE;      --cf-good-edge:#BFE3CE;
  --cf-bad-ink:#B3123C;       --cf-bad-bg:#FCEDF1;       --cf-bad-edge:#F3C9D5;
  --cf-warn-ink:#8A5A00;      --cf-warn-bg:#FBF2E3;      --cf-warn-edge:#EBDBB6;
  --cf-high-ink:#5B3BB5;      --cf-high-bg:#EFEAFB;      --cf-high-edge:#D6CBF2;
}

/* ---- boxes ---- */
.prose .cf-note,
.prose .cf-good,
.prose .cf-bad,
.prose .cf-warn,
.prose .cf-highlight{
  margin:var(--x7) 0;
  padding:var(--x5) var(--x6);
  border-radius:var(--r-s);
  border:1px solid transparent;
  border-left-width:3px;
  font-size:1rem;
  line-height:1.6;
}
.prose .cf-note>*:last-child,
.prose .cf-good>*:last-child,
.prose .cf-bad>*:last-child,
.prose .cf-warn>*:last-child,
.prose .cf-highlight>*:last-child{margin-bottom:0}
.prose .cf-note>*:first-child,
.prose .cf-good>*:first-child,
.prose .cf-bad>*:first-child,
.prose .cf-warn>*:first-child,
.prose .cf-highlight>*:first-child{margin-top:0}

.prose .cf-note     {background:var(--cf-note-bg);border-color:var(--cf-note-edge);border-left-color:var(--blue)}
.prose .cf-good     {background:var(--cf-good-bg);border-color:var(--cf-good-edge);border-left-color:var(--cf-good-ink)}
.prose .cf-bad      {background:var(--cf-bad-bg); border-color:var(--cf-bad-edge); border-left-color:var(--cf-bad-ink)}
.prose .cf-warn     {background:var(--cf-warn-bg);border-color:var(--cf-warn-edge);border-left-color:var(--cf-warn-ink)}
.prose .cf-highlight{background:var(--cf-high-bg);border-color:var(--cf-high-edge);border-left-color:var(--cf-high-ink)}

/* A box's own heading takes the box's colour; its body text stays ink, which
   is what keeps long passages readable inside a tinted ground. */
.prose .cf-note strong:first-child,
.prose .cf-note h3,
.prose .cf-note h4   {color:var(--cf-note-ink)}
.prose .cf-good strong:first-child,
.prose .cf-good h3,
.prose .cf-good h4   {color:var(--cf-good-ink)}
.prose .cf-bad strong:first-child,
.prose .cf-bad h3,
.prose .cf-bad h4    {color:var(--cf-bad-ink)}
.prose .cf-warn strong:first-child,
.prose .cf-warn h3,
.prose .cf-warn h4   {color:var(--cf-warn-ink)}
.prose .cf-highlight strong:first-child,
.prose .cf-highlight h3,
.prose .cf-highlight h4{color:var(--cf-high-ink)}

/* ---- side-by-side pairs (the pro/con layout in comparison posts) ---- */
.prose .cf-pair{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(260px,100%),1fr));
  gap:var(--x5);margin:var(--x7) 0}
.prose .cf-pair>.cf-col{margin:0}
.prose .cf-col{min-width:0;padding:var(--x5);border-radius:var(--r-s);
  border:1px solid var(--line);background:var(--panel)}
.prose .cf-col>*:last-child{margin-bottom:0}
.prose .cf-col.cf-good{background:var(--cf-good-bg);border-color:var(--cf-good-edge)}
.prose .cf-col.cf-bad {background:var(--cf-bad-bg); border-color:var(--cf-bad-edge)}

/* ---- tables: the posts carried their own borders; these are the theme's ---- */
.prose table{width:100%;border-collapse:collapse;margin:var(--x7) 0;font-size:.9375rem;
  line-height:1.5;min-width:0}
.prose thead th{background:var(--panel);color:var(--ink);font-weight:600;text-align:left;
  border-bottom:1px solid var(--line-2);white-space:nowrap}
.prose th,.prose td{padding:var(--x3) var(--x4);border-bottom:1px solid var(--line);
  vertical-align:top;text-align:left}
.prose tbody tr:last-child td{border-bottom:0}
.prose tbody tr:hover{background:var(--wash)}
/* A wide table scrolls inside its own box rather than widening the page. */
.prose .cf-tablewrap{overflow-x:auto;margin:var(--x7) 0;border:1px solid var(--line);
  border-radius:var(--r-s)}
.prose .cf-tablewrap table{margin:0;border:0}

/* ---- figures and captions ---- */
.prose figure{margin:var(--x7) 0}
.prose figure img{display:block;width:100%;height:auto;border-radius:var(--r-s);border:1px solid var(--line)}
.prose figcaption{margin-top:var(--x3);font-size:.875rem;line-height:1.5;color:var(--mute);text-align:left}

/* ---- embeds: 26 bare iframes in the sample, now wrapped by the filter ---- */
.prose .cf-embed{position:relative;margin:var(--x7) 0;padding-top:56.25%;
  border-radius:var(--r-s);overflow:hidden;background:var(--panel)}
.prose .cf-embed iframe{position:absolute;inset:0;width:100%;height:100%;border:0}

/* ---- inline SVG charts keep their own geometry; only the frame is ours ---- */
.prose svg{max-width:100%;height:auto}

/* ==========================================================================
   Roles rescued from inline styling.

   These are not new ornament. Each one replaces a decision the author already
   made in the post and the strip would otherwise discard — a box's title, its
   opening sentence, its small print, a prompt block, a centred figure, a
   deliberately sized logo. inc/content-filter.php names them; this styles them.
   ========================================================================== */

/* ---- a box's title ---- */
.prose .cf-label{
  margin:0 0 var(--x3);
  font-size:.75rem;
  font-weight:600;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--mute);
}
.prose .cf-note .cf-label,
.prose .cf-note>.cf-label     {color:var(--cf-note-ink)}
.prose .cf-good .cf-label     {color:var(--cf-good-ink)}
.prose .cf-bad .cf-label      {color:var(--cf-bad-ink)}
.prose .cf-warn .cf-label     {color:var(--cf-warn-ink)}
.prose .cf-highlight .cf-label{color:var(--cf-high-ink)}

/* ---- the sentence a box leads with ---- */
.prose .cf-lead{
  margin:0 0 var(--x4);
  font-size:1.0625rem;
  font-weight:600;
  line-height:1.45;
  color:var(--ink);
}

/* ---- small print: disclosures, caveats, source lists ---- */
.prose .cf-fine{font-size:.875rem;line-height:1.6;color:var(--mute)}
.prose .cf-fine a{color:inherit}

/* ---- prompt and code blocks that were set in monospace by hand ---- */
.prose .cf-code{
  margin:var(--x5) 0;
  padding:var(--x4) var(--x5);
  border:1px solid var(--line);
  border-left:3px solid var(--blue);
  border-radius:var(--r-s);
  background:var(--panel);
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:.8125rem;
  line-height:1.65;
  overflow-x:auto;
}

/* ---- centring the author asked for ---- */
.prose .cf-center{text-align:center}

/* ---- an image given an explicit pixel width keeps it ----
   The width itself stays inline, because it is per-image; this only undoes
   the full-bleed treatment that would otherwise stretch a vendor logo. */
.prose img.cf-fixed-w,
.prose figure img.cf-fixed-w{
  width:auto;
  max-width:100%;
  margin-inline:auto;
  border:0;
  border-radius:0;
}

/* ---- a wide table scrolls inside its box instead of widening the page ---- */
.prose .cf-tablewrap{-webkit-overflow-scrolling:touch}

/* ---- in-article call-to-action buttons ----
   The posts hardcoded a different button colour each time (#000a3a, #165ad9,
   #4f46e5). This is the one element a reader is most likely to click, so it
   is the one that least deserves to be off-palette. */
.prose a.cf-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:var(--x2);
  min-height:48px;
  margin:var(--x2) 0;
  padding:0 var(--x6);
  border:1px solid var(--blue);
  border-radius:var(--r-m);
  background:var(--blue);
  color:#fff;
  font-weight:500;
  font-size:1.0625rem;
  line-height:1.2;
  text-decoration:none;
  transition:background var(--dur) var(--ease);
}
.prose a.cf-btn:hover{background:var(--blue-d);border-color:var(--blue-d);color:#fff}
.prose a.cf-btn:active{transform:translateY(1px)}

/* ---- a wide table needs room before it needs a scroll ----
   Most of these tables set no width of their own, so on a phone the browser
   squeezes four columns into 357px and breaks "What it unlocks" one word per
   line. The wrapper above already scrolls; these give the table something to
   scroll, scaled to how many columns it actually has, so a two-column table
   is left alone. Where :has() is unsupported the table simply behaves as it
   does today. */
.prose .cf-tablewrap table:has(th:nth-child(3)),
.prose .cf-tablewrap table:has(td:nth-child(3)){min-width:30rem}
.prose .cf-tablewrap table:has(th:nth-child(5)),
.prose .cf-tablewrap table:has(td:nth-child(5)){min-width:40rem}

/* The "(paid link)" marker is set in --mute, which reads at 1.19:1 against the
   button's blue — invisible, on the one label that must be legible before a
   click. White at 85% gives 5.25:1 and still reads as secondary. */
.prose a.cf-btn[rel~="sponsored"]:not(.cf-aff)::after{color:rgba(255,255,255,.85)}

/* ---- the author box a snippet appends to every post ----
   It arrives as a flex row, so the filter reads it as a cf-pair and lays the
   96px avatar out as an equal 260px column beside the bio. It is a named
   component, not a generic pair, so it gets its own rule. These selectors
   match .cf-pair/.cf-col on specificity and win on source order. */
.prose .cf-author-box{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:var(--x5);
  align-items:start;
  margin:var(--x8) 0 0;
  padding:var(--x6);
  border:1px solid var(--line);
  border-radius:var(--r-m);
  background:var(--panel);
}
.prose .cf-author-box>.cf-col{padding:0;border:0;background:none;min-width:0}
.prose .cf-author-box img.avatar{
  width:72px;height:72px;border-radius:50%;display:block;border:0;max-width:none;
}
.prose .cf-author-box .cf-label{margin:0 0 var(--x2)}
.prose .cf-author-box h3{margin:0 0 var(--x3);font-size:1.0625rem;line-height:1.3}
.prose .cf-author-box h3 a{color:var(--ink);text-decoration:none}
.prose .cf-author-box h3 a:hover{color:var(--blue)}
.prose .cf-author-box p{margin:0;font-size:.9375rem;line-height:1.6;color:var(--body)}
.prose .cf-author-box p+p{margin-top:var(--x3)}

@media (max-width:520px){
  .prose .cf-author-box{grid-template-columns:1fr}
}

/* ---- long unbreakable strings ----
   At 320px the only thing that pushed the page wider than the viewport was an
   inline <code> holding a bare URL. Code is deliberately protected from the
   content filter, so it keeps whatever it arrived with; CSS still reaches it. */
.prose code{overflow-wrap:anywhere}
.prose a{overflow-wrap:break-word}
