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

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800;900&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* Ink & surfaces — obsidian blueprint navy on warm architect's paper */
  --ink: #0a1428;
  --ink-2: #0f2140;
  --text: #19222e;
  --text-muted: #5b6675;
  --bg: #ffffff;
  --bg-subtle: #f1efe8;
  --paper: #f5f3ec;
  --border: #e4e0d6;
  --border-strong: #d6d1c4;
  --line: rgba(10,20,40,.035);          /* faint drafting grid */
  --line-strong: rgba(10,20,40,.06);   /* major grid line */
  /* Brand — refined petrol navy + brass accent */
  --primary: #16407e;
  --primary-dark: #0e2c5c;
  --accent: #c2902e;                    /* brass / gold */
  --accent-bright: #d7a53c;
  --accent-soft: #f6ecd6;
  --brass: #c2902e;
  --radius: 11px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(10,20,40,.06), 0 1px 1px rgba(10,20,40,.04);
  --shadow-md: 0 12px 32px -12px rgba(10,20,40,.20), 0 2px 6px rgba(10,20,40,.06);
  --shadow-lg: 0 28px 64px -20px rgba(10,20,40,.34);
  --maxw: 1180px;
  --font: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::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.65;
  color: var(--text);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    linear-gradient(var(--line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-strong) 1px, transparent 1px);
  background-size: 28px 28px, 28px 28px, 140px 140px, 140px 140px;
  background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { font-family: var(--font); line-height: 1.14; margin: 0 0 16px; letter-spacing: -0.022em; color: var(--ink); }
h1 { font-size: 38px; font-weight: 800; }
h2 { font-size: 26px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0 0 16px; }

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

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: 48px 0; } /* 48px buffer keeps ads away from inputs/buttons (Module 5) */
.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; }

/* ==========================================================================
   Category hub pages  (added with the 8 category hubs)
   ========================================================================== */
.breadcrumb { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--primary); }
.breadcrumb span { margin: 0 6px; }
.hub-block > h2 { margin-top: 40px; }
.hub-block > h2:first-child { margin-top: 4px; }
.calc-list { list-style: none; padding: 0; margin: 0; max-width: 760px; }
.calc-list li { position: relative; padding-left: 30px; margin-bottom: 12px; }
.calc-list li::before { content: "\2713"; position: absolute; left: 0; color: var(--primary); font-weight: 800; }
.muted { color: var(--text-muted); margin-bottom: 16px; }
.tool-card.coming { opacity: .65; pointer-events: none; background: var(--bg-subtle); border-style: dashed; }
.tool-card.coming .tag { color: var(--accent); }
.grid-3-cards { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 600px) { .grid-3-cards { grid-template-columns: 1fr; } }

/* ==========================================================================
   Calculator tool pages  (added with Phase 8 — the reusable calc template)
   ========================================================================== */
.calc-layout { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; margin: 8px 0 4px; }
@media (max-width: 860px) { .calc-layout { grid-template-columns: 1fr; } }
.calc-form { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.calc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.field-error { color: #cf222e; font-size: 14px; margin-top: 6px; }
.field-error[hidden] { display: none; }
.calc-side { position: sticky; top: 84px; display: grid; gap: 16px; }
@media (max-width: 860px) { .calc-side { position: static; } }
.calc-result { background: var(--primary); color: #fff; border-radius: var(--radius); padding: 22px 24px; }
.calc-result h2 { color: #fff; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 14px; opacity: .85; }
.result-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.18); }
.result-row:last-child { border-bottom: none; }
.result-label { font-size: 14px; opacity: .9; }
.result-value { font-size: 22px; font-weight: 800; line-height: 1.2; text-align: right; }
.result-row.primary .result-value { font-size: 30px; }
.result-summary { margin-top: 14px; font-size: 14px; opacity: .96; line-height: 1.5; }
.formula-block { background: #0d1117; color: #e6edf3; border-radius: var(--radius); padding: 16px 18px; overflow-x: auto; max-width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.55; white-space: pre; margin: 8px 0 16px; }
.ref-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 15px; }
.ref-table th, .ref-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ref-table th { background: var(--bg-subtle); font-weight: 700; }
.tips-list { padding-left: 22px; }
.tips-list li { margin-bottom: 10px; }
.disclaimer-line { font-size: 14px; color: var(--text-muted); margin-top: 8px; }
.anchor-jump { font-size: 14px; margin-bottom: 8px; }

/* ==========================================================================
   LUXURY THEME — "Blueprint Atelier"  (obsidian ink · brass · architect paper)
   Layered over the base above; overrides key components for a high-contrast,
   contemporary-luxury feel with a subtle construction drafting-grid backdrop.
   ========================================================================== */

/* Header — glassy paper with blur */
.site-header {
  background: rgba(245,243,236,.82);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header.is-scrolled { box-shadow: var(--shadow-md); border-bottom-color: var(--border-strong); }
.logo { color: var(--ink); }
.logo-mark {
  background: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 2px 8px rgba(10,20,40,.28);
}
.logo b { color: var(--accent); }
.main-nav a { color: var(--text-muted); font-weight: 600; }
.main-nav a:hover { color: var(--ink); background: rgba(194,144,46,.10); }
@media (max-width: 859px) {
  .main-nav { background: var(--paper); }
  .nav-toggle { border-color: var(--border-strong); }
  .nav-toggle svg { stroke: var(--ink); }
}

/* Eyebrow — technical mono spec tag */
.eyebrow {
  font-family: var(--font-mono);
  background: rgba(194,144,46,.12);
  color: #8a6a1f;
  border: 1px solid rgba(194,144,46,.30);
  letter-spacing: .14em; font-weight: 600; font-size: 12px;
  border-radius: 6px; padding: 6px 12px; text-transform: uppercase;
}

/* Hero / page-hero — the construction wallpaper moment (stronger drafting grid) */
.hero, .page-hero {
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 90% at 50% -20%, rgba(255,255,255,.75), transparent 62%),
    linear-gradient(rgba(245,243,236,.84), rgba(245,243,236,.92)),
    linear-gradient(var(--line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-strong) 1px, transparent 1px),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: auto, auto, 112px 112px, 112px 112px, 28px 28px, 28px 28px;
  border-bottom: 1px solid var(--border-strong);
}
.hero h1, .page-hero h1 { color: var(--ink); }
.hero .lede, .page-hero .lede { color: var(--text-muted); }

/* Subtle page-load reveal (respects reduced-motion via global rule) */
@keyframes cwUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hero h1, .page-hero h1 { animation: cwUp .5s ease both; }
.calc-result { animation: cwUp .55s .05s ease both; }

/* Cards — warm hairlines, layered shadow, confident hover lift */
.cat-card, .tool-card, .contact-card, .calc-form, .related-cals, .faq details, .toc {
  border-color: var(--border);
}
.cat-card, .tool-card, .contact-card, .calc-form { box-shadow: var(--shadow-sm); }
.cat-card:hover, .tool-card:hover {
  border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-3px);
}
.cat-icon { background: rgba(194,144,46,.12); }
.cat-icon svg { stroke: var(--accent); }
.trust-icon { background: rgba(22,64,126,.08); }
.trust-icon svg { stroke: var(--primary); }
.related-cals { background: var(--bg-subtle); }
.related-cals a:hover { border-color: var(--accent); color: var(--ink); }
.calc-list li::before { color: var(--accent); }
.step::before { background: var(--ink); box-shadow: 0 4px 12px -4px rgba(10,20,40,.5); }

/* Buttons — obsidian primary, refined ghost */
.btn { font-weight: 700; border-radius: 10px; transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease; }
.btn-primary {
  background: linear-gradient(180deg, var(--ink-2), var(--ink)); color: #fff;
  box-shadow: 0 6px 18px -6px rgba(10,20,40,.5), inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px -8px rgba(10,20,40,.55), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-ghost { background: #fff; border-color: var(--border-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--bg-subtle); border-color: var(--accent); }

/* Inputs / search / tooltip — brass focus instead of bright blue */
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194,144,46,.22); outline: none;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194,144,46,.20); }
.tooltip-trigger:hover { border-color: var(--accent); color: var(--accent); }
.tooltip { background: var(--ink); }

/* RESULT CARD — the showpiece: obsidian + brass rule + gold headline number */
.calc-result {
  background:
    linear-gradient(158deg, #102443 0%, #0a1428 72%),
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: auto, 26px 26px, 26px 26px;
  color: #eaf0f8; border-radius: var(--radius-lg);
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow-lg);
  padding: 24px 26px; position: relative; overflow: hidden;
}
.calc-result::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(80% 55% at 100% 0%, rgba(215,165,60,.18), transparent 60%);
}
.calc-result h2 {
  font-family: var(--font-mono); color: var(--accent-bright);
  letter-spacing: .16em; opacity: 1; font-weight: 600; font-size: 12px;
}
.calc-result .result-row { border-bottom-color: rgba(255,255,255,.12); }
.calc-result .result-label { color: #aab8cc; opacity: 1; }
.calc-result .result-value { color: #fff; }
.calc-result .result-row.primary .result-value { color: var(--accent-bright); font-size: 34px; letter-spacing: -.01em; }
.calc-result .result-summary { color: #b9c5d7; opacity: 1; }

/* Tables */
.ref-table th { background: var(--bg-subtle); color: var(--ink); border-bottom: 2px solid var(--border-strong); }
.ref-table td { border-bottom-color: var(--border); }
.ref-table tbody tr:hover td { background: rgba(194,144,46,.05); }

/* Formula block, callouts, FAQ marker */
.formula-block { background: #0a1428; color: #dbe6f5; border: 1px solid #18253f; border-radius: var(--radius); }
.callout { border-left-color: var(--accent); background: var(--bg-subtle); }
.callout-warn { border-left-color: var(--accent); background: var(--accent-soft); }
.faq summary::after { color: var(--accent); }
.email-display .addr { color: var(--ink); }

/* Footer — obsidian with brass top rule */
.site-footer { background: var(--ink); color: #aeb9c9; border-top: 3px solid var(--accent); }
.footer-cols h4 { color: #fff; font-family: var(--font-mono); letter-spacing: .12em; font-size: 12px; }
.footer-cols a { color: #aeb9c9; }
.footer-cols a:hover { color: var(--accent-bright); }
.footer-bottom { border-top-color: rgba(255,255,255,.1); color: #7d8a9c; }

/* Focus ring — distinctive brass */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Contemporary nav bar — wraps to multiple rows so every category stays visible */
@media (min-width: 860px) {
  .site-header .header-inner { max-width: 1400px; padding-left: 28px; padding-right: 28px; }
  .header-inner { min-height: 70px; height: auto; padding-top: 8px; padding-bottom: 8px; align-items: center; }
  .logo { font-size: 21px; flex: 0 0 auto; }
  .logo-mark { width: 30px; height: 30px; border-radius: 8px; }
  .main-nav { flex: 1 1 auto; min-width: 0; overflow: visible; }
  .main-nav ul {
    flex-wrap: wrap; gap: 4px 2px; justify-content: flex-start;
  }
  .main-nav a {
    white-space: nowrap; font-size: 13px; font-weight: 600;
    color: var(--text-muted); padding: 8px 9px; border-radius: 9px;
    letter-spacing: -.005em; transition: color .15s ease, background .15s ease;
  }
  .main-nav a:hover { color: var(--ink); background: rgba(194,144,46,.12); }
  .lang-select { flex: 0 0 auto; }
}

/* Calculator input diagram — labeled blueprint visual at top of the form */
.calc-diagram { margin: 0 0 22px; padding: 16px 16px 12px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.calc-diagram svg { display: block; width: 100%; max-width: 460px; height: auto; max-height: 220px; margin: 0 auto; }
.calc-diagram figcaption { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin-top: 10px; }

/* Diagram input-highlighting — dimension glows when its field is focused/hovered */
.calc-diagram .cw-dim line, .calc-diagram .cw-dim text { transition: stroke .14s ease, fill .14s ease, stroke-width .14s ease; }
.calc-diagram .cw-dim.hl line { stroke: var(--accent-bright); stroke-width: 2.6; }
.calc-diagram .cw-dim.hl text { fill: var(--accent-bright); font-weight: 700; }

/* Metric/Imperial unit toggle (unit-aware calculators) */
.unit-toggle { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 18px; padding: 4px; background: var(--paper); border: 1px solid var(--border-strong); border-radius: 999px; }
.unit-toggle-label { font-family: var(--font-mono); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); padding: 0 8px 0 10px; }
.unit-toggle button { -webkit-appearance: none; appearance: none; border: 0; background: transparent; color: var(--text); font-family: var(--font); font-size: .84rem; font-weight: 600; padding: 7px 16px; border-radius: 999px; cursor: pointer; transition: background .15s ease, color .15s ease; }
.unit-toggle button:hover { color: var(--ink); }
.unit-toggle button.active { background: var(--brass); color: #fff; box-shadow: 0 1px 4px rgba(10,20,40,.18); }

/* Language switcher (multilingual phase 1) */
.lang-select { margin-left: 12px; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: .82rem; font-weight: 600; cursor: pointer; }
.lang-select:hover { border-color: var(--brass); }
.lang-select:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
@media (max-width: 760px) { .lang-select { margin: 8px 0 0; } }

/* ==========================================================================
   Project Dashboard (client-side localStorage) — added v25
   ========================================================================== */
.cw-dashboard { padding: 36px 0 64px; }
.cw-dashboard .container { max-width: 1000px; }

/* Empty state */
.cw-dash-empty { text-align: center; max-width: 520px; margin: 24px auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 48px 28px; box-shadow: var(--shadow-sm); }
.cw-dash-empty-mark { font-size: 38px; line-height: 1; margin-bottom: 14px; }
.cw-dash-empty h2 { font-size: 21px; margin: 0 0 8px; }
.cw-dash-empty p { color: var(--text-muted); margin: 0 0 22px; }

/* Summary bar */
.cw-dash-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 26px; padding: 14px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.cw-dash-stats { display: flex; flex-wrap: wrap; gap: 22px; font-size: 14px; color: var(--text-muted); }
.cw-dash-stats b { color: var(--ink); font-size: 19px; margin-right: 4px; }
.cw-dash-bar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cw-dash-bar-actions .btn { min-height: 40px; padding: 9px 16px; font-size: 14px; }
.cw-dash-danger { color: #b42318; border-color: #f0c8c2; }
.cw-dash-danger:hover { background: #fbecea; border-color: #e0a59c; }

/* Sections */
.cw-dash-section { margin-bottom: 34px; }
.cw-dash-section h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); margin: 0 0 6px; }
.cw-dash-note { color: var(--text-muted); font-size: 13.5px; margin: 0 0 14px; }
.cw-dash-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.cw-dash-scroll .ref-table { margin: 0; }
.cw-dash-scroll .ref-table th, .cw-dash-scroll .ref-table td { padding: 12px 14px; vertical-align: top; }
.cw-dash-agg .num, .cw-dash-table .num { text-align: right; white-space: nowrap; }
.cw-dash-agg td .num, th.num { text-align: right; }
.ref-table th.num { text-align: right; }

/* Saved estimates table */
.cw-dash-expand { background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 700; color: var(--primary); cursor: pointer; text-align: left; line-height: 1.3; }
.cw-dash-expand:hover { color: var(--primary-dark); text-decoration: underline; }
.cw-dash-tag { display: inline-block; margin-top: 4px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.cw-dash-date { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.cw-dash-actcol { width: 1%; white-space: nowrap; }
.cw-dash-actions { white-space: nowrap; }
.cw-dash-link { display: inline-block; background: none; border: 0; padding: 0; margin: 0 0 0 14px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--primary); cursor: pointer; text-decoration: none; }
.cw-dash-actions a.cw-dash-link:first-child, .cw-dash-actions .cw-dash-link:first-child { margin-left: 0; }
.cw-dash-link:hover { text-decoration: underline; }
.cw-dash-del { color: #b42318; }

/* Expandable detail row */
.cw-dash-detail > td { background: var(--bg-subtle); }
.cw-dash-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.cw-dash-detail-grid h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 8px; }
.cw-dash-detail-grid ul { list-style: none; margin: 0; padding: 0; }
.cw-dash-detail-grid li { display: flex; justify-content: space-between; gap: 14px; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.cw-dash-detail-grid li span { color: var(--text-muted); }
.cw-dash-detail-grid li b { color: var(--ink); text-align: right; }
.cw-dash-summary { margin: 16px 0 0; color: var(--text-muted); font-size: 13.5px; }

@media (max-width: 640px) {
  .cw-dash-detail-grid { grid-template-columns: 1fr; gap: 16px; }
  .cw-dash-bar { padding: 12px 14px; }
  .cw-dash-stats { gap: 16px; }
}

/* ==========================================================================
   Quick-Fill industry presets — added v26
   ========================================================================== */
.cw-qf { margin: 8px 0 2px; }
.cw-qf-select {
  width: 100%; max-width: 340px;
  padding: 8px 32px 8px 11px;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  color: var(--primary-dark); background-color: var(--accent-soft);
  border: 1px solid var(--accent); border-radius: 8px; cursor: pointer;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c2902e' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.cw-qf-select:hover { border-color: var(--accent-bright); background-color: #f2e4c6; }
.cw-qf-select:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ==========================================================================
   Visual warning thresholds + reverse-calc advisory — added v27
   ========================================================================== */
.calc-result.cw-status-ok   { outline: 2px solid rgba(46,160,67,.60); outline-offset: -2px; }
.calc-result.cw-status-warn { outline: 2px solid rgba(215,165,60,.85); outline-offset: -2px; }
.calc-result.cw-status-fail { outline: 2px solid rgba(240,120,110,.90); outline-offset: -2px; }
.cw-advisory { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.18); display: grid; gap: 9px; }
.cw-adv-main, .cw-adv-fix { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; }
.cw-adv-icon { flex: none; font-weight: 700; line-height: 1.5; }
.cw-advisory[data-level="ok"]   .cw-adv-icon { color: #7ddc97; }
.cw-advisory[data-level="warn"] .cw-adv-icon { color: #f0cd7a; }
.cw-advisory[data-level="fail"] .cw-adv-icon { color: #f3a39b; }
.cw-advisory[data-level="ok"]   .cw-adv-msg { color: #b6e6c3; }
.cw-advisory[data-level="warn"] .cw-adv-msg { color: #f0d79a; }
.cw-advisory[data-level="fail"] .cw-adv-msg { color: #f4b8b1; }
.cw-adv-msg b { color: #fff; }
.cw-adv-fix { color: #d6efdb; background: rgba(46,160,67,.16); border: 1px solid rgba(46,160,67,.32); border-radius: 8px; padding: 9px 11px; }
.cw-adv-fix b { color: #fff; }
.cw-adv-fix .cw-adv-icon { color: #8fe0a6; }

/* ==========================================================================
   Module 1: data-driven SVG extras — added v28
   ========================================================================== */
/* Waste-% margin overlay on flat (planrect) diagrams */
.cw-waste-margin { fill: rgba(194,144,46,.10); stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 5 4; }
.cw-waste-label { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 10.5px; font-weight: 600; fill: var(--accent); }

/* Abstract energy infographic */
.cw-energy-diagram { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 14px 8px; margin: 18px 0; }
.cw-energy-mount svg { width: 100%; height: auto; display: block; }
.cw-energy-diagram figcaption { margin-top: 6px; }
.cw-esec { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; fill: var(--text-muted); }
.cw-echip { fill: var(--bg-subtle); stroke: var(--border-strong, var(--border)); stroke-width: 1; }
.cw-echip-t { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 8.5px; font-weight: 700; letter-spacing: .04em; fill: var(--text-muted); }
.cw-echip-v { font-family: var(--font); font-size: 14px; font-weight: 800; fill: var(--ink); }
.cw-eop { font-family: var(--font); font-size: 15px; font-weight: 700; fill: var(--text-muted); }
.cw-eresult { fill: var(--primary); }
.cw-eresult-t { font-family: var(--font); font-size: 14px; font-weight: 800; fill: #fff; }
.cw-ebar-l { font-family: var(--font); font-size: 11px; font-weight: 600; fill: var(--ink); }
.cw-ebar-track { fill: var(--bg-subtle); }
.cw-ebar-v { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 10.5px; font-weight: 700; fill: var(--ink); }
.cw-egauge-min, .cw-egauge-max { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 9.5px; fill: var(--text-muted); }
.cw-egauge-cur { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 10.5px; font-weight: 700; fill: var(--ink); }
@media (max-width: 520px) { .cw-echip-v { font-size: 12.5px; } .cw-eresult-t { font-size: 12px; } }

/* ==========================================================================
   Module 3.2: professional print stylesheet (also the PDF fallback path) — v29
   ========================================================================== */
@media print {
  .site-header, .site-footer, .cookie-banner, .ad-slot, .main-nav, .nav-toggle,
  .lang-select, .calc-actions, .cw-qf, .breadcrumbs, .related-calcs, .skip-link,
  .search-wrap, .tooltip-trigger, .byline { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  main, .container { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
  .page-hero { padding: 0 0 8pt !important; }
  .page-hero h1 { font-size: 20pt !important; }
  .calc-form, .calc-result, .cw-energy-diagram, .calc-diagram {
    box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; page-break-inside: avoid;
  }
  .calc-result { background: #fff !important; color: #111 !important; outline: none !important; border: 2px solid #16407e !important; }
  .calc-result .result-label, .calc-result .result-value, .calc-result * { color: #111 !important; }
  .cw-advisory { border-top: 1px solid #ccc !important; }
  .cw-advisory .cw-adv-msg, .cw-advisory .cw-adv-msg b, .cw-adv-icon { color: #111 !important; }
  .cw-adv-fix { background: #f3f3f3 !important; border: 1px solid #bbb !important; color: #111 !important; }
  a[href]::after { content: ""; } /* don't append raw URLs */
  body::after {
    content: "Estimate via CalcWright — verify with a licensed professional.";
    display: block; margin-top: 14pt; padding-top: 8pt; border-top: 1px solid #ccc;
    font-size: 9pt; color: #555;
  }
}

/* ==========================================================================
   Module 5: AdSense slots — CLS-safe reserved space + clear labeling — v30
   ========================================================================== */
.ad-slot.cw-ad-live { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); }
.ad-slot .ad-label { font-family: var(--font-mono, "IBM Plex Mono", monospace); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.ad-slot .adsbygoogle { display: inline-block; } /* fixed width/height set inline -> zero layout shift */

/* Readability: lift body copy off the drafting grid (paper halo). text-shadow inherits to inline children. */
:where(.calc-main, .section .container, .page-hero .container, .faq-body, .section-head) :where(h1,h2,h3,h4,p,li,td,th,dt,dd,caption,figcaption,blockquote,summary),
.breadcrumb {
  text-shadow: 0 0 2px var(--paper), 0 0 2px var(--paper), 0 0 3px var(--paper);
}
.calc-result, .calc-result *, .formula-block, .formula-block *, .site-footer, .site-footer *, .cw-ad-live, .cw-ad-live *, .main-nav, .main-nav * {
  text-shadow: none;
}
