/* Stair stringer calculator - one page, readable on a phone at the job site, prints a cut sheet. */
:root {
  --ink: #1d232a;
  --muted: #5b6570;
  --accent: #8a4b14;
  --line: #d4d9de;
  --panel: #f6f3ee;
  --ok: #1d6b3a;
  --fail: #a32020;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #ffffff;
}

header.site,
footer.site {
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

footer.site {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.brand {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

h1 {
  margin: 24px 0 6px;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin: 28px 0 10px;
  font-size: 21px;
}

.lede {
  margin-top: 0;
  color: var(--muted);
}

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
  font-size: 15px;
}

input,
select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #b9c0c7;
  border-radius: 7px;
  font: inherit;
  font-weight: 400;
  background: #ffffff;
}

small {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

#error {
  color: var(--fail);
  font-weight: 600;
}

.has-error #results,
.has-error #cutsheet {
  opacity: 0.35;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 0;
}

.stats > * {
  min-width: 0;
}

.stats dt {
  color: var(--muted);
  font-size: 13px;
}

.stats dd {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}

.stats dd small {
  font-size: 13px;
}

.checks {
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.checks li {
  margin: 4px 0;
  padding: 6px 10px;
  border-left: 4px solid var(--line);
  background: var(--panel);
}

.checks li.ok {
  border-color: var(--ok);
}

.checks li.fail {
  border-color: var(--fail);
  color: var(--fail);
  font-weight: 600;
}

.diagram {
  margin: 16px 0;
}

.diagram svg {
  width: 100%;
  max-height: 340px;
}

.diagram .board {
  fill: #e3d7c6;
  stroke: #a08a6c;
  stroke-width: 0.4;
}

.diagram .cut {
  fill: none;
  stroke: var(--ink);
  stroke-width: 0.7;
}

.diagram .floor {
  fill: none;
  stroke: var(--muted);
  stroke-width: 0.6;
  stroke-dasharray: 2 2;
}

figcaption {
  color: var(--muted);
  font-size: 13px;
}

button {
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #ffffff;
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#status {
  color: var(--muted);
}

table.marks {
  width: 100%;
  border-collapse: collapse;
}

.marks th,
.marks td {
  padding: 6px 8px;
  border: 1px solid var(--line);
  text-align: left;
}

.marks th {
  background: var(--panel);
  font-size: 14px;
}

.disclaimer {
  color: var(--muted);
  font-size: 14px;
}

/* Print: the cut sheet, the stats and the diagram only. */
@media print {
  header.site,
  footer.site,
  form,
  .lede,
  .actions,
  .guide {
    display: none;
  }

  body {
    font-size: 11pt;
  }

  h1 {
    margin-top: 0;
    font-size: 18pt;
  }

  .checks li,
  .marks th {
    background: none;
  }

  .diagram svg {
    max-height: 3in;
  }

  #cutsheet {
    break-inside: avoid;
  }
}

/* Narrow screens */
#cutsheet,
.scroll {
  overflow-x: auto;
}

@media (max-width: 600px) {
  .inputs {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .marks th,
  .marks td {
    padding: 4px 5px;
    font-size: 13px;
  }
}
