/* Stylesheet written for this site.
   Layout: one centred column, a paper-and-thread palette, generous form controls for phone use,
   reference tables and buy lists that print cleanly. Class names follow the page markup the build produces. */

:root {
  --paper: #fbf8f2;
  --sheet: #ffffff;
  --ink: #23201b;
  --ink-soft: #5d554a;
  --rule: #ddd3c3;
  --tint: #f3ece0;
  --thread: #8c3a1e;
  --thread-wash: #f5e4db;
  --on-thread: #ffffff;
  --sage: #2f6b4f;
  --alarm: #9c1c1c;
  --ring: #2f6b4f;
  --round: 8px;
  --gap: clamp(14px, 3vw, 22px);
  --measure: 62rem;
  --lift: 0 1px 0 rgba(35, 32, 27, 0.06), 0 2px 6px rgba(35, 32, 27, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17140f;
    --sheet: #201c16;
    --ink: #efe9df;
    --ink-soft: #bdb2a2;
    --rule: #3d362c;
    --tint: #29241c;
    --thread: #eb9a76;
    --thread-wash: #3b261c;
    --on-thread: #17140f;
    --sage: #8fc9a9;
    --alarm: #ff9a9a;
    --ring: #8fc9a9;
    --lift: none;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  font-size: 17px;
  line-height: 1.6;
}

h1,
h2,
h3,
legend,
button,
label,
.stat-label,
.brand,
nav {
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.15;
  margin: 0.3rem 0 0.6rem;
}

h2 {
  font-size: 1.32rem;
  line-height: 1.25;
  margin: 2.2rem 0 0.7rem;
  padding-top: 0.6rem;
  border-top: 2px solid var(--rule);
}

h3 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.4rem;
}

a {
  color: var(--thread);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

img,
svg {
  max-width: 100%;
}

.wrap {
  width: min(100% - 2 * 16px, var(--measure));
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: -100vw;
}

.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 2;
  padding: 0.4rem 0.8rem;
  background: var(--thread);
  color: var(--on-thread);
}

.sr-only,
.offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg.i {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* ---------- header, footer ---------- */
header.site {
  border-bottom: 1px solid var(--rule);
  background: var(--sheet);
}

header.site .wrap,
footer.site .foot-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}

header.site .wrap {
  padding-block: 0.7rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}

.brand .logo {
  width: 1.6rem;
  height: 1.6rem;
}

.lg-bg {
  fill: var(--thread);
}

.lg-fg,
.lg-tick {
  stroke: var(--on-thread);
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
}

nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

nav a:hover {
  color: var(--thread);
}

footer.site {
  margin-top: 3rem;
  padding-block: 2rem;
  border-top: 1px solid var(--rule);
  background: var(--tint);
  font-size: 0.93rem;
  color: var(--ink-soft);
}

footer.site .foot-grid {
  align-items: flex-start;
}

.foot-about {
  max-width: 24rem;
}

.foot-col h2 {
  border: 0;
  margin: 0 0 0.4rem;
  padding: 0;
  font-size: 0.95rem;
}

.foot-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 1.5rem;
}

.copy {
  margin-top: 1.4rem;
}

main {
  padding-block: 1.4rem 2rem;
}

/* ---------- home, hubs, lists ---------- */
.hero,
.hub-hero,
.page-head,
.tool-hero {
  padding-block: 0.6rem 0.4rem;
}

.lead {
  font-size: 1.12rem;
  color: var(--ink-soft);
  max-width: 44rem;
}

.band {
  margin-block: 1.2rem;
}

.band.alt {
  padding: var(--gap);
  border-radius: var(--round);
  background: var(--tint);
}

.section-head h2 a {
  color: inherit;
  text-decoration: none;
}

.home-list,
.toollist,
.rel-list {
  padding-left: 1.2rem;
}

.home-list li,
.toollist li,
.rel-list li {
  margin-block: 0.25rem;
}

.grid {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.card-link {
  display: block;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.card {
  height: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: var(--round);
  background: var(--sheet);
  box-shadow: var(--lift);
}

.card-link:hover .card {
  border-color: var(--thread);
}

.card h3 {
  margin: 0.3rem 0;
}

.card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ico {
  color: var(--thread);
}

.badge {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* the directory search needs a script this site does not ship */
.finder {
  display: none;
}

.crumbs {
  font-family: system-ui, sans-serif;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.byline {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.more-in {
  margin-top: 0.5rem;
}

/* ---------- the calculator ---------- */
.tool {
  margin-block: 1.2rem 1.6rem;
  padding: var(--gap);
  border: 2px solid var(--ink);
  border-radius: var(--round);
  background: var(--sheet);
}

fieldset {
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

legend {
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.fields {
  display: grid;
  gap: 0.8rem 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.5rem 0.65rem;
  border: 1px solid #8a8070;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

textarea {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.95rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

button {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  border: 0;
  background: var(--thread);
  color: var(--on-thread);
}

button.secondary {
  border: 1px solid var(--rule);
  background: var(--tint);
  color: var(--ink);
}

.hint,
.src {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.error,
.warn {
  color: var(--alarm);
  font-weight: 600;
}

.note {
  color: var(--ink-soft);
}

.status {
  min-height: 1.4em;
  color: var(--sage);
}

.planner-result {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--rule);
}

.cards {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.85rem;
  border-radius: var(--round);
  background: var(--tint);
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
}

.stat-sub {
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.buy-units {
  margin-block: 1rem;
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--thread);
  border-radius: 0 var(--round) var(--round) 0;
  background: var(--thread-wash);
}

.buy-units h3 {
  margin: 0 0 0.35rem;
}

.buy-units ul {
  margin: 0;
  padding-left: 1.1rem;
}

.assumptions ol {
  padding-left: 1.3rem;
  font-size: 0.93rem;
}

.scroll-hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- tables ---------- */
.table-wrap,
.ref-wrap,
.quick-answer {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  padding-bottom: 0.3rem;
}

th,
td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

thead th {
  border-bottom: 2px solid var(--ink);
}

td.num,
th.num {
  text-align: right;
}

.quick-answer {
  margin-block: 1rem;
}

.qa-intro,
.qa-jump,
.qa-skip {
  font-size: 0.93rem;
}

.original-element {
  margin-block: 1.6rem;
  padding: var(--gap);
  border: 1px solid var(--rule);
  border-radius: var(--round);
  background: var(--sheet);
}

.original-element h2 {
  border: 0;
  margin-top: 0;
  padding-top: 0;
}

.ref-source {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* ---------- prose pages, figures, notices ---------- */
.prose {
  max-width: 44rem;
}

.notice,
.safety {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--alarm);
  border-radius: var(--round);
}

.diagram {
  margin: 1rem 0;
}

.diagram figcaption {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

details {
  margin-block: 0.4rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--round);
  background: var(--sheet);
}

summary {
  cursor: pointer;
  font-weight: 600;
}

.source-links {
  padding-left: 1.2rem;
}

.fix-note {
  margin-top: 2.2rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--rule);
  font-size: 0.92rem;
  color: var(--ink-soft);
}

[data-sys][hidden],
[hidden] {
  display: none !important;
}

/* ---------- print: the answer, charts and buy lists, without the site around them ---------- */
@media print {
  header.site,
  footer.site,
  .crumbs,
  .fix-note,
  .actions,
  form,
  .rel-list,
  .more-in,
  .scroll-hint,
  noscript {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .tool,
  .original-element,
  .buy-units,
  .stat {
    border: 1px solid #000;
    background: #fff;
    break-inside: avoid;
  }

  th,
  td,
  thead th {
    border-color: #000;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
