/*
 * One stylesheet, one accent, no gradients, no shadows, no card grid.
 *
 * The restraint is deliberate and is the design standard's section 29: the visual quality comes
 * from the spacing and type scale below, reused everywhere, rather than from decoration. Borders
 * appear on form controls, on the one caveat block and on table rules, and nowhere else.
 */

:root {
  --ink: #15181c;
  --ink-soft: #4c535b;
  --line: #e2e6ea;
  --line-strong: #c7ced6;
  --bg: #ffffff;
  --bg-soft: #f7f8f9;
  --accent: #14508c;
  --accent-ink: #0d3b69;
  --caveat-rule: #b4852a;
  --caveat-bg: #fdfaf3;

  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;

  --radius: 6px;
  --measure: 36rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Noto Sans", sans-serif;
  font-feature-settings: "kern" 1;
}

.shell {
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 var(--s5);
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--s4);
  top: var(--s2);
  z-index: 10;
  background: var(--bg);
  padding: var(--s2) var(--s3);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  border-bottom: 1px solid var(--line);
}
.masthead .shell {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3) var(--s5);
  align-items: baseline;
  justify-content: space-between;
  padding-top: var(--s4);
  padding-bottom: var(--s4);
}
.brand {
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.masthead nav {
  display: flex;
  gap: var(--s4);
  flex-wrap: wrap;
}
.masthead nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9375rem;
}
.masthead nav a:hover { color: var(--accent); }
.masthead nav a[aria-current="page"] { color: var(--ink); font-weight: 500; }

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

main { padding-top: var(--s6); padding-bottom: var(--s8); }

h1 {
  font-size: 1.875rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 var(--s3);
  max-width: var(--measure);
}
h2 {
  font-size: 1.1875rem;
  line-height: 1.3;
  font-weight: 600;
  margin: var(--s7) 0 var(--s3);
  max-width: var(--measure);
}
h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: var(--s5) 0 var(--s2);
}
p, li { max-width: var(--measure); }
p { margin: 0 0 var(--s4); }

.intro {
  font-size: 1.125rem;
  color: var(--ink-soft);
  margin-bottom: var(--s3);
}
.headline-caveat {
  font-size: 0.9375rem;
  color: var(--ink-soft);
  margin-bottom: var(--s5);
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

ul, ol { padding-left: 1.25rem; margin: 0 0 var(--s4); }
li { margin-bottom: var(--s2); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s7) 0; }

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

.calc { margin: 0 0 var(--s5); }

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s5);
  max-width: 44rem;
}
.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field > label { font-size: 0.9375rem; font-weight: 500; }
.field .hint { font-size: 0.8125rem; color: var(--ink-soft); }
/*
 * Number first, unit second, and the number gets the room.
 *
 * A flex row let the unit <select> size itself to its longest option and squeeze the number field
 * into a sliver, which is what the first design review caught: the figure that determines the
 * answer became the hardest thing on the page to read. A two-column grid with an explicit cap on
 * the select fixes the proportion at every width, and `minmax(0, 1fr)` is what stops the row
 * overflowing a 390px viewport.
 */
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); }
.pair input { min-width: 0; }
.pair select { width: auto; max-width: 6.5rem; padding-right: var(--s4); }

input[type="text"], input[type="number"], select {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.65rem;
  min-height: 2.75rem;
  width: 100%;
}
select { padding-right: var(--s5); }
input:focus-visible, select:focus-visible, a:focus-visible, button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[aria-invalid="true"] { border-color: #a1341f; }

.result {
  border-top: 1px solid var(--line);
  padding-top: var(--s5);
  margin-bottom: var(--s5);
}
.answer { margin-bottom: var(--s5); }
.answer-label {
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin: 0 0 var(--s1);
}
.answer-value {
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.answer-value .unit { font-size: 1.125rem; font-weight: 500; color: var(--ink-soft); }
/* The bound reads as part of the figure. Smaller than the number, larger than a footnote. */
.answer-value .qual {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--caveat-rule);
  letter-spacing: 0;
}
.answer-note { font-size: 0.9375rem; color: var(--ink-soft); margin: var(--s2) 0 0; }

.secondary-answers { margin-bottom: var(--s4); }

.rows { margin: 0 0 var(--s4); }
.rows .row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  justify-content: space-between;
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--line);
  max-width: var(--measure);
}
.rows dt { color: var(--ink-soft); font-size: 0.9375rem; }
.rows dd { margin: 0; font-variant-numeric: tabular-nums; }

/*
 * Answer-specific notices from the engine. One rule down the side of the group, not one box per
 * sentence: three stacked bordered blocks read as three separate alarms, which is more alarming
 * and less legible than the one qualification they actually are.
 */
.notices {
  margin: 0 0 var(--s5);
  padding: 0 0 0 var(--s3);
  border-left: 2px solid var(--caveat-rule);
  max-width: var(--measure);
}
.notices li {
  list-style: none;
  margin-bottom: var(--s2);
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.notices li:last-child { margin-bottom: 0; }

.problem {
  border-left: 2px solid #a1341f;
  padding-left: var(--s3);
  font-size: 0.9375rem;
  margin: 0 0 var(--s4);
}

details { margin: 0 0 var(--s4); max-width: var(--measure); }
.advanced { margin: calc(-1 * var(--s3)) 0 var(--s5); }
.advanced .fields { margin-bottom: 0; }
summary { cursor: pointer; font-size: 0.9375rem; color: var(--accent); }
details > *:not(summary) { margin-top: var(--s3); }
.working {
  font-size: 0.9375rem;
  color: var(--ink-soft);
}
.working ol { padding-left: 1.25rem; }
.working code { font-size: 0.875rem; }

.noscript {
  border-left: 2px solid var(--caveat-rule);
  padding-left: var(--s3);
  font-size: 0.9375rem;
}

/* ---------------------------------------------------------------- caveat block */

.caveat {
  background: var(--caveat-bg);
  border-left: 3px solid var(--caveat-rule);
  padding: var(--s4) var(--s5);
  margin: var(--s6) 0;
}
.caveat h2 {
  margin: 0 0 var(--s3);
  font-size: 1rem;
}
.caveat p {
  font-size: 0.9375rem;
  margin-bottom: var(--s3);
}
.caveat p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 0 0 var(--s5); }
table {
  border-collapse: collapse;
  font-size: 0.9375rem;
  width: 100%;
  min-width: 22rem;
}
caption {
  text-align: left;
  color: var(--ink-soft);
  font-size: 0.875rem;
  padding-bottom: var(--s2);
}
th, td {
  text-align: left;
  padding: var(--s2) var(--s3) var(--s2) 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
thead th { font-weight: 600; border-bottom: 1px solid var(--line-strong); }
tbody th { font-weight: 500; }

/* ---------------------------------------------------------------- lists of links */

.page-list { padding-left: 0; }
.page-list li {
  list-style: none;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  max-width: var(--measure);
}
.page-list a { font-weight: 500; text-decoration: none; }
.page-list a:hover { text-decoration: underline; }
.page-list p { font-size: 0.9375rem; color: var(--ink-soft); margin: var(--s1) 0 0; }

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: var(--s2) var(--s4);
  padding-left: 0;
  max-width: none;
}
.index-grid li { list-style: none; max-width: none; font-size: 0.9375rem; }

/* ---------------------------------------------------------------- legal pages */

.legal h2 { margin-top: var(--s6); }
.legal p { font-size: 1rem; }

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

.footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: var(--s6) 0 var(--s7);
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.footer p { max-width: 44rem; margin-bottom: var(--s3); }
.stamp { margin-bottom: var(--s6); }
.stamp-links a, .caveat-links a { color: var(--accent); }
.stamp-links { display: flex; flex-wrap: wrap; gap: var(--s1) 0; }

.footer-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--s5);
}
.footer-nav h2 {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 var(--s2);
  font-weight: 600;
}
.footer-nav ul { padding-left: 0; margin: 0; }
.footer-nav li { list-style: none; margin-bottom: var(--s1); max-width: none; }
.footer-nav a { color: var(--ink-soft); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }

/* ---------------------------------------------------------------- chart */

.curve { width: 100%; height: auto; max-width: 34rem; margin: 0 0 var(--s4); }
.curve .axis { stroke: var(--line-strong); stroke-width: 1; }
.curve .plot { stroke: var(--accent); stroke-width: 2; fill: none; }
.curve text { font-size: 11px; fill: var(--ink-soft); }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 30rem) {
  body { font-size: 16px; }
  .shell { padding: 0 var(--s4); }
  h1 { font-size: 1.5rem; }
  .answer-value { font-size: 1.75rem; }
  .fields { grid-template-columns: 1fr; gap: var(--s3); }
  .caveat { padding: var(--s4); }
  main { padding-top: var(--s5); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ebee;
    --ink-soft: #a3abb4;
    --line: #2a2f35;
    --line-strong: #434a52;
    --bg: #14171a;
    --bg-soft: #1a1e22;
    --accent: #7fb3e8;
    --accent-ink: #a9cdf4;
    --caveat-rule: #c79a3d;
    --caveat-bg: #1f1c15;
  }
  input[aria-invalid="true"] { border-color: #e08a76; }
  .problem { border-left-color: #e08a76; }
}
