/* Layout: spec-sheet calculators. Inputs on the left, a results readout pinned on the right,
   reference notes and code citations below. Stacks to one column on phones. */
:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --ink: #17202a;
  --muted: #5b6672;
  --line: #d6dad3;
  --accent: #d4520e;          /* marking-paint orange */
  --accent-ink: #ffffff;
  --link: #1d4d9e;
  --ok: #1e7a46;
  --ok-bg: #e3f2e8;
  --warn: #8a5a00;
  --warn-bg: #fbf0d6;
  --bad: #b3261e;
  --bad-bg: #fbe4e1;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161b; --surface: #182029; --surface-2: #1f2832; --ink: #e6eaee; --muted: #9aa5b0;
    --line: #2b3640; --accent: #ff7a33; --accent-ink: #1a0d04; --link: #84aef7;
    --ok: #6fd39a; --ok-bg: #16301f; --warn: #f2c25c; --warn-bg: #33280f; --bad: #ff8a80; --bad-bg: #3a1b18;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161b; --surface: #182029; --surface-2: #1f2832; --ink: #e6eaee; --muted: #9aa5b0;
  --line: #2b3640; --accent: #ff7a33; --accent-ink: #1a0d04; --link: #84aef7;
  --ok: #6fd39a; --ok-bg: #16301f; --warn: #f2c25c; --warn-bg: #33280f; --bad: #ff8a80; --bad-bg: #3a1b18;
  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-family: var(--body); font-size: 16px; line-height: 1.55;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 1140px; margin: 0 auto; padding-inline: 16px; }

/* Header */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); text-decoration: none; }
.brand-mark { font-family: var(--display); font-weight: 700; font-size: 1.6rem; letter-spacing: .01em; text-transform: uppercase; }
.brand-mark span { color: var(--accent); }
.brand-sub { font-size: .8rem; color: var(--muted); }
/* Main menu: one dropdown per trade */
.nav { display: flex; align-items: center; gap: 2px; font-size: .95rem; }
.nav-item { position: relative; }
.nav-trigger, .nav-link {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; color: var(--ink);
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 10px; cursor: pointer; text-decoration: none;
}
.nav-trigger::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.nav-item.open .nav-trigger::after { transform: translateY(1px) rotate(225deg); }
.nav-item.is-current > .nav-trigger, .nav-link[aria-current="page"] { border-bottom-color: var(--accent); }
.nav-trigger:hover, .nav-link:hover { color: var(--accent); }
.menu {
  display: none; position: absolute; top: 100%; left: 0; z-index: 30; min-width: 240px; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
}
.menu a { display: block; padding: 8px 10px; border-radius: 4px; color: var(--ink); text-decoration: none; }
.menu a:hover { background: var(--surface-2); }
.menu a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.menu .menu-hub { font-weight: 600; color: var(--accent); border-bottom: 1px solid var(--line); border-radius: 4px 4px 0 0; margin-bottom: 4px; }
.nav-item.open .menu { display: flex; }
.nav-item:nth-last-child(-n+2) .menu { left: auto; right: 0; }
@media (hover: hover) and (min-width: 861px) { .nav-item:hover .menu { display: flex; } }
.nav-toggle { display: none; font: inherit; font-weight: 600; font-size: .9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 12px; cursor: pointer; }

@media (max-width: 600px) { .brand-sub { display: none; } }
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; border-top: 1px solid var(--line); padding-top: 6px; }
  .site-head.nav-open .nav { display: flex; }
  .nav-trigger, .nav-link { width: 100%; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .nav-item.is-current > .nav-trigger { border-bottom-color: var(--line); color: var(--accent); }
  .menu { position: static; box-shadow: none; border: 0; padding: 4px 0 8px 12px; min-width: 0; }
}

/* Breadcrumbs */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .84rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--link); }
.crumbs .sep { opacity: .6; }
.crumbs [aria-current="page"] { color: var(--ink); }

/* Home: calculators grouped by trade */
.trade-group { margin-top: 28px; }
.trade-group-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.trade-group-head h2 { margin: 0; }
.trade-group-head a { font-size: .9rem; }

/* Page head */
.page-head { padding-block: 28px 18px; }
.eyebrow { font-family: var(--mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 2.9rem); font-weight: 700; letter-spacing: -.005em; }
h2 { font-size: 1.6rem; font-weight: 700; margin-top: 36px; margin-bottom: 10px; }
h3 { font-size: 1.2rem; font-weight: 600; margin-top: 22px; margin-bottom: 6px; }
.lede { max-width: 68ch; color: var(--muted); margin: 10px 0 0; font-size: 1.05rem; }
.cite-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip { font-family: var(--mono); font-size: .74rem; border: 1px solid var(--line); background: var(--surface); padding: 3px 8px; border-radius: 99px; color: var(--muted); }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel-title { font-family: var(--mono); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.results { position: sticky; top: 16px; border-top: 4px solid var(--accent); }
@media (max-width: 860px) { .results { position: static; } }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .fields { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .label { font-size: .86rem; font-weight: 600; }
.field .hint { font-size: .78rem; color: var(--muted); }
.input-unit { display: flex; align-items: stretch; }
input[type="number"], input[type="text"], select {
  width: 100%; min-width: 0; font: inherit; font-family: var(--mono); font-size: .98rem;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 10px;
}
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.unit { display: flex; align-items: center; padding: 0 10px; font-family: var(--mono); font-size: .82rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; white-space: nowrap; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: .9rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; cursor: pointer; background: var(--bg); }
.seg input { accent-color: var(--accent); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--surface); }

.btn { font: inherit; font-weight: 600; font-size: .9rem; border-radius: var(--radius); padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn:hover { border-color: var(--ink); }
.btn-ghost { background: transparent; }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.row .x { width: 36px; height: 38px; padding: 0; font-size: 1.1rem; line-height: 1; }

/* Readout */
.readout { display: grid; gap: 14px; }
.big { font-family: var(--display); font-weight: 700; font-size: clamp(2.4rem, 7vw, 3.4rem); line-height: 1; }
.big small { font-size: .45em; font-weight: 600; color: var(--muted); margin-left: 6px; }
.big-label { font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; padding: 6px 10px; border-radius: var(--radius); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--ok); background: var(--ok-bg); }
.status.warn { color: var(--warn); background: var(--warn-bg); }
.status.bad { color: var(--bad); background: var(--bad-bg); }
.meter { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--ok); width: 0; transition: width .25s; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.meter > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
.note { font-size: .82rem; color: var(--muted); margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--mono); font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); font-weight: 500; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.hit td { background: var(--ok-bg); font-weight: 600; }

/* Prose */
.prose { max-width: 72ch; }
.prose p, .prose li { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.2em; }
.formula { font-family: var(--mono); font-size: .92rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: var(--radius); overflow-x: auto; white-space: pre; }
.callout { border: 1px solid var(--warn); background: var(--warn-bg); color: var(--ink); border-radius: var(--radius); padding: 12px 14px; font-size: .92rem; max-width: 72ch; }
.callout strong { color: var(--warn); }
details { border-bottom: 1px solid var(--line); padding: 12px 0; max-width: 72ch; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); }

/* Cards on home */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card .trade { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.card h3 { margin: 0; font-size: 1.3rem; }
.card p { margin: 0; font-size: .9rem; color: var(--muted); }
.card .soon { color: var(--muted); }
.related { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* Ad slots: placeholders until AdSense is approved. Collapse when empty. */
.ad-slot:empty { display: none; }

/* Footer */
.site-foot { margin-top: 56px; border-top: 1px solid var(--line); background: var(--surface); font-size: .86rem; color: var(--muted); }
.site-foot .wrap { padding-block: 22px; display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.site-foot a { color: var(--muted); }
.disclaimer { max-width: 72ch; }

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