/* global.css — CoverageMath shared chrome: tokens, theme, layout, nav, footer,
   typography, disclaimer + ad slots. Light theme is the canonical default; a dark
   theme is carried as an optional toggle (and respects prefers-color-scheme). */

:root {
  --blue: #1d6fd6;
  --blue-600: #1559ad;
  --teal: #0d9488;
  --teal-600: #0f766e;
  --green: #16a34a;
  --green-600: #15803d;
  --amber: #d97706;

  /* Light theme (default / canonical) */
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --border: #dbe3ec;
  --text: #0f1f2e;
  --text-muted: #44586b;
  --text-faint: #687a8c;
  --accent: var(--teal);
  --accent-hover: var(--teal-600);
  --accent-blue: var(--blue);
  --success: var(--green);
  --warn: var(--amber);
  --warn-bg: #fff7ed;
  --warn-border: #fed7aa;
  --warn-text: #9a3412;
  --shadow: 0 1px 3px rgba(15, 31, 46, 0.08), 0 1px 2px rgba(15, 31, 46, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 31, 46, 0.10);
  --focus: #1d6fd6;
  --radius: 12px;
}

[data-theme='dark'] {
  --bg: #0b1320;
  --surface: #131f30;
  --surface-2: #1b2a3f;
  --border: #2a3b52;
  --text: #e9eff7;
  --text-muted: #aebccf;
  --text-faint: #8395ab;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-blue: #60a5fa;
  --success: #22c55e;
  --warn: #fbbf24;
  --warn-bg: #2a1f10;
  --warn-border: #5b4321;
  --warn-text: #fcd9a5;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.5);
  --focus: #60a5fa;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.6;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; color: var(--text); }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 0.5rem; }
h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent-blue); }

.container { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 1rem; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* Header / nav */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; max-width: 920px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-weight: 800; font-size: 1rem;
}
.brand-name span { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 0.6rem; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; }
.nav-links a:hover, .nav-links a[aria-current='page'] { color: var(--accent); }

/* Calculators dropdown */
.tools-menu { position: relative; }
.tools-toggle {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.35rem 0.85rem; cursor: pointer; font-family: inherit; font-size: 0.9rem;
}
.tools-toggle:hover { color: var(--text); }
.tools-toggle .caret { transition: transform 0.15s ease; font-size: 0.7em; }
.tools-menu.open .tools-toggle .caret { transform: rotate(180deg); }
.tools-panel {
  position: absolute; top: calc(100% + 0.45rem); right: 0; z-index: 60;
  min-width: 280px; margin: 0; padding: 0.35rem; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: none;
}
.tools-menu.open .tools-panel { display: block; }
.tools-panel li { margin: 0; }
.tools-panel a, .tools-panel .tools-soon {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.55rem 0.6rem; border-radius: 8px; font-size: 0.92rem; text-decoration: none; color: var(--text);
}
.tools-panel a:hover { background: var(--surface-2); color: var(--accent); }
.tools-panel a[aria-current='page'] { color: var(--accent); font-weight: 700; }
.tools-soon { color: var(--text-faint); cursor: default; }
.tools-soon em {
  font-style: normal; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface-2); color: var(--text-faint); padding: 0.12rem 0.45rem; border-radius: 999px;
}

.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.35rem 0.75rem; cursor: pointer; font-size: 0.85rem;
}
.theme-toggle:hover { color: var(--text); }

/* Footer */
.site-footer { margin-top: 3rem; border-top: 1px solid var(--border); background: var(--surface); color: var(--text-faint); font-size: 0.9rem; }
.site-footer .container { padding-top: 2rem; padding-bottom: 2rem; }
.site-footer a { color: var(--text-muted); }
.footer-disclaimer { font-size: 0.82rem; margin-top: 1rem; }
.footer-updated { font-size: 0.82rem; margin-top: 0.75rem; color: var(--text-faint); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--accent); color: #fff; border: none;
  padding: 0.7rem 1.2rem; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* Trust badges */
.trust-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; }
.trust-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  padding: 0.4rem 0.7rem; border-radius: 999px; font-size: 0.85rem;
}
.trust-badge svg { flex: none; }

/* Ad units — Google AdSense (horizontal/responsive). Each .ad-unit wraps one
   <ins class="adsbygoogle"> slot; placement mirrors the FreelanceFinanceCalc site
   (home: below the cards; calculators: top/middle/bottom, never inside a result). */
.ad-unit { margin: 1.5rem auto; min-height: 100px; text-align: center; max-width: 100%; overflow: hidden; }
.ad-unit .adsbygoogle { display: block; max-width: 100%; }

/* Legacy dev placeholder (unused now that real ad units are in place). */
.ad-slot { display: none; }
.ad-slot.show {
  display: flex; align-items: center; justify-content: center;
  margin: 1.5rem auto; max-width: 728px; min-height: 90px;
  border: 1px dashed var(--border); border-radius: 8px;
  color: var(--text-faint); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase;
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, var(--surface-2) 10px, var(--surface-2) 20px);
}
.ad-slot.show::before { content: 'Advertisement'; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }

/* Direct-answer hero block (featured-snippet bait) */
.direct-answer {
  background: linear-gradient(160deg, color-mix(in srgb, var(--teal) 8%, var(--surface)), var(--surface));
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 1rem 0 1.5rem; box-shadow: var(--shadow);
}
.direct-answer p { margin: 0; font-size: 1.05rem; }
.direct-answer strong { color: var(--text); }

/* Standard disclaimer block (reused beneath every results panel) */
.disclaimer-block {
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 0.85rem 1rem; margin: 1.25rem 0; font-size: 0.85rem; color: var(--text-muted);
}
.disclaimer-block strong { color: var(--text); }

/* Contextual "near a threshold" nudge */
.threshold-nudge {
  display: flex; gap: 0.6rem; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text);
  border-radius: 10px; padding: 0.8rem 1rem; margin: 1rem 0; font-size: 0.9rem;
}
.threshold-nudge svg { flex: none; margin-top: 0.1rem; }

/* Focus visibility */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* Utility */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: fade-up 0.35s ease both; }
  @keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ── Guides (content articles) ─────────────────────────────────────────────
   Reuses .content-section, .card, .tools-grid/.tool-card, .related-grid,
   .direct-answer, .btn, .sources-list. Adds only what guides specifically need. */
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.75rem; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--text); }
.breadcrumb .sep { margin: 0 0.4rem; color: var(--text-faint); }

.byline { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.88rem;
  color: var(--text-muted); margin: 0.4rem 0 1.4rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--border); }
.byline .b-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.byline strong { color: var(--text); font-weight: 600; }

.toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 1.5rem 0; }
.toc .toc-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin: 0 0 0.6rem; }
.toc ol { margin: 0; padding-left: 1.25rem; columns: 2; column-gap: 1.5rem; }
.toc li { margin: 0.3rem 0; break-inside: avoid; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 560px) { .toc ol { columns: 1; } }

/* Calculator call-to-action box, dropped mid-article and at the end. */
.cta-box { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface));
  border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin: 1.75rem 0; box-shadow: var(--shadow); }
.cta-box h2, .cta-box h3 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.cta-box p { margin: 0 0 0.9rem; color: var(--text-muted); }
.cta-box .btn { margin: 0; }

/* "Key takeaways" list inside a .direct-answer box. */
.takeaways { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.takeaways li { margin: 0.35rem 0; }

.guide-meta-note { font-size: 0.85rem; color: var(--text-faint); margin-top: 0.5rem; }

/* Guides hub — "browse by topic" cards (not wrapping links, so guide links can nest). */
.topic-card h3 { margin-top: 0; font-size: 1.05rem; }
.topic-card h3 a { color: var(--accent); text-decoration: none; }
.topic-card h3 a:hover { text-decoration: underline; }
.topic-card > p { color: var(--text-muted); font-size: 0.92rem; margin: 0 0 0.6rem; }
.topic-links { list-style: none; margin: 0; padding: 0; }
.topic-links li { margin: 0.3rem 0; }
.topic-links li a { font-size: 0.95rem; }
.topic-links .topic-tool a { color: var(--text-muted); font-size: 0.9rem; }

/* Tool/guide card grid — used by the home page tool cards AND the guides hub.
   (Previously these lived only in index.html's inline <style>, so the guides hub
   rendered them unstyled.) The heading rule covers h2 (home) and h3 (hub). */
.tools-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 2rem 0; }
.tool-card { display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: transform .12s ease, box-shadow .12s ease; }
.tool-card.live:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tool-card .tool-badge { align-self: flex-start; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 999px; margin-bottom: .6rem; }
.tool-card.live .tool-badge { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.tool-card.soon { opacity: .7; cursor: default; }
.tool-card.soon .tool-badge { background: var(--surface-2); color: var(--text-faint); }
.tool-card h2, .tool-card h3 { margin: 0 0 .4rem; font-size: 1.2rem; border: none; padding: 0; }
.tool-card p { color: var(--text-muted); font-size: .95rem; margin: 0 0 1rem; }
.tool-card .tool-cta { margin-top: auto; font-weight: 700; color: var(--accent); }
