/*
 * CalcSystems — Editorial Finance design language (Phase 1: tokens + base type)
 *
 * Every rule in this file is scoped under [data-theme="editorial"], which is
 * set on <html> only when the build-time env var PUBLIC_THEME=editorial is
 * present. When the flag is absent, none of these rules match and the site
 * renders identically to the existing Tailwind-based design.
 *
 * Loaded AFTER Tailwind so its rules win the cascade where they intentionally
 * override Tailwind utilities on the same elements.
 *
 * Phase 1 scope:
 *   - design tokens (colors, typography, spacing, radii)
 *   - body + heading base type
 *   - .serif / .mono / .tabnum helper classes
 *   - selection styling
 *
 * Out of scope until later phases:
 *   - masthead, footer, ticker (Phase 2)
 *   - calculator template (Phase 3)
 *   - sweep across calculators (Phase 4)
 *   - homepage (Phase 5)
 */

/* ─── tokens ─────────────────────────────────────────── */
[data-theme="editorial"] {
  --serif: "Source Serif 4", ui-serif, Georgia, Cambria, serif;
  --sans:  "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --accent: #7c0e1e;
  --accent-soft: #fbeae0;
  --accent-tint: #f5e4d9;

  --ink:   #1a1614;
  --ink-2: #3a3431;
  --ink-3: #6d6661;
  --ink-4: #a39b95;

  --line:   #e6dfd6;
  --line-2: #efe9df;

  --paper:   #faf7f1;
  --paper-2: #f3eee4;
  --paper-3: #ffffff;

  --rad:    4px;
  --rad-lg: 6px;

  --pad-x: clamp(20px, 4vw, 80px);
  --max:   1280px;
}

/* ─── base typography ────────────────────────────────── */

/*
 * Override the existing body base styles set by Tailwind utilities
 * (`bg-white text-black font-sans antialiased`). Because this stylesheet
 * is loaded after Tailwind, the same-specificity selector here wins
 * tie-breaks via cascade order, but we use a slightly-more-specific
 * descendant selector for paint paranoia.
 */
[data-theme="editorial"] body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Headings inherit the serif by default in editorial mode. Individual
 * components can opt back to sans via the .sans helper or Tailwind utility. */
/* Headings get serif font + tighter letter-spacing in editorial mode.
 * We deliberately do NOT set `color` here. Color inherits from body
 * (--ink), so any explicit Tailwind utility on the heading — `text-white`
 * for headers on the maroon card bar, `text-gray-X` elsewhere — keeps
 * winning. Setting color here at [data-theme] scope (specificity 0,1,1)
 * would beat .text-white (0,1,0) and break headings on dark backgrounds. */
[data-theme="editorial"] h1,
[data-theme="editorial"] h2,
[data-theme="editorial"] h3 {
  font-family: var(--serif);
  letter-spacing: -0.012em;
}

[data-theme="editorial"] h1 { font-weight: 700; line-height: 1.04; }
[data-theme="editorial"] h2 { font-weight: 700; line-height: 1.10; }
[data-theme="editorial"] h3 { font-weight: 600; line-height: 1.20; }

/* ─── helper classes ─────────────────────────────────── */
[data-theme="editorial"] .serif  { font-family: var(--serif); }
[data-theme="editorial"] .sans   { font-family: var(--sans); }
[data-theme="editorial"] .mono   { font-family: var(--mono); }
[data-theme="editorial"] .tabnum { font-variant-numeric: tabular-nums; }

/* ─── selection ──────────────────────────────────────── */
[data-theme="editorial"] ::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 2 — chrome (masthead, footer, homepage cards).
   All selectors target classes/IDs/attributes that already exist in
   BaseLayout.astro and src/pages/index.astro. No DOM changes required.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── masthead ───────────────────────────────────────── */

/* The existing header is `<header class="border-b border-gray-200 sticky
 * top-0 bg-white z-50">`. Use the unique combination of `position: sticky`
 * + `top-0` (rendered as `top-0` Tailwind class) to target only the masthead,
 * not other sticky elements. */
[data-theme="editorial"] header.sticky.top-0 {
  background: var(--paper);
  border-bottom-color: var(--line);
}

/* Brand: <a aria-label="CalcSystems Home"> with two spans (Calc + Systems) */
[data-theme="editorial"] a[aria-label="CalcSystems Home"] > span {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}
/* "Calc" — first span — keeps accent color via existing text-maroon utility,
 * which we override to use the accent token. */
[data-theme="editorial"] a[aria-label="CalcSystems Home"] > span:first-child {
  color: var(--accent);
}
[data-theme="editorial"] a[aria-label="CalcSystems Home"] > span:last-child {
  color: var(--ink);
}

/* Top-level nav links (Calculators dropdown trigger, Embed Widgets, About,
 * Contact). They share `text-gray-600` via the parent .text-gray-600 wrapper.
 * Target the wrapper's <a> children. */
[data-theme="editorial"] header.sticky nav > div.text-gray-600 > a,
[data-theme="editorial"] #calc-nav-btn {
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  transition: color 0.15s;
}
[data-theme="editorial"] header.sticky nav > div.text-gray-600 > a:hover,
[data-theme="editorial"] #calc-nav-btn:hover {
  color: var(--accent);
}

/* Calculators dropdown panel — softer paper background, smaller radius.
 * Use literal hex values (not var()) for paint-critical properties so a
 * stray cascade or stale-cache state can't render the panel transparent. */
[data-theme="editorial"] #calc-nav-panel {
  background-color: #ffffff;
  border: 1px solid #e6dfd6;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(26, 22, 20, 0.08);
}

/* Section eyebrows inside the dropdown (Payroll / Tax / Mortgage / Loan /
 * Personal Finance / Investment) — these use the exact class combo
 * `text-[10px] font-bold uppercase tracking-widest text-gray-500`. */
[data-theme="editorial"] #calc-nav-panel div.uppercase.tracking-widest {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--ink);
  font-weight: 500;
}

/* Dropdown links */
[data-theme="editorial"] #calc-nav-panel a[role="menuitem"] {
  color: var(--ink-2);
  font-family: var(--sans);
}
[data-theme="editorial"] #calc-nav-panel a[role="menuitem"]:hover {
  color: var(--accent);
}

/* ─── footer ─────────────────────────────────────────── */

/* Single <footer> per page — target it directly. */
[data-theme="editorial"] body > footer {
  background: var(--paper);
  border-top-color: var(--line);
  color: var(--ink-3);
  font-family: var(--sans);
  font-size: 13px;
}

/* Footer column eyebrow headings — same uppercase pattern as masthead. */
[data-theme="editorial"] body > footer div.uppercase.tracking-widest {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--ink);
  font-weight: 500;
}

/* Footer links */
[data-theme="editorial"] body > footer a {
  color: var(--ink-3);
  transition: color 0.15s;
}
[data-theme="editorial"] body > footer a:hover {
  color: var(--accent);
}

/* Footer brand at bottom-left of legal row */
[data-theme="editorial"] body > footer a[href="/"] > span {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Footer bottom-bar legal text */
[data-theme="editorial"] body > footer .border-t.border-gray-200 {
  border-top-color: var(--line);
}

/* ─── homepage card grid ─────────────────────────────── */

/* Cards on the homepage have `data-search="..."` set per row from
 * src/pages/index.astro. That attribute uniquely identifies them, so we
 * can target without touching the markup. */
[data-theme="editorial"] a[data-search] {
  background: var(--paper-3);
  border-width: 1px;
  border-color: var(--accent);
  border-radius: var(--rad-lg);
  padding: 22px 22px 20px;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
}
[data-theme="editorial"] a[data-search]:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 var(--accent), 0 8px 24px rgba(124, 14, 30, 0.08);
}

/* Card title */
[data-theme="editorial"] a[data-search] > h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--ink);
}
[data-theme="editorial"] a[data-search]:hover > h3 {
  color: var(--ink); /* override the existing group-hover:text-maroon */
}
/* Icon inside title — keep at accent */
[data-theme="editorial"] a[data-search] > h3 > svg {
  color: var(--accent);
}

/* Card description */
[data-theme="editorial"] a[data-search] > p {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.5;
}

/* "Open Calculator →" footer */
[data-theme="editorial"] a[data-search] > div.text-maroon {
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
  margin-top: 4px;
}

/* Section heading above each card grid (e.g. "Payroll Calculators") —
 * the homepage uses `<h2 class="font-display text-[1.625rem] font-bold ...">`.
 * Target via [data-category-section] to avoid affecting other h2s. */
[data-theme="editorial"] [data-category-section] > div > h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -0.012em;
  line-height: 1.1;
}
[data-theme="editorial"] [data-category-section] > div > h2 a {
  color: var(--ink);
}
[data-theme="editorial"] [data-category-section] > div > h2 a:hover {
  color: var(--accent);
}
/* Section "View all →" link */
[data-theme="editorial"] [data-category-section] > div > a.text-maroon {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}
/* Hairline rule between heading and "View all" — already exists as a div;
 * recolor to match line token. */
[data-theme="editorial"] [data-category-section] > div > div.bg-gray-100 {
  background: var(--line);
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 3 — calculator-page template, applied to every calculator page
   that uses the BaseLayout + standard widget + MethodologySources +
   <article class="prose"> + related-calculators-card pattern. The page
   structure is shared across calculators, so this stylesheet doesn't
   need per-calculator scoping. (CD calculator was the visual reference.)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── page header (h1 + lede paragraph) ─────────────── */

/* The standard calculator-page top is:
 *   <div class="max-w-4xl mx-auto px-4 sm:px-6 py-8">
 *     <header class="mb-8">
 *       <h1 class="font-display text-4xl sm:text-5xl ...">Calculator Name</h1>
 *       <p class="mt-3 text-lg text-gray-600 max-w-2xl">Lede.</p>
 *     </header>
 * Target the outer wrapper's first <header> so we don't catch the masthead. */
[data-theme="editorial"] body > main > div.max-w-4xl > header,
[data-theme="editorial"] body > main > div.max-w-6xl > header,
[data-theme="editorial"] body main > div > header.mb-8 {
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
  margin-bottom: 36px;
}

[data-theme="editorial"] body main > div > header.mb-8 > h1,
[data-theme="editorial"] body main > div > header.mb-6 > h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(40px, 4.6vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin: 0 0 18px;
}

[data-theme="editorial"] body main > div > header.mb-8 > p,
[data-theme="editorial"] body main > div > header.mb-6 > p {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 680px;
}

/* Year/data-stamp byline that some calc pages show under the lede. */
[data-theme="editorial"] body main > div > header.mb-8 > p.text-xs,
[data-theme="editorial"] body main > div > header.mb-6 > p.text-xs {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* Breadcrumb (rendered by some state-templated pages) — shifts to mono eyebrow */
[data-theme="editorial"] nav[aria-label="Breadcrumb"] {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
[data-theme="editorial"] nav[aria-label="Breadcrumb"] a {
  color: var(--ink-3);
}
[data-theme="editorial"] nav[aria-label="Breadcrumb"] a:hover {
  color: var(--accent);
}

/* ─── calculator widget container ───────────────────── */

/* Every standard calculator widget has a marker attribute (data-cd-calculator,
 * data-paycheck-calculator) OR uses the canonical outer class string
 * `bg-white border border-gray-200 rounded-2xl shadow-sm overflow-hidden mb-10`.
 * We target both, so widgets without an explicit data-attribute (mortgage,
 * auto-loan, refinance, extra-payment, etc.) still pick up the styling. */
[data-theme="editorial"] [data-cd-calculator],
[data-theme="editorial"] [data-paycheck-calculator],
[data-theme="editorial"] [data-apy-calculator],
[data-theme="editorial"] [data-compound-interest-calculator],
[data-theme="editorial"] body main div.bg-white.border.border-gray-200.rounded-2xl.shadow-sm.mb-10 {
  border-radius: var(--rad-lg);
  border-color: var(--line);
  box-shadow: none;
  background: var(--paper-3);
}

/* Maroon header bar inside the widget — keep accent fill, just retype. */
[data-theme="editorial"] [data-cd-calculator] > div.bg-maroon,
[data-theme="editorial"] [data-paycheck-calculator] > div.bg-maroon,
[data-theme="editorial"] [data-apy-calculator] > div.bg-maroon,
[data-theme="editorial"] [data-compound-interest-calculator] > div.bg-maroon,
[data-theme="editorial"] body main div.bg-white.border.border-gray-200.rounded-2xl.shadow-sm.mb-10 > div.bg-maroon {
  background: var(--accent);
}
[data-theme="editorial"] [data-cd-calculator] > div.bg-maroon > h2,
[data-theme="editorial"] [data-paycheck-calculator] > div.bg-maroon > h2,
[data-theme="editorial"] [data-apy-calculator] > div.bg-maroon > h2,
[data-theme="editorial"] [data-compound-interest-calculator] > div.bg-maroon > h2,
[data-theme="editorial"] body main div.bg-white.border.border-gray-200.rounded-2xl.shadow-sm.mb-10 > div.bg-maroon > h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  /* color stays white via existing text-white utility */
}

/* ─── inputs ────────────────────────────────────────── */

/* Every input field follows the same pattern:
 *   <label for="..." class="block text-sm font-semibold text-gray-700 mb-1.5">Label</label>
 *   <div class="relative">
 *     <span class="absolute left-3.5 ...">$</span>           ← optional prefix
 *     <input type="number" id="..." class="w-full pl-8 pr-4 py-3 border border-gray-300 rounded-lg ..." />
 *     <span class="absolute right-3.5 ...">%</span>          ← optional suffix
 *   </div>
 * We retype labels to editorial style and recolor input borders. */
[data-theme="editorial"] body main label.text-gray-700 {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0;
}

/* Inputs */
[data-theme="editorial"] body main input[type="number"].w-full.border.border-gray-300,
[data-theme="editorial"] body main input[type="text"].w-full.border.border-gray-300 {
  border-color: var(--line);
  border-radius: var(--rad);
  background: var(--paper);
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
}
[data-theme="editorial"] body main input[type="number"].w-full.border.border-gray-300:focus,
[data-theme="editorial"] body main input[type="text"].w-full.border.border-gray-300:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Selects */
[data-theme="editorial"] body main select.w-full.border.border-gray-300 {
  border-color: var(--line);
  border-radius: var(--rad);
  background: var(--paper-3);
  font-family: var(--sans);
  color: var(--ink);
}

/* $ / % adornment spans inside the relative input wrapper */
[data-theme="editorial"] body main div.relative > span.absolute.text-gray-600 {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-3);
}

/* Helper text under inputs */
[data-theme="editorial"] body main p.text-xs.text-gray-500 {
  color: var(--ink-3);
}

/* ─── result blocks ─────────────────────────────────── */

/* Hero result callout — pattern is a div with `border-2 border-maroon
 * bg-maroon/5` containing a label, big number, and sub. */
[data-theme="editorial"] body main div.rounded-xl.border-2.border-maroon {
  border-width: 1px;
  border-color: var(--accent);
  border-radius: var(--rad-lg);
  background: var(--accent-soft);
  padding: 22px;
}
/* Eyebrow label inside the hero result */
[data-theme="editorial"] body main div.rounded-xl.border-2.border-maroon > div.text-sm.font-semibold.text-maroon {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 10px;
}
/* Big number — already 3xl, recast as serif + tabular */
[data-theme="editorial"] body main div.rounded-xl.border-2.border-maroon > div.font-bold.text-3xl.text-maroon {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(36px, 4.4vw, 52px);
  line-height: 1;
  letter-spacing: -0.022em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
/* Sub-text under the big number */
[data-theme="editorial"] body main div.rounded-xl.border-2.border-maroon > div.text-xs.text-gray-600 {
  color: var(--ink-3);
  font-size: 13px;
  margin-top: 8px;
}

/* Summary tables inside the widget (Initial Deposit / Total Interest / etc.).
 * These are wrapped in `rounded-xl border border-gray-200 overflow-hidden`.
 * Bump the wrapper border to --ink-4 so it visibly separates from the
 * warm-paper page background. */
[data-theme="editorial"] body main div.rounded-xl.border.border-gray-200.overflow-hidden {
  border-color: var(--ink-4);
}
[data-theme="editorial"] body main div.rounded-xl.border.border-gray-200.overflow-hidden > table {
  font-variant-numeric: tabular-nums;
}
[data-theme="editorial"] body main div.rounded-xl.border.border-gray-200.overflow-hidden > table td.text-gray-600 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
[data-theme="editorial"] body main div.rounded-xl.border.border-gray-200.overflow-hidden > table td.text-right {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink);
}

/* Section headings inside the widget below the result panel
 * ("Balance Over CD Term", "Growth Schedule", etc.). */
[data-theme="editorial"] body main div[data-cd-calculator] h3,
[data-theme="editorial"] body main div[data-paycheck-calculator] h3,
[data-theme="editorial"] body main div[data-apy-calculator] h3,
[data-theme="editorial"] body main div[data-compound-interest-calculator] h3,
[data-theme="editorial"] body main div.bg-white.border.border-gray-200.rounded-2xl.shadow-sm.mb-10 h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}

/* Growth-schedule and amortization tables — usually `<table class="w-full text-sm">` */
[data-theme="editorial"] body main div.rounded-xl.border.border-gray-200.overflow-hidden > table thead {
  background: var(--paper-2);
}
[data-theme="editorial"] body main div.rounded-xl.border.border-gray-200.overflow-hidden > table th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

/* ─── methodology & sources panel ───────────────────── */

/* MethodologySources renders an <aside> with this exact class string.
 * Use a slightly darker border (--ink-4) so the panel edge is clearly
 * visible against the warm-paper page background, and tint the header
 * strip with --paper-2 instead of --paper so it's distinct from both
 * the panel body (--paper-3) AND the surrounding page (--paper). */
[data-theme="editorial"] aside.not-prose.rounded-2xl.border.border-gray-200.bg-gray-50 {
  background: var(--paper-3);
  border-color: var(--ink-4);
  border-radius: var(--rad-lg);
}

/* Header strip of the methodology panel */
[data-theme="editorial"] aside.not-prose.rounded-2xl > header.bg-white.border-b {
  background: var(--paper-2);
  border-bottom-color: var(--ink-4);
}
[data-theme="editorial"] aside.not-prose.rounded-2xl > header > h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
[data-theme="editorial"] aside.not-prose.rounded-2xl > header > span.text-xs {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Body of the methodology panel */
[data-theme="editorial"] aside.not-prose.rounded-2xl > div.text-gray-700 {
  color: var(--ink-2);
}
[data-theme="editorial"] aside.not-prose.rounded-2xl details > summary {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
}
[data-theme="editorial"] aside.not-prose.rounded-2xl details > summary:hover {
  color: var(--accent);
}
[data-theme="editorial"] aside.not-prose.rounded-2xl a.text-maroon {
  color: var(--accent);
}

/* Final disclaimer paragraph at panel bottom */
[data-theme="editorial"] aside.not-prose.rounded-2xl p.text-gray-500 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--ink-4);
  line-height: 1.6;
}

/* ─── supporting article (FAQ + worked examples + content) ─── */

/* Many calculator pages render long-tail content inside a Tailwind-prose
 * <article>. Override prose font choices for editorial mode. */
[data-theme="editorial"] article.prose h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -0.012em;
  line-height: 1.1;
  color: var(--ink);
}
[data-theme="editorial"] article.prose h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--ink);
}
[data-theme="editorial"] article.prose p {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-2);
}
[data-theme="editorial"] article.prose strong {
  color: var(--ink);
  font-weight: 600;
}
[data-theme="editorial"] article.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
[data-theme="editorial"] article.prose code {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--ink-2);
  background: var(--paper-2);
  padding: 1px 6px;
  border-radius: 3px;
}
/* Tables inside supporting prose. Use --ink-4 for the outer border so the
 * box edge is clearly visible against the warm-paper page background;
 * --line was too close in tone and the box appeared to have no edge. */
[data-theme="editorial"] article.prose table {
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--ink-4);
  border-radius: var(--rad-lg);
  overflow: hidden;
  background: var(--paper-3);
}
[data-theme="editorial"] article.prose table th {
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--ink-4);
  padding: 12px 18px;
}
[data-theme="editorial"] article.prose table td {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--line-2);
  padding: 12px 18px;
}
[data-theme="editorial"] article.prose table tr:last-child td {
  border-bottom: 0;
}

/* ─── related-calculators cards ─────────────────────── */

/* Related-cards section is `<section class="mt-12 border-t border-gray-100 pt-10">`
 * containing anchors with the canonical card-class string. */
[data-theme="editorial"] section.mt-12.border-t.border-gray-100.pt-10 {
  border-top-color: var(--line);
}
[data-theme="editorial"] section.mt-12.border-t.border-gray-100.pt-10 > h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.012em;
  color: var(--ink);
}
[data-theme="editorial"] section.mt-12.border-t.border-gray-100.pt-10 a.block.bg-white.border.border-gray-200.rounded-xl {
  border-color: var(--line);
  border-radius: var(--rad-lg);
  background: var(--paper-3);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
[data-theme="editorial"] section.mt-12.border-t.border-gray-100.pt-10 a.block.bg-white.border.border-gray-200.rounded-xl:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 14, 30, 0.06);
}
[data-theme="editorial"] section.mt-12.border-t.border-gray-100.pt-10 a > div.font-semibold.text-black {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--ink);
}
[data-theme="editorial"] section.mt-12.border-t.border-gray-100.pt-10 a > div.text-sm.text-gray-600 {
  color: var(--ink-3);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 4 — sweep across the rest of the catalog. Patches structural
   patterns Phase 3 didn't reach: state pSEO templates (bracket tables,
   neighbor comparisons, top-cities lists), hub-page CalculatorGrid,
   the embed pill button + collapsible panel, and the newer
   data-related-calc-list cards pattern.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── section headings outside <article class="prose"> ─────── */

/* State pSEO pages render a heading like
 *   <h2 class="font-display text-3xl font-bold text-black mb-4">
 *     California Take-Home Pay at Common Salaries (2026)
 *   </h2>
 * These sit OUTSIDE the prose article so Phase 3's prose h2 rule misses
 * them. Catch them via the canonical class string. */
[data-theme="editorial"] body main section h2.font-display.text-3xl.font-bold,
[data-theme="editorial"] body main section h2.font-display.text-2xl.font-bold {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.012em;
  line-height: 1.1;
  color: var(--ink);
}

/* Section-level descriptive paragraphs that follow these h2s */
[data-theme="editorial"] body main section h2.font-display + p,
[data-theme="editorial"] body main section > p.text-sm.text-gray-600 {
  font-family: var(--sans);
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.55;
}

/* ─── tables OUTSIDE the prose article ─────────────────────── */

/* State paycheck pages have a salary table at the top of
 * <section class="mb-12"> wrapped in `rounded-xl border border-gray-200`.
 * That wrapper is already covered by Phase 3's widget-summary-table rule
 * (same class string). Reapply mono headers + tabular cells in case any
 * page renders such a table without that wrapper. */
[data-theme="editorial"] body main section table.w-full.text-sm thead {
  background: var(--paper-2);
}
[data-theme="editorial"] body main section table.w-full.text-sm thead th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
  padding: 12px 16px;
}
[data-theme="editorial"] body main section table.w-full.text-sm td {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  padding: 12px 16px;
}
[data-theme="editorial"] body main section table.w-full.text-sm tbody td.text-right {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Bracket table caption / state-tax structure card from
 * <StateBracketTable> — rendered inside <section class="mb-12">. */
[data-theme="editorial"] body main section.mb-12 div.rounded-xl.border.border-gray-200 {
  border-color: var(--ink-4);
  border-radius: var(--rad-lg);
  background: var(--paper-3);
}

/* "Related Calculators" section without the .mt-12 wrapper class
 * (state pages use a slightly different border-top section). */
[data-theme="editorial"] body main section.border-t.border-gray-100.pt-10 {
  border-top-color: var(--line);
}

/* ─── hub-page CalculatorGrid cards ────────────────────────── */

/* CalculatorGrid renders cards with one of two class strings depending on
 * c.featured. Both end with `border rounded-xl p-5 transition-all group`. */
[data-theme="editorial"] div.grid > a.block.bg-white.border.rounded-xl.p-5 {
  background: var(--paper-3);
  border-radius: var(--rad-lg);
  border-width: 1px;
  border-color: var(--line);
  padding: 22px;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
}
/* Featured cards get the accent border by default */
[data-theme="editorial"] div.grid > a.block.bg-white.border.rounded-xl.p-5.border-maroon {
  border-color: var(--accent);
}
[data-theme="editorial"] div.grid > a.block.bg-white.border.rounded-xl.p-5:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 var(--accent), 0 8px 24px rgba(124, 14, 30, 0.08);
}
[data-theme="editorial"] div.grid > a.block.bg-white.border.rounded-xl.p-5 > div > h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--ink);
}
[data-theme="editorial"] div.grid > a.block.bg-white.border.rounded-xl.p-5 > div > span.text-maroon {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--accent);
}
[data-theme="editorial"] div.grid > a.block.bg-white.border.rounded-xl.p-5 > p {
  color: var(--ink-3);
  font-size: 13px;
}

/* ─── newer related-cards pattern (data-related-calc-list) ── */

/* Loans cluster + recent calculator pages use this pattern. Same outer
 * card class string as the older related cards section, but inside a
 * wrapper marked with data-related-calc-list. */
[data-theme="editorial"] [data-related-calc-list] {
  /* container — no styling needed, but selector here documents the hook */
}
[data-theme="editorial"] [data-related-calc-list] > a.block.bg-white.border.border-gray-200.rounded-xl {
  border-color: var(--line);
  border-radius: var(--rad-lg);
  background: var(--paper-3);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
[data-theme="editorial"] [data-related-calc-list] > a.block.bg-white.border.border-gray-200.rounded-xl:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 14, 30, 0.06);
}
[data-theme="editorial"] [data-related-calc-list] > a > div.font-semibold.text-black {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--ink);
}
[data-theme="editorial"] [data-related-calc-list] > a > div.text-sm.text-gray-600 {
  color: var(--ink-3);
  font-size: 13px;
}

/* ─── embed pill button + collapsible panel ────────────────── */

/* The "Embed this calculator" pill near the top of widget-enabled pages.
 * Outer button: `inline-flex ... rounded-full border border-gray-300 ...` */
[data-theme="editorial"] [data-embed-this] > button {
  background: var(--paper-3);
  border-color: var(--line);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
[data-theme="editorial"] [data-embed-this] > button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* The disclosure panel that opens below the pill */
[data-theme="editorial"] [id^="embed-panel-"] {
  background: var(--paper-2);
  border-color: var(--line);
  border-radius: var(--rad);
}
[data-theme="editorial"] [id^="embed-panel-"] > p {
  color: var(--ink-3);
  font-family: var(--sans);
}
[data-theme="editorial"] [id^="embed-panel-"] textarea[id^="embed-code-"] {
  background: var(--paper-3);
  border-color: var(--line);
  border-radius: var(--rad);
  color: var(--ink);
}
[data-theme="editorial"] [id^="embed-panel-"] textarea[id^="embed-code-"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}
/* "Copy code" CTA button inside the panel */
[data-theme="editorial"] [id^="embed-panel-"] button.bg-maroon {
  background: var(--accent);
  border-radius: var(--rad);
  font-family: var(--sans);
}
[data-theme="editorial"] [id^="embed-panel-"] button.bg-maroon:hover {
  filter: brightness(1.05);
}
/* "Preview embed →" link inside the panel */
[data-theme="editorial"] [id^="embed-panel-"] a.text-maroon {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── /calculator-widgets/ — listing page items ───────────── */

/* Each widget listing block is a row under <h3><a>{name}</a></h3>. The
 * page already inherits prose-style typography from Phase 3 for body.
 * Pull h3s into the editorial pairing and accent the "View full
 * calculator →" links. */
[data-theme="editorial"] body main section h3.font-display {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ─── breadcrumb on state-template pages ───────────────────── */

/* The state templates render a breadcrumb at the top of <main> — Phase 3
 * already styles nav[aria-label="Breadcrumb"], here we just reinforce
 * the separator color. */
[data-theme="editorial"] nav[aria-label="Breadcrumb"] span.mx-1\.5 {
  color: var(--ink-4);
}

/* ═══════════════════════════════════════════════════════════════════
   PHASE 5 — homepage. Hero, recently-updated row, browse-by-state,
   trust strip, and the dark editorial embed-CTA conversion block at
   the bottom of the page.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── hero ───────────────────────────────────────────── */

/* Hero is the first <section> on the homepage:
 *   <section class="py-20 px-4 border-b border-gray-100">
 *     <div class="max-w-3xl mx-auto text-center">
 *       <p class="text-sm font-semibold text-maroon uppercase tracking-widest mb-4">Free ·…</p>
 *       <h1 class="font-display text-5xl sm:text-6xl ...">… <span class="text-maroon">…</span></h1>
 *       <p class="mt-6 text-xl text-gray-600 ...">…</p>
 *       <div class="mt-8 max-w-sm mx-auto relative"><svg.../><input id="calc-search" .../></div>
 *     </div>
 *   </section>
 *
 * Target the canonical container shape so other sections that happen to
 * share .py-20 (none today) wouldn't accidentally match. */
[data-theme="editorial"] body main > section.py-20.px-4.border-b.border-gray-100 {
  background: var(--paper);
  border-bottom-color: var(--line);
  padding-top: 88px;
  padding-bottom: 64px;
}

/* Hero eyebrow */
[data-theme="editorial"] body main > section.py-20.px-4 p.text-sm.font-semibold.text-maroon.uppercase {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 28px;
}

/* Hero H1 */
[data-theme="editorial"] body main > section.py-20.px-4 h1.font-display {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(40px, 5.6vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.018em;
  color: var(--ink);
}
/* Second line of the H1 — currently `<span class="text-maroon">…</span>` */
[data-theme="editorial"] body main > section.py-20.px-4 h1.font-display > span.text-maroon {
  color: var(--accent);
  font-style: italic;
  font-weight: 600;
}

/* Hero sub paragraph */
[data-theme="editorial"] body main > section.py-20.px-4 p.text-xl.text-gray-600 {
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-2);
  margin-top: 32px;
  max-width: 600px;
}

/* Hero search input — restyle the pill */
[data-theme="editorial"] body main > section.py-20.px-4 #calc-search {
  background: var(--paper-3);
  border-color: var(--line);
  border-radius: 999px;
  font-family: var(--sans);
  color: var(--ink);
  padding-top: 14px;
  padding-bottom: 14px;
}
[data-theme="editorial"] body main > section.py-20.px-4 #calc-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: 0;
}
[data-theme="editorial"] body main > section.py-20.px-4 #calc-search::placeholder {
  color: var(--ink-4);
}
/* Search icon */
[data-theme="editorial"] body main > section.py-20.px-4 div.mt-8 > svg.text-gray-500 {
  color: var(--ink-3);
}

/* ─── recently updated row ───────────────────────────── */

/* `<section class="border-b border-gray-100 py-10 px-4 bg-gray-50">` */
[data-theme="editorial"] body main > section.bg-gray-50.py-10 {
  background: var(--paper-2);
  border-bottom-color: var(--line);
}
[data-theme="editorial"] body main > section.bg-gray-50.py-10 h2.font-display {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: -0.01em;
  color: var(--ink);
}
[data-theme="editorial"] body main > section.bg-gray-50.py-10 p.text-xs.text-gray-500 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
}
[data-theme="editorial"] body main > section.bg-gray-50.py-10 a.block.bg-white.border.border-gray-200.rounded-lg {
  background: var(--paper-3);
  border-color: var(--line);
  border-radius: var(--rad-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
[data-theme="editorial"] body main > section.bg-gray-50.py-10 a.block.bg-white.border.border-gray-200.rounded-lg:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(124, 14, 30, 0.05);
}
[data-theme="editorial"] body main > section.bg-gray-50.py-10 a > div.font-semibold.text-sm.text-black {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
[data-theme="editorial"] body main > section.bg-gray-50.py-10 a > div.text-xs.text-gray-600 {
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.45;
}

/* ─── popular savings & interest section ───────────────── */

/* `<section class="border-b border-gray-100 py-14 px-4">` immediately
 * before the main calculator-grid section. Heading + sub + view-all
 * combo lives directly inside .max-w-6xl. */
[data-theme="editorial"] body main > section.border-b.border-gray-100.py-14 {
  border-bottom-color: var(--line);
}
[data-theme="editorial"] body main > section.border-b.border-gray-100.py-14 h2.font-display.text-2xl,
[data-theme="editorial"] body main > section.border-b.border-gray-100.py-14 h2.font-display.text-3xl {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -0.012em;
  color: var(--ink);
}
[data-theme="editorial"] body main > section.border-b.border-gray-100.py-14 a.text-maroon {
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
}
[data-theme="editorial"] body main > section.border-b.border-gray-100.py-14 p.text-sm.text-gray-600 {
  color: var(--ink-3);
  font-size: 14.5px;
}

/* ─── browse-by-state section ─────────────────────────── */

/* `<section class="border-t border-gray-100 py-14 px-4">` containing the
 * 10 state pills. */
[data-theme="editorial"] body main > section.border-t.border-gray-100.py-14:not(.bg-gray-50) {
  border-top-color: var(--line);
}
[data-theme="editorial"] body main > section.border-t.border-gray-100.py-14 a.block.bg-white.border.border-gray-200.rounded-lg.text-sm.font-medium.text-gray-700 {
  background: var(--paper-3);
  border-color: var(--line);
  border-radius: var(--rad);
  font-family: var(--sans);
  color: var(--ink-2);
  transition: border-color 0.15s, color 0.15s;
}
[data-theme="editorial"] body main > section.border-t.border-gray-100.py-14 a.block.bg-white.border.border-gray-200.rounded-lg.text-sm.font-medium.text-gray-700:hover {
  border-color: var(--accent);
  color: var(--accent);
}
[data-theme="editorial"] body main > section.border-t.border-gray-100.py-14 a.text-maroon.font-medium {
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 500;
}

/* ─── trust / methodology strip ───────────────────────── */

/* `<section class="border-t border-gray-100 py-14 px-4 bg-gray-50">` —
 * the "Transparent calculations, no sign-up required" block with the
 * stat callouts on the right. */
[data-theme="editorial"] body main > section.border-t.border-gray-100.bg-gray-50 {
  background: var(--paper-2);
  border-top-color: var(--line);
}
[data-theme="editorial"] body main > section.border-t.border-gray-100.bg-gray-50 h2.font-display {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.012em;
  color: var(--ink);
}
[data-theme="editorial"] body main > section.border-t.border-gray-100.bg-gray-50 p.text-gray-700 {
  font-family: var(--serif);
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.65;
}
/* The big stat numbers (e.g. "32" calculators, "100%") */
[data-theme="editorial"] body main > section.border-t.border-gray-100.bg-gray-50 div.font-display.text-3xl.font-bold.text-maroon {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(32px, 3.6vw, 44px);
  letter-spacing: -0.018em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
[data-theme="editorial"] body main > section.border-t.border-gray-100.bg-gray-50 div.text-sm.text-gray-600 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* Vertical divider line in the stats column */
[data-theme="editorial"] body main > section.border-t.border-gray-100.bg-gray-50 div.md\:border-l.md\:border-gray-200 {
  border-left-color: var(--line);
}

/* ─── dark embed-CTA block ──────────────────── */

/* Two-column grid: left = eyebrow + headline + paragraph + button,
 * right = code snippet. */
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-cta {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--rad-lg);
  padding: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
}
@media (max-width: 960px) {
  [data-theme="editorial"] [data-editorial-cta] .editorial-embed-cta {
    grid-template-columns: minmax(0, 1fr);
    padding: 32px;
    gap: 32px;
  }
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin-bottom: 14px;
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-text h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0 0 14px;
  color: var(--paper);
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-text p {
  font-family: var(--sans);
  color: rgba(250, 247, 241, 0.72);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 24px;
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-btn:hover {
  background: #ffffff;
  color: var(--ink);
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-btn svg {
  width: 14px;
  height: 14px;
}

/* Secondary "Contact us" link inside the dark CTA — sits next to the
 * primary button. Quieter than the pill button: paper-tone, no border,
 * underline on hover. */
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-link {
  color: rgba(250, 247, 241, 0.78);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-link:hover {
  color: var(--paper);
  text-decoration: underline;
}

[data-theme="editorial"] [data-editorial-cta] .editorial-embed-snippet {
  background: #0e0c0a;
  border: 1px solid #2a2520;
  border-radius: var(--rad);
  font-family: var(--mono);
  font-size: clamp(10px, 0.7vw + 4px, 11.5px);
  line-height: 1.6;
  color: #cdc4b8;
  padding: 16px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-snippet code {
  font-family: inherit;
  background: transparent;
  padding: 0;
  color: inherit;
}
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-snippet .tg { color: #7fa3a3; }
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-snippet .at { color: #c89c5a; }
[data-theme="editorial"] [data-editorial-cta] .editorial-embed-snippet .st { color: #c47e7e; }


/* ═══════════════════════════════════════════════════════════════════════
   ═══   editorial v2 — Home v2 / CD Cluster refinement layer            ═══
   ═══   May 2026 (formerly /styles/editorial-v2.css)                    ═══
   ═══   Merged into editorial.css May 15 2026 to drop one HTTP request. ═══
   ═══════════════════════════════════════════════════════════════════════

   Original file scope:    public/styles/editorial-v2.css
   Original opt-in:        body.editorial-v2 (BaseLayout default)

   Rules below kept their original `body.editorial-v2` selector so all
   existing specificity calculations vs the legacy `[data-theme="editorial"]`
   editorial.css rules above continue to hold. Cascade order is preserved
   (this section loads AFTER all of editorial.css — same as the previous
   two-file load order). Roll back by removing this section. */

/*
 * editorial-v2.css — incremental refinement layer on top of editorial.css.
 *
 * Page-scoped to `body.editorial-v2`. Loaded only when BaseLayout receives
 * bodyClass="editorial-v2". Currently opted in by:
 *   - /cd-calculator/                            (parent page)
 *   - /[term]-cd-calculator/  (5 long-tail term pages: 6-month, 1-year,
 *                              2-year, 3-year, 5-year)
 *   - /cd-ladder-calculator/                     (ladder calculator)
 * Embed route at /embed/cd-calculator/ does not opt in, so the embed
 * visual contract is unchanged.
 *
 * The Asset-04 related-cards selector is a bare `[data-related-calc-list]`
 * (any value) — every opted-in page has its own slug there for gtag
 * analytics, and within the body.editorial-v2 scope every related-grid is a
 * <CalculatorCard> grid we want elevated. Originally an `$="cd-calculator"`
 * ends-with match, but that broke when /cd-ladder-calculator/ joined the
 * pilot — its slug ends with "cd-ladder-calculator", not "cd-calculator".
 * Body.editorial-v2 scope keeps this safe from leaking to non-pilot pages.
 *
 * Source: Claude Design handoff "calcsystem-freshen" (May 14, 2026),
 * specifically the assets the user landed on after iterating:
 *   Asset 01  Cream palette + warm hairlines (refinement of editorial tones)
 *   Asset 02  Square corners (zero out small radii)
 *   Asset 03  Cleaner crimson #8a1a1a (was #7c0e1e)
 *   Asset 04  Related cards → elevated white tiles with 3px rail + ↗ arrow
 *   Asset 05  Footer labels → IBM Plex Mono in muted brown
 *   Asset 06  CTA buttons → solid square crimson with hover lift
 *   Asset 07  Main card + Methodology aside → elevated white; hide internal
 *             maroon header band (page H1 already covers that role)
 *   Asset 08  Embed panel → elevated white card
 *
 * All rules use specificity >= 0,2,0 (body.editorial-v2 + at least one class /
 * attribute) so they win over editorial.css which is mostly 0,1,1.
 */

body.editorial-v2 {
  --ev2-cream: #f7f1e8;       /* page background */
  --ev2-paper: #fbf6ed;       /* warm panel surface (cards, search bar) — matches Home v2 design */
  --ev2-tinted: #efe6d4;      /* tinted band surface (Recently Updated + Trust stripes) */
  --ev2-rule-warm: #d9cdb8;
  --ev2-rule-warm-soft: #e6dcc8;
  --ev2-ink: #1a1410;
  --ev2-muted-warm: #6b5d50;
  --ev2-body-warm: #3a2f26;
  --ev2-crimson: #8a1a1a;
  --ev2-crimson-dark: #6b1212;
  --ev2-elev:
    0 1px 0 rgba(26, 20, 16, 0.04),
    0 1px 2px rgba(26, 20, 16, 0.05),
    0 10px 22px -14px rgba(26, 20, 16, 0.22);
  --ev2-elev-hover:
    0 1px 0 rgba(26, 20, 16, 0.04),
    0 2px 4px rgba(26, 20, 16, 0.06),
    0 18px 32px -16px rgba(26, 20, 16, 0.28);

  /* Re-point editorial.css's own font tokens at the handoff stack so every
     rule that says `font-family: var(--sans)` / `var(--mono)` / `var(--serif)`
     picks up Inter Tight or IBM Plex Mono automatically. The handoff keeps
     Source Serif 4 in exactly one place — the `.accent-italic` span ("earn")
     — which has its own explicit `font-family` declaration below, so
     remapping --serif here does not affect it. */
  --sans:  'Inter Tight', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --serif: 'Inter Tight', system-ui, -apple-system, sans-serif;

  /* Re-point editorial.css's --accent (and editorial's hover --accent-2) at
     the handoff crimson family so any rule that says
     `color: var(--accent)` / `background: var(--accent)` / etc. picks up
     #8a1a1a / #6b1212 automatically. Without this, eyebrows, link colors,
     and accent borders rendered via editorial.css's var(--accent) stay at
     the older #7c0e1e while the .accent-italic spans (which use the pilot's
     own --ev2-crimson) sit at #8a1a1a — a visible inconsistency the moment
     the pilot expanded beyond the CD cluster onto a page like the homepage
     where the eyebrow + H1 italic accent sit one above the other. */
  --accent:   var(--ev2-crimson);
  --accent-2: var(--ev2-crimson-dark);

  /* Brand-color remap — Tailwind utilities and the underlying theme token.
     The repo's tailwind.config.mjs defines `maroon` as `#800020`, and
     editorial.css overrides `.text-maroon` to the editorial accent via
     long compound class selectors that only match the original utility
     chains (e.g. `.font-display.font-bold.text-maroon`). When markup
     stops using those compound chains the editorial override silently
     drops out and Tailwind's flat `#800020` wins.

     Three clean overrides here resolve that ambiguity: any `text-maroon`,
     `bg-maroon`, or `border-maroon` on a pilot page resolves to the new
     crimson family without depending on the editorial.css compound chain.
     Non-pilot pages still use the existing editorial behavior. */

  background: var(--ev2-cream) !important;
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif;
}

/* Headings: handoff explicitly uses Inter Tight for H1/H2/H3 — Source Serif
   is reserved for the .accent-italic word in the H1 lede. Override both the
   generic editorial heading rule and the more specific page-H1 selector. */
body.editorial-v2 h1,
body.editorial-v2 h2,
body.editorial-v2 h3,
body.editorial-v2 h4 {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif !important;
  letter-spacing: -0.018em;
}
body.editorial-v2 main > div > header.mb-8 > h1,
body.editorial-v2 main > div > header.mb-6 > h1 {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif !important;
}

/* Tailwind utilities `font-display` and `font-serif` on this page should
   also resolve to Inter Tight, since the handoff treats the page as
   single-family (Inter Tight) with Source Serif italic for accents only. */
body.editorial-v2 .font-display,
body.editorial-v2 .font-serif {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif !important;
}
body.editorial-v2 .font-mono {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace !important;
}

/* Lede paragraph under the H1: editorial.css applies a magazine "lede"
   treatment (Source Serif at 18px). The handoff keeps the lede in sans —
   serif is reserved exclusively for the .accent-italic word. */
body.editorial-v2 main > div > header.mb-8 > p,
body.editorial-v2 main > div > header.mb-6 > p {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif !important;
}
/* .accent-italic is a span INSIDE the lede paragraph — its later, equally
   specific rule wins, but be explicit so future refactors don't break it. */
body.editorial-v2 main > div > header > p .accent-italic {
  font-family: 'Source Serif 4', Georgia, serif !important;
}

/* Hero result callout — editorial.css recasts the big "$10,450.00" maturity
   value as Source Serif (its "magazine masthead number" treatment). The
   handoff puts financial numbers in IBM Plex Mono with tabular figures —
   precise / spreadsheet-grade, not editorial-flourish. Override here. */
body.editorial-v2 main div.rounded-xl.border-2.border-maroon > div.font-bold.text-3xl.text-maroon,
body.editorial-v2 [data-cd-calculator] #res-maturity-value {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace !important;
  font-variant-numeric: tabular-nums;
}

/* Sticky header + footer pick up the cream tone */
body.editorial-v2 header.sticky.bg-white { background: var(--ev2-cream) !important; border-color: var(--ev2-rule-warm) !important; }
body.editorial-v2 footer.bg-gray-50       { background: var(--ev2-cream) !important; border-color: var(--ev2-rule-warm) !important; }
body.editorial-v2 footer .border-t.border-gray-200 { border-color: var(--ev2-rule-warm) !important; }

/* Asset 01 — warm-up hairlines + panels */
body.editorial-v2 .border-gray-200 { border-color: var(--ev2-rule-warm) !important; }
body.editorial-v2 .border-gray-100 { border-color: var(--ev2-rule-warm-soft) !important; }
body.editorial-v2 .border-gray-300 { border-color: var(--ev2-rule-warm) !important; }
body.editorial-v2 .bg-gray-50      { background: var(--ev2-paper) !important; }

/* Tinted bands — pages mark distinct horizontal stripes (Recently Updated,
   Trust band) with `data-tinted-band`. The design uses a deeper warm tone
   (#efe6d4) here than the regular --ev2-paper panels, so the stripe reads
   as a deliberate section break against the cream page background.
   Overrides the bg-gray-50 → --ev2-paper remap above. */
body.editorial-v2 [data-tinted-band] {
  background: var(--ev2-tinted) !important;
  border-color: var(--ev2-rule-warm) !important;
}

/* Hero search pill — Home v2 design has this as a 999px pill on warm
   paper. The Asset-02 "zero out small radii" rule below would otherwise
   flatten the rounded-full back to a rectangle. Restore the pill + tint
   the field bg so the search reads as a deliberate object against the
   cream page bg. */
body.editorial-v2 [data-hero-search] input[type="search"] {
  border-radius: 9999px !important;
  background: var(--ev2-paper) !important;
}

/* Asset 03 — Tailwind maroon utilities → handoff crimson #8a1a1a.
   Tailwind compiles `text-maroon` to `color: rgb(128 0 32 / opacity)`
   based on tailwind.config.mjs (#800020). Editorial.css overrides this
   for some compound class chains via var(--accent), but the override
   relies on the markup using specific Tailwind utility combos that
   change page-to-page. Anchoring the remap directly to the bare
   utility classes makes the brand-color shift reliable wherever the
   pilot is opted in. */
body.editorial-v2 .text-maroon   { color: var(--ev2-crimson) !important; }
body.editorial-v2 .bg-maroon     { background-color: var(--ev2-crimson) !important; }
body.editorial-v2 .border-maroon { border-color: var(--ev2-crimson) !important; }
body.editorial-v2 .ring-maroon\/20,
body.editorial-v2 [class*="ring-maroon"] { --tw-ring-color: rgba(138,26,26,0.2) !important; }
/* Hover + focus variants from the original maroon utility chain */
body.editorial-v2 .hover\:text-maroon:hover { color: var(--ev2-crimson) !important; }
body.editorial-v2 .focus\:border-maroon:focus { border-color: var(--ev2-crimson) !important; }
body.editorial-v2 .hover\:bg-maroon:hover { background-color: var(--ev2-crimson) !important; }

/* Tailwind's `open:bg-gray-50` variant compiles to `.open\:bg-gray-50[open]`
   and emits its own background-color declaration — different class than
   `bg-gray-50`, so the rule above does not catch it. The FAQ <details>
   accordions use this variant for their open-state tint. Without this
   override, opened FAQ items render Tailwind's cool gray-50 (#f9fafb)
   against the warm cream/paper palette. Map to the warm paper token so
   opened items pop subtly in the same tonal family as the rest of the
   editorial pilot. Attribute-class selector avoids the CSS \: escape. */
body.editorial-v2 [class*="open:bg-gray-50"][open] {
  background: var(--ev2-paper) !important;
}

/* Asset 02 — zero out Tailwind's small radii.
   Keep `rounded-full` and `rounded-sm` for legend dots and progress segments. */
body.editorial-v2 .rounded-2xl,
body.editorial-v2 .rounded-xl,
body.editorial-v2 .rounded-lg,
body.editorial-v2 .rounded-md { border-radius: 0 !important; }

/* Asset 07A — Main calculator card: elevated white on cream.
   editorial.css styles `[data-cd-calculator]` etc. as elevated white at
   the editorial baseline (6px radius, single shadow). We override with
   the layered three-stop shadow and zero out the radius. No hover lift
   since this is the page's primary surface, not a tile.
   The selector list follows the project's `data-{name}-calculator`
   widget-marker convention used across editorial.css. */
body.editorial-v2 [data-cd-calculator],
body.editorial-v2 [data-cd-ladder-calculator],
body.editorial-v2 [data-paycheck-calculator],
body.editorial-v2 [data-income-tax-calculator],
body.editorial-v2 [data-sales-tax-calculator],
body.editorial-v2 [data-apy-calculator],
body.editorial-v2 [data-compound-interest-calculator] {
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: var(--ev2-elev) !important;
}

/* Asset 07D — Hide the internal maroon "Calculate Your X Return" header
   band on every calculator card. The pattern is consistent across the
   site's ~38 widget files: a `<div class="bg-maroon ...">` wrapping an
   `<h2 class="text-white ...">` (white-on-maroon strip above the inputs).
   The page H1 above already serves the "what is this calculator" role,
   so the internal band is a redundant pre-editorial header strip.

   Universal selector via `:has()` — semantically matches the band on
   every calculator widget, not just the 7 that follow the
   `data-{name}-calculator` convention. (The bulk of calculator pages —
   401k, retirement, mortgage variants, debt payoff, etc. — don't use
   that data attribute, so the previous per-attribute rule was leaving
   the band visible on most of the site.)

   Scoped to body.editorial-v2 so embed routes (which render through
   EmbedLayout without this class) keep the band — embeds have no page
   H1 above the widget and rely on the band for "what is this?" context. */
body.editorial-v2 div.bg-maroon:has(> h2.text-white) { display: none !important; }

/* Asset 07B — Methodology aside: same elevated treatment */
body.editorial-v2 aside[aria-label="Methodology and sources"] {
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: var(--ev2-elev) !important;
}
body.editorial-v2 aside[aria-label="Methodology and sources"] > header {
  background: transparent !important;
}

/* Asset 08 — Embed panel: elevated white card.
   The EmbedThisCalculator component renders an element with id like
   `embed-panel-cd-calculator`; we match by id prefix. */
body.editorial-v2 [id^="embed-panel-"] {
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: var(--ev2-elev) !important;
  padding: 18px !important;
}
body.editorial-v2 [id^="embed-panel-"] textarea {
  background: var(--ev2-paper) !important;
  border-color: var(--ev2-rule-warm) !important;
}

/* Asset 06 — Embed-toggle CTA: solid square crimson with hover lift */
body.editorial-v2 [data-embed-toggle] {
  background: var(--ev2-crimson) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 12px 18px !important;
  font: 500 13px/1 'Inter Tight', sans-serif !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  transition: background 120ms ease, transform 120ms ease !important;
}
body.editorial-v2 [data-embed-toggle] svg { color: #fff !important; }
body.editorial-v2 [data-embed-toggle]:hover {
  background: var(--ev2-crimson-dark) !important;
  transform: translateY(-1px);
  color: #fff !important;
}

/* Any other maroon button-ish links get the same hover lift */
body.editorial-v2 a.bg-maroon,
body.editorial-v2 button.bg-maroon {
  transition: background 120ms ease, transform 120ms ease !important;
}
body.editorial-v2 a.bg-maroon:hover,
body.editorial-v2 button.bg-maroon:hover {
  background: var(--ev2-crimson-dark) !important;
  transform: translateY(-1px);
}

/* `.editorial-embed-btn` (homepage "Browse Embed Widgets" + the same
   button on /calculator-widgets/) is styled by editorial.css as a pale
   pill on warm-paper — the original pre-pilot CTA chrome. Home v2
   design specifies a solid crimson square button (white text, 1px lift
   on hover) sitting on the dark embed-CTA panel. Override here so both
   surfaces match the rest of the editorial-v2 CTA vocabulary. */
body.editorial-v2 [data-editorial-cta] .editorial-embed-btn,
body.editorial-v2 .editorial-embed-cta .editorial-embed-btn {
  background: var(--ev2-crimson) !important;
  color: #fff !important;
  border-radius: 0 !important;
  padding: 12px 18px !important;
  font: 500 14px/1 'Inter Tight', sans-serif !important;
  transition: background 120ms ease, transform 120ms ease !important;
}
body.editorial-v2 [data-editorial-cta] .editorial-embed-btn:hover,
body.editorial-v2 .editorial-embed-cta .editorial-embed-btn:hover {
  background: var(--ev2-crimson-dark) !important;
  color: #fff !important;
  transform: translateY(-1px);
}
body.editorial-v2 [data-editorial-cta] .editorial-embed-btn svg,
body.editorial-v2 .editorial-embed-cta .editorial-embed-btn svg {
  color: #fff !important;
}

/* Asset 04 — Universal CalculatorCard treatment: elevated white tile,
   3px crimson rail (grows full-height on hover), ↗ arrow top-right
   (translates +3,-3 on hover), -2px lift with deeper shadow on hover.

   The CSS targets both:
   1. Direct <a> children of any [data-related-calc-list] grid
      (the related-calc strips at the bottom of calculator detail pages),
      AND
   2. Any anchor with the CalculatorCard's distinctive class chain
      `a.group.bg-white.border-2.border-maroon` (matches the homepage
      Recently Updated row, every category grid on the homepage, every
      hub-page grid, and the 404 popular-calculators list).

   The data-related-calc-list selector ALSO sets a forced 4-column grid
   (the related-calc grids ship as `lg:grid-cols-4`, but we want them
   uniformly 4-up at desktop). The CalculatorCard selector does NOT
   force a grid — the surrounding markup sets column count per section
   (e.g. homepage Recently Updated is `lg:grid-cols-5`, category grids
   are `lg:grid-cols-3`, hub pages vary). */
body.editorial-v2 [data-related-calc-list] {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 14px !important;
  border: 0 !important;
}
@media (max-width: 900px) {
  body.editorial-v2 [data-related-calc-list] { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 520px) {
  body.editorial-v2 [data-related-calc-list] { grid-template-columns: 1fr !important; }
}
body.editorial-v2 [data-related-calc-list] > a,
body.editorial-v2 a.group.bg-white.border-2.border-maroon {
  position: relative;
  display: flex !important;
  flex-direction: column;
  gap: 6px;
  min-height: 132px;
  padding: 18px 44px 18px 22px !important;
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: var(--ev2-elev) !important;
  transition: transform 160ms ease, box-shadow 160ms ease !important;
}
body.editorial-v2 [data-related-calc-list] > a::before,
body.editorial-v2 a.group.bg-white.border-2.border-maroon::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 3px; height: 26px;
  background: var(--ev2-crimson);
  transition: height 160ms ease;
}
body.editorial-v2 [data-related-calc-list] > a:hover,
body.editorial-v2 a.group.bg-white.border-2.border-maroon:hover {
  transform: translateY(-2px);
  box-shadow: var(--ev2-elev-hover) !important;
}
body.editorial-v2 [data-related-calc-list] > a:hover::before,
body.editorial-v2 a.group.bg-white.border-2.border-maroon:hover::before { height: 100%; }
body.editorial-v2 [data-related-calc-list] > a::after,
body.editorial-v2 a.group.bg-white.border-2.border-maroon::after {
  content: '↗';
  position: absolute;
  top: 18px; right: 18px;
  width: 22px; height: 22px;
  color: var(--ev2-crimson);
  font: 500 18px/22px 'Inter Tight', sans-serif;
  text-align: center;
  transition: transform 140ms ease;
}
body.editorial-v2 [data-related-calc-list] > a:hover::after,
body.editorial-v2 a.group.bg-white.border-2.border-maroon:hover::after { transform: translate(3px, -3px); }

/* CalculatorCard internal text styles — color & font for h3 / p / eyebrow.
   CalculatorCard's first child is the <h3> (with optional icon + title),
   second is the <p> description, optional third is a "Reviewed" stamp,
   and the last is the "Open Calculator →" CTA div. */
body.editorial-v2 [data-related-calc-list] > a h3,
body.editorial-v2 a.group.bg-white.border-2.border-maroon h3 {
  font: 600 18px/1.2 'Inter Tight', sans-serif !important;
  letter-spacing: -0.018em !important;
  color: var(--ev2-ink) !important;
  margin: 0 !important;
}
/* The H3 in CalculatorCard contains an icon SVG + a <span> for the title.
   The Home v2 — Elevated design drops the icons entirely — the 3px crimson
   rail on the left and the ↗ arrow in the corner are the design's
   "this is a calculator" affordances, so the inline icon is redundant
   and adds visual noise. Hide it on editorial-v2 pages. */
body.editorial-v2 a.group.bg-white.border-2.border-maroon h3 svg {
  display: none !important;
}
body.editorial-v2 [data-related-calc-list] > a p,
body.editorial-v2 a.group.bg-white.border-2.border-maroon p {
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  color: var(--ev2-body-warm) !important;
  margin: 0 !important;
}
/* The lastReviewed stamp (Plex Mono uppercase "REVIEWED MAY 2026")
   already uses font-mono + uppercase from CalculatorCard's markup —
   color/letter-spacing tweak to bring it in line with the editorial-v2
   eyebrow vocabulary. */
body.editorial-v2 a.group.bg-white.border-2.border-maroon p.font-mono {
  color: var(--ev2-muted-warm) !important;
  letter-spacing: 0.14em !important;
}
/* Optional explicit eyebrow div (data-related-calc-list cards use this). */
body.editorial-v2 [data-related-calc-list] > a > div:first-child:not(:has(h3)),
body.editorial-v2 a > .calc-card-eyebrow {
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 10.5px !important;
  font-weight: 500 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ev2-crimson) !important;
  margin-bottom: 0 !important;
}
/* Hide the bottom "Open Calculator →" footer CTA — the ↗ corner now does
   the affordance. Targets the last child div containing `text-maroon`. */
body.editorial-v2 [data-related-calc-list] > a > div:last-child:not(:first-child):not(:has(h3)),
body.editorial-v2 a.group.bg-white.border-2.border-maroon > div.text-maroon:last-child {
  display: none !important;
}

/* Asset 05 — Footer category labels: IBM Plex Mono, muted brown.
   Matches both the older Tailwind utility-class footer and the editorial
   version. */
body.editorial-v2 footer .text-\[10px\].font-bold.uppercase,
body.editorial-v2 body > footer div.uppercase.tracking-widest {
  font-family: 'IBM Plex Mono', monospace !important;
  font-weight: 500 !important;
  font-size: 10.5px !important;
  letter-spacing: 0.18em !important;
  color: var(--ev2-muted-warm) !important;
}

/* "Last updated" stamp — IBM Plex Mono uppercase */
body.editorial-v2 .last-updated-mono {
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
  color: var(--ev2-muted-warm) !important;
}

/* Accent italic for serif emphases in the H1 (e.g. the word "earn") */
body.editorial-v2 .accent-italic {
  font-family: 'Source Serif 4', Georgia, serif !important;
  font-style: italic;
  font-weight: 500;
  color: var(--ev2-crimson);
}
