/* MarkupMath — site styles. Mobile-first; the audience is on a phone in a truck.
 *
 * THEMING RULE (workspace standing rule): a foreground and background that meet
 * must BOTH be themed tokens, or both be constants. Never pair a hardcoded
 * #fff/#000 with a luminance-inverting token — the dark theme flips one side
 * and they collide. Every pair below is declared for both themes and contrast-
 * checked against WCAG AA.
 */

:root {
  --bg: #ffffff;
  --ink: #16181d;
  --surface: #f5f7f9;
  --surface-ink: #16181d;
  --line: #dde2e8;
  --muted: #5c6470;              /* 5.98:1 on --bg */
  --accent: #0b6b3a;
  --accent-ink: #ffffff;         /* 6.58:1 on --accent */
  --accent-soft: #e6f4ec;
  --accent-soft-ink: #0a4d2b;
  --result-bg: #0b6b3a;
  --result-ink: #ffffff;         /* 6.58:1 on --result-bg */
  --radius: 10px;
  --maxw: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --ink: #e8ecf2;
    --surface: #171b21;
    --surface-ink: #e8ecf2;
    --line: #262d36;
    --muted: #9aa4b0;            /* 7.4:1 on --bg */
    --accent: #34c07a;
    --accent-ink: #05210f;       /* 9.1:1 on --accent */
    --accent-soft: #12291d;
    --accent-soft-ink: #8fe3b6;
    --result-bg: #14311f;
    --result-ink: #6fe0a6;       /* 8.6:1 on --result-bg */
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }

/* --- header / footer ---------------------------------------------------- */

.site-head { border-bottom: 1px solid var(--line); background: var(--surface); color: var(--surface-ink); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; padding-block: .85rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-left: auto; font-size: .95rem; }
.nav a { color: var(--muted); text-decoration: none; padding: .35rem 0; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.site-foot { border-top: 1px solid var(--line); margin-top: 3rem; padding-block: 1.5rem 2.5rem; color: var(--muted); font-size: .9rem; }
.site-foot a { color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-bottom: .75rem; }

/* --- type --------------------------------------------------------------- */

h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.15; letter-spacing: -.02em; margin: 1.5rem 0 .5rem; }
h2 { font-size: 1.3rem; line-height: 1.25; margin: 2.25rem 0 .5rem; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .35rem; }
p, li { max-width: 38rem; }
a { color: var(--accent); }
.lede { font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); }
small { color: var(--muted); }

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

.calc {
  background: var(--surface); color: var(--surface-ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: 1.5rem 0;
}
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: .25rem; }
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.field input {
  width: 100%; min-height: 48px; /* thumb-sized target */
  padding: .6rem .7rem; font-size: 1.05rem; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
.field input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.row { display: grid; gap: .9rem; }
@media (min-width: 32rem) { .row.two { grid-template-columns: 1fr 1fr; } }

.result {
  background: var(--result-bg); color: var(--result-ink);
  border-radius: var(--radius); padding: 1rem; margin-top: 1rem;
}
.result .big { font-size: clamp(2rem, 9vw, 2.75rem); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.result .label { font-size: .9rem; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.result dl { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: .9rem 0 0; font-size: .95rem; }
.result dt { opacity: .85; }
.result dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.callout {
  background: var(--accent-soft); color: var(--accent-soft-ink);
  border-left: 4px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  padding: .85rem 1rem; margin: 1.5rem 0;
}
.callout p { margin: 0; max-width: none; }

[data-error]:not(:empty) {
  background: var(--accent-soft); color: var(--accent-soft-ink);
  border-radius: 8px; padding: .6rem .75rem; margin-top: .75rem; font-size: .95rem;
}

/* --- tool grid ---------------------------------------------------------- */

.tools { display: grid; gap: .85rem; padding: 0; margin: 1.5rem 0; list-style: none; }
@media (min-width: 34rem) { .tools { grid-template-columns: 1fr 1fr; } }
.tools a {
  display: block; height: 100%;
  background: var(--surface); color: var(--surface-ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; text-decoration: none;
}
.tools a:hover { border-color: var(--accent); }
.tools strong { display: block; color: var(--ink); margin-bottom: .15rem; }
.tools span { color: var(--muted); font-size: .92rem; }

/* --- misc --------------------------------------------------------------- */

.faq dt { font-weight: 600; margin-top: 1.1rem; }
.faq dd { margin: .25rem 0 0; color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.scroll-x { overflow-x: auto; }
