/* Direction: the delivery ticket.
   When ready-mix arrives the driver hands over a batch docket — a slip on manila stock, quantities
   in a typewriter column, the total ruled off in accounting style, and a signature line at the
   bottom. This page is that docket, filled in before the truck is ordered rather than after.
   Everything follows from it: the ground is dry-mix grey rather than white, quantities are set in
   monospace because a docket's are, headings are small stamps, and the one accent is the red-brown
   of a carbon impression, used on the ruling and nowhere else.
   No web fonts: the ticket's character is in the ruling and the figures, not in a typeface. */

:root {
  --ground: #dedbd3;
  --panel: #f8f7f3;
  --ink: #17181a;
  --ink-soft: #5c605e;
  --rule: #b9b6ac;
  --hair: #cecabf;
  --mark: #9c3218;
  --mark-soft: #f2e6e0;
  --slot: #e6e3da;
  --radius: 2px;
  --gap: 1rem;
  --measure: 44rem;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #17181a;
    --panel: #1f2124;
    --ink: #ecebe6;
    --ink-soft: #a4a8a5;
    --rule: #3a3d40;
    --hair: #2d3033;
    --mark: #e2795c;
    --mark-soft: #2a1d18;
    --slot: #1b1d20;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main, .bar, .foot {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.skip {
  position: absolute;
  left: -9999px;
  background: var(--panel);
  color: var(--ink);
  padding: 0.75rem 1rem;
}
.skip:focus { left: 0; top: 0; z-index: 10; }

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

:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

/* -- the ticket head -------------------------------------------------- */

/* A docket is headed by a rule, not by a logo. */
.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: baseline;
  padding-top: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px double var(--rule);
}
.brand { font-weight: 800; text-decoration: none; letter-spacing: -0.015em; }
.bar nav { display: flex; gap: 1.25rem; }
.bar nav a { font-size: 0.9375rem; }

h1 {
  font-size: clamp(1.5rem, 1.15rem + 1.7vw, 2.125rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 1.5rem 0 0.75rem;
  max-width: 24ch;
}

/* Headings are stamps: small, spaced, quiet. Nothing on the page competes with the total. */
h2 {
  font-size: 0.8125rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 2rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--hair);
}

h3 { font-size: 1rem; margin: 1.25rem 0 0.25rem; }

p { margin: 0 0 0.85rem; }
.lede, .lead { color: var(--ink-soft); }
section { margin-bottom: 1.5rem; }

/* -- the form, as ticket lines ---------------------------------------- */

.calc-row { display: grid; gap: 1rem; }
@media (min-width: 46rem) {
  .calc-row { grid-template-columns: 1fr 15rem; align-items: start; }
}

.calc {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 1rem;
}
.calc fieldset { border: 0; margin: 0; padding: 0; }
.calc legend {
  padding: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

/* The dotted leader between a line's name and its figure is the docket's own device. */
.field {
  display: grid;
  grid-template-columns: 1fr 6.5rem 2.5rem;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
}
.field label { font-weight: 500; overflow: hidden; white-space: nowrap; }
.field label::after {
  content: "";
  display: inline-block;
  width: 100%;
  margin-left: 0.4rem;
  border-bottom: 1px dotted var(--rule);
  transform: translateY(-0.25em);
}
.field input {
  min-height: 44px;
  padding: 0.45rem 0.6rem;
  font: 1rem/1 var(--mono);
  text-align: right;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.field .unit { color: var(--ink-soft); font-size: 0.875rem; }

/* -- the total -------------------------------------------------------- */

/* The signature: the answer is the ticket's total. A torn top edge, the figure set in monospace at
   display size, and the accounting double rule that says the column above it is closed. */
.result {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.1rem 1rem 1rem;
  margin-top: 1.5rem;
}
.result::before {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: -7px;
  height: 7px;
  background: repeating-linear-gradient(90deg, var(--rule) 0 5px, transparent 5px 10px);
}
.result h2 { margin-top: 0; border: 0; }
.result .lead {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 3px double var(--mark);
  color: var(--ink);
}
.result .lead [data-out] {
  font: 700 clamp(2.5rem, 1.7rem + 3.6vw, 3.75rem)/1 var(--mono);
  letter-spacing: -0.04em;
  color: var(--mark);
}
.result .lead .unit { font-size: 1rem; color: var(--ink-soft); }

.result dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 1rem;
  margin: 0;
}
.result dt { color: var(--ink-soft); font-size: 0.9375rem; }
.result dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 0.9375rem; }
.result dd .unit { color: var(--ink-soft); font-size: 0.8125rem; font-family: inherit; }

/* -- the key diagram -------------------------------------------------- */

.fig {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.6rem;
  margin: 0;
}
.fig svg {
  display: block;
  width: 100%;
  max-width: 22rem;
  height: auto;
  margin: 0 auto;
  color: var(--ink-soft);
}
.fig-rule { stroke: var(--mark); }
.fig-label { fill: var(--ink-soft); font-family: var(--mono); font-size: 11px; }

/* -- tables, ruled like the ticket ------------------------------------ */

.scroll { overflow-x: auto; max-width: 100%; }
.scroll:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}
caption { text-align: left; color: var(--ink-soft); padding-bottom: 0.4rem; }
caption.dup {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
th, td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--hair); }
thead th {
  text-align: left;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
}
tbody th { text-align: left; font-weight: 600; }
td { text-align: right; font-family: var(--mono); }

ul.index { list-style: none; padding: 0; margin: 0; }
ul.index li { padding: 0.45rem 0; border-bottom: 1px solid var(--hair); color: var(--ink-soft); }
ul.index li a { font-weight: 600; color: var(--ink); }

.formula {
  font-family: var(--mono);
  font-size: 0.875rem;
  background: var(--mark-soft);
  border-left: 2px solid var(--mark);
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
}

.note, .provenance { color: var(--ink-soft); font-size: 0.875rem; }

/* -- ad slots --------------------------------------------------------- */

/* The height is reserved from the first build, whether or not a script ever fills it, so turning
   ads on does not move a single line of the page. */
.ad-slot {
  min-height: var(--ad-reserve);
  margin: 1.5rem 0;
  background: var(--slot);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}
.ad-slot--anchor { position: sticky; bottom: 0; margin: 0; }

/* -- the signature line ----------------------------------------------- */

.foot {
  border-top: 3px double var(--rule);
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.foot nav { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 0.85rem; }
.foot a { min-height: 44px; display: inline-flex; align-items: center; }
.foot .updated { font-family: var(--mono); font-size: 0.8125rem; }

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

@media (max-width: 30rem) {
  /* The widest thing anyone types here is a price, and 183.51 has to fit without being cut. */
  .field { grid-template-columns: minmax(0, 1fr) 6rem auto; gap: 0.4rem; }
  .field .unit { white-space: nowrap; }
  .field input { font-size: 0.9375rem; padding: 0.45rem 0.4rem; }
  .field label::after { display: none; }
  table { font-size: 0.875rem; }
  th, td { padding: 0.4rem 0.25rem; }
}

@media (max-width: 40rem) {
  thead th { white-space: normal; }
}

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