/* ==========================================================================
   CalcWright — shared stylesheet (loaded site-wide, cached after first load)
   Design system per Foundation spec (sheet 19). System fonts only.
   ========================================================================== */

:root {
  --primary: #0366d6;
  --primary-dark: #0250a8;
  --accent: #d97706;            /* warm construction accent, used sparingly */
  --accent-soft: #fff4e5;
  --text: #24292e;
  --text-muted: #57606a;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --border: #e1e4e8;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(27,31,36,.06);
  --shadow-md: 0 4px 14px rgba(27,31,36,.10);
  --maxw: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 16px; letter-spacing: -0.01em; }
h1 { font-size: 36px; font-weight: 800; }
h2 { font-size: 24px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0 0 16px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Accessibility ----------------------------------------------------------- */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 1000;
  background: var(--primary); color: #fff; padding: 10px 16px;
  border-radius: var(--radius); transition: top .15s ease;
}
.skip-link:focus { top: 8px; text-decoration: none; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Header ------------------------------------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: box-shadow .2s ease;
}
.site-header.is-scrolled { box-shadow: var(--shadow-md); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 16px;
}
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.02em;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 16px; font-weight: 800;
}
.logo b { color: var(--primary); }

.main-nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 4px; flex-wrap: wrap;
}
.main-nav a {
  display: block; padding: 8px 12px; border-radius: 6px;
  color: var(--text-muted); font-size: 15px; font-weight: 600;
}
.main-nav a:hover { color: var(--primary); background: var(--bg-subtle); text-decoration: none; }

.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 1px solid var(--border);
  background: var(--bg); border-radius: 6px; cursor: pointer;
}
.nav-toggle svg { width: 22px; height: 22px; stroke: var(--text); }

@media (max-width: 859px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    position: absolute; left: 0; right: 0; top: 64px;
    background: var(--bg); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-height: 0; overflow: hidden; transition: max-height .25s ease;
  }
  .main-nav.is-open { max-height: 70vh; overflow-y: auto; }
  .main-nav ul { flex-direction: column; padding: 8px 20px 16px; gap: 0; }
  .main-nav a { padding: 12px 8px; font-size: 16px; border-bottom: 1px solid var(--border); }
}

/* Hero -------------------------------------------------------------------- */
.hero {
  padding: 64px 0 48px;
  background:
    linear-gradient(rgba(255,255,255,.92), rgba(255,255,255,.96)),
    repeating-linear-gradient(0deg, var(--border) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 28px);
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.hero h1 { font-size: clamp(30px, 6vw, 46px); }
.hero .lede {
  font-size: 18px; color: var(--text-muted);
  max-width: 620px; margin: 0 auto 28px;
}
.eyebrow {
  display: inline-block; margin-bottom: 16px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px;
}

/* Search ------------------------------------------------------------------ */
.search-wrap { position: relative; max-width: 560px; margin: 0 auto; text-align: left; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow-sm);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(3,102,214,.15); }
.search-box svg { width: 20px; height: 20px; stroke: var(--text-muted); flex: none; }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; font-family: var(--font); color: var(--text); padding: 10px 0;
}
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto;
}
.search-results:empty, .search-results[hidden] { display: none; }
.search-results a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; color: var(--text); border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a.is-active { background: var(--bg-subtle); text-decoration: none; }
.search-results .cat { font-size: 12px; color: var(--text-muted); text-transform: capitalize; flex: none; }
.search-empty { padding: 16px; color: var(--text-muted); font-size: 14px; }

/* Section scaffolding ----------------------------------------------------- */
.section { padding: 56px 0; }
.section--subtle { background: var(--bg-subtle); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 36px; }
.section-head p { color: var(--text-muted); margin: 0; }

/* Category grid ----------------------------------------------------------- */
.cat-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, 1fr);
}
.cat-card {
  display: block; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.cat-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-md);
  border-color: var(--primary); text-decoration: none;
}
.cat-icon {
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--accent-soft); display: grid; place-items: center; margin-bottom: 14px;
}
.cat-icon svg { width: 24px; height: 24px; stroke: var(--accent); fill: none; stroke-width: 1.8; }
.cat-card h3 { margin: 0 0 4px; color: var(--text); }
.cat-card .count { font-size: 14px; color: var(--text-muted); }

/* Tool cards -------------------------------------------------------------- */
.tool-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(5, 1fr);
}
.tool-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.tool-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
  border-color: var(--primary); text-decoration: none;
}
.tool-card .name { font-weight: 700; color: var(--text); font-size: 15px; }
.tool-card .tag { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

/* Why columns ------------------------------------------------------------- */
.cols-3 { display: grid; gap: 28px; grid-template-columns: repeat(3, 1fr); }
.trust { text-align: center; }
.trust-icon {
  width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 12px;
  background: rgba(3,102,214,.08); display: grid; place-items: center;
}
.trust-icon svg { width: 28px; height: 28px; stroke: var(--primary); fill: none; stroke-width: 1.8; }
.trust h3 { margin-bottom: 8px; }
.trust p { color: var(--text-muted); margin: 0; }

/* How it works ------------------------------------------------------------ */
.steps { display: grid; gap: 24px; grid-template-columns: repeat(3, 1fr); counter-reset: step; }
.step { position: relative; padding-left: 56px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
}
.step h3 { margin-bottom: 4px; }
.step p { color: var(--text-muted); margin: 0; }

/* FAQ --------------------------------------------------------------------- */
.faq { max-width: 760px; margin: 0 auto; }
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; background: var(--bg); overflow: hidden;
}
.faq summary {
  cursor: pointer; padding: 16px 20px; font-weight: 700; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 22px; color: var(--text-muted); font-weight: 400; }
.faq details[open] summary::after { content: "\2212"; }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq .faq-body { padding: 16px 20px; color: var(--text-muted); }
.faq .faq-body p:last-child { margin-bottom: 0; }

/* About ------------------------------------------------------------------- */
.about { max-width: 760px; margin: 0 auto; color: var(--text-muted); }
.about h2 { color: var(--text); }

/* Footer ------------------------------------------------------------------ */
.site-footer { background: #24292e; color: #c9d1d9; padding: 48px 0 24px; margin-top: 8px; }
.footer-cols { display: grid; gap: 32px; grid-template-columns: repeat(3, 1fr); }
.footer-cols h4 { color: #fff; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 14px; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols li { margin-bottom: 10px; }
.footer-cols a { color: #c9d1d9; font-size: 15px; }
.footer-cols a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #3a3f45; margin-top: 32px; padding-top: 20px;
  font-size: 13px; color: #8b949e; text-align: center;
}

/* Buttons (used on calculator pages) -------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--font); font-size: 15px; font-weight: 600;
  padding: 12px 20px; border-radius: var(--radius); border: 1px solid transparent;
  min-height: 44px; line-height: 1;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-subtle); text-decoration: none; }

/* Tooltip pattern (calculator inputs) ------------------------------------- */
.tooltip-trigger {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-subtle); color: var(--text-muted);
  font-size: 12px; font-weight: 700; cursor: pointer; line-height: 1;
  display: inline-grid; place-items: center; vertical-align: middle;
}
.tooltip-trigger:hover { border-color: var(--primary); color: var(--primary); }
.tooltip {
  display: block; margin-top: 6px; padding: 10px 12px;
  background: var(--text); color: #fff; font-size: 14px; line-height: 1.45;
  border-radius: 6px; max-width: 320px;
}
.tooltip[hidden] { display: none; }

/* Ad slots / related calculators ------------------------------------------ */
.ad-slot { min-height: 280px; margin: 32px 0; }
.ad-slot[data-slot="4"] { position: sticky; top: 80px; }
.ad-slot[data-slot="mobile-bottom"] { min-height: 100px; }
.related-cals {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.related-cals h4 { margin: 0 0 14px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.related-cals .related-grid { display: grid; gap: 10px; }
.related-cals a {
  display: block; padding: 12px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-weight: 600; font-size: 15px;
}
.related-cals a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

@media (min-width: 768px) { .ad-slot[data-slot="mobile-bottom"] { display: none; } }
@media (max-width: 767px) { .ad-slot[data-slot="4"] { display: none; } }

/* Cookie banner ----------------------------------------------------------- */
.cookie-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200;
  background: var(--text); color: #f0f3f6; border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  max-width: 720px; margin: 0 auto;
}
.cookie-banner p { margin: 0; font-size: 14px; flex: 1 1 280px; }
.cookie-banner a { color: #fff; text-decoration: underline; }
.cookie-actions { display: flex; gap: 10px; }
.cookie-banner .btn-primary { min-height: 40px; padding: 10px 18px; }
.cookie-banner .btn-ghost { background: transparent; color: #fff; border-color: #57606a; min-height: 40px; padding: 10px 18px; }
.cookie-banner[hidden] { display: none; }

/* Responsive grids -------------------------------------------------------- */
@media (max-width: 900px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  h1 { font-size: 30px; }
  .section { padding: 40px 0; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .cols-3, .steps, .footer-cols { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Legal / content pages, contact form  (added with the 5 legal pages)
   ========================================================================== */
.page-hero { padding: 48px 0 28px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.page-hero h1 { margin-bottom: 8px; }
.page-hero .lede { color: var(--text-muted); font-size: 18px; margin: 0; max-width: 640px; }

.prose { max-width: 800px; margin: 0 auto; padding: 40px 20px 56px; }
.doc-meta { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; display: flex; gap: 18px; flex-wrap: wrap; }
.doc-meta strong { color: var(--text); }
.prose h2 { margin-top: 36px; scroll-margin-top: 84px; font-size: 22px; }
.prose h3 { margin-top: 22px; }
.prose p, .prose li { color: #2f363d; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.byline { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 14px; }

.toc { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 8px; }
.toc h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.toc ol { margin: 0; padding-left: 20px; columns: 2; column-gap: 32px; }
.toc li { margin-bottom: 6px; break-inside: avoid; }
@media (max-width: 600px) { .toc ol { columns: 1; } }

.callout { border-left: 4px solid var(--primary); background: var(--bg-subtle); padding: 16px 20px; border-radius: 0 var(--radius) var(--radius) 0; margin: 24px 0; }
.callout strong { display: block; margin-bottom: 6px; }
.callout-danger { border-left-color: #cf222e; background: #fff5f5; }
.callout-warn { border-left-color: var(--accent); background: var(--accent-soft); }

.contact-cards { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); margin: 24px 0; }
.contact-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.contact-card h3 { font-size: 16px; margin: 0 0 6px; }
.contact-card p { margin: 0; color: var(--text-muted); font-size: 14px; }
@media (max-width: 760px) { .contact-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px) { .contact-cards { grid-template-columns: 1fr; } }

.email-display { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; }
.email-display .addr { font-size: 20px; font-weight: 700; color: var(--primary); }

.form-field { margin-bottom: 18px; }
.form-field label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-field .req { color: #cf222e; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; font-family: var(--font); font-size: 16px; color: var(--text);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); min-height: 44px;
}
.form-field textarea { min-height: 140px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(3,102,214,.15);
}
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.char-count { font-size: 13px; color: var(--text-muted); text-align: right; margin-top: 4px; }
.form-status { margin-top: 14px; font-weight: 600; min-height: 22px; }
.form-status.ok { color: #1a7f37; }
.form-status.err { color: #cf222e; }
