/* SumTakeoff: jobsite signage. Graphite and hi-vis yellow for answers, blueprint blue for links.
   System fonts only: no web-font download, which keeps pages fast for Core Web Vitals and ad RPM. */

:root {
  --bg: #ffffff;
  --surface: #f3f5f6;
  --ink: #1b2126;
  --ink-muted: #56606a;
  --line: #d8dde1;
  --link: #1d5aa6;
  --hivis: #ffd21f;
  --sign: #1f262c;          /* results panel */
  --sign-ink: #f4f6f7;
  --sign-muted: #b7c0c8;
  --focus: #1d5aa6;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark follows the device unless the header toggle stored a choice (data-theme on <html>).
   The two dark blocks must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111518;
    --surface: #1a2025;
    --ink: #e7eaed;
    --ink-muted: #a3adb6;
    --line: #2d353c;
    --link: #8fb8f0;
    --sign: #232b32;
    --focus: #8fb8f0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111518;
  --surface: #1a2025;
  --ink: #e7eaed;
  --ink-muted: #a3adb6;
  --line: #2d353c;
  --link: #8fb8f0;
  --sign: #232b32;
  --focus: #8fb8f0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--font);
}
img { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 .4rem; }
h2 { font-size: 1.45rem; font-weight: 750; margin: 2.5rem 0 .75rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 .4rem; }
p { margin: 0 0 1rem; }

.wrap {
  max-width: 72rem;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; background: var(--hivis); color: #1b2126; padding: .5rem .75rem; z-index: 10; }

/* Header and footer */
.site-header { border-bottom: 0; background: var(--bg); }

/* Tape-measure blade under the header row. Same colors in light and dark mode.
   Ticks: inch 64px, half 32px, quarter 16px, eighth 8px.
   Height: 11px inch tick + .5rem gap + 10px numbers + 1px bottom offset + 2px borders. */
.tape {
  position: relative; height: calc(11px + .5rem + 10px + 1px + 2px); overflow: hidden;
  background-color: #FFD21F;
  border-top: 1px solid #E6BC12; border-bottom: 1px solid #C9A30A;
  background-image:
    linear-gradient(to right, #1B2126 0 2px,   transparent 2px),
    linear-gradient(to right, #1B2126 0 1.5px, transparent 1.5px),
    linear-gradient(to right, #1B2126 0 1px,   transparent 1px),
    linear-gradient(to right, #1B2126 0 1px,   transparent 1px);
  background-size: 64px 11px, 32px 8px, 16px 5px, 8px 3px;
  background-repeat: repeat-x;
}
.tape-nums { position: absolute; left: 32px; bottom: 1px; display: flex; }
.tape-nums span {
  width: 64px; flex: none; text-align: center;
  font: 800 10px/10px system-ui, sans-serif; color: #1B2126;
}
.tape-nums .stud { color: #C8102E; }
/* Slogan printed on the blade. The row is a .wrap, like .header-row, so the text starts at the wordmark. */
.tape-print-row {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}
.tape-print {
  margin-left: -12px;   /* offsets the padding so the "W" lines up with the wordmark */
  padding: 0 12px;      /* yellow padding covers the ticks and numbers under the text */
  height: 100%;         /* fills the blade, whatever its height */
  display: flex;
  align-items: center;
  background: #FFD21F;
  color: #1B2126;
  font: 850 10.5px/1 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tape-print sup {
  font-size: 7px;
  letter-spacing: 0;
  margin-left: 1px;
}
/* Phones: drop the eighth-inch ticks so the blade isn't busy */
@media (max-width: 600px) {
  .tape { background-size: 64px 11px, 32px 8px, 16px 5px, 0 0; }
}
.header-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding-block: .8rem; }
.wordmark { font-weight: 850; font-size: 1.35rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.wordmark span {
  display: inline-block; background: var(--hivis); color: #1b2126;
  padding: 0 .28em; margin: 0 .06em; border-radius: 3px; transform: rotate(-4deg);
}
.hub-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; font-size: .95rem; }
.hub-nav a { color: var(--ink); text-decoration: none; }
.hub-nav a:hover { text-decoration: underline; }
/* Phones: wordmark and theme toggle share the top row; the nav is one row below that scrolls sideways
   when the hubs don't fit, so the header stays two rows however many hubs go live. */
@media (max-width: 600px) {
  .header-row { row-gap: .35rem; }
  .hub-nav {
    order: 3; flex-basis: 100%; flex-wrap: nowrap; gap: 1rem; white-space: nowrap;
    overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px;
    /* Fade the right edge so a clipped link reads as "scroll for more" */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
  }
  .hub-nav::-webkit-scrollbar { display: none; }
}
.theme-toggle {
  margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink);
}
.theme-toggle:hover { border-color: var(--ink-muted); }
.theme-toggle svg { width: 1.2rem; height: 1.2rem; }
/* Show the icon for the mode a click switches to */
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

main { padding-block: 1.25rem 3rem; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--ink-muted); font-size: .9rem; }
.footer-row { padding-block: 1.5rem; }
.footer-row p { margin: 0 0 .4rem; }
.fine { font-size: .82rem; }

.breadcrumbs { font-size: .9rem; color: var(--ink-muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--ink-muted); }
.promise { font-size: 1.12rem; color: var(--ink-muted); max-width: 46rem; }
.page-head, .home-head { margin-bottom: 1.5rem; }

/* Calculator: inputs and answer side by side on wide screens, stacked on phones */
.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 760px) { .calculator { grid-template-columns: minmax(0, 1fr); } }

.calc-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; min-width: 0; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1rem; }
.presets-label { font-size: .9rem; color: var(--ink-muted); margin-right: .2rem; }
.presets button, .link-button {
  font: inherit; font-size: .9rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 999px; padding: .3rem .8rem;
}
.presets button:hover { border-color: var(--ink-muted); }

.shape-toggle { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.shape-toggle legend { font-weight: 650; font-size: .95rem; padding: 0; margin-bottom: .35rem; }
.shape-toggle label { display: inline-flex; gap: .35rem; align-items: center; margin-right: 1.25rem; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
@media (max-width: 420px) { .field-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 650; font-size: .95rem; min-width: 0; }
.field small { font-weight: 400; color: var(--ink-muted); }
.field--wide { grid-column: 1 / -1; }
.input-unit {
  display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); overflow: hidden;
}
.input-unit:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.input-unit input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 500; padding: .6rem .7rem; font-variant-numeric: tabular-nums; }
.input-unit input:focus { outline: none; }
.input-unit abbr, .input-unit--prefix > span {
  display: flex; align-items: center; padding: 0 .7rem; background: var(--surface);
  color: var(--ink-muted); font-weight: 500; text-decoration: none; border-left: 1px solid var(--line);
}
.input-unit--prefix > span { border-left: 0; border-right: 1px solid var(--line); }
select {
  font: inherit; font-weight: 500; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .6rem; min-width: 0; width: 100%;
}

/* Board list (board foot calculator): one row per board, columns sized to fit 390px phones */
.board-hint { font-size: .9rem; color: var(--ink-muted); margin: -.25rem 0 .6rem; }
.board-list { display: grid; gap: .5rem; }
.board-head, .board-row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, .8fr) 2.25rem; gap: .4rem; align-items: center;
}
.board-head { font-weight: 650; font-size: .85rem; }
.board-head small { font-size: .78rem; }
.board-row input {
  min-width: 0; width: 100%; font: inherit; font-weight: 500; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .5rem; font-variant-numeric: tabular-nums;
}
.board-row input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.row-remove {
  width: 2.25rem; height: 2.25rem; padding: 0; cursor: pointer; font: inherit; font-size: 1.2rem; line-height: 1;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink-muted);
}
.row-remove:hover { color: var(--ink); border-color: var(--ink-muted); }
.row-bf { grid-column: 1 / -1; font-size: .82rem; color: var(--ink-muted); margin-top: -.2rem; font-variant-numeric: tabular-nums; }
.row-bf:empty { display: none; }
.add-row {
  margin: .6rem 0 1rem; font: inherit; font-size: .9rem; font-weight: 650; cursor: pointer;
  border: 1px dashed var(--ink-muted); background: transparent; color: var(--ink); border-radius: var(--radius); padding: .45rem .9rem;
}
.add-row:hover { border-style: solid; }
.board-extras { margin-top: .4rem; }

/* Unit picker inside an input (cubic yard depth) */
.input-unit .unit-select {
  width: auto; flex: none; border: 0; border-left: 1px solid var(--line); border-radius: 0;
  background: var(--surface); color: var(--ink-muted); padding: 0 .5rem;
}

/* Volume converter (cubic yard page) */
.converter-form { max-width: 34rem; }
.conversion-list { margin: 1rem 0 0; display: grid; gap: .35rem; }
.conversion-list div { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: .35rem; }
.conversion-list dt { color: var(--ink-muted); }
.conversion-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }

/* The answer: a jobsite sign */
.results {
  background: var(--sign); color: var(--sign-ink); border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem; position: sticky; top: 1rem; min-width: 0;
  border-top: 6px solid var(--hivis);
}
@media (max-width: 760px) { .results { position: static; } }
.results-label { margin: 0; color: var(--sign-muted); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.result-primary { margin: .1rem 0 .9rem; font-variant-numeric: tabular-nums; line-height: 1.05; }
.result-primary [data-out] { color: var(--hivis); font-size: clamp(2.6rem, 6vw, 3.4rem); font-weight: 850; letter-spacing: -0.02em; }
.result-primary .unit [data-out] { font: inherit; color: inherit; letter-spacing: normal; }
.result-primary .unit { display: block; font-size: 1.05rem; font-weight: 650; color: var(--sign-ink); margin-top: .2rem; }
.result-list { margin: 0 0 .9rem; display: grid; gap: .35rem; }
.result-list div { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid rgb(255 255 255 / .12); padding-top: .35rem; }
.result-list dt { color: var(--sign-muted); }
.result-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.results-note { font-size: .85rem; color: var(--sign-muted); margin-bottom: .75rem; }
.results .link-button { background: transparent; color: var(--sign-ink); border-color: rgb(255 255 255 / .3); }

/* Dimension checks (stair): full width under the calculator */
.checks-panel { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; }
.checks-title { font-size: 1.05rem; margin: 0 0 .5rem; }
.checks { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .35rem; }
.check { display: flex; gap: .55rem; align-items: baseline; }
.check::before { flex: none; width: 1.2rem; height: 1.2rem; border-radius: 999px; display: inline-grid; place-items: center; font-size: .75rem; font-weight: 800; }
.check--ok::before { content: "✓"; background: #1f7a3d; color: #fff; }
.check--warn::before { content: "!"; background: #b42318; color: #fff; }
.check--info::before { content: "i"; background: var(--surface); color: var(--ink-muted); border: 1px solid var(--line); }
.check--warn { font-weight: 650; }
.checks-note { font-size: .85rem; color: var(--ink-muted); margin: 0; }
/* Within/over-target line inside the results sign (voltage drop) */
.results-checks { margin: 0 0 .85rem; }
.results .check--info::before { background: transparent; color: var(--sign-muted); }
/* Safety note (electrical): a hi-vis edge so it isn't skimmed past */
.safety-panel { border-left: 5px solid var(--hivis); }
.safety-panel p { margin: 0; }

/* Diagrams drawn from the inputs (roof pitch, stair): full width under the calculator */
.diagram { grid-column: 1 / -1; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.diagram svg { display: block; width: 100%; max-width: 40rem; height: auto; margin: 0 auto; }
.diagram figcaption { font-size: .85rem; color: var(--ink-muted); text-align: center; margin-top: .25rem; }
.diagram-plate { stroke: var(--ink-muted); stroke-width: 2; }
.diagram-rise { stroke: var(--ink-muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.diagram-rafter { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.diagram-label { font: 12px var(--font); fill: var(--ink); }
.diagram-label--strong { font-weight: 800; font-size: 15px; }

/* Explanation, reference, FAQ */
.explain, .reference, .faq, .related, .prose { max-width: 46rem; }
.formula { padding-left: 1.3rem; }
.formula li { margin-bottom: .35rem; }
.worked-example { background: var(--surface); border-left: 4px solid var(--hivis); padding: .9rem 1.1rem; border-radius: 0 var(--radius) var(--radius) 0; }
.worked-example h3 { margin-top: 0; }
.worked-example p { margin: 0; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
thead th { font-size: .85rem; color: var(--ink-muted); font-weight: 650; }
tbody th { font-weight: 650; }

/* Lists of calculators */
.card-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: .75rem; }
.card-list li { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.card-list a, .card-list span { font-weight: 700; }
.card-list p { margin: .25rem 0 0; font-size: .9rem; color: var(--ink-muted); }
.card-list .is-planned, .is-planned { opacity: .75; }
small { font-size: .78rem; font-weight: 500; color: var(--ink-muted); }

.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1rem; }
.hub-card { border: 1px solid var(--line); border-top: 4px solid var(--hivis); border-radius: var(--radius); padding: 1rem 1.1rem; }
.hub-card h3 { margin-top: 0; }
.hub-card p { color: var(--ink-muted); font-size: .95rem; }
.hub-card ul { padding-left: 1.1rem; margin: 0; }
.hub-card li { margin-bottom: .2rem; }
.planned { color: var(--ink-muted); }

/* Ad slots reserve their space so nothing shifts when an ad loads */
.ad-slot { margin: 2rem 0; min-height: 280px; background: var(--surface); }
.ad-slot--mobile-anchor { min-height: 60px; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
