/* LumberMath design system
   Paper #FBFBF9 · Graphite #262A2E · Chalk-line blue #1E5AA8 · Tape yellow #F2B705 · Maple #E2C48E · Walnut #6B4430
   UI + display: Archivo (semi-expanded for headings) · Long-form: Literata */
:root {
  --bg: #FBFBF9;
  --surface: #FFFFFF;
  --surface-2: #F0F1EE;
  --text: #262A2E;
  --muted: #5D646B;
  --border: #D5D8D6;
  --grid: #E6E9EC;
  --grid-major: #D3D9DF;
  --accent: #1E5AA8;
  --accent-ink: #FFFFFF;
  --tape: #F2B705;
  --tape-ink: #262A2E;
  --dim: #1E5AA8;
  --maple: #E2C48E;
  --maple-end: #CFA866;
  --maple-line: #B88A4A;
  --walnut: #6B4430;
  --resin: #3E8FB0;
  --bad: #B3261E;
  --radius: 4px;
  --ui: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --read: "Literata", "Iowan Old Style", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191B;
    --surface: #1E2124;
    --surface-2: #272B2F;
    --text: #ECEDEA;
    --muted: #A4ABB1;
    --border: #363B40;
    --grid: #22262A;
    --grid-major: #2C3237;
    --accent: #7FB0F0;
    --accent-ink: #10161D;
    --dim: #8DB8F2;
    --maple: #C9A773;
    --maple-end: #B08A52;
    --maple-line: #8C6634;
    --walnut: #8A5C44;
    --resin: #4FA6C8;
    --bad: #F2867D;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.55 var(--ui); }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 6px 32px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 21px; font-stretch: 112%; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.logo svg { width: 26px; height: 26px; flex: none; }
.nav { display: flex; gap: 0 22px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 8px 0; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--tape); font-weight: 600; }

.site-footer { border-top: 1px solid var(--border); margin-top: 72px; padding: 32px 0; font-size: 15px; color: var(--muted); }
.site-footer .wrap { display: flex; gap: 24px 64px; flex-wrap: wrap; align-items: flex-start; }
.footer-tools { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.footer-tools b { color: var(--text); margin-bottom: 4px; }
.footer-tools a { color: var(--muted); text-decoration: none; }
.footer-tools a:hover { color: var(--text); text-decoration: underline; }
.site-footer .footer-copy { display: block; margin-top: 28px; font-size: 14px; }

/* ---------- page intro ---------- */
.crumbs { font-size: 14px; color: var(--muted); margin: 22px 0 0; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.06; font-weight: 800; font-stretch: 112%; letter-spacing: -.02em; margin: 14px 0 12px; max-width: 20ch; text-wrap: balance; }
.lede { color: var(--muted); font-size: 18px; margin: 0 0 28px; max-width: 64ch; }

/* ---------- tool: form on the left, shop drawing on the right ---------- */
.tool { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tool-form { padding: 22px 22px 24px; border-right: 1px solid var(--border); }
.sheet { position: relative; padding: 22px; min-height: 380px; display: flex; flex-direction: column;
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; background-position: -1px -1px; }
@media (max-width: 820px) {
  .tool { grid-template-columns: 1fr; }
  .tool-form { border-right: 0; border-bottom: 1px solid var(--border); padding: 18px 16px 20px; }
  .sheet { min-height: 0; padding: 18px 16px; }
}

/* answer: the big figure */
.answer { margin: 0 0 6px; }
.answer-value { display: block; font-size: clamp(48px, 8vw, 76px); line-height: .95; font-weight: 800; font-stretch: 115%; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.answer-unit { display: block; font-size: 17px; font-weight: 600; margin-top: 6px; }
.answer-sub { margin: 10px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 20px; border-top: 2px solid var(--text); padding-top: 10px; font-variant-numeric: tabular-nums; }
.answer-sub li { font-size: 14px; color: var(--muted); }
.answer-sub b { display: block; font-size: 20px; color: var(--text); font-weight: 700; }
.drawing { margin-top: auto; padding-top: 18px; }
.drawing svg { display: block; width: 100%; height: auto; overflow: visible; }
.drawing text { font-family: var(--ui); font-size: 13px; fill: var(--text); font-variant-numeric: tabular-nums; }
.drawing .dim { stroke: var(--dim); stroke-width: 1.2; fill: none; }
.drawing .dim-text { fill: var(--dim); font-weight: 600; }
.drawing .ext { stroke: var(--dim); stroke-width: .8; stroke-dasharray: 3 3; }
.drawing .tick { fill: var(--dim); }
.drawing .face { fill: var(--maple); stroke: var(--maple-line); stroke-width: 1; }
.drawing .face-top { fill: var(--maple); filter: brightness(1.06); stroke: var(--maple-line); }
.drawing .face-end { fill: var(--maple-end); stroke: var(--maple-line); }
.drawing .grain { stroke: var(--maple-line); stroke-width: .8; fill: none; opacity: .55; }
.drawing .resin { fill: var(--resin); opacity: .85; }
.drawing .bark { fill: var(--walnut); }
.drawing .ink { stroke: var(--text); stroke-width: 1.5; fill: none; }
.drawing .ink-fill { fill: var(--text); }
.drawing .mark { fill: var(--tape); stroke: var(--tape-ink); stroke-width: 1; }
.drawing-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* form controls */
.field { margin: 0 0 16px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 5px 0 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
input[type="number"], input[type="text"], select {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-bottom: 2px solid var(--text); border-radius: var(--radius) var(--radius) 0 0;
  padding: 9px 10px; min-height: 46px; font-variant-numeric: tabular-nums; }
input:focus, select:focus { outline: none; border-bottom-color: var(--accent); box-shadow: 0 2px 0 var(--accent); }
input[aria-invalid="true"] { border-bottom-color: var(--bad); }
.unit-input { position: relative; }
.unit-input input { padding-right: 42px; }
.unit-input span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--muted); pointer-events: none; }
.seg { display: inline-flex; border: 1px solid var(--text); border-radius: var(--radius); overflow: hidden; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 8px 14px; font-size: 15px; min-height: 40px; line-height: 24px; }
.seg label + label span { border-left: 1px solid var(--text); }
.seg input:checked + span { background: var(--text); color: var(--bg); font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }
.error { color: var(--bad); font-size: 14px; margin: 6px 0 0; }

.btn { font: inherit; font-weight: 600; font-size: 15px; border-radius: var(--radius); padding: 9px 16px; min-height: 42px; cursor: pointer; border: 1px solid var(--text); background: transparent; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-small { min-height: 34px; padding: 4px 10px; font-size: 14px; }

/* lumber list table (board foot calculator) */
.lumber-list { width: 100%; border-collapse: collapse; margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.lumber-list th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px 6px; }
.lumber-list td { padding: 3px 4px; vertical-align: middle; }
.lumber-list input, .lumber-list select { min-height: 40px; padding: 6px 7px; font-size: 16px; }
.lumber-list td.bf { text-align: right; font-weight: 600; white-space: nowrap; min-width: 52px; }
.lumber-list .remove { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 6px; min-height: 36px; }
.lumber-list .remove:hover { color: var(--bad); }
.lumber-list tr.active td { background: var(--surface-2); }
@media (max-width: 520px) {
  .lumber-list thead { display: none; }
  .lumber-list tr { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .lumber-list td { padding: 0; }
  .lumber-list td[data-l]::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); }
  .lumber-list td.bf { grid-column: 1 / 5; text-align: left; font-size: 15px; }
  .lumber-list td.bf::after { content: " board feet"; font-weight: 400; color: var(--muted); }
  .lumber-list tr.active td { background: none; }
}

/* ---------- ads ---------- */
.ad { margin: 32px 0; min-height: 0; }
.ad[data-placeholder] { display: none; }

/* ---------- article ---------- */
.content { max-width: 70ch; margin-top: 48px; font-family: var(--read); font-size: 18px; line-height: 1.7; }
.content h2 { font-family: var(--ui); font-size: 28px; line-height: 1.15; font-weight: 800; font-stretch: 108%; letter-spacing: -.015em; margin: 52px 0 12px; text-wrap: balance; }
.content h3 { font-family: var(--ui); font-size: 20px; line-height: 1.25; font-weight: 700; margin: 30px 0 8px; }
.content p, .content ul, .content ol { margin: 0 0 16px; }
.content li { margin-bottom: 6px; }
.content .steps { padding-left: 22px; }
.content .steps li::marker { font-family: var(--ui); font-weight: 800; }
.formula { font-family: var(--ui); font-size: 19px; font-weight: 600; background: var(--surface-2); border-left: 4px solid var(--tape); padding: 12px 16px; margin: 0 0 18px; overflow-x: auto; }
.content table { width: 100%; border-collapse: collapse; font-family: var(--ui); font-size: 15px; margin: 0 0 20px; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; margin: 0 0 20px; }
.table-scroll table { margin: 0; min-width: 460px; }
.content th, .content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.content thead th { border-bottom: 2px solid var(--text); font-weight: 700; }
.content caption { text-align: left; font-size: 14px; color: var(--muted); padding-bottom: 6px; }
.diagram { margin: 24px 0 28px; }
.diagram img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.diagram figcaption { font-family: var(--ui); font-size: 14px; color: var(--muted); margin-top: 8px; }
.callout { font-family: var(--ui); font-size: 16px; border-top: 2px solid var(--text); border-bottom: 1px solid var(--border); padding: 12px 0; margin: 0 0 20px; }

.faq details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq summary { font-family: var(--ui); font-weight: 700; font-size: 17px; cursor: pointer; list-style-position: outside; }
.faq details p { margin: 10px 0 2px; }

/* related tools: a plain list, not cards */
.related { max-width: 70ch; margin-top: 56px; border-top: 2px solid var(--text); }
.related h2 { font-size: 20px; font-weight: 800; margin: 14px 0 4px; }
.related a { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.related a b { color: var(--accent); }
.related a span { display: block; color: var(--muted); font-size: 15px; }
.related a:hover b { text-decoration: underline; }

/* plain pages */
.prose { max-width: 70ch; font-family: var(--read); font-size: 18px; line-height: 1.7; }
.prose h2 { font-family: var(--ui); font-size: 24px; margin: 36px 0 10px; }
@media (max-width: 520px) { .drawing text { font-size: 16px; } }

/* homepage calculator index: plain rows on a rule, grouped by trade */
.tool-index { max-width: 70ch; margin: 36px 0 0; border-top: 2px solid var(--text); }
.tool-index h2 { font-size: 15px; font-weight: 700; color: var(--muted); margin: 12px 0 2px; }
.tool-index a { display: grid; grid-template-columns: minmax(0, 15em) minmax(0, 1fr); gap: 4px 24px; padding: 14px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.tool-index a b { font-size: 19px; font-weight: 700; font-stretch: 108%; color: var(--accent); }
.tool-index a span { color: var(--muted); font-size: 16px; }
.tool-index a:hover b { text-decoration: underline; }
@media (max-width: 600px) { .tool-index a { grid-template-columns: 1fr; } }
