/* WrenchMath — system-font, information-first stylesheet.
   Budget: < 12 KB. No preprocessors, no variables gymnastics.
   Shop-manual aesthetic: dense, honest, utilitarian. Think McMaster-Carr. */

/* ── Reset & base ─────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px; /* base; inputs inherit to prevent iOS zoom */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif, "Apple Color Emoji";
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Typography & prose ───────────────────────────────────────────────────── */

h1 { font-size: 1.5rem; margin-bottom: 0.5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.4rem; line-height: 1.25; }
h3 { font-size: 1.1rem;  margin: 1rem 0 0.3rem; }

p { max-width: 72ch; margin-bottom: 0.75rem; }

main ol, main ul { padding-left: 1.5rem; margin-bottom: 0.75rem; max-width: 72ch; }
main li { margin-bottom: 0.35rem; }

a { color: #c2410c; }
a:visited { color: #9a3412; }
a:hover { color: #7c2d12; }

/* ── Layout shell ─────────────────────────────────────────────────────────── */

header {
  background: #f4f4f4;
  border-bottom: 3px solid #ea580c;
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.wordmark {
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  color: #1a1a1a;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.wordmark { color: #c2410c; display: inline-flex; align-items: center; gap: 0.55rem; }
.wordmark img { display: block; }
.wordmark:visited { color: #1a1a1a; }
.wordmark:hover   { color: #c2410c; }

header nav {
  min-width: 0;                   /* flex child may shrink below content width */
  max-width: 100%;
  position: relative;
}

/* Mom-test scroll affordance: fade + chevron say "more tools this way" */
header nav::after {
  content: "›";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.3rem;
  background: linear-gradient(to right, rgba(244,244,244,0), #f4f4f4 65%);
  color: #c2410c;
  font-size: 1.4rem;
  font-weight: 700;
  pointer-events: none;           /* purely visual; swipes pass through */
}

@media (min-width: 900px) {
  header nav::after { display: none; }  /* nav wraps on wide screens */
}

header nav ul {
  list-style: none;
  display: flex;
  flex-wrap: nowrap;              /* single line on phones… */
  overflow-x: auto;               /* …that scrolls sideways */
  max-width: 100%;
  gap: 0.25rem 1rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
header nav ul::-webkit-scrollbar { display: none; }
@media (min-width: 900px) {
  header nav ul { flex-wrap: wrap; overflow-x: visible; }
}

header nav a {
  font-size: 0.875rem;
  text-decoration: none;
  color: #333;
  white-space: nowrap;
}
header nav a:hover { color: #c2410c; text-decoration: underline; }

main {
  flex: 1;
  padding: 1.25rem 1rem;
  max-width: 72ch;
  width: 100%;
  margin: 0 auto;
}

footer {
  background: #f4f4f4;
  border-top: 1px solid #ccc;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #555;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
}

footer nav { display: flex; gap: 0.75rem; flex-wrap: wrap; }
footer nav a { color: #555; font-size: 0.8rem; }
footer nav a:hover { color: #c2410c; }

.reviewed { font-style: italic; }

/* ── Tool list (index page) ───────────────────────────────────────────────── */

.tool-list {
  list-style: disc outside;
  padding-left: 1.25rem;
  margin: 0.75rem 0 1rem 0;
  max-width: 60ch;
}

.tool-list li { margin-bottom: 0.35rem; }
.tool-list a  { font-size: 1rem; }

/* ── Calculator panel ─────────────────────────────────────────────────────── */

.calc {
  border: 1px solid #bbb;
  border-radius: 4px;
  padding: 1rem;
  max-width: 56ch;
  margin-bottom: 1.5rem;
}

.calc label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}

.calc label:first-of-type { margin-top: 0; }

.calc input,
.calc select {
  width: 100%;
  font-size: 1rem;      /* ≥16px prevents iOS zoom */
  padding: 0.5rem 0.6rem;
  border: 1px solid #bbb;
  border-radius: 3px;
  background: #fff;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
  min-height: 44px;     /* generous tap target */
  appearance: none;
}

.calc input,
.calc select { accent-color: #c2410c; }

.calc input:focus,
.calc select:focus {
  outline: 2px solid #c2410c;
  outline-offset: 1px;
}

.calc button {
  margin-top: 1rem;
  padding: 0.6rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  min-height: 44px;
}

.calc button:hover { background: #333; }

.unit { font-weight: 400; color: #555; }
.unit::before { content: "("; }
.unit::after  { content: ")"; }

/* ── Result display ───────────────────────────────────────────────────────── */

.result {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono",
               Menlo, monospace;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.75rem 0;
}

.result-unit {
  font-size: 1rem;
  font-weight: 400;
  color: #555;
}

.result-pair { white-space: nowrap; }

.result-note {
  font-size: 0.875rem;
  color: #555;
  margin-top: -0.5rem;
}

/* ── Data tables ──────────────────────────────────────────────────────────── */

table {
  border-collapse: collapse;
  width: 100%;
  max-width: 72ch;
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 4px 8px;
  border: 1px solid #ccc;
  text-align: left;
  font-size: 0.875rem;
}

th {
  background: #f4f4f4;
  font-weight: 600;
}

tr:nth-child(even) td { background: #fafafa; }

caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 4px 0;
}

.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

/* ── Utility ──────────────────────────────────────────────────────────────── */

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

/* ── Print ────────────────────────────────────────────────────────────────── */

@media print {
  header, nav, .calc, footer { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  table { border-collapse: collapse; }
  th, td { border: 1px solid #000; padding: 3px 6px; }
}

/* ── Narrow mobile ────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  header nav { width: 100%; }
  main   { padding: 1rem 0.75rem; }
  .calc  { padding: 0.75rem; }
}

/* ── Wide screen: center the content column ───────────────────────────────── */

@media (min-width: 900px) {
  main { padding: 1.5rem 2rem; }
}
