/*
 * The answer pages (/answers/), which are plain HTML with no scripts (client/src/answers/render.tsx).
 * They look like the calculator they link to: the grey page, the work column, the take-home on the
 * orange card, name-left value-right rows on white. The values below are the app's own tokens from
 * client/src/styles/tokens.css, copied because these pages don't load the app; a test checks they
 * still match (client/src/answers/answers-css.test.ts).
 */
:root {
  --font-family: "Modulas", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --size-100: 0.8125rem;
  --size-200: 0.9375rem;
  --size-300: 1rem;
  --size-400: 1.25rem;
  --size-500: 1.5rem;
  --size-600: 2rem;
  --size-700: 2.75rem;
  --size-900: 5.5rem;
  --display-size: clamp(var(--size-700), 1rem + 12vw, var(--size-900));
  --headline-size: clamp(var(--size-500), 1.25rem + 1vw, var(--size-600));
  --weight-regular: 400;
  --weight-medium: 500;
  --background: hsl(0 0% 94%);
  --background-elevated: hsl(0 0% 100%);
  --label: hsl(0 0% 0%);
  --label-secondary: hsl(0 0% 27%);
  --separator: hsl(0 0% 0% / 0.12);
  --orange: hsl(10 90% 60%);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-9: 48px;
  --space-10: 64px;
  --gutter: var(--space-4);
  --column-max: 1344px;
  --work-max: 50rem;
  --frame-narrow: calc(var(--column-max) + 2 * var(--gutter));
  --page-top: calc(var(--space-9) + var(--space-2));
  --bar-height: 56px;
  --target-min: 44px;
  --hairline: 1px;
  --stroke-focus: 2px;
  --radius-l: 20px;
  --radius-full: 999px;
  color-scheme: light;
}

/* The page's side padding: 16px on a phone, 46px from 960px, as the app's. */
@media (min-width: 960px) {
  :root {
    --gutter: 46px;
  }
}

@font-face {
  font-family: "Modulas";
  src: url("/fonts/Modulas-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Modulas";
  src: url("/fonts/Modulas-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--label);
  font-family: var(--font-family);
  font-size: var(--size-300);
  line-height: 1.4;
  letter-spacing: 0.005em;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: var(--weight-medium);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-thickness: var(--hairline);
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: var(--stroke-focus) solid var(--label);
  outline-offset: var(--stroke-focus);
}

/* The top bar and the footer are the app's own (layout/Header.tsx, layout/SlimFooter.tsx), as wide as
   a visitor's page; only the page between them sits in the work column, as the calculator does. */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  width: 100%;
  max-width: var(--frame-narrow);
  min-height: var(--bar-height);
  margin-inline: auto;
  padding-block-start: var(--space-6);
  padding-inline: var(--gutter);
}

.bar a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  text-decoration: none;
}

.bar .brand {
  font-size: var(--size-400);
  font-weight: var(--weight-medium);
  line-height: 1.25;
}

.bar nav a {
  padding-inline: var(--space-2);
  font-size: var(--size-200);
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
}

.bar nav a:hover {
  text-decoration: underline;
  text-decoration-color: currentColor;
}

main {
  display: grid;
  gap: var(--space-9);
  width: min(calc(100% - 2 * var(--gutter)), var(--work-max));
  margin-inline: auto;
  padding-top: var(--page-top);
}

article {
  display: grid;
  gap: var(--space-9);
}

/* A heading with its paragraph sits close; separate groups get the section's room. */
section {
  display: grid;
  gap: var(--space-3);
}

/* The question in the headline style; the figure on the card is the page's largest text. */
h1 {
  font-size: var(--headline-size);
  line-height: 1.1;
  letter-spacing: -0.005em;
}

h2 {
  font-size: var(--size-400);
  line-height: 1.25;
}

h3 {
  font-size: var(--size-300);
  margin-top: var(--space-2);
}

.lede {
  margin-top: calc(var(--space-3) - var(--space-9));
  color: var(--label-secondary);
}

.caption,
.trail,
.disclaimer,
.line {
  font-size: var(--size-100);
  line-height: 1.35;
  letter-spacing: 0.015em;
  color: var(--label-secondary);
}

.trail ol {
  display: flex;
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}

.trail + h1,
.trail + article {
  margin-top: calc(var(--space-3) - var(--space-9));
}

/* The take-home on the orange card, ink on top, as in the calculator. */
.card {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  border-radius: var(--radius-l);
  background: var(--orange);
  color: var(--label);
}

.card dt {
  font-size: var(--size-200);
  font-weight: var(--weight-medium);
}

.card dd {
  font-size: var(--size-400);
  font-weight: var(--weight-medium);
}

.card .figure {
  font-size: var(--display-size);
  line-height: 0.95;
  letter-spacing: -0.02em;
}

/* The main action: the black ink pill. */
.button {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  padding-inline: var(--space-5);
  border-radius: var(--radius-full);
  background: var(--label);
  color: var(--background);
  font-size: var(--size-200);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

/* Name left, value right, on a white surface with dividers between. */
.rows {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--radius-l);
  overflow: hidden;
  background: var(--background-elevated);
}

.rows th,
.rows td {
  padding: var(--space-4);
  border-bottom: var(--hairline) solid var(--separator);
  text-align: left;
  font-weight: var(--weight-regular);
}

/* Amounts right-aligned, with the face's own proportional digits: its tabular ones are set too wide. */
.rows td {
  text-align: right;
}

.rows tr:last-child > * {
  border-bottom: 0;
}

.rows .total > *,
.rows thead th {
  font-weight: var(--weight-medium);
}

.rows thead th {
  font-size: var(--size-200);
  color: var(--label-secondary);
}

.rows thead th:not(:first-child) {
  text-align: right;
}

/* A table wider than a phone scrolls inside its own box, so the page never scrolls sideways. */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-l);
}

/* A note on the table sits with it. Inside a section, the section's own gap already does. */
:is(.rows, .table-scroll) + .caption {
  margin-top: calc(var(--space-3) - var(--space-9));
}

section > :is(.rows, .table-scroll) + .caption {
  margin-top: 0;
}

/* Under the answer, where its figures come from, close to it. */
.lede + .caption {
  margin-top: calc(var(--space-2) - var(--space-9));
}

ul {
  padding-left: var(--space-5);
}

.links,
.sources {
  display: grid;
  gap: var(--space-2);
}

.faq {
  display: grid;
  gap: var(--space-4);
}

.faq dt {
  font-weight: var(--weight-medium);
}

.faq dd {
  margin-top: var(--space-1);
}

footer {
  width: min(calc(100% - 2 * var(--gutter)), var(--column-max));
  margin: var(--space-10) auto 0;
  padding-block: var(--space-3) var(--space-5);
  border-top: var(--hairline) solid var(--separator);
}

.line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--space-5);
}

.line ul {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-5);
  padding: 0;
  list-style: none;
}

/* The footer's links are quiet, as the app's: no line until the pointer is over them. */
.line ul a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  text-decoration: none;
}

.line ul a:hover {
  text-decoration: underline;
}
