/* Free browser tools (/tools/). Linked from base.njk only when a page sets
   `isTool` or `isToolsHub`, so style.css is untouched and no other page on the
   site can be reached by these rules — including the `body` rule below, which
   is why a black page here does not touch the rest of the site.

   BRIEF (Kristian 2026-09-21): black page · centred heading · the calculator
   complete on first load with no scrolling · a slightly smaller, neater box ·
   and an easier-to-read typeface than Space Mono.

   TYPE SYSTEM — words are sans, numbers are mono, nothing mixes:
   Space Mono is a display face and is the hardest thing on this page to read at
   10–13px, so it is not used here at all. Labels and prose take DM Sans; every
   figure takes JetBrains Mono, which is drawn for screen reading and carries
   true tabular figures so a changing number never shifts its column. Both are
   already self-hosted (src/assets/fonts), so this adds no download.

   CONTRAST — small labels do NOT use var(--text3): measured 2.51:1 on the old
   background, under the 4.5:1 AA floor, and it is the same token behind the
   sitewide findings still open on row slrv. Rather than change a shared token
   from inside a new section, this file carries its own tones.
   Proof: scripts/tools-design-check.mjs · fold: scripts/tools-fold-check.mjs */

:root {
  --tool-sans: 'DM Sans', system-ui, sans-serif;
  --tool-mono: 'JetBrains Mono', ui-monospace, monospace;

  --tool-page: #000;
  --tool-panel: #0b0b0b;
  --tool-well: #000;

  --tool-dim: rgba(255,255,255,0.60);
  --tool-dim2: rgba(255,255,255,0.72);
  --tool-line: rgba(255,255,255,0.10);
  --tool-line2: rgba(255,255,255,0.16);
}

/* Scoped by the conditional <link> in base.njk — tool pages only. */
body { background: var(--tool-page); }

/* ---- page frame --------------------------------------------------------- */

/* body already carries padding-top:58px to clear the fixed nav (style.css:38),
   so this is breathing room only — 80 here was double-counting that clearance
   and cost 50px of fold budget for nothing. */
.tool-wrap { padding: 30px 24px 90px; }
.tool { max-width: 1060px; margin: 0 auto; }

/* Centred header block (Kristian 2026-09-21). */
.tool-head { text-align: center; margin-bottom: 14px; }
/* ⚠️ style.css:84 styles a BARE `nav` selector — position:fixed, inset:0 0 auto 0,
   z-index:1200, display:flex, height:58px, black background. It was written for
   the site header but it catches EVERY <nav> on the page, so a breadcrumb marked
   up correctly (a <nav> with aria-label="Breadcrumb") silently becomes a second
   fixed bar pinned over the real one. Every property has to be given back.
   Found 2026-09-21 by looking at the rendered page; the guides' .guide-crumbs
   has the identical bug and is live — see remember row `nvcr`. */
.tool-crumbs {
  position: static; inset: auto; z-index: auto;
  display: block; height: auto; padding: 0;
  background: none; border-bottom: none; transition: none;
  font-family: var(--tool-sans); font-weight: 500;
  font-size: 11px; letter-spacing: 0.4px;
  color: var(--tool-dim); margin-bottom: 12px;
}
.tool-crumbs a { color: var(--tool-dim2); text-decoration: none; }
.tool-crumbs a:hover { color: var(--red); }
.tool-crumbs span { margin: 0 7px; color: var(--tool-dim); }

.tool h1 {
  font-family: var(--tool-sans); font-weight: 700;
  font-size: clamp(30px, 2.8vw, 40px);
  line-height: 1.12; letter-spacing: -0.7px;
  color: #fff; margin: 0 0 9px;
}
.tool-standfirst {
  font-family: var(--tool-sans);
  font-size: 16px; line-height: 1.5; color: var(--tool-dim2);
  margin: 0 auto 10px; max-width: 780px;
}
.tool-meta {
  font-family: var(--tool-sans); font-weight: 500;
  font-size: 11.5px; letter-spacing: 0.2px;
  color: var(--tool-dim); margin: 0;
}

/* ---- the calculator ----------------------------------------------------- */

.calc {
  background: var(--tool-panel);
  border: 1px solid var(--tool-line2);
  border-radius: 6px;
  overflow: hidden;
}
.calc-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 17px;
  background: rgba(255,255,255,0.025);
  border-bottom: 1px solid var(--tool-line);
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase;
  color: var(--tool-dim);
}
.calc-bar strong { color: #fff; font-weight: 700; letter-spacing: 1.3px; }

.calc-split { display: grid; grid-template-columns: 348px 1fr; }
.calc-in { padding: 20px 22px; border-right: 1px solid var(--tool-line); }
.calc-res { padding: 20px 24px; min-width: 0; }

.calc-col-h {
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 10.5px; letter-spacing: 1.7px;
  text-transform: uppercase; color: var(--tool-dim);
  padding-bottom: 9px; margin-bottom: 13px;
  border-bottom: 1px solid var(--tool-line);
}

/* ---- inputs ------------------------------------------------------------- */

.calc-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.calc-field:last-child { margin-bottom: 0; }
.calc-field label {
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 11px; letter-spacing: 0.5px;
  color: var(--tool-dim2);
}
.calc-field input,
.calc-field select {
  font-family: var(--tool-mono); font-weight: 500;
  font-size: 15px; color: #fff;
  background: var(--tool-well); border: 1px solid var(--tool-line2);
  border-radius: 3px; padding: 10px 12px; width: 100%;
  appearance: none; -webkit-appearance: none;
  font-variant-numeric: tabular-nums;
}
/* The instrument list is words, not figures. */
.calc-field select { font-family: var(--tool-sans); font-weight: 500; font-size: 14.5px; }
.calc-field select {
  background-image: linear-gradient(45deg, transparent 50%, #8f8f8f 50%),
                    linear-gradient(135deg, #8f8f8f 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% + 1px), calc(100% - 11px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.calc-field input:hover,
.calc-field select:hover { border-color: rgba(255,255,255,0.26); }
.calc-field input:focus,
.calc-field select:focus { outline: none; border-color: var(--red); }
.calc-field input:focus-visible,
.calc-field select:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.calc-field .calc-hint {
  font-family: var(--tool-sans);
  font-size: 11.5px; color: var(--tool-dim); line-height: 1.4;
}

/* Unit switch sits beside its input rather than above it — that is most of
   what buys the fold. */
.calc-pair { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: stretch; }
.calc-seg { display: flex; border: 1px solid var(--tool-line2); border-radius: 3px; overflow: hidden; }
.calc-seg button {
  min-width: 44px;
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 11.5px; letter-spacing: 0.3px;
  color: var(--tool-dim2); background: var(--tool-well);
  border: none; border-right: 1px solid var(--tool-line2);
  padding: 0 10px; cursor: pointer; min-height: 40px;
  transition: background 0.15s ease, color 0.15s ease;
}
.calc-seg button:last-child { border-right: none; }
.calc-seg button:hover { background: #151515; color: #fff; }
/* #C41920 (13 Nov review): white on the brand red measured 4.48:1 at 11.5px, a hair under 4.5; the darker red is ~6:1.
   The focus ring is white because a red ring on a red pressed button was invisible. */
.calc-seg button[aria-pressed="true"] { background: #C41920; color: #fff; }
.calc-seg button:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

/* ---- results ------------------------------------------------------------ */

.calc-headline { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.calc-headline .calc-num {
  font-family: var(--tool-mono); font-weight: 700;
  font-size: 48px; line-height: 1; color: #fff; letter-spacing: -1.8px;
  font-variant-numeric: tabular-nums;
}
.calc-headline .calc-num-label {
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 12.5px; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--tool-dim2);
}

/* One rhythm, one hairline, every figure on a common right edge. */
.calc-rows { display: grid; grid-template-columns: minmax(0, 1fr); }
.calc-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 8px 0; border-bottom: 1px solid var(--tool-line);
}
.calc-row:first-child { border-top: 1px solid var(--tool-line); }
.calc-row .calc-k { font-family: var(--tool-sans); font-size: 14px; color: var(--tool-dim2); }
.calc-row .calc-v {
  font-family: var(--tool-mono); font-weight: 500;
  font-size: 14px; color: #fff;
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}

.calc-note {
  margin: 12px 0 0; padding: 11px 13px;
  background: #0f0f0f; border: 1px solid var(--tool-line2);
  border-left: 2px solid var(--red); border-radius: 3px;
  font-family: var(--tool-sans);
  font-size: 12.5px; line-height: 1.55; color: var(--tool-dim2);
}
.calc-note strong { color: #fff; font-weight: 600; }
.calc-warn { display: none; }
.calc-warn.is-on { display: block; }

/* ---- the ATM hand-off: a comparison, not two cards ---------------------- */

.calc-nt { margin-top: 14px; }
.calc-nt-head,
.calc-nt-row {
  display: grid; grid-template-columns: 1fr 124px 124px;
  align-items: baseline; gap: 12px;
}
.calc-nt-head {
  padding-bottom: 8px; border-bottom: 1px solid var(--tool-line2);
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 10.5px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--tool-dim);
}
.calc-nt-cols { display: contents; }
.calc-nt-cols span { text-align: right; }
.calc-nt-cols .is-rec { color: #fff; }
.calc-nt-cols em {
  display: block; font-style: normal; color: var(--red);
  font-size: 9.5px; letter-spacing: 0.8px; margin-top: 3px;
}
.calc-nt-row { padding: 9px 0; border-bottom: 1px solid var(--tool-line); }
.calc-nt-k { font-family: var(--tool-sans); font-size: 14px; color: var(--tool-dim2); }
.calc-nt-v {
  font-family: var(--tool-mono); font-weight: 700;
  font-size: 18px; color: var(--tool-dim2);
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}
.calc-nt-v.is-rec { color: #fff; }
.calc-nt-foot {
  font-family: var(--tool-sans);
  margin: 9px 0 0; font-size: 12px; line-height: 1.5; color: var(--tool-dim);
}

/* ---- prose below the tool ---------------------------------------------- */

.tool-body {
  font-family: var(--tool-sans);
/* Was 150px (Kristian 2026-09-21: nothing from the article showing before a scroll on the calculator). Since 13 Nov the
   calculator page has a second calculator under the first, which keeps the article below the fold by itself, and the
   tick-value guides are reference pages — the 13 Nov review measured the 150px as an empty hole. 56px, 48px on phones. */
  font-size: 17px; line-height: 1.72; color: var(--text);
  margin: 56px auto 0; max-width: 780px;
}
.tool-body h2 {
  font-family: var(--tool-sans); font-weight: 700;
  font-size: 25px; line-height: 1.25;
  letter-spacing: -0.3px; color: #fff; margin: 46px 0 16px;
}
.tool-body h3 { font-weight: 700; font-size: 19px; color: #fff; margin: 32px 0 12px; }
.tool-body p { margin: 0 0 18px; }
.tool-body a { color: var(--red); text-decoration: none; border-bottom: 1px solid var(--tool-line2); }
.tool-body a:hover { border-bottom-color: var(--red); }
.tool-body strong { color: #fff; font-weight: 600; }
.tool-body ul, .tool-body ol { margin: 0 0 18px; padding-left: 22px; }
.tool-body li { margin: 0 0 9px; }
.tool-body ul li::marker { color: var(--red); }

.tool-table { width: 100%; border-collapse: collapse; margin: 0 0 22px; font-size: 15px; }
.tool-table th, .tool-table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--tool-line);
}
.tool-table th {
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 11px; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--tool-dim);
}
.tool-table td { color: var(--tool-dim2); }
.tool-table td:first-child { color: #fff; font-family: var(--tool-mono); font-weight: 500; font-size: 13.5px; }
.tool-table td.is-num { font-family: var(--tool-mono); font-weight: 500; font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* Sizing output can read as advice if it is not framed. */
.tool-disclaimer {
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--tool-line);
  font-size: 13px; line-height: 1.6;
  color: rgba(255,255,255,0.52);
}
.tool-disclaimer a { color: rgba(255,255,255,0.74); border-bottom-color: var(--tool-line2); }
.tool-disclaimer a:hover { color: var(--red); }

/* ---- hub cards ---------------------------------------------------------- */

.tools-hub-list { display: grid; gap: 14px; margin: 30px 0 0; }
.tool-card {
  display: block; padding: 22px 24px;
  background: var(--tool-panel); border: 1px solid var(--tool-line);
  border-radius: 5px; text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.tool-card:hover { border-color: var(--tool-line2); background: #101010; }
.tool-card .tool-card-q { font-family: var(--tool-sans); font-weight: 700; font-size: 19px; color: #fff; margin: 0 0 6px; letter-spacing: -0.2px; }
.tool-card .tool-card-d { font-family: var(--tool-sans); font-size: 14px; color: var(--tool-dim2); line-height: 1.55; margin: 0; }
.tool-card .tool-card-tag { font-family: var(--tool-sans); font-weight: 600; font-size: 11px; letter-spacing: 0.5px; color: var(--red); margin-top: 10px; display: inline-block; }

/* ---- CTA ---------------------------------------------------------------- */

.tool-cta {
  margin: 54px auto 0; padding: 26px; max-width: 780px;
  background: var(--tool-panel); border: 1px solid var(--tool-line2);
  border-radius: 6px;
}
.tool-cta .tool-cta-label {
  font-family: var(--tool-sans); font-weight: 600;
  font-size: 10.5px; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--tool-dim); margin-bottom: 10px;
}
.tool-cta h3 { font-family: var(--tool-sans); font-weight: 700; font-size: 22px; color: #fff; margin: 0 0 8px; }
.tool-cta p { font-family: var(--tool-sans); color: var(--tool-dim2); font-size: 15px; line-height: 1.6; margin: 0 0 18px; }
.tool-cta-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tool-cta-btn {
  font-family: var(--tool-sans); font-size: 13px; font-weight: 700; letter-spacing: 0.4px;
  color: #fff; background: var(--red); border: 1px solid var(--red);
  border-radius: 3px; padding: 12px 22px; text-decoration: none;
  transition: background 0.18s ease;
}
.tool-cta-btn:hover { background: var(--green2); }
.tool-cta-price { font-family: var(--tool-sans); font-weight: 500; font-size: 14px; color: var(--tool-dim2); }

/* ---- short screens ------------------------------------------------------ */

/* The panel is deliberately generous (Kristian 2026-09-21: "slightly bigger"),
   which is right on a 1080p screen but 43px too tall for a 1440x900 laptop.
   Rather than shrink it for everyone, compact it only where the viewport is
   genuinely short. Width guard keeps this off phones, which stack anyway and
   always scroll. */
@media (min-width: 901px) and (max-height: 870px) {
  .tool-wrap { padding-top: 18px; }
  .tool-head { margin-bottom: 12px; }
  .calc-in { padding: 15px 22px; }
  .calc-res { padding: 15px 24px; }
  .calc-row { padding: 6px 0; }
  .calc-headline .calc-num { font-size: 42px; }
  .calc-headline { margin-bottom: 10px; }
  .calc-nt { margin-top: 12px; }
}

/* ---- narrow ------------------------------------------------------------- */

/* The two-column split needs real width. Below this it stacks, and the fold
   promise no longer applies — a phone always scrolls. */
@media (max-width: 900px) {
  .calc-split { grid-template-columns: 1fr; }
  .calc-in { border-right: none; border-bottom: 1px solid var(--tool-line); }
}
@media (max-width: 768px) {
  .tool-wrap { padding: 26px 16px 70px; }
  .calc-in, .calc-res { padding: 16px; }
  .calc-headline .calc-num { font-size: 36px; }
  .tool-body { font-size: 16px; }
  /* Everything tappable clears the 44px comfort guideline on a phone. The
     desktop paddings put these at 37–41px, measured by tools-design-check. */
  .calc-seg button { padding: 13px 10px; }
  .calc-field input,
  .calc-field select { padding: 12px 11px; font-size: 15px; }
  .calc-field select { padding-right: 30px; }
  .calc-nt-head, .calc-nt-row { grid-template-columns: 1fr 86px 86px; gap: 8px; }
  .calc-nt-v { font-size: 14.5px; }
  .tool-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tool-table { min-width: 460px; }
}

/* ---- profit or loss of one trade (13 Nov 2026, src/_includes/pnl-calc.njk) ----------------------------------------
   The same parts as the position size calculator above; only the spacing between the two and the price pair are new. */
.calc-pnl { margin-top: 28px; }
.calc [hidden] { display: none !important; }
.calc-pnl-prices { gap: 8px; }
.calc-pnl-prices .calc-seg { align-self: flex-start; }
.calc-pnl-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calc-pnl-two > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.calc-pnl-foot { display: block; margin: 12px 0 0; font-family: var(--tool-sans); font-size: 11.5px; color: var(--tool-dim); line-height: 1.4; }

/* ---- tick-value guides (13 Nov 2026, src/guides/tick-value.njk + futures-tick-values.njk) -------------------------- */
.tv-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0 0 28px;
  border: 1px solid var(--tool-line2); border-radius: 6px; background: var(--tool-panel); overflow: hidden; }
.tv-fact { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-right: 1px solid var(--tool-line); min-width: 0; }
.tv-fact:last-child { border-right: none; }
.tv-k { font-family: var(--tool-sans); font-weight: 600; font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase; color: var(--tool-dim); }
.tv-v { font-family: var(--tool-mono); font-weight: 700; font-size: 26px; line-height: 1.1; color: #fff; letter-spacing: -0.6px; font-variant-numeric: tabular-nums; }
.tv-all .tv-group td { font-family: var(--tool-sans); font-weight: 600; font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase;
  color: var(--tool-dim); background: rgba(255,255,255,0.025); }
.tv-all td:first-child a { color: var(--red); text-decoration: none; }
.tv-all td:first-child a:hover { text-decoration: underline; }
.tv-note { font-family: var(--tool-sans); font-size: 12.5px; color: var(--tool-dim); margin: 10px 0 0; }
@media (max-width: 768px) {
  .tv-facts { grid-template-columns: 1fr 1fr; }
  .tv-fact:nth-child(2) { border-right: none; }
  .tv-fact:nth-child(-n+2) { border-bottom: 1px solid var(--tool-line); }
  .tv-v { font-size: 22px; }
}

/* ---- 13 Nov 2026 design review fixes (phones) ----------------------------------------------------------------------- */
.calc-num.is-empty { color: var(--tool-dim); }
.tv-name-sm { display: none; }
@media (max-width: 768px) {
  .calc-seg button { min-height: 44px; }
  .tool-body { margin-top: 48px; }
}
@media (max-width: 480px) {
  .calc-headline { flex-wrap: wrap; }
  .calc-row { flex-wrap: wrap; row-gap: 2px; }
  .calc-row .calc-v { white-space: normal; margin-left: auto; }
  .calc-bar-r { display: none; }
  /* Contract tables: the name moves under the symbol, so the numbers all fit without sideways scrolling. */
  .tv-all { min-width: 0; }
  .tv-all .tv-name { display: none; }
  .tv-all .tv-name-sm { display: block; font-family: var(--tool-sans); font-size: 12px; font-weight: 400; color: var(--tool-dim); margin-top: 2px; }
  .tv-all th, .tv-all td { padding: 8px 8px; }
  /* Example tables keep 1 and 10 contracts on a phone. */
  .tv-ex { min-width: 0; }
  .tv-ex .c2, .tv-ex .c5 { display: none; }
  .tv-ex th, .tv-ex td { padding: 8px 8px; }
}

/* ---- 13 Nov 2026 audit fixes ------------------------------------------------------------------------------------------
   Contrast: white on the brand red measured 4.48:1 (WCAG wants 4.5) on the product button; the darker red is ~6:1. The small
   red "any size" label measured 4.38:1 at 9.5px; a lighter red clears it. Breadcrumb and author links get an underline so they
   read as links (their grey sat 1.4:1 from the text around them), and a taller tap area on a phone. */
.tool-cta-btn { background: #C41920; border-color: #C41920; }
.tool-cta-btn:hover { background: #A3141A; border-color: #A3141A; }
.calc-nt-cols em { color: #FF6B70; }
.tool-crumbs a, .tool-meta a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tool-meta a { color: var(--tool-dim2); }
.tool-meta a:hover { color: #fff; }
/* A long dollar figure (+$1,000,000.00) steps down a size instead of running past the panel. */
.calc-headline .calc-num.is-long { font-size: 34px; letter-spacing: -1px; }
@media (max-width: 768px) {
  .tool-crumbs a { display: inline-block; padding: 12px 0; }
  .calc-headline .calc-num.is-long { font-size: 26px; }
  /* ATM table: the two value columns take the width their numbers need, so $500,000.00 is never clipped. */
  .calc-nt-head, .calc-nt-row { grid-template-columns: 1fr auto auto; }
  .calc-nt-v { font-size: 13.5px; }
}
